@@ -9,20 +9,20 @@ discard block |
||
9 | 9 | require_once(dirname(__FILE__).'/class.Source.php'); |
10 | 10 | require_once(dirname(__FILE__).'/class.GeoidHeight.php'); |
11 | 11 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
12 | - require_once(dirname(__FILE__).'/class.APRS.php'); |
|
12 | + require_once(dirname(__FILE__).'/class.APRS.php'); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | class SpotterImport { |
16 | - private $all_flights = array(); |
|
17 | - private $last_delete_hourly = 0; |
|
18 | - private $last_delete = 0; |
|
19 | - private $stats = array(); |
|
20 | - private $tmd = 0; |
|
21 | - private $source_location = array(); |
|
22 | - public $db = null; |
|
23 | - public $nb = 0; |
|
16 | + private $all_flights = array(); |
|
17 | + private $last_delete_hourly = 0; |
|
18 | + private $last_delete = 0; |
|
19 | + private $stats = array(); |
|
20 | + private $tmd = 0; |
|
21 | + private $source_location = array(); |
|
22 | + public $db = null; |
|
23 | + public $nb = 0; |
|
24 | 24 | |
25 | - public function __construct($dbc = null) { |
|
25 | + public function __construct($dbc = null) { |
|
26 | 26 | global $globalBeta, $globalServerAPRS, $APRSSpotter, $globalNoDB, $GeoidClass, $globalDebug, $globalGeoid; |
27 | 27 | if (!(isset($globalNoDB) && $globalNoDB)) { |
28 | 28 | $Connection = new Connection($dbc); |
@@ -34,14 +34,14 @@ discard block |
||
34 | 34 | $currentdate = date('Y-m-d'); |
35 | 35 | $sourcestat = $Stats->getStatsSource($currentdate); |
36 | 36 | if (!empty($sourcestat)) { |
37 | - foreach($sourcestat as $srcst) { |
|
38 | - $type = $srcst['stats_type']; |
|
37 | + foreach($sourcestat as $srcst) { |
|
38 | + $type = $srcst['stats_type']; |
|
39 | 39 | if ($type == 'polar' || $type == 'hist') { |
40 | - $source = $srcst['source_name']; |
|
41 | - $data = $srcst['source_data']; |
|
42 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
43 | - } |
|
44 | - } |
|
40 | + $source = $srcst['source_name']; |
|
41 | + $data = $srcst['source_data']; |
|
42 | + $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
43 | + } |
|
44 | + } |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | $GeoidClass = FALSE; |
57 | 57 | } |
58 | 58 | } |
59 | - } |
|
59 | + } |
|
60 | 60 | |
61 | - public function get_Schedule($id,$ident) { |
|
61 | + public function get_Schedule($id,$ident) { |
|
62 | 62 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
63 | 63 | // Get schedule here, so it's done only one time |
64 | 64 | |
@@ -78,43 +78,43 @@ discard block |
||
78 | 78 | $operator = $Spotter->getOperator($ident); |
79 | 79 | $scheduleexist = false; |
80 | 80 | if ($Schedule->checkSchedule($operator) == 0) { |
81 | - $operator = $Translation->checkTranslation($ident); |
|
82 | - if ($Schedule->checkSchedule($operator) == 0) { |
|
81 | + $operator = $Translation->checkTranslation($ident); |
|
82 | + if ($Schedule->checkSchedule($operator) == 0) { |
|
83 | 83 | $schedule = $Schedule->fetchSchedule($operator); |
84 | 84 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
85 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
86 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
87 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
88 | - // Should also check if route schedule = route from DB |
|
89 | - if ($schedule['DepartureAirportIATA'] != '') { |
|
85 | + if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
86 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
87 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
88 | + // Should also check if route schedule = route from DB |
|
89 | + if ($schedule['DepartureAirportIATA'] != '') { |
|
90 | 90 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
91 | - $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
92 | - if (trim($airport_icao) != '') { |
|
91 | + $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
92 | + if (trim($airport_icao) != '') { |
|
93 | 93 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
94 | 94 | if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
95 | - } |
|
95 | + } |
|
96 | + } |
|
96 | 97 | } |
97 | - } |
|
98 | - if ($schedule['ArrivalAirportIATA'] != '') { |
|
98 | + if ($schedule['ArrivalAirportIATA'] != '') { |
|
99 | 99 | if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) { |
100 | - $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
101 | - if (trim($airport_icao) != '') { |
|
100 | + $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
101 | + if (trim($airport_icao) != '') { |
|
102 | 102 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
103 | 103 | if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
104 | - } |
|
104 | + } |
|
105 | 105 | } |
106 | - } |
|
107 | - $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
106 | + } |
|
107 | + $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
108 | 108 | } |
109 | - } else $scheduleexist = true; |
|
109 | + } else $scheduleexist = true; |
|
110 | 110 | } else $scheduleexist = true; |
111 | 111 | // close connection, at least one way will work ? |
112 | - if ($scheduleexist) { |
|
112 | + if ($scheduleexist) { |
|
113 | 113 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
114 | - $sch = $Schedule->getSchedule($operator); |
|
114 | + $sch = $Schedule->getSchedule($operator); |
|
115 | 115 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
116 | 116 | if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']); |
117 | - } |
|
117 | + } |
|
118 | 118 | $Spotter->db = null; |
119 | 119 | $Schedule->db = null; |
120 | 120 | $Translation->db = null; |
@@ -129,78 +129,78 @@ discard block |
||
129 | 129 | } |
130 | 130 | */ |
131 | 131 | } |
132 | - } |
|
132 | + } |
|
133 | 133 | |
134 | - public function checkAll() { |
|
134 | + public function checkAll() { |
|
135 | 135 | global $globalDebug, $globalNoImport; |
136 | 136 | if ($globalDebug) echo "Update last seen flights data...\n"; |
137 | 137 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
138 | - foreach ($this->all_flights as $key => $flight) { |
|
138 | + foreach ($this->all_flights as $key => $flight) { |
|
139 | 139 | if (isset($this->all_flights[$key]['id'])) { |
140 | - //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
|
141 | - $Spotter = new Spotter($this->db); |
|
142 | - $real_arrival = $this->arrival($key); |
|
143 | - if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
144 | - } |
|
145 | - } |
|
140 | + //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
|
141 | + $Spotter = new Spotter($this->db); |
|
142 | + $real_arrival = $this->arrival($key); |
|
143 | + if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
144 | + } |
|
145 | + } |
|
146 | + } |
|
146 | 147 | } |
147 | - } |
|
148 | 148 | |
149 | - public function arrival($key) { |
|
149 | + public function arrival($key) { |
|
150 | 150 | global $globalClosestMinDist, $globalDebug; |
151 | 151 | if ($globalDebug) echo 'Update arrival...'."\n"; |
152 | 152 | $Spotter = new Spotter($this->db); |
153 | - $airport_icao = ''; |
|
154 | - $airport_time = ''; |
|
155 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
153 | + $airport_icao = ''; |
|
154 | + $airport_time = ''; |
|
155 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
156 | 156 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
157 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
158 | - if (isset($closestAirports[0])) { |
|
159 | - if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
160 | - $airport_icao = $closestAirports[0]['icao']; |
|
161 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
162 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
163 | - } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
164 | - foreach ($closestAirports as $airport) { |
|
165 | - if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
166 | - $airport_icao = $airport['icao']; |
|
167 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
168 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
169 | - break; |
|
170 | - } |
|
171 | - } |
|
172 | - } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
173 | - $airport_icao = $closestAirports[0]['icao']; |
|
174 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
175 | - } else { |
|
176 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
177 | - } |
|
178 | - } else { |
|
179 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
180 | - } |
|
157 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
158 | + if (isset($closestAirports[0])) { |
|
159 | + if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
160 | + $airport_icao = $closestAirports[0]['icao']; |
|
161 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
162 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
163 | + } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
164 | + foreach ($closestAirports as $airport) { |
|
165 | + if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
166 | + $airport_icao = $airport['icao']; |
|
167 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
168 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
169 | + break; |
|
170 | + } |
|
171 | + } |
|
172 | + } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
173 | + $airport_icao = $closestAirports[0]['icao']; |
|
174 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
175 | + } else { |
|
176 | + if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
177 | + } |
|
178 | + } else { |
|
179 | + if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
180 | + } |
|
181 | 181 | |
182 | - } else { |
|
183 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
184 | - } |
|
185 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
186 | - } |
|
182 | + } else { |
|
183 | + if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
184 | + } |
|
185 | + return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
186 | + } |
|
187 | 187 | |
188 | 188 | |
189 | 189 | |
190 | - public function del() { |
|
190 | + public function del() { |
|
191 | 191 | global $globalDebug, $globalNoImport, $globalNoDB; |
192 | 192 | // Delete old infos |
193 | 193 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
194 | 194 | foreach ($this->all_flights as $key => $flight) { |
195 | - if (isset($flight['lastupdate'])) { |
|
195 | + if (isset($flight['lastupdate'])) { |
|
196 | 196 | if ($flight['lastupdate'] < (time()-1800)) { |
197 | - $this->delKey($key); |
|
197 | + $this->delKey($key); |
|
198 | + } |
|
198 | 199 | } |
199 | - } |
|
200 | 200 | } |
201 | - } |
|
201 | + } |
|
202 | 202 | |
203 | - public function delKey($key) { |
|
203 | + public function delKey($key) { |
|
204 | 204 | global $globalDebug, $globalNoImport, $globalNoDB; |
205 | 205 | // Delete old infos |
206 | 206 | if (isset($this->all_flights[$key]['id'])) { |
@@ -221,9 +221,9 @@ discard block |
||
221 | 221 | } |
222 | 222 | } |
223 | 223 | unset($this->all_flights[$key]); |
224 | - } |
|
224 | + } |
|
225 | 225 | |
226 | - public function add($line) { |
|
226 | + public function add($line) { |
|
227 | 227 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval, $GeoidClass, $globalArchive; |
228 | 228 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
229 | 229 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.01'; |
@@ -249,20 +249,20 @@ discard block |
||
249 | 249 | |
250 | 250 | // SBS format is CSV format |
251 | 251 | if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
252 | - //print_r($line); |
|
253 | - if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
254 | - if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
252 | + //print_r($line); |
|
253 | + if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
254 | + if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
255 | 255 | |
256 | 256 | // Increment message number |
257 | 257 | if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
258 | - $current_date = date('Y-m-d'); |
|
259 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
260 | - else $source = ''; |
|
261 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
262 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
263 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
264 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
265 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
258 | + $current_date = date('Y-m-d'); |
|
259 | + if (isset($line['source_name'])) $source = $line['source_name']; |
|
260 | + else $source = ''; |
|
261 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
262 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
263 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
264 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
265 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /* |
@@ -278,54 +278,54 @@ discard block |
||
278 | 278 | //$this->db = $dbc; |
279 | 279 | |
280 | 280 | //$hex = trim($line['hex']); |
281 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
282 | - else $id = trim($line['id']); |
|
281 | + if (!isset($line['id'])) $id = trim($line['hex']); |
|
282 | + else $id = trim($line['id']); |
|
283 | 283 | |
284 | 284 | if (!isset($this->all_flights[$id])) { |
285 | - if ($globalDebug) echo 'New flight...'."\n"; |
|
286 | - $this->all_flights[$id] = array(); |
|
287 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
288 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
|
289 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
290 | - if (!isset($line['id'])) { |
|
285 | + if ($globalDebug) echo 'New flight...'."\n"; |
|
286 | + $this->all_flights[$id] = array(); |
|
287 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
288 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
|
289 | + if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
290 | + if (!isset($line['id'])) { |
|
291 | 291 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
292 | 292 | // 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'))); |
293 | 293 | // 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'))); |
294 | 294 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
295 | - //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
296 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
297 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
295 | + //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
296 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
297 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
298 | 298 | } |
299 | 299 | if (isset($line['source_type']) && $line['source_type'] != '') { |
300 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
300 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | //print_r($this->all_flights); |
304 | 304 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
305 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
306 | - //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
305 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
306 | + //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
307 | 307 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
308 | - //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
309 | - 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') { |
|
308 | + //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
309 | + 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') { |
|
310 | 310 | $timeelapsed = microtime(true); |
311 | 311 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
312 | - $Spotter = new Spotter($this->db); |
|
313 | - if (isset($this->all_flights[$id]['source_type'])) { |
|
312 | + $Spotter = new Spotter($this->db); |
|
313 | + if (isset($this->all_flights[$id]['source_type'])) { |
|
314 | 314 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
315 | - } else { |
|
315 | + } else { |
|
316 | 316 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
317 | - } |
|
318 | - $Spotter->db = null; |
|
319 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
320 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
317 | + } |
|
318 | + $Spotter->db = null; |
|
319 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
320 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
321 | + } |
|
321 | 322 | } |
322 | - } |
|
323 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
324 | - if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
323 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
324 | + if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
325 | 325 | } |
326 | - if (isset($line['id']) && !isset($line['hex'])) { |
|
327 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
328 | - } |
|
326 | + if (isset($line['id']) && !isset($line['hex'])) { |
|
327 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
328 | + } |
|
329 | 329 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
330 | 330 | $icao = $line['aircraft_icao']; |
331 | 331 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -355,9 +355,9 @@ discard block |
||
355 | 355 | } |
356 | 356 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
357 | 357 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
358 | - if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
358 | + if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
359 | 359 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
360 | - } else { |
|
360 | + } else { |
|
361 | 361 | 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"; |
362 | 362 | 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"; |
363 | 363 | /* |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | print_r($line); |
367 | 367 | */ |
368 | 368 | return ''; |
369 | - } |
|
369 | + } |
|
370 | 370 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
371 | 371 | if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
372 | 372 | return ''; |
@@ -382,21 +382,21 @@ discard block |
||
382 | 382 | } |
383 | 383 | |
384 | 384 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG' && $line['registration'] != 'NA') { |
385 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
385 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
386 | 386 | } |
387 | 387 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
388 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
388 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
389 | 389 | } |
390 | 390 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
391 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
391 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
392 | 392 | } |
393 | 393 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
394 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
394 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | if (isset($line['ident']) && trim($line['ident']) != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
398 | 398 | |
399 | - if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
399 | + if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
400 | 400 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
401 | 401 | if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
402 | 402 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
@@ -405,23 +405,23 @@ discard block |
||
405 | 405 | elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
406 | 406 | 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'])); |
407 | 407 | } else { |
408 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
409 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
408 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
409 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
410 | 410 | $timeelapsed = microtime(true); |
411 | - $Spotter = new Spotter($this->db); |
|
412 | - $fromsource = NULL; |
|
413 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
414 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
411 | + $Spotter = new Spotter($this->db); |
|
412 | + $fromsource = NULL; |
|
413 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
414 | + elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
415 | 415 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
416 | 416 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
417 | 417 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
418 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
418 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
419 | 419 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
420 | 420 | $Spotter->db = null; |
421 | 421 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
422 | - } |
|
422 | + } |
|
423 | 423 | } |
424 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
424 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
425 | 425 | |
426 | 426 | /* |
427 | 427 | if (!isset($line['id'])) { |
@@ -431,63 +431,63 @@ discard block |
||
431 | 431 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
432 | 432 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
433 | 433 | */ |
434 | - 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'])); |
|
434 | + 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'])); |
|
435 | 435 | |
436 | - //$putinarchive = true; |
|
437 | - if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
436 | + //$putinarchive = true; |
|
437 | + if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
438 | 438 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
439 | - } |
|
440 | - if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
439 | + } |
|
440 | + if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
441 | 441 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
442 | - } |
|
443 | - if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
444 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
445 | - } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
442 | + } |
|
443 | + if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
444 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
445 | + } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
446 | 446 | $timeelapsed = microtime(true); |
447 | 447 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
448 | 448 | $Spotter = new Spotter($this->db); |
449 | 449 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
450 | 450 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
451 | - $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' => '')); |
|
451 | + $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' => '')); |
|
452 | 452 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
453 | - } |
|
454 | - } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
453 | + } |
|
454 | + } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
455 | 455 | $timeelapsed = microtime(true); |
456 | 456 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
457 | - $Spotter = new Spotter($this->db); |
|
458 | - $route = $Spotter->getRouteInfo(trim($line['ident'])); |
|
459 | - if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) { |
|
457 | + $Spotter = new Spotter($this->db); |
|
458 | + $route = $Spotter->getRouteInfo(trim($line['ident'])); |
|
459 | + if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) { |
|
460 | 460 | $Translation = new Translation($this->db); |
461 | 461 | $ident = $Translation->checkTranslation(trim($line['ident'])); |
462 | 462 | $route = $Spotter->getRouteInfo($ident); |
463 | 463 | $Translation->db = null; |
464 | - } |
|
465 | - $Spotter->db = null; |
|
466 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
467 | - } |
|
464 | + } |
|
465 | + $Spotter->db = null; |
|
466 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
467 | + } |
|
468 | 468 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
469 | - //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
470 | - if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
469 | + //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
470 | + if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
471 | 471 | // $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'])); |
472 | - $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'])); |
|
473 | - } |
|
472 | + $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'])); |
|
473 | + } |
|
474 | 474 | } |
475 | 475 | if (!isset($globalFork)) $globalFork = TRUE; |
476 | 476 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
477 | 477 | if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
478 | 478 | } |
479 | - } |
|
479 | + } |
|
480 | 480 | } |
481 | 481 | |
482 | 482 | if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) { |
483 | 483 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
484 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
485 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
486 | - //$dataFound = true; |
|
484 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
485 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
486 | + //$dataFound = true; |
|
487 | 487 | } 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'])) { |
488 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
489 | - if ($distance > 1000 && $distance < 10000) { |
|
490 | - // use datetime |
|
488 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
489 | + if ($distance > 1000 && $distance < 10000) { |
|
490 | + // use datetime |
|
491 | 491 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
492 | 492 | $speed = $speed*3.6; |
493 | 493 | if ($speed < 1000) { |
@@ -496,49 +496,49 @@ discard block |
||
496 | 496 | } else { |
497 | 497 | if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
498 | 498 | } |
499 | - } |
|
499 | + } |
|
500 | 500 | } |
501 | 501 | |
502 | 502 | |
503 | 503 | |
504 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
505 | - if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
|
506 | - if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
507 | - return false; |
|
508 | - } |
|
509 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
510 | - else unset($timediff); |
|
511 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
512 | - else unset($timediff_archive); |
|
513 | - if ($this->tmd > 5 |
|
514 | - || (isset($line['format_source']) |
|
515 | - && $line['format_source'] == 'airwhere' |
|
516 | - && ((!isset($this->all_flights[$id]['latitude']) |
|
517 | - || !isset($this->all_flights[$id]['longitude'])) |
|
518 | - || (isset($this->all_flights[$id]['latitude']) |
|
519 | - && isset($this->all_flights[$id]['longitude']) |
|
520 | - && $this->all_flights[$id]['latitude'] != $line['latitude'] |
|
521 | - && $this->all_flights[$id]['longitude'] != $line['longitude'] |
|
522 | - ) |
|
523 | - ) |
|
524 | - ) |
|
525 | - || (isset($globalVA) && $globalVA) |
|
526 | - || (isset($globalIVAO) && $globalIVAO) |
|
527 | - || (isset($globalVATSIM) && $globalVATSIM) |
|
528 | - || (isset($globalphpVMS) && $globalphpVMS) |
|
529 | - || (isset($globalVAM) && $globalVAM) |
|
530 | - || !isset($timediff) |
|
531 | - || $timediff > $globalLiveInterval |
|
532 | - || $globalArchive |
|
533 | - || ($timediff > 30 |
|
534 | - && isset($this->all_flights[$id]['latitude']) |
|
535 | - && isset($this->all_flights[$id]['longitude']) |
|
536 | - && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
537 | - ) |
|
538 | - ) { |
|
504 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
505 | + if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
|
506 | + if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
507 | + return false; |
|
508 | + } |
|
509 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
510 | + else unset($timediff); |
|
511 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
512 | + else unset($timediff_archive); |
|
513 | + if ($this->tmd > 5 |
|
514 | + || (isset($line['format_source']) |
|
515 | + && $line['format_source'] == 'airwhere' |
|
516 | + && ((!isset($this->all_flights[$id]['latitude']) |
|
517 | + || !isset($this->all_flights[$id]['longitude'])) |
|
518 | + || (isset($this->all_flights[$id]['latitude']) |
|
519 | + && isset($this->all_flights[$id]['longitude']) |
|
520 | + && $this->all_flights[$id]['latitude'] != $line['latitude'] |
|
521 | + && $this->all_flights[$id]['longitude'] != $line['longitude'] |
|
522 | + ) |
|
523 | + ) |
|
524 | + ) |
|
525 | + || (isset($globalVA) && $globalVA) |
|
526 | + || (isset($globalIVAO) && $globalIVAO) |
|
527 | + || (isset($globalVATSIM) && $globalVATSIM) |
|
528 | + || (isset($globalphpVMS) && $globalphpVMS) |
|
529 | + || (isset($globalVAM) && $globalVAM) |
|
530 | + || !isset($timediff) |
|
531 | + || $timediff > $globalLiveInterval |
|
532 | + || $globalArchive |
|
533 | + || ($timediff > 30 |
|
534 | + && isset($this->all_flights[$id]['latitude']) |
|
535 | + && isset($this->all_flights[$id]['longitude']) |
|
536 | + && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
537 | + ) |
|
538 | + ) { |
|
539 | 539 | |
540 | 540 | if ((isset($timediff) && !isset($timediff_archive)) || (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude']))) { |
541 | - if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
|
541 | + if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
|
542 | 542 | || (isset($line['format_source']) && $line['format_source'] == 'airwhere') |
543 | 543 | || !$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'])) { |
544 | 544 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -546,9 +546,9 @@ discard block |
||
546 | 546 | $this->all_flights[$id]['putinarchive'] = true; |
547 | 547 | $this->tmd = 0; |
548 | 548 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
549 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
550 | - $timeelapsed = microtime(true); |
|
551 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
549 | + if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
550 | + $timeelapsed = microtime(true); |
|
551 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
552 | 552 | $Spotter = new Spotter($this->db); |
553 | 553 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
554 | 554 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
@@ -556,11 +556,11 @@ discard block |
||
556 | 556 | $Spotter->db = null; |
557 | 557 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
558 | 558 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
559 | - } |
|
559 | + } |
|
560 | 560 | } |
561 | 561 | $this->all_flights[$id]['time_last_archive_coord'] = time(); |
562 | - } |
|
563 | - /* |
|
562 | + } |
|
563 | + /* |
|
564 | 564 | else { |
565 | 565 | if (!isset($timediff)) echo 'NO TIMEDIFF'; |
566 | 566 | else { |
@@ -574,16 +574,16 @@ discard block |
||
574 | 574 | } |
575 | 575 | |
576 | 576 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
577 | - //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) { |
|
577 | + //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) { |
|
578 | 578 | if (!isset($this->all_flights[$id]['archive_latitude'])) { |
579 | 579 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
580 | 580 | $this->all_flights[$id]['time_last_coord'] = time(); |
581 | 581 | } |
582 | 582 | //if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
583 | 583 | if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
584 | - $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
585 | - $dataFound = true; |
|
586 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
584 | + $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
585 | + $dataFound = true; |
|
586 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
587 | 587 | } |
588 | 588 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
589 | 589 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
@@ -594,24 +594,24 @@ discard block |
||
594 | 594 | //$putinarchive = true; |
595 | 595 | } |
596 | 596 | */ |
597 | - /* |
|
597 | + /* |
|
598 | 598 | } elseif (isset($this->all_flights[$id]['latitude'])) { |
599 | 599 | 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"; |
600 | 600 | } |
601 | 601 | */ |
602 | 602 | } |
603 | 603 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
604 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
605 | - //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) { |
|
604 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
605 | + //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) { |
|
606 | 606 | if (!isset($this->all_flights[$id]['archive_longitude'])) { |
607 | 607 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
608 | 608 | $this->all_flights[$id]['time_last_coord'] = time(); |
609 | 609 | } |
610 | 610 | //if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
611 | 611 | if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
612 | - $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
613 | - $dataFound = true; |
|
614 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
612 | + $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
613 | + $dataFound = true; |
|
614 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
615 | 615 | } |
616 | 616 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
617 | 617 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
@@ -629,67 +629,67 @@ discard block |
||
629 | 629 | */ |
630 | 630 | } |
631 | 631 | |
632 | - } else if ($globalDebug && $timediff > 30) { |
|
632 | + } else if ($globalDebug && $timediff > 30) { |
|
633 | 633 | $this->tmd = $this->tmd + 1; |
634 | 634 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
635 | 635 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
636 | 636 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
637 | 637 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
638 | - } |
|
638 | + } |
|
639 | 639 | } |
640 | 640 | if (isset($line['last_update']) && $line['last_update'] != '') { |
641 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
642 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
641 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
642 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
643 | 643 | } |
644 | 644 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
645 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
646 | - //$dataFound = true; |
|
645 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
646 | + //$dataFound = true; |
|
647 | 647 | } |
648 | 648 | if (isset($line['format_source']) && $line['format_source'] != '') { |
649 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
649 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
650 | 650 | } |
651 | 651 | if (isset($line['source_name']) && $line['source_name'] != '') { |
652 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
652 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
653 | 653 | } |
654 | 654 | if (isset($line['emergency']) && $line['emergency'] != '') { |
655 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
656 | - //$dataFound = true; |
|
655 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
656 | + //$dataFound = true; |
|
657 | 657 | } |
658 | 658 | if (isset($line['ground']) && $line['ground'] != '') { |
659 | - if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
659 | + if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
660 | 660 | // Here we force archive of flight because after ground it's a new one (or should be) |
661 | 661 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
662 | 662 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
663 | 663 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
664 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
664 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
665 | 665 | 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'])); |
666 | - } |
|
667 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
668 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
669 | - //$dataFound = true; |
|
666 | + } |
|
667 | + if ($line['ground'] != 1) $line['ground'] = 0; |
|
668 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
669 | + //$dataFound = true; |
|
670 | 670 | } |
671 | 671 | if (isset($line['squawk']) && $line['squawk'] != '') { |
672 | - 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'])) { |
|
673 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
674 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
675 | - $highlight = ''; |
|
676 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
677 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
678 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
679 | - if ($highlight != '') { |
|
672 | + 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'])) { |
|
673 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
674 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
675 | + $highlight = ''; |
|
676 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
677 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
678 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
679 | + if ($highlight != '') { |
|
680 | 680 | $timeelapsed = microtime(true); |
681 | 681 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
682 | - $Spotter = new Spotter($this->db); |
|
683 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
684 | - $Spotter->db = null; |
|
685 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
682 | + $Spotter = new Spotter($this->db); |
|
683 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
684 | + $Spotter->db = null; |
|
685 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
686 | 686 | } |
687 | 687 | //$putinarchive = true; |
688 | 688 | //$highlight = ''; |
689 | - } |
|
689 | + } |
|
690 | 690 | |
691 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
692 | - //$dataFound = true; |
|
691 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
692 | + //$dataFound = true; |
|
693 | 693 | } |
694 | 694 | |
695 | 695 | if (isset($line['altitude']) && $line['altitude'] != '') { |
@@ -700,13 +700,13 @@ discard block |
||
700 | 700 | $line['altitude'] = $line['altitude'] - $geoid; |
701 | 701 | } |
702 | 702 | } |
703 | - //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
703 | + //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
704 | 704 | 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; |
705 | 705 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
706 | 706 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
707 | 707 | //$dataFound = true; |
708 | - //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
709 | - if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
|
708 | + //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
709 | + if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
|
710 | 710 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
711 | 711 | if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
712 | 712 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
@@ -715,27 +715,27 @@ discard block |
||
715 | 715 | elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
716 | 716 | 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'])); |
717 | 717 | } |
718 | - } |
|
719 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
718 | + } |
|
719 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
720 | 720 | } |
721 | 721 | |
722 | 722 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
723 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
723 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
724 | 724 | } |
725 | 725 | |
726 | 726 | if (isset($line['heading']) && $line['heading'] != '') { |
727 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
728 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
729 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
730 | - //$dataFound = true; |
|
727 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
728 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
729 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
730 | + //$dataFound = true; |
|
731 | 731 | } 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']) { |
732 | - $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']); |
|
733 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
734 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
735 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
732 | + $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']); |
|
733 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
734 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
735 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
736 | 736 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
737 | - // If not enough messages and ACARS set heading to 0 |
|
738 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
737 | + // If not enough messages and ACARS set heading to 0 |
|
738 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
739 | 739 | } |
740 | 740 | if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
741 | 741 | elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
@@ -748,133 +748,133 @@ discard block |
||
748 | 748 | //if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
749 | 749 | //if ($dataFound === true && isset($this->all_flights[$id]['hex'])) { |
750 | 750 | if ($dataFound === true && isset($this->all_flights[$id]['id'])) { |
751 | - $this->all_flights[$id]['lastupdate'] = time(); |
|
752 | - if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
753 | - 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'])) { |
|
754 | - //print_r($this->all_flights); |
|
755 | - //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
756 | - //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
757 | - if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
751 | + $this->all_flights[$id]['lastupdate'] = time(); |
|
752 | + if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
753 | + 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'])) { |
|
754 | + //print_r($this->all_flights); |
|
755 | + //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
756 | + //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
757 | + if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
758 | 758 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
759 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
760 | - $timeelapsed = microtime(true); |
|
761 | - $SpotterLive = new SpotterLive($this->db); |
|
762 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
759 | + if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
760 | + $timeelapsed = microtime(true); |
|
761 | + $SpotterLive = new SpotterLive($this->db); |
|
762 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
763 | 763 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
764 | 764 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
765 | - } elseif (isset($line['id'])) { |
|
765 | + } elseif (isset($line['id'])) { |
|
766 | 766 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
767 | 767 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
768 | - } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
768 | + } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
769 | 769 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
770 | 770 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
771 | - } else $recent_ident = ''; |
|
772 | - $SpotterLive->db=null; |
|
773 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
774 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
771 | + } else $recent_ident = ''; |
|
772 | + $SpotterLive->db=null; |
|
773 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
774 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
775 | 775 | } else $recent_ident = ''; |
776 | - } else { |
|
776 | + } else { |
|
777 | 777 | $recent_ident = ''; |
778 | 778 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
779 | - } |
|
780 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
781 | - if($recent_ident == "") |
|
782 | - { |
|
779 | + } |
|
780 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
781 | + if($recent_ident == "") |
|
782 | + { |
|
783 | 783 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
784 | 784 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
785 | 785 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
786 | 786 | //adds the spotter data for the archive |
787 | 787 | $ignoreImport = false; |
788 | 788 | foreach($globalAirportIgnore as $airportIgnore) { |
789 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
789 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
790 | 790 | $ignoreImport = true; |
791 | - } |
|
791 | + } |
|
792 | 792 | } |
793 | 793 | if (count($globalAirportAccept) > 0) { |
794 | - $ignoreImport = true; |
|
795 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
794 | + $ignoreImport = true; |
|
795 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
796 | 796 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
797 | - $ignoreImport = false; |
|
797 | + $ignoreImport = false; |
|
798 | + } |
|
798 | 799 | } |
799 | - } |
|
800 | 800 | } |
801 | 801 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
802 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
802 | + foreach($globalAirlineIgnore as $airlineIgnore) { |
|
803 | 803 | if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
804 | - $ignoreImport = true; |
|
804 | + $ignoreImport = true; |
|
805 | + } |
|
805 | 806 | } |
806 | - } |
|
807 | 807 | } |
808 | 808 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
809 | - $ignoreImport = true; |
|
810 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
809 | + $ignoreImport = true; |
|
810 | + foreach($globalAirlineAccept as $airlineAccept) { |
|
811 | 811 | if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
812 | - $ignoreImport = false; |
|
812 | + $ignoreImport = false; |
|
813 | + } |
|
813 | 814 | } |
814 | - } |
|
815 | 815 | } |
816 | 816 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
817 | - $ignoreImport = true; |
|
818 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
817 | + $ignoreImport = true; |
|
818 | + foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
819 | 819 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
820 | - $ignoreImport = false; |
|
820 | + $ignoreImport = false; |
|
821 | + } |
|
821 | 822 | } |
822 | - } |
|
823 | 823 | } |
824 | 824 | |
825 | 825 | if (!$ignoreImport) { |
826 | - $highlight = ''; |
|
827 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
828 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
829 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
830 | - 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'))); |
|
831 | - $timeelapsed = microtime(true); |
|
832 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
826 | + $highlight = ''; |
|
827 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
828 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
829 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
830 | + 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'))); |
|
831 | + $timeelapsed = microtime(true); |
|
832 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
833 | 833 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
834 | - $Spotter = new Spotter($this->db); |
|
835 | - $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']); |
|
836 | - $Spotter->db = null; |
|
837 | - if ($globalDebug) { |
|
834 | + $Spotter = new Spotter($this->db); |
|
835 | + $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']); |
|
836 | + $Spotter->db = null; |
|
837 | + if ($globalDebug) { |
|
838 | 838 | if (isset($result['error'])) echo 'Error: '.$result['error']."\n"; |
839 | 839 | else echo 'Success'; |
840 | - } |
|
841 | - if (count($result) > 1) { |
|
842 | - // ':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type, |
|
840 | + } |
|
841 | + if (count($result) > 1) { |
|
842 | + // ':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type, |
|
843 | 843 | if ($this->all_flights[$id]['aircraft_icao'] == '') $this->all_flights[$id]['aircraft_icao'] = $result[':aircraft_icao']; |
844 | 844 | if ($this->all_flights[$id]['registration'] == '') $this->all_flights[$id]['registration'] = $result[':registration']; |
845 | - } |
|
845 | + } |
|
846 | 846 | } |
847 | - } |
|
848 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
849 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
847 | + } |
|
848 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
849 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
850 | 850 | |
851 | - // Add source stat in DB |
|
852 | - $Stats = new Stats($this->db); |
|
853 | - if (!empty($this->stats)) { |
|
851 | + // Add source stat in DB |
|
852 | + $Stats = new Stats($this->db); |
|
853 | + if (!empty($this->stats)) { |
|
854 | 854 | if ($globalDebug) echo 'Add source stats : '; |
855 | - foreach($this->stats as $date => $data) { |
|
856 | - foreach($data as $source => $sourced) { |
|
857 | - //print_r($sourced); |
|
858 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
859 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
860 | - if (isset($sourced['msg'])) { |
|
861 | - if (time() - $sourced['msg']['date'] > 10) { |
|
862 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
863 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
864 | - unset($this->stats[$date][$source]['msg']); |
|
865 | - } |
|
866 | - } |
|
867 | - } |
|
868 | - if ($date != date('Y-m-d')) { |
|
869 | - unset($this->stats[$date]); |
|
870 | - } |
|
871 | - } |
|
872 | - if ($globalDebug) echo 'Done'."\n"; |
|
855 | + foreach($this->stats as $date => $data) { |
|
856 | + foreach($data as $source => $sourced) { |
|
857 | + //print_r($sourced); |
|
858 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
859 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
860 | + if (isset($sourced['msg'])) { |
|
861 | + if (time() - $sourced['msg']['date'] > 10) { |
|
862 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
863 | + echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
864 | + unset($this->stats[$date][$source]['msg']); |
|
865 | + } |
|
866 | + } |
|
867 | + } |
|
868 | + if ($date != date('Y-m-d')) { |
|
869 | + unset($this->stats[$date]); |
|
870 | + } |
|
871 | + } |
|
872 | + if ($globalDebug) echo 'Done'."\n"; |
|
873 | 873 | |
874 | - } |
|
875 | - $Stats->db = null; |
|
876 | - } |
|
877 | - $this->del(); |
|
874 | + } |
|
875 | + $Stats->db = null; |
|
876 | + } |
|
877 | + $this->del(); |
|
878 | 878 | } elseif ($globalDebug) echo 'Ignore data'."\n"; |
879 | 879 | //$ignoreImport = false; |
880 | 880 | $this->all_flights[$id]['addedSpotter'] = 1; |
@@ -892,41 +892,41 @@ discard block |
||
892 | 892 | */ |
893 | 893 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
894 | 894 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
895 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
896 | - //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
897 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
895 | + if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
896 | + //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
897 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
898 | 898 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
899 | - $SpotterLive = new SpotterLive($this->db); |
|
900 | - $SpotterLive->deleteLiveSpotterData(); |
|
901 | - $SpotterLive->db=null; |
|
899 | + $SpotterLive = new SpotterLive($this->db); |
|
900 | + $SpotterLive->deleteLiveSpotterData(); |
|
901 | + $SpotterLive->db=null; |
|
902 | 902 | } |
903 | - } |
|
904 | - if ($globalDebug) echo " Done\n"; |
|
905 | - $this->last_delete = time(); |
|
903 | + } |
|
904 | + if ($globalDebug) echo " Done\n"; |
|
905 | + $this->last_delete = time(); |
|
906 | 906 | } |
907 | - } else { |
|
907 | + } else { |
|
908 | 908 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
909 | - $this->all_flights[$id]['id'] = $recent_ident; |
|
910 | - $this->all_flights[$id]['addedSpotter'] = 1; |
|
909 | + $this->all_flights[$id]['id'] = $recent_ident; |
|
910 | + $this->all_flights[$id]['addedSpotter'] = 1; |
|
911 | 911 | } |
912 | 912 | if (isset($globalDaemon) && !$globalDaemon) { |
913 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
913 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
914 | 914 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
915 | - $Spotter = new Spotter($this->db); |
|
916 | - $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']); |
|
917 | - $Spotter->db = null; |
|
915 | + $Spotter = new Spotter($this->db); |
|
916 | + $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']); |
|
917 | + $Spotter->db = null; |
|
918 | + } |
|
918 | 919 | } |
919 | - } |
|
920 | 920 | } |
921 | 921 | |
922 | - } |
|
922 | + } |
|
923 | 923 | } |
924 | - } |
|
925 | - //adds the spotter LIVE data |
|
926 | - //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
927 | - //echo "\nAdd in Live !! \n"; |
|
928 | - //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"; |
|
929 | - if ($globalDebug) { |
|
924 | + } |
|
925 | + //adds the spotter LIVE data |
|
926 | + //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
927 | + //echo "\nAdd in Live !! \n"; |
|
928 | + //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"; |
|
929 | + if ($globalDebug) { |
|
930 | 930 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
931 | 931 | 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"; |
932 | 932 | 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"; |
@@ -934,60 +934,60 @@ discard block |
||
934 | 934 | 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"; |
935 | 935 | 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"; |
936 | 936 | } |
937 | - } |
|
938 | - $ignoreImport = false; |
|
939 | - if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
940 | - if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
937 | + } |
|
938 | + $ignoreImport = false; |
|
939 | + if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
940 | + if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
941 | 941 | |
942 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
943 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
944 | - $ignoreImport = true; |
|
942 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
943 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
944 | + $ignoreImport = true; |
|
945 | + } |
|
945 | 946 | } |
946 | - } |
|
947 | - if (count($globalAirportAccept) > 0) { |
|
948 | - $ignoreImport = true; |
|
949 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
950 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
947 | + if (count($globalAirportAccept) > 0) { |
|
948 | + $ignoreImport = true; |
|
949 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
950 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
951 | 951 | $ignoreImport = false; |
952 | - } |
|
952 | + } |
|
953 | 953 | } |
954 | - } |
|
955 | - if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
954 | + } |
|
955 | + if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
956 | 956 | foreach($globalAirlineIgnore as $airlineIgnore) { |
957 | - 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)) { |
|
957 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
958 | 958 | $ignoreImport = true; |
959 | - } |
|
959 | + } |
|
960 | 960 | } |
961 | - } |
|
962 | - if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
961 | + } |
|
962 | + if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
963 | 963 | $ignoreImport = true; |
964 | 964 | foreach($globalAirlineAccept as $airlineAccept) { |
965 | - 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)) { |
|
965 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
966 | 966 | $ignoreImport = false; |
967 | - } |
|
967 | + } |
|
968 | + } |
|
968 | 969 | } |
969 | - } |
|
970 | - if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
970 | + if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
971 | 971 | $ignoreImport = true; |
972 | 972 | foreach($globalPilotIdAccept as $pilotIdAccept) { |
973 | - if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
974 | - $ignoreImport = false; |
|
975 | - } |
|
973 | + if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
974 | + $ignoreImport = false; |
|
975 | + } |
|
976 | + } |
|
976 | 977 | } |
977 | - } |
|
978 | 978 | |
979 | - if (!$ignoreImport) { |
|
979 | + if (!$ignoreImport) { |
|
980 | 980 | 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'])) { |
981 | 981 | if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
982 | 982 | $timeelapsed = microtime(true); |
983 | 983 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
984 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
984 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
985 | 985 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
986 | 986 | $SpotterLive = new SpotterLive($this->db); |
987 | 987 | $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']); |
988 | 988 | $SpotterLive->db = null; |
989 | 989 | if ($globalDebug) echo $result."\n"; |
990 | - } |
|
990 | + } |
|
991 | 991 | } |
992 | 992 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
993 | 993 | $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']); |
@@ -999,7 +999,7 @@ discard block |
||
999 | 999 | //if ($line['format_source'] != 'aprs') { |
1000 | 1000 | //if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) { |
1001 | 1001 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
1002 | - if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
|
1002 | + if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
|
1003 | 1003 | $source = $this->all_flights[$id]['source_name']; |
1004 | 1004 | if ($source == '') $source = $this->all_flights[$id]['format_source']; |
1005 | 1005 | if (!isset($this->source_location[$source])) { |
@@ -1025,7 +1025,7 @@ discard block |
||
1025 | 1025 | if ($stats_heading == 16) $stats_heading = 0; |
1026 | 1026 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
1027 | 1027 | for ($i=0;$i<=15;$i++) { |
1028 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
1028 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
1029 | 1029 | } |
1030 | 1030 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
1031 | 1031 | } else { |
@@ -1038,17 +1038,17 @@ discard block |
||
1038 | 1038 | //var_dump($this->stats); |
1039 | 1039 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
1040 | 1040 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
1041 | - end($this->stats[$current_date][$source]['hist']); |
|
1042 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
1041 | + end($this->stats[$current_date][$source]['hist']); |
|
1042 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
1043 | 1043 | } else $mini = 0; |
1044 | 1044 | for ($i=$mini;$i<=$distance;$i+=10) { |
1045 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
1045 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
1046 | 1046 | } |
1047 | 1047 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
1048 | 1048 | } else { |
1049 | 1049 | $this->stats[$current_date][$source]['hist'][$distance] += 1; |
1050 | 1050 | } |
1051 | - } |
|
1051 | + } |
|
1052 | 1052 | } |
1053 | 1053 | |
1054 | 1054 | $this->all_flights[$id]['lastupdate'] = time(); |
@@ -1058,7 +1058,7 @@ discard block |
||
1058 | 1058 | //$this->del(); |
1059 | 1059 | |
1060 | 1060 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
1061 | - if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
1061 | + if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
1062 | 1062 | if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
1063 | 1063 | $SpotterLive = new SpotterLive($this->db); |
1064 | 1064 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
@@ -1066,19 +1066,19 @@ discard block |
||
1066 | 1066 | //SpotterLive->deleteLiveSpotterData(); |
1067 | 1067 | if ($globalDebug) echo " Done\n"; |
1068 | 1068 | $this->last_delete_hourly = time(); |
1069 | - } else { |
|
1069 | + } else { |
|
1070 | 1070 | $this->del(); |
1071 | 1071 | $this->last_delete_hourly = time(); |
1072 | - } |
|
1072 | + } |
|
1073 | 1073 | } |
1074 | 1074 | |
1075 | - } |
|
1076 | - //$ignoreImport = false; |
|
1075 | + } |
|
1076 | + //$ignoreImport = false; |
|
1077 | 1077 | } |
1078 | 1078 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
1079 | 1079 | if ($send) return $this->all_flights[$id]; |
1080 | - } |
|
1080 | + } |
|
1081 | + } |
|
1081 | 1082 | } |
1082 | - } |
|
1083 | 1083 | } |
1084 | 1084 | ?> |