|
@@ -41,12 +41,12 @@ discard block |
|
|
block discarded – undo |
|
41
|
41
|
$currentdate = date('Y-m-d'); |
|
42
|
42
|
$sourcestat = $Stats->getStatsSource($currentdate); |
|
43
|
43
|
if (!empty($sourcestat)) { |
|
44
|
|
- foreach($sourcestat as $srcst) { |
|
|
44
|
+ foreach ($sourcestat as $srcst) { |
|
45
|
45
|
$type = $srcst['stats_type']; |
|
46
|
46
|
if ($type == 'polar' || $type == 'hist') { |
|
47
|
47
|
$source = $srcst['source_name']; |
|
48
|
48
|
$data = $srcst['source_data']; |
|
49
|
|
- $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
|
49
|
+ $this->stats[$currentdate][$source][$type] = json_decode($data, true); |
|
50
|
50
|
} |
|
51
|
51
|
} |
|
52
|
52
|
} |
|
@@ -58,14 +58,14 @@ discard block |
|
|
block discarded – undo |
|
58
|
58
|
if (isset($globalGeoid) && $globalGeoid) { |
|
59
|
59
|
try { |
|
60
|
60
|
$GeoidClass = new GeoidHeight(); |
|
61
|
|
- } catch(Exception $e) { |
|
|
61
|
+ } catch (Exception $e) { |
|
62
|
62
|
if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n"; |
|
63
|
63
|
$GeoidClass = FALSE; |
|
64
|
64
|
} |
|
65
|
65
|
} |
|
66
|
66
|
} |
|
67
|
67
|
|
|
68
|
|
- public function get_Schedule($id,$ident) { |
|
|
68
|
+ public function get_Schedule($id, $ident) { |
|
69
|
69
|
global $globalDebug, $globalFork, $globalSchedulesFetch; |
|
70
|
70
|
// Get schedule here, so it's done only one time |
|
71
|
71
|
|
|
@@ -90,8 +90,8 @@ discard block |
|
|
block discarded – undo |
|
90
|
90
|
$schedule = $Schedule->fetchSchedule($operator); |
|
91
|
91
|
if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
|
92
|
92
|
if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
93
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
94
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
|
93
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime'])); |
|
|
94
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
95
|
95
|
// Should also check if route schedule = route from DB |
|
96
|
96
|
if ($schedule['DepartureAirportIATA'] != '') { |
|
97
|
97
|
if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
|
@@ -111,7 +111,7 @@ discard block |
|
|
block discarded – undo |
|
111
|
111
|
} |
|
112
|
112
|
} |
|
113
|
113
|
} |
|
114
|
|
- $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']); |
|
|
114
|
+ $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']); |
|
115
|
115
|
} |
|
116
|
116
|
} else $scheduleexist = true; |
|
117
|
117
|
} else $scheduleexist = true; |
|
@@ -119,8 +119,8 @@ discard block |
|
|
block discarded – undo |
|
119
|
119
|
if ($scheduleexist) { |
|
120
|
120
|
if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
121
|
121
|
$sch = $Schedule->getSchedule($operator); |
|
122
|
|
- $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'])); |
|
123
|
|
- if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']); |
|
|
122
|
+ $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'])); |
|
|
123
|
+ if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'], $sch['departure_airport_icao'], $sch['departure_airport_time'], $sch['arrival_airport_icao'], $sch['arrival_airport_time']); |
|
124
|
124
|
} |
|
125
|
125
|
$Spotter->db = null; |
|
126
|
126
|
$Schedule->db = null; |
|
@@ -147,7 +147,7 @@ discard block |
|
|
block discarded – undo |
|
147
|
147
|
//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
|
148
|
148
|
$Spotter = new Spotter($this->db); |
|
149
|
149
|
$real_arrival = $this->arrival($key); |
|
150
|
|
- 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']); |
|
|
150
|
+ 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']); |
|
151
|
151
|
} |
|
152
|
152
|
} |
|
153
|
153
|
} |
|
@@ -161,7 +161,7 @@ discard block |
|
|
block discarded – undo |
|
161
|
161
|
$airport_time = ''; |
|
162
|
162
|
if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
163
|
163
|
if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
|
164
|
|
- $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
|
164
|
+ $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist); |
|
165
|
165
|
if (isset($closestAirports[0])) { |
|
166
|
166
|
if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
167
|
167
|
$airport_icao = $closestAirports[0]['icao']; |
|
@@ -176,7 +176,7 @@ discard block |
|
|
block discarded – undo |
|
176
|
176
|
break; |
|
177
|
177
|
} |
|
178
|
178
|
} |
|
179
|
|
- } 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))) { |
|
|
179
|
+ } 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))) { |
|
180
|
180
|
$airport_icao = $closestAirports[0]['icao']; |
|
181
|
181
|
$airport_time = $this->all_flights[$key]['datetime']; |
|
182
|
182
|
} else { |
|
@@ -189,7 +189,7 @@ discard block |
|
|
block discarded – undo |
|
189
|
189
|
} else { |
|
190
|
190
|
if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
191
|
191
|
} |
|
192
|
|
- return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
|
192
|
+ return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time); |
|
193
|
193
|
} |
|
194
|
194
|
|
|
195
|
195
|
|
|
@@ -201,7 +201,7 @@ discard block |
|
|
block discarded – undo |
|
201
|
201
|
|
|
202
|
202
|
foreach ($this->all_flights as $key => $flight) { |
|
203
|
203
|
if (isset($flight['lastupdate'])) { |
|
204
|
|
- if ($flight['lastupdate'] < (time()-1800)) { |
|
|
204
|
+ if ($flight['lastupdate'] < (time() - 1800)) { |
|
205
|
205
|
$this->delKey($key); |
|
206
|
206
|
} |
|
207
|
207
|
} |
|
@@ -218,10 +218,10 @@ discard block |
|
|
block discarded – undo |
|
218
|
218
|
$Spotter = new Spotter($this->db); |
|
219
|
219
|
$SpotterLive = new SpotterLive($this->db); |
|
220
|
220
|
if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
|
221
|
|
- $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']); |
|
|
221
|
+ $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']); |
|
222
|
222
|
if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
223
|
223
|
$this->all_flights[$key]['putinarchive'] = true; |
|
224
|
|
- $result = $SpotterLive->addLiveSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['aircraft_icao'], $this->all_flights[$key]['departure_airport'], $this->all_flights[$key]['arrival_airport'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['waypoints'], $this->all_flights[$key]['altitude'],$this->all_flights[$key]['altitude_real'], $this->all_flights[$key]['heading'], $this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'], $this->all_flights[$key]['departure_airport_time'], $this->all_flights[$key]['arrival_airport_time'], $this->all_flights[$key]['squawk'],$this->all_flights[$key]['route_stop'],$this->all_flights[$key]['hex'],$this->all_flights[$key]['putinarchive'],$this->all_flights[$key]['registration'],$this->all_flights[$key]['pilot_id'],$this->all_flights[$key]['pilot_name'], $this->all_flights[$key]['verticalrate'], $this->all_flights[$key]['noarchive'], $this->all_flights[$key]['ground'],$this->all_flights[$key]['format_source'],$this->all_flights[$key]['source_name'],$this->all_flights[$key]['over_country']); |
|
|
224
|
+ $result = $SpotterLive->addLiveSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['aircraft_icao'], $this->all_flights[$key]['departure_airport'], $this->all_flights[$key]['arrival_airport'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['waypoints'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['altitude_real'], $this->all_flights[$key]['heading'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $this->all_flights[$key]['departure_airport_time'], $this->all_flights[$key]['arrival_airport_time'], $this->all_flights[$key]['squawk'], $this->all_flights[$key]['route_stop'], $this->all_flights[$key]['hex'], $this->all_flights[$key]['putinarchive'], $this->all_flights[$key]['registration'], $this->all_flights[$key]['pilot_id'], $this->all_flights[$key]['pilot_name'], $this->all_flights[$key]['verticalrate'], $this->all_flights[$key]['noarchive'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['format_source'], $this->all_flights[$key]['source_name'], $this->all_flights[$key]['over_country']); |
|
225
|
225
|
if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
226
|
226
|
} |
|
227
|
227
|
$Spotter->db = null; |
|
@@ -257,10 +257,10 @@ discard block |
|
|
block discarded – undo |
|
257
|
257
|
$send = false; |
|
258
|
258
|
|
|
259
|
259
|
// SBS format is CSV format |
|
260
|
|
- if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
|
260
|
+ if (is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
261
|
261
|
//print_r($line); |
|
262
|
262
|
if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
263
|
|
- 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)) { |
|
|
263
|
+ 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)) { |
|
264
|
264
|
|
|
265
|
265
|
// Increment message number |
|
266
|
266
|
if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
|
@@ -293,25 +293,25 @@ discard block |
|
|
block discarded – undo |
|
293
|
293
|
if (!isset($this->all_flights[$id])) { |
|
294
|
294
|
if ($globalDebug) echo 'New flight...'."\n"; |
|
295
|
295
|
$this->all_flights[$id] = array(); |
|
296
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
297
|
|
- $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' => '','coordinates' => 0)); |
|
298
|
|
- if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
|
296
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
|
297
|
+ $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' => '', 'coordinates' => 0)); |
|
|
298
|
+ if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time())); |
|
299
|
299
|
if (!isset($line['id'])) { |
|
300
|
300
|
if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
301
|
301
|
// 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'))); |
|
302
|
302
|
// 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'))); |
|
303
|
|
- 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'))); |
|
|
303
|
+ 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'))); |
|
304
|
304
|
//else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
305
|
|
- } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
|
305
|
+ } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
306
|
306
|
if ($globalAllFlights !== FALSE) $dataFound = true; |
|
307
|
307
|
} |
|
308
|
308
|
if (isset($line['source_type']) && $line['source_type'] != '') { |
|
309
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
|
309
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type'])); |
|
310
|
310
|
} |
|
311
|
311
|
|
|
312
|
312
|
//print_r($this->all_flights); |
|
313
|
313
|
if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
|
314
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
|
314
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex']))); |
|
315
|
315
|
//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
316
|
316
|
//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
|
317
|
317
|
//} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
@@ -320,20 +320,20 @@ discard block |
|
|
block discarded – undo |
|
320
|
320
|
if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
321
|
321
|
$Spotter = new Spotter($this->db); |
|
322
|
322
|
if (isset($this->all_flights[$id]['source_type'])) { |
|
323
|
|
- $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
|
|
323
|
+ $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']); |
|
324
|
324
|
} else { |
|
325
|
325
|
$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
|
326
|
326
|
} |
|
327
|
327
|
$Spotter->db = null; |
|
328
|
|
- if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
329
|
|
- if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
|
328
|
+ if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
|
329
|
+ if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
330
|
330
|
} |
|
331
|
331
|
} |
|
332
|
332
|
if ($globalAllFlights !== FALSE) $dataFound = true; |
|
333
|
333
|
if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
334
|
334
|
} |
|
335
|
335
|
if (isset($line['id']) && !isset($line['hex'])) { |
|
336
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
|
336
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => '')); |
|
337
|
337
|
} |
|
338
|
338
|
if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
|
339
|
339
|
$icao = $line['aircraft_icao']; |
|
@@ -342,14 +342,14 @@ discard block |
|
|
block discarded – undo |
|
342
|
342
|
if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
|
343
|
343
|
$Spotter->db = null; |
|
344
|
344
|
} |
|
345
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao)); |
|
|
345
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $icao)); |
|
346
|
346
|
} elseif (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) { |
|
347
|
347
|
if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
348
|
348
|
// Get aircraft ICAO from aircraft name |
|
349
|
349
|
$Spotter = new Spotter($this->db); |
|
350
|
350
|
$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
|
351
|
351
|
$Spotter->db = null; |
|
352
|
|
- if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
|
352
|
+ if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
353
|
353
|
} |
|
354
|
354
|
} |
|
355
|
355
|
if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
|
@@ -357,15 +357,15 @@ discard block |
|
|
block discarded – undo |
|
357
|
357
|
elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
358
|
358
|
elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
359
|
359
|
elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
360
|
|
- if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
|
360
|
+ if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
361
|
361
|
} |
|
362
|
362
|
if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
|
363
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
|
363
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA')); |
|
364
|
364
|
} |
|
365
|
365
|
//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
366
|
|
- if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
|
|
366
|
+ if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
367
|
367
|
if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
368
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
|
|
368
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime'])); |
|
369
|
369
|
} else { |
|
370
|
370
|
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"; |
|
371
|
371
|
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"; |
|
@@ -376,31 +376,31 @@ discard block |
|
|
block discarded – undo |
|
376
|
376
|
*/ |
|
377
|
377
|
return ''; |
|
378
|
378
|
} |
|
379
|
|
- } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
|
|
379
|
+ } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) { |
|
380
|
380
|
if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
381
|
381
|
return ''; |
|
382
|
|
- } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
|
|
382
|
+ } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) { |
|
383
|
383
|
if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
384
|
384
|
return ''; |
|
385
|
385
|
} elseif (!isset($line['datetime'])) { |
|
386
|
386
|
date_default_timezone_set('UTC'); |
|
387
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
|
387
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
388
|
388
|
} else { |
|
389
|
389
|
if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
390
|
390
|
return ''; |
|
391
|
391
|
} |
|
392
|
392
|
|
|
393
|
393
|
if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG' && $line['registration'] != 'NA') { |
|
394
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
|
394
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration'])); |
|
395
|
395
|
} |
|
396
|
396
|
if (isset($line['waypoints']) && $line['waypoints'] != '') { |
|
397
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
|
397
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints'])); |
|
398
|
398
|
} |
|
399
|
399
|
if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
|
400
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
|
400
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => trim($line['pilot_id']))); |
|
401
|
401
|
} |
|
402
|
402
|
if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
|
403
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
|
403
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => trim($line['pilot_name']))); |
|
404
|
404
|
} |
|
405
|
405
|
|
|
406
|
406
|
if (isset($line['ident']) && trim($line['ident']) != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
|
@@ -408,13 +408,13 @@ discard block |
|
|
block discarded – undo |
|
408
|
408
|
if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
409
|
409
|
if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
|
410
|
410
|
if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
|
411
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
412
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
413
|
|
- 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'))); |
|
414
|
|
- elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
415
|
|
- 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'])); |
|
|
411
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
|
412
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
|
413
|
+ 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'))); |
|
|
414
|
+ elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
|
415
|
+ 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'])); |
|
416
|
416
|
} else { |
|
417
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
|
417
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
418
|
418
|
if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
419
|
419
|
$timeelapsed = microtime(true); |
|
420
|
420
|
$Spotter = new Spotter($this->db); |
|
@@ -424,13 +424,13 @@ discard block |
|
|
block discarded – undo |
|
424
|
424
|
elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
425
|
425
|
elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
426
|
426
|
elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
427
|
|
- $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource,$this->all_flights[$id]['source_type']); |
|
|
427
|
+ $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource, $this->all_flights[$id]['source_type']); |
|
428
|
428
|
if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
429
|
429
|
$Spotter->db = null; |
|
430
|
|
- if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
430
|
+ if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
431
|
431
|
} |
|
432
|
432
|
} |
|
433
|
|
- } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
|
433
|
+ } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
434
|
434
|
|
|
435
|
435
|
/* |
|
436
|
436
|
if (!isset($line['id'])) { |
|
@@ -440,25 +440,25 @@ discard block |
|
|
block discarded – undo |
|
440
|
440
|
else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
441
|
441
|
} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
442
|
442
|
*/ |
|
443
|
|
- 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'])); |
|
|
443
|
+ 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'])); |
|
444
|
444
|
|
|
445
|
445
|
//$putinarchive = true; |
|
446
|
446
|
if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
447
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
|
|
447
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time'])); |
|
448
|
448
|
} |
|
449
|
449
|
if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
450
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
|
450
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
451
|
451
|
} |
|
452
|
452
|
if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
453
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
|
453
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => '')); |
|
454
|
454
|
} elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
455
|
455
|
$timeelapsed = microtime(true); |
|
456
|
456
|
if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
457
|
457
|
$Spotter = new Spotter($this->db); |
|
458
|
458
|
$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
|
459
|
459
|
$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
|
460
|
|
- $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' => '')); |
|
461
|
|
- if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
460
|
+ $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' => '')); |
|
|
461
|
+ if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
462
|
462
|
} |
|
463
|
463
|
} elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
464
|
464
|
$timeelapsed = microtime(true); |
|
@@ -472,35 +472,35 @@ discard block |
|
|
block discarded – undo |
|
472
|
472
|
$Translation->db = null; |
|
473
|
473
|
} |
|
474
|
474
|
$Spotter->db = null; |
|
475
|
|
- if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
475
|
+ if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
476
|
476
|
} |
|
477
|
477
|
if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
|
478
|
478
|
//if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
479
|
479
|
if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
480
|
480
|
// $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'])); |
|
481
|
|
- $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'])); |
|
|
481
|
+ $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'])); |
|
482
|
482
|
} |
|
483
|
483
|
} |
|
484
|
484
|
if (!isset($globalFork)) $globalFork = TRUE; |
|
485
|
485
|
if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
|
486
|
|
- if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
|
486
|
+ if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident'])); |
|
487
|
487
|
} |
|
488
|
488
|
} |
|
489
|
489
|
} |
|
490
|
490
|
|
|
491
|
491
|
if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) { |
|
492
|
492
|
// $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
|
493
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
494
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
|
493
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed']))); |
|
|
494
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true)); |
|
495
|
495
|
//$dataFound = true; |
|
496
|
496
|
} 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'])) { |
|
497
|
|
- $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
|
497
|
+ $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'); |
|
498
|
498
|
if ($distance > 1000 && $distance < 10000) { |
|
499
|
499
|
// use datetime |
|
500
|
500
|
$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
|
501
|
501
|
$speed = $speed*3.6; |
|
502
|
502
|
if ($speed < 1000) { |
|
503
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
|
503
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed))); |
|
504
|
504
|
if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
505
|
505
|
} else { |
|
506
|
506
|
if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
@@ -515,9 +515,9 @@ discard block |
|
|
block discarded – undo |
|
515
|
515
|
if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
516
|
516
|
return false; |
|
517
|
517
|
} |
|
518
|
|
- if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
|
518
|
+ if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']); |
|
519
|
519
|
else unset($timediff); |
|
520
|
|
- if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
|
520
|
+ if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time() - $this->all_flights[$id]['time_last_archive_coord']); |
|
521
|
521
|
else unset($timediff_archive); |
|
522
|
522
|
if ($this->tmd > 5 |
|
523
|
523
|
|| (isset($line['format_source']) |
|
@@ -542,14 +542,14 @@ discard block |
|
|
block discarded – undo |
|
542
|
542
|
|| (isset($timediff) && $timediff > 30 |
|
543
|
543
|
&& isset($this->all_flights[$id]['latitude']) |
|
544
|
544
|
&& isset($this->all_flights[$id]['longitude']) |
|
545
|
|
- && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
|
545
|
+ && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')) |
|
546
|
546
|
) |
|
547
|
547
|
) { |
|
548
|
548
|
|
|
549
|
549
|
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']))) { |
|
550
|
550
|
if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
|
551
|
551
|
|| (isset($line['format_source']) && $line['format_source'] == 'airwhere') |
|
552
|
|
- || ((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'])&& !$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']))) { |
|
|
552
|
+ || ((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']) && !$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']))) { |
|
553
|
553
|
$this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
|
554
|
554
|
$this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
|
555
|
555
|
$this->all_flights[$id]['putinarchive'] = true; |
|
@@ -563,11 +563,11 @@ discard block |
|
|
block discarded – undo |
|
563
|
563
|
$timeelapsed = microtime(true); |
|
564
|
564
|
if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
565
|
565
|
$Spotter = new Spotter($this->db); |
|
566
|
|
- $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
|
566
|
+ $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
567
|
567
|
if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
568
|
568
|
else $this->all_flights[$id]['over_country'] = ''; |
|
569
|
569
|
$Spotter->db = null; |
|
570
|
|
- if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
570
|
+ if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
571
|
571
|
if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
572
|
572
|
} |
|
573
|
573
|
} |
|
@@ -593,13 +593,13 @@ discard block |
|
|
block discarded – undo |
|
593
|
593
|
$this->all_flights[$id]['time_last_coord'] = time(); |
|
594
|
594
|
} |
|
595
|
595
|
//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)) { |
|
596
|
|
- 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)) { |
|
|
596
|
+ 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)) { |
|
597
|
597
|
$this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
598
|
598
|
$dataFound = true; |
|
599
|
599
|
$this->all_flights[$id]['time_last_coord'] = time(); |
|
600
|
600
|
} |
|
601
|
601
|
// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
|
602
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
|
|
602
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude'])); |
|
603
|
603
|
/* |
|
604
|
604
|
if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) { |
|
605
|
605
|
$this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
|
@@ -621,14 +621,14 @@ discard block |
|
|
block discarded – undo |
|
621
|
621
|
$this->all_flights[$id]['time_last_coord'] = time(); |
|
622
|
622
|
} |
|
623
|
623
|
//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)) { |
|
624
|
|
- 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)) { |
|
|
624
|
+ 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)) { |
|
625
|
625
|
$this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
626
|
626
|
$dataFound = true; |
|
627
|
627
|
$this->all_flights[$id]['coordinates'] += 1; |
|
628
|
628
|
$this->all_flights[$id]['time_last_coord'] = time(); |
|
629
|
629
|
} |
|
630
|
630
|
// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
|
631
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
|
|
631
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude'])); |
|
632
|
632
|
/* |
|
633
|
633
|
if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) { |
|
634
|
634
|
$this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
|
@@ -649,52 +649,52 @@ discard block |
|
|
block discarded – undo |
|
649
|
649
|
$SpotterArchive->deleteSpotterArchiveTrackDataByID($this->all_flights[$id]['id']); |
|
650
|
650
|
$SpotterArchive->db = null; |
|
651
|
651
|
$Spotter = new Spotter(); |
|
652
|
|
- $Spotter->updateInitialSpotterData($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']); |
|
|
652
|
+ $Spotter->updateInitialSpotterData($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']); |
|
653
|
653
|
$Spotter->db = null; |
|
654
|
654
|
} |
|
655
|
655
|
} else if ($globalDebug && $timediff > 30) { |
|
656
|
656
|
$this->tmd = $this->tmd + 1; |
|
657
|
657
|
echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
|
658
|
|
- echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
|
659
|
|
- echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
|
658
|
+ echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -"; |
|
|
659
|
+ echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
660
|
660
|
echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
|
661
|
661
|
} |
|
662
|
662
|
} |
|
663
|
663
|
if (isset($line['last_update']) && $line['last_update'] != '') { |
|
664
|
664
|
if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
665
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
|
665
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update'])); |
|
666
|
666
|
} |
|
667
|
667
|
if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
|
668
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
|
668
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate'])); |
|
669
|
669
|
//$dataFound = true; |
|
670
|
670
|
} |
|
671
|
671
|
if (isset($line['format_source']) && $line['format_source'] != '') { |
|
672
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
|
672
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source'])); |
|
673
|
673
|
} |
|
674
|
674
|
if (isset($line['source_name']) && $line['source_name'] != '') { |
|
675
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
|
675
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name'])); |
|
676
|
676
|
} |
|
677
|
677
|
if (isset($line['emergency']) && $line['emergency'] != '') { |
|
678
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
|
678
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency'])); |
|
679
|
679
|
//$dataFound = true; |
|
680
|
680
|
} |
|
681
|
681
|
if (isset($line['ground']) && $line['ground'] != '') { |
|
682
|
682
|
if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
683
|
683
|
// Here we force archive of flight because after ground it's a new one (or should be) |
|
684
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
685
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
686
|
|
- 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'))); |
|
687
|
|
- elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
688
|
|
- 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'])); |
|
|
684
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
|
685
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
|
686
|
+ 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'))); |
|
|
687
|
+ elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
|
688
|
+ elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
689
|
689
|
} |
|
690
|
690
|
if ($line['ground'] != 1) $line['ground'] = 0; |
|
691
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
|
691
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground'])); |
|
692
|
692
|
//$dataFound = true; |
|
693
|
693
|
} |
|
694
|
694
|
if (isset($line['squawk']) && $line['squawk'] != '') { |
|
695
|
695
|
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'])) { |
|
696
|
696
|
if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
697
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
|
697
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
698
|
698
|
$highlight = ''; |
|
699
|
699
|
if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
700
|
700
|
if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
@@ -703,66 +703,66 @@ discard block |
|
|
block discarded – undo |
|
703
|
703
|
$timeelapsed = microtime(true); |
|
704
|
704
|
if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
705
|
705
|
$Spotter = new Spotter($this->db); |
|
706
|
|
- $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
|
706
|
+ $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight); |
|
707
|
707
|
$Spotter->db = null; |
|
708
|
|
- if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
708
|
+ if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
709
|
709
|
} |
|
710
|
710
|
//$putinarchive = true; |
|
711
|
711
|
//$highlight = ''; |
|
712
|
712
|
} |
|
713
|
713
|
|
|
714
|
|
- } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
|
714
|
+ } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
715
|
715
|
//$dataFound = true; |
|
716
|
716
|
} |
|
717
|
717
|
|
|
718
|
718
|
if (isset($line['altitude']) && $line['altitude'] != '') { |
|
719
|
719
|
if (isset($line['altitude_relative']) && isset($GeoidClass) && is_object($GeoidClass)) { |
|
720
|
720
|
if ($line['altitude_relative'] == 'AMSL' || $line['altitude_relative'] == 'MSL') { |
|
721
|
|
- $geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'])*3.28084,2); |
|
|
721
|
+ $geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'])*3.28084, 2); |
|
722
|
722
|
//if ($globalDebug) echo '=> Set altitude to WGS84 Ellipsoid, add '.$geoid.' to '.$line['altitude']."\n"; |
|
723
|
723
|
$line['altitude'] = $line['altitude'] - $geoid; |
|
724
|
724
|
} |
|
725
|
725
|
} |
|
726
|
726
|
//if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
727
|
|
- 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; |
|
728
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
|
729
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
|
|
727
|
+ 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; |
|
|
728
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100))); |
|
|
729
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude'])); |
|
730
|
730
|
//$dataFound = true; |
|
731
|
731
|
//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
732
|
732
|
if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
|
733
|
733
|
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) { |
|
734
|
734
|
if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
|
735
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
736
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
737
|
|
- 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'))); |
|
738
|
|
- elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
739
|
|
- 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'])); |
|
|
735
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
|
736
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
|
737
|
+ 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'))); |
|
|
738
|
+ elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
|
739
|
+ 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'])); |
|
740
|
740
|
} |
|
741
|
741
|
} |
|
742
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
|
742
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_previous' => $line['altitude'])); |
|
743
|
743
|
} |
|
744
|
744
|
|
|
745
|
745
|
if (isset($line['noarchive']) && $line['noarchive'] === true) { |
|
746
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
|
746
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true)); |
|
747
|
747
|
} |
|
748
|
748
|
|
|
749
|
749
|
if (isset($line['heading']) && $line['heading'] != '') { |
|
750
|
|
- if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
751
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
752
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
|
750
|
+ if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
|
751
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading']))); |
|
|
752
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true)); |
|
753
|
753
|
//$dataFound = true; |
|
754
|
754
|
} 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']) { |
|
755
|
|
- $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']); |
|
756
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
757
|
|
- if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
|
755
|
+ $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']); |
|
|
756
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading))); |
|
|
757
|
+ if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
758
|
758
|
if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
759
|
759
|
} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
|
760
|
760
|
// If not enough messages and ACARS set heading to 0 |
|
761
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
|
761
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0)); |
|
762
|
762
|
} |
|
763
|
|
- if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
764
|
|
- elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
765
|
|
- elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinUpdate) $dataFound = false; |
|
|
763
|
+ if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
|
764
|
+ elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
|
765
|
+ elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalAircraftMinUpdate) $dataFound = false; |
|
766
|
766
|
|
|
767
|
767
|
// print_r($this->all_flights[$id]); |
|
768
|
768
|
//gets the callsign from the last hour |
|
@@ -773,7 +773,7 @@ discard block |
|
|
block discarded – undo |
|
773
|
773
|
if ($dataFound === true && isset($this->all_flights[$id]['id'])) { |
|
774
|
774
|
$this->all_flights[$id]['lastupdate'] = time(); |
|
775
|
775
|
if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
776
|
|
- 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'])) { |
|
|
776
|
+ 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'])) { |
|
777
|
777
|
//print_r($this->all_flights); |
|
778
|
778
|
//echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
779
|
779
|
//$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
@@ -784,61 +784,61 @@ discard block |
|
|
block discarded – undo |
|
784
|
784
|
$SpotterLive = new SpotterLive($this->db); |
|
785
|
785
|
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')) { |
|
786
|
786
|
$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
|
787
|
|
- if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
787
|
+ if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
788
|
788
|
} elseif (isset($line['id'])) { |
|
789
|
789
|
$recent_ident = $SpotterLive->checkIdRecent($line['id']); |
|
790
|
|
- if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
790
|
+ if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
791
|
791
|
} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
792
|
792
|
$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
|
793
|
|
- if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
793
|
+ if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
794
|
794
|
} else $recent_ident = ''; |
|
795
|
|
- $SpotterLive->db=null; |
|
|
795
|
+ $SpotterLive->db = null; |
|
796
|
796
|
if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
797
|
797
|
elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
798
|
798
|
} else $recent_ident = ''; |
|
799
|
799
|
} else { |
|
800
|
800
|
$recent_ident = ''; |
|
801
|
|
- $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
|
|
801
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0)); |
|
802
|
802
|
} |
|
803
|
803
|
//if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
804
|
|
- if($recent_ident == "") |
|
|
804
|
+ if ($recent_ident == "") |
|
805
|
805
|
{ |
|
806
|
806
|
if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
807
|
807
|
if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
808
|
808
|
if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
809
|
809
|
//adds the spotter data for the archive |
|
810
|
810
|
$ignoreImport = false; |
|
811
|
|
- foreach($globalAirportIgnore as $airportIgnore) { |
|
|
811
|
+ foreach ($globalAirportIgnore as $airportIgnore) { |
|
812
|
812
|
if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
813
|
813
|
$ignoreImport = true; |
|
814
|
814
|
} |
|
815
|
815
|
} |
|
816
|
816
|
if (count($globalAirportAccept) > 0) { |
|
817
|
817
|
$ignoreImport = true; |
|
818
|
|
- foreach($globalAirportIgnore as $airportIgnore) { |
|
|
818
|
+ foreach ($globalAirportIgnore as $airportIgnore) { |
|
819
|
819
|
if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
820
|
820
|
$ignoreImport = false; |
|
821
|
821
|
} |
|
822
|
822
|
} |
|
823
|
823
|
} |
|
824
|
824
|
if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
825
|
|
- foreach($globalAirlineIgnore as $airlineIgnore) { |
|
826
|
|
- 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)) { |
|
|
825
|
+ foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
|
826
|
+ 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)) { |
|
827
|
827
|
$ignoreImport = true; |
|
828
|
828
|
} |
|
829
|
829
|
} |
|
830
|
830
|
} |
|
831
|
831
|
if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
832
|
832
|
$ignoreImport = true; |
|
833
|
|
- foreach($globalAirlineAccept as $airlineAccept) { |
|
834
|
|
- 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)) { |
|
|
833
|
+ foreach ($globalAirlineAccept as $airlineAccept) { |
|
|
834
|
+ 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)) { |
|
835
|
835
|
$ignoreImport = false; |
|
836
|
836
|
} |
|
837
|
837
|
} |
|
838
|
838
|
} |
|
839
|
839
|
if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
840
|
840
|
$ignoreImport = true; |
|
841
|
|
- foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
|
841
|
+ foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
842
|
842
|
if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
843
|
843
|
$ignoreImport = false; |
|
844
|
844
|
} |
|
@@ -850,12 +850,12 @@ discard block |
|
|
block discarded – undo |
|
850
|
850
|
if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
851
|
851
|
if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
852
|
852
|
if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
853
|
|
- 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'))); |
|
|
853
|
+ 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'))); |
|
854
|
854
|
$timeelapsed = microtime(true); |
|
855
|
855
|
if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
856
|
856
|
if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
857
|
857
|
$Spotter = new Spotter($this->db); |
|
858
|
|
- $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']); |
|
|
858
|
+ $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']); |
|
859
|
859
|
$Spotter->db = null; |
|
860
|
860
|
if ($globalDebug) { |
|
861
|
861
|
if (isset($result['error'])) echo 'Error: '.$result['error']."\n"; |
|
@@ -868,22 +868,22 @@ discard block |
|
|
block discarded – undo |
|
868
|
868
|
} |
|
869
|
869
|
} |
|
870
|
870
|
} |
|
871
|
|
- if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
871
|
+ if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
872
|
872
|
if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
873
|
873
|
|
|
874
|
874
|
// Add source stat in DB |
|
875
|
875
|
$Stats = new Stats($this->db); |
|
876
|
876
|
if (!empty($this->stats)) { |
|
877
|
877
|
if ($globalDebug) echo 'Add source stats : '; |
|
878
|
|
- foreach($this->stats as $date => $data) { |
|
879
|
|
- foreach($data as $source => $sourced) { |
|
|
878
|
+ foreach ($this->stats as $date => $data) { |
|
|
879
|
+ foreach ($data as $source => $sourced) { |
|
880
|
880
|
//print_r($sourced); |
|
881
|
|
- if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
882
|
|
- if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
|
881
|
+ if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date); |
|
|
882
|
+ if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date); |
|
883
|
883
|
if (isset($sourced['msg'])) { |
|
884
|
884
|
if (time() - $sourced['msg']['date'] > 10) { |
|
885
|
885
|
$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
886
|
|
- echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
|
886
|
+ echo $Stats->addStatSource($nbmsg, $source, 'msg', $date); |
|
887
|
887
|
unset($this->stats[$date][$source]['msg']); |
|
888
|
888
|
} |
|
889
|
889
|
} |
|
@@ -921,14 +921,14 @@ discard block |
|
|
block discarded – undo |
|
921
|
921
|
if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
922
|
922
|
$SpotterLive = new SpotterLive($this->db); |
|
923
|
923
|
$SpotterLive->deleteLiveSpotterData(); |
|
924
|
|
- $SpotterLive->db=null; |
|
|
924
|
+ $SpotterLive->db = null; |
|
925
|
925
|
} |
|
926
|
926
|
} |
|
927
|
927
|
if ($globalDebug) echo " Done\n"; |
|
928
|
928
|
$this->last_delete = time(); |
|
929
|
929
|
} |
|
930
|
930
|
} else { |
|
931
|
|
- 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')) { |
|
|
931
|
+ 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')) { |
|
932
|
932
|
$this->all_flights[$id]['id'] = $recent_ident; |
|
933
|
933
|
$this->all_flights[$id]['addedSpotter'] = 1; |
|
934
|
934
|
} |
|
@@ -936,7 +936,7 @@ discard block |
|
|
block discarded – undo |
|
936
|
936
|
if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
937
|
937
|
if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
938
|
938
|
$Spotter = new Spotter($this->db); |
|
939
|
|
- $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']); |
|
|
939
|
+ $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']); |
|
940
|
940
|
$Spotter->db = null; |
|
941
|
941
|
} |
|
942
|
942
|
} |
|
@@ -962,37 +962,37 @@ discard block |
|
|
block discarded – undo |
|
962
|
962
|
if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
963
|
963
|
if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
964
|
964
|
|
|
965
|
|
- foreach($globalAirportIgnore as $airportIgnore) { |
|
|
965
|
+ foreach ($globalAirportIgnore as $airportIgnore) { |
|
966
|
966
|
if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
967
|
967
|
$ignoreImport = true; |
|
968
|
968
|
} |
|
969
|
969
|
} |
|
970
|
970
|
if (count($globalAirportAccept) > 0) { |
|
971
|
971
|
$ignoreImport = true; |
|
972
|
|
- foreach($globalAirportIgnore as $airportIgnore) { |
|
|
972
|
+ foreach ($globalAirportIgnore as $airportIgnore) { |
|
973
|
973
|
if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
974
|
974
|
$ignoreImport = false; |
|
975
|
975
|
} |
|
976
|
976
|
} |
|
977
|
977
|
} |
|
978
|
978
|
if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
979
|
|
- foreach($globalAirlineIgnore as $airlineIgnore) { |
|
980
|
|
- 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)) { |
|
|
979
|
+ foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
|
980
|
+ 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)) { |
|
981
|
981
|
$ignoreImport = true; |
|
982
|
982
|
} |
|
983
|
983
|
} |
|
984
|
984
|
} |
|
985
|
985
|
if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
986
|
986
|
$ignoreImport = true; |
|
987
|
|
- foreach($globalAirlineAccept as $airlineAccept) { |
|
988
|
|
- 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)) { |
|
|
987
|
+ foreach ($globalAirlineAccept as $airlineAccept) { |
|
|
988
|
+ 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)) { |
|
989
|
989
|
$ignoreImport = false; |
|
990
|
990
|
} |
|
991
|
991
|
} |
|
992
|
992
|
} |
|
993
|
993
|
if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
994
|
994
|
$ignoreImport = true; |
|
995
|
|
- foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
|
995
|
+ foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
996
|
996
|
if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
997
|
997
|
$ignoreImport = false; |
|
998
|
998
|
} |
|
@@ -1000,24 +1000,24 @@ discard block |
|
|
block discarded – undo |
|
1000
|
1000
|
} |
|
1001
|
1001
|
|
|
1002
|
1002
|
if (!$ignoreImport) { |
|
1003
|
|
- 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'])) { |
|
1004
|
|
- 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'))); |
|
|
1003
|
+ 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'])) { |
|
|
1004
|
+ 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'))); |
|
1005
|
1005
|
$timeelapsed = microtime(true); |
|
1006
|
1006
|
if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
1007
|
1007
|
if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
1008
|
1008
|
if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
1009
|
1009
|
$SpotterLive = new SpotterLive($this->db); |
|
1010
|
1010
|
//var_dump($this->all_flights[$id]); |
|
1011
|
|
- $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']); |
|
|
1011
|
+ $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']); |
|
1012
|
1012
|
$SpotterLive->db = null; |
|
1013
|
1013
|
if ($globalDebug) echo $result."\n"; |
|
1014
|
1014
|
} |
|
1015
|
1015
|
} |
|
1016
|
1016
|
if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
|
1017
|
|
- $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']); |
|
|
1017
|
+ $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']); |
|
1018
|
1018
|
} |
|
1019
|
1019
|
$this->all_flights[$id]['putinarchive'] = false; |
|
1020
|
|
- if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
1020
|
+ if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
1021
|
1021
|
|
|
1022
|
1022
|
// Put statistics in $this->stats variable |
|
1023
|
1023
|
//if ($line['format_source'] != 'aprs') { |
|
@@ -1036,19 +1036,19 @@ discard block |
|
|
block discarded – undo |
|
1036
|
1036
|
$latitude = $globalCenterLatitude; |
|
1037
|
1037
|
$longitude = $globalCenterLongitude; |
|
1038
|
1038
|
} |
|
1039
|
|
- $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
|
1039
|
+ $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
1040
|
1040
|
} else { |
|
1041
|
1041
|
$latitude = $this->source_location[$source]['latitude']; |
|
1042
|
1042
|
$longitude = $this->source_location[$source]['longitude']; |
|
1043
|
1043
|
} |
|
1044
|
|
- $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
|
1044
|
+ $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
1045
|
1045
|
//$stats_heading = $stats_heading%22.5; |
|
1046
|
1046
|
$stats_heading = round($stats_heading/22.5); |
|
1047
|
|
- $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
|
1047
|
+ $stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
1048
|
1048
|
$current_date = date('Y-m-d'); |
|
1049
|
1049
|
if ($stats_heading == 16) $stats_heading = 0; |
|
1050
|
1050
|
if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
|
1051
|
|
- for ($i=0;$i<=15;$i++) { |
|
|
1051
|
+ for ($i = 0; $i <= 15; $i++) { |
|
1052
|
1052
|
$this->stats[$current_date][$source]['polar'][$i] = 0; |
|
1053
|
1053
|
} |
|
1054
|
1054
|
$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
|
@@ -1063,9 +1063,9 @@ discard block |
|
|
block discarded – undo |
|
1063
|
1063
|
if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
|
1064
|
1064
|
if (isset($this->stats[$current_date][$source]['hist'][0])) { |
|
1065
|
1065
|
end($this->stats[$current_date][$source]['hist']); |
|
1066
|
|
- $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
|
1066
|
+ $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
1067
|
1067
|
} else $mini = 0; |
|
1068
|
|
- for ($i=$mini;$i<=$distance;$i+=10) { |
|
|
1068
|
+ for ($i = $mini; $i <= $distance; $i += 10) { |
|
1069
|
1069
|
$this->stats[$current_date][$source]['hist'][$i] = 0; |
|
1070
|
1070
|
} |
|
1071
|
1071
|
$this->stats[$current_date][$source]['hist'][$distance] = 1; |
|
@@ -1078,7 +1078,7 @@ discard block |
|
|
block discarded – undo |
|
1078
|
1078
|
$this->all_flights[$id]['lastupdate'] = time(); |
|
1079
|
1079
|
if ($this->all_flights[$id]['putinarchive']) $send = true; |
|
1080
|
1080
|
//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1081
|
|
- } 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"; |
|
|
1081
|
+ } 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"; |
|
1082
|
1082
|
//$this->del(); |
|
1083
|
1083
|
|
|
1084
|
1084
|
if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |