@@ -8,20 +8,20 @@ discard block |
||
8 | 8 | require_once(dirname(__FILE__).'/class.Stats.php'); |
9 | 9 | require_once(dirname(__FILE__).'/class.Source.php'); |
10 | 10 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
11 | - require_once(dirname(__FILE__).'/class.APRS.php'); |
|
11 | + require_once(dirname(__FILE__).'/class.APRS.php'); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | class SpotterImport { |
15 | - private $all_flights = array(); |
|
16 | - private $last_delete_hourly = 0; |
|
17 | - private $last_delete = 0; |
|
18 | - private $stats = array(); |
|
19 | - private $tmd = 0; |
|
20 | - private $source_location = array(); |
|
21 | - public $db = null; |
|
22 | - public $nb = 0; |
|
23 | - |
|
24 | - public function __construct($dbc = null) { |
|
15 | + private $all_flights = array(); |
|
16 | + private $last_delete_hourly = 0; |
|
17 | + private $last_delete = 0; |
|
18 | + private $stats = array(); |
|
19 | + private $tmd = 0; |
|
20 | + private $source_location = array(); |
|
21 | + public $db = null; |
|
22 | + public $nb = 0; |
|
23 | + |
|
24 | + public function __construct($dbc = null) { |
|
25 | 25 | global $globalBeta, $globalServerAPRS, $APRSSpotter; |
26 | 26 | $Connection = new Connection($dbc); |
27 | 27 | $this->db = $Connection->db(); |
@@ -32,23 +32,23 @@ discard block |
||
32 | 32 | $currentdate = date('Y-m-d'); |
33 | 33 | $sourcestat = $Stats->getStatsSource($currentdate); |
34 | 34 | if (!empty($sourcestat)) { |
35 | - foreach($sourcestat as $srcst) { |
|
36 | - $type = $srcst['stats_type']; |
|
35 | + foreach($sourcestat as $srcst) { |
|
36 | + $type = $srcst['stats_type']; |
|
37 | 37 | if ($type == 'polar' || $type == 'hist') { |
38 | - $source = $srcst['source_name']; |
|
39 | - $data = $srcst['source_data']; |
|
40 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
41 | - } |
|
42 | - } |
|
38 | + $source = $srcst['source_name']; |
|
39 | + $data = $srcst['source_data']; |
|
40 | + $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
41 | + } |
|
42 | + } |
|
43 | 43 | } |
44 | 44 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
45 | 45 | $APRSSpotter = new APRSSpotter(); |
46 | 46 | //$APRSSpotter->connect(); |
47 | 47 | } |
48 | 48 | |
49 | - } |
|
49 | + } |
|
50 | 50 | |
51 | - public function get_Schedule($id,$ident) { |
|
51 | + public function get_Schedule($id,$ident) { |
|
52 | 52 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
53 | 53 | // Get schedule here, so it's done only one time |
54 | 54 | |
@@ -68,42 +68,42 @@ discard block |
||
68 | 68 | $operator = $Spotter->getOperator($ident); |
69 | 69 | $scheduleexist = false; |
70 | 70 | if ($Schedule->checkSchedule($operator) == 0) { |
71 | - $operator = $Translation->checkTranslation($ident); |
|
72 | - if ($Schedule->checkSchedule($operator) == 0) { |
|
71 | + $operator = $Translation->checkTranslation($ident); |
|
72 | + if ($Schedule->checkSchedule($operator) == 0) { |
|
73 | 73 | $schedule = $Schedule->fetchSchedule($operator); |
74 | 74 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
75 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
76 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
77 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
78 | - // Should also check if route schedule = route from DB |
|
79 | - if ($schedule['DepartureAirportIATA'] != '') { |
|
75 | + if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
76 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
77 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
78 | + // Should also check if route schedule = route from DB |
|
79 | + if ($schedule['DepartureAirportIATA'] != '') { |
|
80 | 80 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
81 | - $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
82 | - if (trim($airport_icao) != '') { |
|
81 | + $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
82 | + if (trim($airport_icao) != '') { |
|
83 | 83 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
84 | 84 | if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
85 | - } |
|
85 | + } |
|
86 | + } |
|
86 | 87 | } |
87 | - } |
|
88 | - if ($schedule['ArrivalAirportIATA'] != '') { |
|
88 | + if ($schedule['ArrivalAirportIATA'] != '') { |
|
89 | 89 | if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) { |
90 | - $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
91 | - if (trim($airport_icao) != '') { |
|
90 | + $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
91 | + if (trim($airport_icao) != '') { |
|
92 | 92 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
93 | 93 | if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
94 | - } |
|
94 | + } |
|
95 | 95 | } |
96 | - } |
|
97 | - $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']); |
|
96 | + } |
|
97 | + $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']); |
|
98 | 98 | } |
99 | - } else $scheduleexist = true; |
|
99 | + } else $scheduleexist = true; |
|
100 | 100 | } else $scheduleexist = true; |
101 | 101 | // close connection, at least one way will work ? |
102 | - if ($scheduleexist) { |
|
102 | + if ($scheduleexist) { |
|
103 | 103 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
104 | - $sch = $Schedule->getSchedule($operator); |
|
104 | + $sch = $Schedule->getSchedule($operator); |
|
105 | 105 | $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'])); |
106 | - } |
|
106 | + } |
|
107 | 107 | $Spotter->db = null; |
108 | 108 | $Schedule->db = null; |
109 | 109 | $Translation->db = null; |
@@ -118,96 +118,96 @@ discard block |
||
118 | 118 | } |
119 | 119 | */ |
120 | 120 | } |
121 | - } |
|
121 | + } |
|
122 | 122 | |
123 | - public function checkAll() { |
|
123 | + public function checkAll() { |
|
124 | 124 | global $globalDebug, $globalNoImport; |
125 | 125 | if ($globalDebug) echo "Update last seen flights data...\n"; |
126 | 126 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
127 | - foreach ($this->all_flights as $key => $flight) { |
|
127 | + foreach ($this->all_flights as $key => $flight) { |
|
128 | 128 | if (isset($this->all_flights[$key]['id'])) { |
129 | - //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
|
130 | - $Spotter = new Spotter($this->db); |
|
131 | - $real_arrival = $this->arrival($key); |
|
132 | - $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']); |
|
133 | - } |
|
134 | - } |
|
129 | + //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
|
130 | + $Spotter = new Spotter($this->db); |
|
131 | + $real_arrival = $this->arrival($key); |
|
132 | + $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']); |
|
133 | + } |
|
134 | + } |
|
135 | + } |
|
135 | 136 | } |
136 | - } |
|
137 | 137 | |
138 | - public function arrival($key) { |
|
138 | + public function arrival($key) { |
|
139 | 139 | global $globalClosestMinDist, $globalDebug; |
140 | 140 | if ($globalDebug) echo 'Update arrival...'."\n"; |
141 | 141 | $Spotter = new Spotter($this->db); |
142 | - $airport_icao = ''; |
|
143 | - $airport_time = ''; |
|
144 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
142 | + $airport_icao = ''; |
|
143 | + $airport_time = ''; |
|
144 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
145 | 145 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
146 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
147 | - if (isset($closestAirports[0])) { |
|
148 | - if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
149 | - $airport_icao = $closestAirports[0]['icao']; |
|
150 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
151 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
152 | - } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
153 | - foreach ($closestAirports as $airport) { |
|
154 | - if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
155 | - $airport_icao = $airport['icao']; |
|
156 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
157 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
158 | - break; |
|
159 | - } |
|
160 | - } |
|
161 | - } 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))) { |
|
162 | - $airport_icao = $closestAirports[0]['icao']; |
|
163 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
164 | - } else { |
|
165 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
166 | - } |
|
167 | - } else { |
|
168 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
169 | - } |
|
170 | - |
|
171 | - } else { |
|
172 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
173 | - } |
|
174 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
175 | - } |
|
176 | - |
|
177 | - |
|
178 | - |
|
179 | - public function del() { |
|
146 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
147 | + if (isset($closestAirports[0])) { |
|
148 | + if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
149 | + $airport_icao = $closestAirports[0]['icao']; |
|
150 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
151 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
152 | + } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
153 | + foreach ($closestAirports as $airport) { |
|
154 | + if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
155 | + $airport_icao = $airport['icao']; |
|
156 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
157 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
158 | + break; |
|
159 | + } |
|
160 | + } |
|
161 | + } 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))) { |
|
162 | + $airport_icao = $closestAirports[0]['icao']; |
|
163 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
164 | + } else { |
|
165 | + if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
166 | + } |
|
167 | + } else { |
|
168 | + if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
169 | + } |
|
170 | + |
|
171 | + } else { |
|
172 | + if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
173 | + } |
|
174 | + return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
175 | + } |
|
176 | + |
|
177 | + |
|
178 | + |
|
179 | + public function del() { |
|
180 | 180 | global $globalDebug, $globalNoImport, $globalNoDB; |
181 | 181 | // Delete old infos |
182 | 182 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
183 | 183 | foreach ($this->all_flights as $key => $flight) { |
184 | - if (isset($flight['lastupdate'])) { |
|
185 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
186 | - if (isset($this->all_flights[$key]['id'])) { |
|
187 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
184 | + if (isset($flight['lastupdate'])) { |
|
185 | + if ($flight['lastupdate'] < (time()-3000)) { |
|
186 | + if (isset($this->all_flights[$key]['id'])) { |
|
187 | + if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
188 | 188 | /* |
189 | 189 | $SpotterLive = new SpotterLive(); |
190 | 190 | $SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']); |
191 | 191 | $SpotterLive->db = null; |
192 | 192 | */ |
193 | 193 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
194 | - $real_arrival = $this->arrival($key); |
|
195 | - $Spotter = new Spotter($this->db); |
|
196 | - if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
|
194 | + $real_arrival = $this->arrival($key); |
|
195 | + $Spotter = new Spotter($this->db); |
|
196 | + if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
|
197 | 197 | $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']); |
198 | 198 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
199 | - } |
|
199 | + } |
|
200 | 200 | // Put in archive |
201 | 201 | // $Spotter->db = null; |
202 | 202 | } |
203 | - } |
|
204 | - unset($this->all_flights[$key]); |
|
205 | - } |
|
206 | - } |
|
207 | - } |
|
208 | - } |
|
203 | + } |
|
204 | + unset($this->all_flights[$key]); |
|
205 | + } |
|
206 | + } |
|
207 | + } |
|
208 | + } |
|
209 | 209 | |
210 | - public function add($line) { |
|
210 | + public function add($line) { |
|
211 | 211 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB; |
212 | 212 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
213 | 213 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
@@ -232,18 +232,18 @@ discard block |
||
232 | 232 | |
233 | 233 | // SBS format is CSV format |
234 | 234 | if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
235 | - //print_r($line); |
|
236 | - if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
235 | + //print_r($line); |
|
236 | + if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
237 | 237 | |
238 | 238 | // Increment message number |
239 | 239 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
240 | - $current_date = date('Y-m-d'); |
|
241 | - $source = $line['source_name']; |
|
242 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
243 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
244 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
245 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
246 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
240 | + $current_date = date('Y-m-d'); |
|
241 | + $source = $line['source_name']; |
|
242 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
243 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
244 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
245 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
246 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /* |
@@ -259,49 +259,49 @@ discard block |
||
259 | 259 | //$this->db = $dbc; |
260 | 260 | |
261 | 261 | //$hex = trim($line['hex']); |
262 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
263 | - else $id = trim($line['id']); |
|
262 | + if (!isset($line['id'])) $id = trim($line['hex']); |
|
263 | + else $id = trim($line['id']); |
|
264 | 264 | |
265 | 265 | if (!isset($this->all_flights[$id])) { |
266 | - $this->all_flights[$id] = array(); |
|
267 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
268 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', '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' => '')); |
|
269 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
270 | - if (!isset($line['id'])) { |
|
266 | + $this->all_flights[$id] = array(); |
|
267 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
268 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', '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' => '')); |
|
269 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
270 | + if (!isset($line['id'])) { |
|
271 | 271 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
272 | 272 | // 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'))); |
273 | 273 | // 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'))); |
274 | 274 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
275 | - //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
276 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
277 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
275 | + //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
276 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
277 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
278 | 278 | } |
279 | 279 | if (isset($line['source_type']) && $line['source_type'] != '') { |
280 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
280 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | //print_r($this->all_flights); |
284 | 284 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
285 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
286 | - //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
285 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
286 | + //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
287 | 287 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
288 | - //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
289 | - if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') { |
|
288 | + //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
289 | + if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') { |
|
290 | 290 | $timeelapsed = microtime(true); |
291 | 291 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
292 | - $Spotter = new Spotter($this->db); |
|
293 | - if (isset($this->all_flights[$id]['source_type'])) { |
|
292 | + $Spotter = new Spotter($this->db); |
|
293 | + if (isset($this->all_flights[$id]['source_type'])) { |
|
294 | 294 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
295 | - } else { |
|
295 | + } else { |
|
296 | 296 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
297 | - } |
|
298 | - $Spotter->db = null; |
|
299 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
300 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
297 | + } |
|
298 | + $Spotter->db = null; |
|
299 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
300 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
301 | 301 | } |
302 | - } |
|
303 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
304 | - if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
302 | + } |
|
303 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
304 | + if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
305 | 305 | } |
306 | 306 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
307 | 307 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao'])); |
@@ -327,9 +327,9 @@ discard block |
||
327 | 327 | } |
328 | 328 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
329 | 329 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60) { |
330 | - if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
330 | + if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
331 | 331 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
332 | - } else { |
|
332 | + } else { |
|
333 | 333 | 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"; |
334 | 334 | 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"; |
335 | 335 | /* |
@@ -338,43 +338,43 @@ discard block |
||
338 | 338 | print_r($line); |
339 | 339 | */ |
340 | 340 | return ''; |
341 | - } |
|
341 | + } |
|
342 | 342 | } else { |
343 | 343 | date_default_timezone_set('UTC'); |
344 | 344 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
345 | 345 | } |
346 | 346 | |
347 | 347 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') { |
348 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
348 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
349 | 349 | } |
350 | 350 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
351 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
351 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
352 | 352 | } |
353 | 353 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
354 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id'])); |
|
354 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id'])); |
|
355 | 355 | } |
356 | 356 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
357 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name'])); |
|
357 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name'])); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
361 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
362 | - if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
361 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
362 | + if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
363 | 363 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
364 | - $timeelapsed = microtime(true); |
|
365 | - $Spotter = new Spotter($this->db); |
|
366 | - $fromsource = NULL; |
|
367 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
368 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
369 | - elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
370 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
371 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
372 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
373 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
374 | - $Spotter->db = null; |
|
375 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
376 | - } |
|
377 | - } |
|
364 | + $timeelapsed = microtime(true); |
|
365 | + $Spotter = new Spotter($this->db); |
|
366 | + $fromsource = NULL; |
|
367 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
368 | + elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
369 | + elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
370 | + elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
371 | + elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
372 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
373 | + if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
374 | + $Spotter->db = null; |
|
375 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
376 | + } |
|
377 | + } |
|
378 | 378 | |
379 | 379 | /* |
380 | 380 | if (!isset($line['id'])) { |
@@ -384,104 +384,104 @@ discard block |
||
384 | 384 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
385 | 385 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
386 | 386 | */ |
387 | - 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'])); |
|
387 | + 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'])); |
|
388 | 388 | |
389 | - //$putinarchive = true; |
|
390 | - if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
389 | + //$putinarchive = true; |
|
390 | + if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
391 | 391 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
392 | - } |
|
393 | - if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
392 | + } |
|
393 | + if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
394 | 394 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
395 | - } |
|
396 | - if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
397 | - $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' => '')); |
|
398 | - } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
395 | + } |
|
396 | + if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
397 | + $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' => '')); |
|
398 | + } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
399 | 399 | $timeelapsed = microtime(true); |
400 | 400 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
401 | 401 | $Spotter = new Spotter($this->db); |
402 | 402 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
403 | 403 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
404 | - $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' => '')); |
|
404 | + $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' => '')); |
|
405 | 405 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
406 | - } |
|
407 | - } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
406 | + } |
|
407 | + } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
408 | 408 | $timeelapsed = microtime(true); |
409 | 409 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
410 | - $Spotter = new Spotter($this->db); |
|
411 | - $route = $Spotter->getRouteInfo(trim($line['ident'])); |
|
412 | - if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) { |
|
410 | + $Spotter = new Spotter($this->db); |
|
411 | + $route = $Spotter->getRouteInfo(trim($line['ident'])); |
|
412 | + if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) { |
|
413 | 413 | $Translation = new Translation($this->db); |
414 | 414 | $ident = $Translation->checkTranslation(trim($line['ident'])); |
415 | 415 | $route = $Spotter->getRouteInfo($ident); |
416 | 416 | $Translation->db = null; |
417 | - } |
|
418 | - $Spotter->db = null; |
|
419 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
420 | - } |
|
417 | + } |
|
418 | + $Spotter->db = null; |
|
419 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
420 | + } |
|
421 | 421 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
422 | - //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
423 | - if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
422 | + //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
423 | + if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
424 | 424 | // $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'])); |
425 | - $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'])); |
|
426 | - } |
|
425 | + $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'])); |
|
426 | + } |
|
427 | 427 | } |
428 | 428 | if (!isset($globalFork)) $globalFork = TRUE; |
429 | 429 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
430 | 430 | if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
431 | 431 | } |
432 | - } |
|
432 | + } |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | if (isset($line['speed']) && $line['speed'] != '') { |
436 | 436 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
437 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
438 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
439 | - //$dataFound = true; |
|
437 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
438 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
439 | + //$dataFound = true; |
|
440 | 440 | } 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'])) { |
441 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
442 | - if ($distance > 1000 && $distance < 10000) { |
|
443 | - // use datetime |
|
441 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
442 | + if ($distance > 1000 && $distance < 10000) { |
|
443 | + // use datetime |
|
444 | 444 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
445 | 445 | $speed = $speed*3.6; |
446 | 446 | if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
447 | 447 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
448 | - } |
|
448 | + } |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | |
452 | 452 | |
453 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
454 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
455 | - else unset($timediff); |
|
456 | - if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) { |
|
453 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
454 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
455 | + else unset($timediff); |
|
456 | + if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) { |
|
457 | 457 | if (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'])) { |
458 | - if (!$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'])) { |
|
458 | + if (!$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'])) { |
|
459 | 459 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
460 | 460 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
461 | 461 | $this->all_flights[$id]['putinarchive'] = true; |
462 | 462 | $this->tmd = 0; |
463 | 463 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
464 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
465 | - $timeelapsed = microtime(true); |
|
466 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
464 | + if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
465 | + $timeelapsed = microtime(true); |
|
466 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
467 | 467 | $Spotter = new Spotter($this->db); |
468 | 468 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
469 | 469 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
470 | 470 | $Spotter->db = null; |
471 | 471 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
472 | 472 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
473 | - } |
|
473 | + } |
|
474 | + } |
|
474 | 475 | } |
475 | - } |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
479 | - //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
479 | + //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
480 | 480 | if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
481 | 481 | 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') { |
482 | - $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
483 | - $dataFound = true; |
|
484 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
482 | + $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
483 | + $dataFound = true; |
|
484 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
485 | 485 | } |
486 | 486 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
487 | 487 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
@@ -492,20 +492,20 @@ discard block |
||
492 | 492 | //$putinarchive = true; |
493 | 493 | } |
494 | 494 | */ |
495 | - /* |
|
495 | + /* |
|
496 | 496 | } elseif (isset($this->all_flights[$id]['latitude'])) { |
497 | 497 | if ($globalDebug) echo '!!! Strange latitude value - diff : '.abs($this->all_flights[$id]['latitude']-$line['latitude']).'- previous lat : '.$this->all_flights[$id]['latitude'].'- new lat : '.$line['latitude']."\n"; |
498 | 498 | } |
499 | 499 | */ |
500 | 500 | } |
501 | 501 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
502 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
503 | - //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
502 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
503 | + //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
504 | 504 | if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
505 | 505 | 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') { |
506 | - $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
507 | - $dataFound = true; |
|
508 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
506 | + $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
507 | + $dataFound = true; |
|
508 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
509 | 509 | } |
510 | 510 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
511 | 511 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
@@ -523,95 +523,95 @@ discard block |
||
523 | 523 | */ |
524 | 524 | } |
525 | 525 | |
526 | - } else if ($globalDebug && $timediff > 30) { |
|
526 | + } else if ($globalDebug && $timediff > 30) { |
|
527 | 527 | $this->tmd = $this->tmd + 1; |
528 | 528 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
529 | 529 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
530 | 530 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
531 | 531 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
532 | - } |
|
532 | + } |
|
533 | 533 | } |
534 | 534 | if (isset($line['last_update']) && $line['last_update'] != '') { |
535 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
536 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
535 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
536 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
537 | 537 | } |
538 | 538 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
539 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
540 | - //$dataFound = true; |
|
539 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
540 | + //$dataFound = true; |
|
541 | 541 | } |
542 | 542 | if (isset($line['format_source']) && $line['format_source'] != '') { |
543 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
543 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
544 | 544 | } |
545 | 545 | if (isset($line['source_name']) && $line['source_name'] != '') { |
546 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
546 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
547 | 547 | } |
548 | 548 | if (isset($line['emergency']) && $line['emergency'] != '') { |
549 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
550 | - //$dataFound = true; |
|
549 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
550 | + //$dataFound = true; |
|
551 | 551 | } |
552 | 552 | if (isset($line['ground']) && $line['ground'] != '') { |
553 | - if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
553 | + if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
554 | 554 | // Here we force archive of flight because after ground it's a new one (or should be) |
555 | 555 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
556 | 556 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
557 | 557 | 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'].'-'.date('YmdGi'))); |
558 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
558 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
559 | 559 | 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'])); |
560 | - } |
|
561 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
562 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
563 | - //$dataFound = true; |
|
560 | + } |
|
561 | + if ($line['ground'] != 1) $line['ground'] = 0; |
|
562 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
563 | + //$dataFound = true; |
|
564 | 564 | } |
565 | 565 | if (isset($line['squawk']) && $line['squawk'] != '') { |
566 | - 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'])) { |
|
567 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
568 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
569 | - $highlight = ''; |
|
570 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
571 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
572 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
573 | - if ($highlight != '') { |
|
566 | + 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'])) { |
|
567 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
568 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
569 | + $highlight = ''; |
|
570 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
571 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
572 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
573 | + if ($highlight != '') { |
|
574 | 574 | $timeelapsed = microtime(true); |
575 | 575 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
576 | - $Spotter = new Spotter($this->db); |
|
577 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
578 | - $Spotter->db = null; |
|
579 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
576 | + $Spotter = new Spotter($this->db); |
|
577 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
578 | + $Spotter->db = null; |
|
579 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
580 | 580 | } |
581 | 581 | //$putinarchive = true; |
582 | 582 | //$highlight = ''; |
583 | - } |
|
583 | + } |
|
584 | 584 | |
585 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
586 | - //$dataFound = true; |
|
585 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
586 | + //$dataFound = true; |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | if (isset($line['altitude']) && $line['altitude'] != '') { |
590 | - //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
590 | + //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
591 | 591 | 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; |
592 | 592 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
593 | 593 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
594 | 594 | //$dataFound = true; |
595 | - //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
595 | + //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
596 | 596 | } |
597 | 597 | |
598 | 598 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
599 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
599 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | if (isset($line['heading']) && $line['heading'] != '') { |
603 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
604 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
605 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
606 | - //$dataFound = true; |
|
603 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
604 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
605 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
606 | + //$dataFound = true; |
|
607 | 607 | } 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']) { |
608 | - $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']); |
|
609 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
610 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
611 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
608 | + $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']); |
|
609 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
610 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
611 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
612 | 612 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
613 | - // If not enough messages and ACARS set heading to 0 |
|
614 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
613 | + // If not enough messages and ACARS set heading to 0 |
|
614 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
615 | 615 | } |
616 | 616 | if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
617 | 617 | elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
@@ -622,125 +622,125 @@ discard block |
||
622 | 622 | //if ($dataFound == true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['ident'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
623 | 623 | //if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
624 | 624 | if ($dataFound === true && isset($this->all_flights[$id]['hex'])) { |
625 | - $this->all_flights[$id]['lastupdate'] = time(); |
|
626 | - if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
627 | - 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'])) { |
|
628 | - //print_r($this->all_flights); |
|
629 | - //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
630 | - //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
631 | - if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
625 | + $this->all_flights[$id]['lastupdate'] = time(); |
|
626 | + if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
627 | + 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'])) { |
|
628 | + //print_r($this->all_flights); |
|
629 | + //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
630 | + //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
631 | + if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
632 | 632 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
633 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
634 | - $timeelapsed = microtime(true); |
|
635 | - $SpotterLive = new SpotterLive($this->db); |
|
636 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) { |
|
633 | + if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
634 | + $timeelapsed = microtime(true); |
|
635 | + $SpotterLive = new SpotterLive($this->db); |
|
636 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) { |
|
637 | 637 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
638 | 638 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
639 | - } elseif (isset($line['id'])) { |
|
639 | + } elseif (isset($line['id'])) { |
|
640 | 640 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
641 | 641 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
642 | - } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
642 | + } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
643 | 643 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
644 | 644 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
645 | - } else $recent_ident = ''; |
|
646 | - $SpotterLive->db=null; |
|
647 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
648 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
645 | + } else $recent_ident = ''; |
|
646 | + $SpotterLive->db=null; |
|
647 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
648 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
649 | 649 | } else $recent_ident = ''; |
650 | - } else { |
|
650 | + } else { |
|
651 | 651 | $recent_ident = ''; |
652 | 652 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
653 | - } |
|
654 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
655 | - if($recent_ident == "") |
|
656 | - { |
|
653 | + } |
|
654 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
655 | + if($recent_ident == "") |
|
656 | + { |
|
657 | 657 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
658 | 658 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
659 | 659 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
660 | 660 | //adds the spotter data for the archive |
661 | 661 | $ignoreImport = false; |
662 | 662 | foreach($globalAirportIgnore as $airportIgnore) { |
663 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
663 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
664 | 664 | $ignoreImport = true; |
665 | - } |
|
665 | + } |
|
666 | 666 | } |
667 | 667 | if (count($globalAirportAccept) > 0) { |
668 | - $ignoreImport = true; |
|
669 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
668 | + $ignoreImport = true; |
|
669 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
670 | 670 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
671 | - $ignoreImport = false; |
|
671 | + $ignoreImport = false; |
|
672 | + } |
|
672 | 673 | } |
673 | - } |
|
674 | 674 | } |
675 | 675 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
676 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
676 | + foreach($globalAirlineIgnore as $airlineIgnore) { |
|
677 | 677 | 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)) { |
678 | - $ignoreImport = true; |
|
678 | + $ignoreImport = true; |
|
679 | + } |
|
679 | 680 | } |
680 | - } |
|
681 | 681 | } |
682 | 682 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
683 | - $ignoreImport = true; |
|
684 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
683 | + $ignoreImport = true; |
|
684 | + foreach($globalAirlineAccept as $airlineAccept) { |
|
685 | 685 | 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)) { |
686 | - $ignoreImport = false; |
|
686 | + $ignoreImport = false; |
|
687 | + } |
|
687 | 688 | } |
688 | - } |
|
689 | 689 | } |
690 | 690 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
691 | - $ignoreImport = true; |
|
692 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
691 | + $ignoreImport = true; |
|
692 | + foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
693 | 693 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
694 | - $ignoreImport = false; |
|
694 | + $ignoreImport = false; |
|
695 | + } |
|
695 | 696 | } |
696 | - } |
|
697 | 697 | } |
698 | 698 | |
699 | 699 | if (!$ignoreImport) { |
700 | - $highlight = ''; |
|
701 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
702 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
703 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
704 | - 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'))); |
|
705 | - $timeelapsed = microtime(true); |
|
706 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
700 | + $highlight = ''; |
|
701 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
702 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
703 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
704 | + 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'))); |
|
705 | + $timeelapsed = microtime(true); |
|
706 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
707 | 707 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
708 | - $Spotter = new Spotter($this->db); |
|
709 | - $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']); |
|
710 | - $Spotter->db = null; |
|
711 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
708 | + $Spotter = new Spotter($this->db); |
|
709 | + $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']); |
|
710 | + $Spotter->db = null; |
|
711 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
712 | + } |
|
712 | 713 | } |
713 | - } |
|
714 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
715 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
714 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
715 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
716 | 716 | |
717 | - // Add source stat in DB |
|
718 | - $Stats = new Stats($this->db); |
|
719 | - if (!empty($this->stats)) { |
|
717 | + // Add source stat in DB |
|
718 | + $Stats = new Stats($this->db); |
|
719 | + if (!empty($this->stats)) { |
|
720 | 720 | if ($globalDebug) echo 'Add source stats : '; |
721 | - foreach($this->stats as $date => $data) { |
|
722 | - foreach($data as $source => $sourced) { |
|
723 | - //print_r($sourced); |
|
724 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
725 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
726 | - if (isset($sourced['msg'])) { |
|
727 | - if (time() - $sourced['msg']['date'] > 10) { |
|
728 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
729 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
730 | - unset($this->stats[$date][$source]['msg']); |
|
731 | - } |
|
732 | - } |
|
733 | - } |
|
734 | - if ($date != date('Y-m-d')) { |
|
735 | - unset($this->stats[$date]); |
|
736 | - } |
|
737 | - } |
|
738 | - if ($globalDebug) echo 'Done'."\n"; |
|
739 | - |
|
740 | - } |
|
741 | - $Stats->db = null; |
|
742 | - } |
|
743 | - $this->del(); |
|
721 | + foreach($this->stats as $date => $data) { |
|
722 | + foreach($data as $source => $sourced) { |
|
723 | + //print_r($sourced); |
|
724 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
725 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
726 | + if (isset($sourced['msg'])) { |
|
727 | + if (time() - $sourced['msg']['date'] > 10) { |
|
728 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
729 | + echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
730 | + unset($this->stats[$date][$source]['msg']); |
|
731 | + } |
|
732 | + } |
|
733 | + } |
|
734 | + if ($date != date('Y-m-d')) { |
|
735 | + unset($this->stats[$date]); |
|
736 | + } |
|
737 | + } |
|
738 | + if ($globalDebug) echo 'Done'."\n"; |
|
739 | + |
|
740 | + } |
|
741 | + $Stats->db = null; |
|
742 | + } |
|
743 | + $this->del(); |
|
744 | 744 | } elseif ($globalDebug) echo 'Ignore data'."\n"; |
745 | 745 | //$ignoreImport = false; |
746 | 746 | $this->all_flights[$id]['addedSpotter'] = 1; |
@@ -758,41 +758,41 @@ discard block |
||
758 | 758 | */ |
759 | 759 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
760 | 760 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
761 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
762 | - //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
763 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
761 | + if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
762 | + //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
763 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
764 | 764 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
765 | - $SpotterLive = new SpotterLive($this->db); |
|
766 | - $SpotterLive->deleteLiveSpotterData(); |
|
767 | - $SpotterLive->db=null; |
|
765 | + $SpotterLive = new SpotterLive($this->db); |
|
766 | + $SpotterLive->deleteLiveSpotterData(); |
|
767 | + $SpotterLive->db=null; |
|
768 | + } |
|
768 | 769 | } |
769 | - } |
|
770 | - if ($globalDebug) echo " Done\n"; |
|
771 | - $this->last_delete = time(); |
|
770 | + if ($globalDebug) echo " Done\n"; |
|
771 | + $this->last_delete = time(); |
|
772 | 772 | } |
773 | - } else { |
|
773 | + } else { |
|
774 | 774 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) { |
775 | - $this->all_flights[$id]['id'] = $recent_ident; |
|
776 | - $this->all_flights[$id]['addedSpotter'] = 1; |
|
775 | + $this->all_flights[$id]['id'] = $recent_ident; |
|
776 | + $this->all_flights[$id]['addedSpotter'] = 1; |
|
777 | 777 | } |
778 | 778 | if (isset($globalDaemon) && !$globalDaemon) { |
779 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
779 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
780 | 780 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
781 | - $Spotter = new Spotter($this->db); |
|
782 | - $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']); |
|
783 | - $Spotter->db = null; |
|
781 | + $Spotter = new Spotter($this->db); |
|
782 | + $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']); |
|
783 | + $Spotter->db = null; |
|
784 | + } |
|
784 | 785 | } |
785 | - } |
|
786 | 786 | } |
787 | 787 | |
788 | - } |
|
788 | + } |
|
789 | + } |
|
789 | 790 | } |
790 | - } |
|
791 | - //adds the spotter LIVE data |
|
792 | - //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
793 | - //echo "\nAdd in Live !! \n"; |
|
794 | - //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
|
795 | - if ($globalDebug) { |
|
791 | + //adds the spotter LIVE data |
|
792 | + //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
793 | + //echo "\nAdd in Live !! \n"; |
|
794 | + //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
|
795 | + if ($globalDebug) { |
|
796 | 796 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
797 | 797 | if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
798 | 798 | else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
@@ -800,60 +800,60 @@ discard block |
||
800 | 800 | if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
801 | 801 | else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
802 | 802 | } |
803 | - } |
|
804 | - $ignoreImport = false; |
|
805 | - if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
806 | - if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
803 | + } |
|
804 | + $ignoreImport = false; |
|
805 | + if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
806 | + if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
807 | 807 | |
808 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
809 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
810 | - $ignoreImport = true; |
|
808 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
809 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
810 | + $ignoreImport = true; |
|
811 | 811 | } |
812 | - } |
|
813 | - if (count($globalAirportAccept) > 0) { |
|
814 | - $ignoreImport = true; |
|
815 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
816 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
812 | + } |
|
813 | + if (count($globalAirportAccept) > 0) { |
|
814 | + $ignoreImport = true; |
|
815 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
816 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
817 | 817 | $ignoreImport = false; |
818 | - } |
|
818 | + } |
|
819 | + } |
|
819 | 820 | } |
820 | - } |
|
821 | - if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
821 | + if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
822 | 822 | foreach($globalAirlineIgnore as $airlineIgnore) { |
823 | - 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)) { |
|
823 | + 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)) { |
|
824 | 824 | $ignoreImport = true; |
825 | - } |
|
825 | + } |
|
826 | 826 | } |
827 | - } |
|
828 | - if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
827 | + } |
|
828 | + if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
829 | 829 | $ignoreImport = true; |
830 | 830 | foreach($globalAirlineAccept as $airlineAccept) { |
831 | - 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)) { |
|
831 | + 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)) { |
|
832 | 832 | $ignoreImport = false; |
833 | - } |
|
833 | + } |
|
834 | + } |
|
834 | 835 | } |
835 | - } |
|
836 | - if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
836 | + if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
837 | 837 | $ignoreImport = true; |
838 | 838 | foreach($globalPilotIdAccept as $pilotIdAccept) { |
839 | - if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
840 | - $ignoreImport = false; |
|
841 | - } |
|
839 | + if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
840 | + $ignoreImport = false; |
|
841 | + } |
|
842 | + } |
|
842 | 843 | } |
843 | - } |
|
844 | 844 | |
845 | - if (!$ignoreImport) { |
|
845 | + if (!$ignoreImport) { |
|
846 | 846 | 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'])) { |
847 | 847 | 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'))); |
848 | 848 | $timeelapsed = microtime(true); |
849 | 849 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
850 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
850 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
851 | 851 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
852 | 852 | $SpotterLive = new SpotterLive($this->db); |
853 | 853 | $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']); |
854 | 854 | $SpotterLive->db = null; |
855 | 855 | if ($globalDebug) echo $result."\n"; |
856 | - } |
|
856 | + } |
|
857 | 857 | } |
858 | 858 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
859 | 859 | $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']); |
@@ -865,7 +865,7 @@ discard block |
||
865 | 865 | //if ($line['format_source'] != 'aprs') { |
866 | 866 | //if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) { |
867 | 867 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
868 | - if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
|
868 | + if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
|
869 | 869 | $source = $this->all_flights[$id]['source_name']; |
870 | 870 | if ($source == '') $source = $this->all_flights[$id]['format_source']; |
871 | 871 | if (!isset($this->source_location[$source])) { |
@@ -891,7 +891,7 @@ discard block |
||
891 | 891 | if ($stats_heading == 16) $stats_heading = 0; |
892 | 892 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
893 | 893 | for ($i=0;$i<=15;$i++) { |
894 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
894 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
895 | 895 | } |
896 | 896 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
897 | 897 | } else { |
@@ -904,17 +904,17 @@ discard block |
||
904 | 904 | //var_dump($this->stats); |
905 | 905 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
906 | 906 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
907 | - end($this->stats[$current_date][$source]['hist']); |
|
908 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
907 | + end($this->stats[$current_date][$source]['hist']); |
|
908 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
909 | 909 | } else $mini = 0; |
910 | 910 | for ($i=$mini;$i<=$distance;$i+=10) { |
911 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
911 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
912 | 912 | } |
913 | 913 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
914 | 914 | } else { |
915 | 915 | $this->stats[$current_date][$source]['hist'][$distance] += 1; |
916 | 916 | } |
917 | - } |
|
917 | + } |
|
918 | 918 | } |
919 | 919 | |
920 | 920 | $this->all_flights[$id]['lastupdate'] = time(); |
@@ -924,7 +924,7 @@ discard block |
||
924 | 924 | //$this->del(); |
925 | 925 | |
926 | 926 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
927 | - if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
927 | + if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
928 | 928 | if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
929 | 929 | $SpotterLive = new SpotterLive($this->db); |
930 | 930 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
@@ -932,19 +932,19 @@ discard block |
||
932 | 932 | //SpotterLive->deleteLiveSpotterData(); |
933 | 933 | if ($globalDebug) echo " Done\n"; |
934 | 934 | $this->last_delete_hourly = time(); |
935 | - } else { |
|
935 | + } else { |
|
936 | 936 | $this->del(); |
937 | 937 | $this->last_delete_hourly = time(); |
938 | - } |
|
938 | + } |
|
939 | 939 | } |
940 | 940 | |
941 | - } |
|
942 | - //$ignoreImport = false; |
|
941 | + } |
|
942 | + //$ignoreImport = false; |
|
943 | 943 | } |
944 | 944 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
945 | 945 | if ($send) return $this->all_flights[$id]; |
946 | - } |
|
946 | + } |
|
947 | + } |
|
947 | 948 | } |
948 | - } |
|
949 | 949 | } |
950 | 950 | ?> |