@@ -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,42 +78,42 @@ 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 | + } |
|
117 | 117 | $Spotter->db = null; |
118 | 118 | $Schedule->db = null; |
119 | 119 | $Translation->db = null; |
@@ -128,78 +128,78 @@ discard block |
||
128 | 128 | } |
129 | 129 | */ |
130 | 130 | } |
131 | - } |
|
131 | + } |
|
132 | 132 | |
133 | - public function checkAll() { |
|
133 | + public function checkAll() { |
|
134 | 134 | global $globalDebug, $globalNoImport; |
135 | 135 | if ($globalDebug) echo "Update last seen flights data...\n"; |
136 | 136 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
137 | - foreach ($this->all_flights as $key => $flight) { |
|
137 | + foreach ($this->all_flights as $key => $flight) { |
|
138 | 138 | if (isset($this->all_flights[$key]['id'])) { |
139 | - //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
|
140 | - $Spotter = new Spotter($this->db); |
|
141 | - $real_arrival = $this->arrival($key); |
|
142 | - if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
143 | - } |
|
144 | - } |
|
139 | + //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
|
140 | + $Spotter = new Spotter($this->db); |
|
141 | + $real_arrival = $this->arrival($key); |
|
142 | + if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
143 | + } |
|
144 | + } |
|
145 | + } |
|
145 | 146 | } |
146 | - } |
|
147 | 147 | |
148 | - public function arrival($key) { |
|
148 | + public function arrival($key) { |
|
149 | 149 | global $globalClosestMinDist, $globalDebug; |
150 | 150 | if ($globalDebug) echo 'Update arrival...'."\n"; |
151 | 151 | $Spotter = new Spotter($this->db); |
152 | - $airport_icao = ''; |
|
153 | - $airport_time = ''; |
|
154 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
152 | + $airport_icao = ''; |
|
153 | + $airport_time = ''; |
|
154 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
155 | 155 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
156 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
157 | - if (isset($closestAirports[0])) { |
|
158 | - if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
159 | - $airport_icao = $closestAirports[0]['icao']; |
|
160 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
161 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
162 | - } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
163 | - foreach ($closestAirports as $airport) { |
|
164 | - if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
165 | - $airport_icao = $airport['icao']; |
|
166 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
167 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
168 | - break; |
|
169 | - } |
|
170 | - } |
|
171 | - } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
172 | - $airport_icao = $closestAirports[0]['icao']; |
|
173 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
174 | - } else { |
|
175 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
176 | - } |
|
177 | - } else { |
|
178 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
179 | - } |
|
156 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
157 | + if (isset($closestAirports[0])) { |
|
158 | + if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
159 | + $airport_icao = $closestAirports[0]['icao']; |
|
160 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
161 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
162 | + } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
163 | + foreach ($closestAirports as $airport) { |
|
164 | + if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
165 | + $airport_icao = $airport['icao']; |
|
166 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
167 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
168 | + break; |
|
169 | + } |
|
170 | + } |
|
171 | + } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
172 | + $airport_icao = $closestAirports[0]['icao']; |
|
173 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
174 | + } else { |
|
175 | + if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
176 | + } |
|
177 | + } else { |
|
178 | + if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
179 | + } |
|
180 | 180 | |
181 | - } else { |
|
182 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
183 | - } |
|
184 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
185 | - } |
|
181 | + } else { |
|
182 | + if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
183 | + } |
|
184 | + return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
185 | + } |
|
186 | 186 | |
187 | 187 | |
188 | 188 | |
189 | - public function del() { |
|
189 | + public function del() { |
|
190 | 190 | global $globalDebug, $globalNoImport, $globalNoDB; |
191 | 191 | // Delete old infos |
192 | 192 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
193 | 193 | foreach ($this->all_flights as $key => $flight) { |
194 | - if (isset($flight['lastupdate'])) { |
|
194 | + if (isset($flight['lastupdate'])) { |
|
195 | 195 | if ($flight['lastupdate'] < (time()-1800)) { |
196 | - $this->delKey($key); |
|
196 | + $this->delKey($key); |
|
197 | 197 | } |
198 | - } |
|
198 | + } |
|
199 | + } |
|
199 | 200 | } |
200 | - } |
|
201 | 201 | |
202 | - public function delKey($key) { |
|
202 | + public function delKey($key) { |
|
203 | 203 | global $globalDebug, $globalNoImport, $globalNoDB; |
204 | 204 | // Delete old infos |
205 | 205 | if (isset($this->all_flights[$key]['id'])) { |
@@ -214,9 +214,9 @@ discard block |
||
214 | 214 | } |
215 | 215 | } |
216 | 216 | unset($this->all_flights[$key]); |
217 | - } |
|
217 | + } |
|
218 | 218 | |
219 | - public function add($line) { |
|
219 | + public function add($line) { |
|
220 | 220 | 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; |
221 | 221 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
222 | 222 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.01'; |
@@ -242,20 +242,20 @@ discard block |
||
242 | 242 | |
243 | 243 | // SBS format is CSV format |
244 | 244 | if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
245 | - //print_r($line); |
|
246 | - if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
247 | - if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
245 | + //print_r($line); |
|
246 | + if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
247 | + if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
248 | 248 | |
249 | 249 | // Increment message number |
250 | 250 | if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
251 | - $current_date = date('Y-m-d'); |
|
252 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
253 | - else $source = ''; |
|
254 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
255 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
256 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
257 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
258 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
251 | + $current_date = date('Y-m-d'); |
|
252 | + if (isset($line['source_name'])) $source = $line['source_name']; |
|
253 | + else $source = ''; |
|
254 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
255 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
256 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
257 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
258 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | /* |
@@ -271,54 +271,54 @@ discard block |
||
271 | 271 | //$this->db = $dbc; |
272 | 272 | |
273 | 273 | //$hex = trim($line['hex']); |
274 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
275 | - else $id = trim($line['id']); |
|
274 | + if (!isset($line['id'])) $id = trim($line['hex']); |
|
275 | + else $id = trim($line['id']); |
|
276 | 276 | |
277 | 277 | if (!isset($this->all_flights[$id])) { |
278 | - if ($globalDebug) echo 'New flight...'."\n"; |
|
279 | - $this->all_flights[$id] = array(); |
|
280 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
281 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
|
282 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
283 | - if (!isset($line['id'])) { |
|
278 | + if ($globalDebug) echo 'New flight...'."\n"; |
|
279 | + $this->all_flights[$id] = array(); |
|
280 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
281 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
|
282 | + if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
283 | + if (!isset($line['id'])) { |
|
284 | 284 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
285 | 285 | // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
286 | 286 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
287 | 287 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
288 | - //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
289 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
290 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
288 | + //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
289 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
290 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
291 | 291 | } |
292 | 292 | if (isset($line['source_type']) && $line['source_type'] != '') { |
293 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
293 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | //print_r($this->all_flights); |
297 | 297 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
298 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
299 | - //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
298 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
299 | + //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
300 | 300 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
301 | - //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
302 | - 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') { |
|
301 | + //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
302 | + 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') { |
|
303 | 303 | $timeelapsed = microtime(true); |
304 | 304 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
305 | - $Spotter = new Spotter($this->db); |
|
306 | - if (isset($this->all_flights[$id]['source_type'])) { |
|
305 | + $Spotter = new Spotter($this->db); |
|
306 | + if (isset($this->all_flights[$id]['source_type'])) { |
|
307 | 307 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
308 | - } else { |
|
308 | + } else { |
|
309 | 309 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
310 | - } |
|
311 | - $Spotter->db = null; |
|
312 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
313 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
310 | + } |
|
311 | + $Spotter->db = null; |
|
312 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
313 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
314 | 314 | } |
315 | - } |
|
316 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
317 | - if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
315 | + } |
|
316 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
317 | + if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
318 | 318 | } |
319 | - if (isset($line['id']) && !isset($line['hex'])) { |
|
320 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
321 | - } |
|
319 | + if (isset($line['id']) && !isset($line['hex'])) { |
|
320 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
321 | + } |
|
322 | 322 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
323 | 323 | $icao = $line['aircraft_icao']; |
324 | 324 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -349,9 +349,9 @@ discard block |
||
349 | 349 | } |
350 | 350 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
351 | 351 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
352 | - if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
352 | + if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
353 | 353 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
354 | - } else { |
|
354 | + } else { |
|
355 | 355 | 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"; |
356 | 356 | 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"; |
357 | 357 | /* |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | print_r($line); |
361 | 361 | */ |
362 | 362 | return ''; |
363 | - } |
|
363 | + } |
|
364 | 364 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
365 | 365 | if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
366 | 366 | return ''; |
@@ -376,21 +376,21 @@ discard block |
||
376 | 376 | } |
377 | 377 | |
378 | 378 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG' && $line['registration'] != 'NA') { |
379 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
379 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
380 | 380 | } |
381 | 381 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
382 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
382 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
383 | 383 | } |
384 | 384 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
385 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
385 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
386 | 386 | } |
387 | 387 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
388 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
388 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
392 | 392 | |
393 | - if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
393 | + if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
394 | 394 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
395 | 395 | if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
396 | 396 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
@@ -399,23 +399,23 @@ discard block |
||
399 | 399 | elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
400 | 400 | 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'])); |
401 | 401 | } else { |
402 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
403 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
402 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
403 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
404 | 404 | $timeelapsed = microtime(true); |
405 | - $Spotter = new Spotter($this->db); |
|
406 | - $fromsource = NULL; |
|
407 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
408 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
405 | + $Spotter = new Spotter($this->db); |
|
406 | + $fromsource = NULL; |
|
407 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
408 | + elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
409 | 409 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
410 | 410 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
411 | 411 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
412 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
412 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
413 | 413 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
414 | 414 | $Spotter->db = null; |
415 | 415 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
416 | - } |
|
416 | + } |
|
417 | 417 | } |
418 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
418 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
419 | 419 | |
420 | 420 | /* |
421 | 421 | if (!isset($line['id'])) { |
@@ -425,63 +425,63 @@ discard block |
||
425 | 425 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
426 | 426 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
427 | 427 | */ |
428 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
428 | + 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'])); |
|
429 | 429 | |
430 | - //$putinarchive = true; |
|
431 | - if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
430 | + //$putinarchive = true; |
|
431 | + if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
432 | 432 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
433 | - } |
|
434 | - if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
433 | + } |
|
434 | + if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
435 | 435 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
436 | - } |
|
437 | - if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
438 | - $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' => '')); |
|
439 | - } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
436 | + } |
|
437 | + if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
438 | + $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' => '')); |
|
439 | + } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
440 | 440 | $timeelapsed = microtime(true); |
441 | 441 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
442 | 442 | $Spotter = new Spotter($this->db); |
443 | 443 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
444 | 444 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
445 | - $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 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
446 | 446 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
447 | - } |
|
448 | - } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
447 | + } |
|
448 | + } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
449 | 449 | $timeelapsed = microtime(true); |
450 | 450 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
451 | - $Spotter = new Spotter($this->db); |
|
452 | - $route = $Spotter->getRouteInfo(trim($line['ident'])); |
|
453 | - if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) { |
|
451 | + $Spotter = new Spotter($this->db); |
|
452 | + $route = $Spotter->getRouteInfo(trim($line['ident'])); |
|
453 | + if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) { |
|
454 | 454 | $Translation = new Translation($this->db); |
455 | 455 | $ident = $Translation->checkTranslation(trim($line['ident'])); |
456 | 456 | $route = $Spotter->getRouteInfo($ident); |
457 | 457 | $Translation->db = null; |
458 | - } |
|
459 | - $Spotter->db = null; |
|
460 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
461 | - } |
|
458 | + } |
|
459 | + $Spotter->db = null; |
|
460 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
461 | + } |
|
462 | 462 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
463 | - //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
464 | - if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
463 | + //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
464 | + if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
465 | 465 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop'])); |
466 | - $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'])); |
|
467 | - } |
|
466 | + $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'])); |
|
467 | + } |
|
468 | 468 | } |
469 | 469 | if (!isset($globalFork)) $globalFork = TRUE; |
470 | 470 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
471 | 471 | if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
472 | 472 | } |
473 | - } |
|
473 | + } |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) { |
477 | 477 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
478 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
479 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
480 | - //$dataFound = true; |
|
478 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
479 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
480 | + //$dataFound = true; |
|
481 | 481 | } 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'])) { |
482 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
483 | - if ($distance > 1000 && $distance < 10000) { |
|
484 | - // use datetime |
|
482 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
483 | + if ($distance > 1000 && $distance < 10000) { |
|
484 | + // use datetime |
|
485 | 485 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
486 | 486 | $speed = $speed*3.6; |
487 | 487 | if ($speed < 1000) { |
@@ -490,49 +490,49 @@ discard block |
||
490 | 490 | } else { |
491 | 491 | if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
492 | 492 | } |
493 | - } |
|
493 | + } |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | |
497 | 497 | |
498 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
499 | - if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
|
500 | - if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
501 | - return false; |
|
502 | - } |
|
503 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
504 | - else unset($timediff); |
|
505 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
506 | - else unset($timediff_archive); |
|
507 | - if ($this->tmd > 5 |
|
508 | - || (isset($line['format_source']) |
|
509 | - && $line['format_source'] == 'airwhere' |
|
510 | - && ((!isset($this->all_flights[$id]['latitude']) |
|
511 | - || !isset($this->all_flights[$id]['longitude'])) |
|
512 | - || (isset($this->all_flights[$id]['latitude']) |
|
513 | - && isset($this->all_flights[$id]['longitude']) |
|
514 | - && $this->all_flights[$id]['latitude'] != $line['latitude'] |
|
515 | - && $this->all_flights[$id]['longitude'] != $line['longitude'] |
|
516 | - ) |
|
517 | - ) |
|
518 | - ) |
|
519 | - || (isset($globalVA) && $globalVA) |
|
520 | - || (isset($globalIVAO) && $globalIVAO) |
|
521 | - || (isset($globalVATSIM) && $globalVATSIM) |
|
522 | - || (isset($globalphpVMS) && $globalphpVMS) |
|
523 | - || (isset($globalVAM) && $globalVAM) |
|
524 | - || !isset($timediff) |
|
525 | - || $timediff > $globalLiveInterval |
|
526 | - || $globalArchive |
|
527 | - || ($timediff > 30 |
|
528 | - && isset($this->all_flights[$id]['latitude']) |
|
529 | - && isset($this->all_flights[$id]['longitude']) |
|
530 | - && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
531 | - ) |
|
532 | - ) { |
|
498 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
499 | + if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
|
500 | + if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
501 | + return false; |
|
502 | + } |
|
503 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
504 | + else unset($timediff); |
|
505 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
506 | + else unset($timediff_archive); |
|
507 | + if ($this->tmd > 5 |
|
508 | + || (isset($line['format_source']) |
|
509 | + && $line['format_source'] == 'airwhere' |
|
510 | + && ((!isset($this->all_flights[$id]['latitude']) |
|
511 | + || !isset($this->all_flights[$id]['longitude'])) |
|
512 | + || (isset($this->all_flights[$id]['latitude']) |
|
513 | + && isset($this->all_flights[$id]['longitude']) |
|
514 | + && $this->all_flights[$id]['latitude'] != $line['latitude'] |
|
515 | + && $this->all_flights[$id]['longitude'] != $line['longitude'] |
|
516 | + ) |
|
517 | + ) |
|
518 | + ) |
|
519 | + || (isset($globalVA) && $globalVA) |
|
520 | + || (isset($globalIVAO) && $globalIVAO) |
|
521 | + || (isset($globalVATSIM) && $globalVATSIM) |
|
522 | + || (isset($globalphpVMS) && $globalphpVMS) |
|
523 | + || (isset($globalVAM) && $globalVAM) |
|
524 | + || !isset($timediff) |
|
525 | + || $timediff > $globalLiveInterval |
|
526 | + || $globalArchive |
|
527 | + || ($timediff > 30 |
|
528 | + && isset($this->all_flights[$id]['latitude']) |
|
529 | + && isset($this->all_flights[$id]['longitude']) |
|
530 | + && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
531 | + ) |
|
532 | + ) { |
|
533 | 533 | |
534 | 534 | 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']))) { |
535 | - if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
|
535 | + if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
|
536 | 536 | || (isset($line['format_source']) && $line['format_source'] == 'airwhere') |
537 | 537 | || !$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'])) { |
538 | 538 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -540,9 +540,9 @@ discard block |
||
540 | 540 | $this->all_flights[$id]['putinarchive'] = true; |
541 | 541 | $this->tmd = 0; |
542 | 542 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
543 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
544 | - $timeelapsed = microtime(true); |
|
545 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
543 | + if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
544 | + $timeelapsed = microtime(true); |
|
545 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
546 | 546 | $Spotter = new Spotter($this->db); |
547 | 547 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
548 | 548 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
@@ -550,11 +550,11 @@ discard block |
||
550 | 550 | $Spotter->db = null; |
551 | 551 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
552 | 552 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
553 | - } |
|
553 | + } |
|
554 | 554 | } |
555 | 555 | $this->all_flights[$id]['time_last_archive_coord'] = time(); |
556 | - } |
|
557 | - /* |
|
556 | + } |
|
557 | + /* |
|
558 | 558 | else { |
559 | 559 | if (!isset($timediff)) echo 'NO TIMEDIFF'; |
560 | 560 | else { |
@@ -568,16 +568,16 @@ discard block |
||
568 | 568 | } |
569 | 569 | |
570 | 570 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
571 | - //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) { |
|
571 | + //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) { |
|
572 | 572 | if (!isset($this->all_flights[$id]['archive_latitude'])) { |
573 | 573 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
574 | 574 | $this->all_flights[$id]['time_last_coord'] = time(); |
575 | 575 | } |
576 | 576 | //if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
577 | 577 | 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)) { |
578 | - $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
579 | - $dataFound = true; |
|
580 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
578 | + $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
579 | + $dataFound = true; |
|
580 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
581 | 581 | } |
582 | 582 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
583 | 583 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
@@ -588,24 +588,24 @@ discard block |
||
588 | 588 | //$putinarchive = true; |
589 | 589 | } |
590 | 590 | */ |
591 | - /* |
|
591 | + /* |
|
592 | 592 | } elseif (isset($this->all_flights[$id]['latitude'])) { |
593 | 593 | 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"; |
594 | 594 | } |
595 | 595 | */ |
596 | 596 | } |
597 | 597 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
598 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
599 | - //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) { |
|
598 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
599 | + //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) { |
|
600 | 600 | if (!isset($this->all_flights[$id]['archive_longitude'])) { |
601 | 601 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
602 | 602 | $this->all_flights[$id]['time_last_coord'] = time(); |
603 | 603 | } |
604 | 604 | //if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
605 | 605 | 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)) { |
606 | - $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
607 | - $dataFound = true; |
|
608 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
606 | + $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
607 | + $dataFound = true; |
|
608 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
609 | 609 | } |
610 | 610 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
611 | 611 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
@@ -623,67 +623,67 @@ discard block |
||
623 | 623 | */ |
624 | 624 | } |
625 | 625 | |
626 | - } else if ($globalDebug && $timediff > 30) { |
|
626 | + } else if ($globalDebug && $timediff > 30) { |
|
627 | 627 | $this->tmd = $this->tmd + 1; |
628 | 628 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
629 | 629 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
630 | 630 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
631 | 631 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
632 | - } |
|
632 | + } |
|
633 | 633 | } |
634 | 634 | if (isset($line['last_update']) && $line['last_update'] != '') { |
635 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
636 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
635 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
636 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
637 | 637 | } |
638 | 638 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
639 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
640 | - //$dataFound = true; |
|
639 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
640 | + //$dataFound = true; |
|
641 | 641 | } |
642 | 642 | if (isset($line['format_source']) && $line['format_source'] != '') { |
643 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
643 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
644 | 644 | } |
645 | 645 | if (isset($line['source_name']) && $line['source_name'] != '') { |
646 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
646 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
647 | 647 | } |
648 | 648 | if (isset($line['emergency']) && $line['emergency'] != '') { |
649 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
650 | - //$dataFound = true; |
|
649 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
650 | + //$dataFound = true; |
|
651 | 651 | } |
652 | 652 | if (isset($line['ground']) && $line['ground'] != '') { |
653 | - if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
653 | + if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
654 | 654 | // Here we force archive of flight because after ground it's a new one (or should be) |
655 | 655 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
656 | 656 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
657 | 657 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
658 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
658 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
659 | 659 | 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'])); |
660 | - } |
|
661 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
662 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
663 | - //$dataFound = true; |
|
660 | + } |
|
661 | + if ($line['ground'] != 1) $line['ground'] = 0; |
|
662 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
663 | + //$dataFound = true; |
|
664 | 664 | } |
665 | 665 | if (isset($line['squawk']) && $line['squawk'] != '') { |
666 | - 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'])) { |
|
667 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
668 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
669 | - $highlight = ''; |
|
670 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
671 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
672 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
673 | - if ($highlight != '') { |
|
666 | + 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'])) { |
|
667 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
668 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
669 | + $highlight = ''; |
|
670 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
671 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
672 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
673 | + if ($highlight != '') { |
|
674 | 674 | $timeelapsed = microtime(true); |
675 | 675 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
676 | - $Spotter = new Spotter($this->db); |
|
677 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
678 | - $Spotter->db = null; |
|
679 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
676 | + $Spotter = new Spotter($this->db); |
|
677 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
678 | + $Spotter->db = null; |
|
679 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
680 | 680 | } |
681 | 681 | //$putinarchive = true; |
682 | 682 | //$highlight = ''; |
683 | - } |
|
683 | + } |
|
684 | 684 | |
685 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
686 | - //$dataFound = true; |
|
685 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
686 | + //$dataFound = true; |
|
687 | 687 | } |
688 | 688 | |
689 | 689 | if (isset($line['altitude']) && $line['altitude'] != '') { |
@@ -694,13 +694,13 @@ discard block |
||
694 | 694 | $line['altitude'] = $line['altitude'] - $geoid; |
695 | 695 | } |
696 | 696 | } |
697 | - //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
697 | + //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
698 | 698 | 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; |
699 | 699 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
700 | 700 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
701 | 701 | //$dataFound = true; |
702 | - //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
703 | - if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
|
702 | + //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
703 | + if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
|
704 | 704 | 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) { |
705 | 705 | if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
706 | 706 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
@@ -709,27 +709,27 @@ discard block |
||
709 | 709 | elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
710 | 710 | 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'])); |
711 | 711 | } |
712 | - } |
|
713 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
712 | + } |
|
713 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
714 | 714 | } |
715 | 715 | |
716 | 716 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
717 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
717 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
718 | 718 | } |
719 | 719 | |
720 | 720 | if (isset($line['heading']) && $line['heading'] != '') { |
721 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
722 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
723 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
724 | - //$dataFound = true; |
|
721 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
722 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
723 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
724 | + //$dataFound = true; |
|
725 | 725 | } 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']) { |
726 | - $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']); |
|
727 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
728 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
729 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
726 | + $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']); |
|
727 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
728 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
729 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
730 | 730 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
731 | - // If not enough messages and ACARS set heading to 0 |
|
732 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
731 | + // If not enough messages and ACARS set heading to 0 |
|
732 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
733 | 733 | } |
734 | 734 | if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
735 | 735 | elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
@@ -742,125 +742,125 @@ discard block |
||
742 | 742 | //if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
743 | 743 | //if ($dataFound === true && isset($this->all_flights[$id]['hex'])) { |
744 | 744 | if ($dataFound === true && isset($this->all_flights[$id]['id'])) { |
745 | - $this->all_flights[$id]['lastupdate'] = time(); |
|
746 | - if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
747 | - 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'])) { |
|
748 | - //print_r($this->all_flights); |
|
749 | - //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
750 | - //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
751 | - if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
745 | + $this->all_flights[$id]['lastupdate'] = time(); |
|
746 | + if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
747 | + 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'])) { |
|
748 | + //print_r($this->all_flights); |
|
749 | + //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
750 | + //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
751 | + if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
752 | 752 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
753 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
754 | - $timeelapsed = microtime(true); |
|
755 | - $SpotterLive = new SpotterLive($this->db); |
|
756 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
753 | + if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
754 | + $timeelapsed = microtime(true); |
|
755 | + $SpotterLive = new SpotterLive($this->db); |
|
756 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
757 | 757 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
758 | 758 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
759 | - } elseif (isset($line['id'])) { |
|
759 | + } elseif (isset($line['id'])) { |
|
760 | 760 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
761 | 761 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
762 | - } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
762 | + } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
763 | 763 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
764 | 764 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
765 | - } else $recent_ident = ''; |
|
766 | - $SpotterLive->db=null; |
|
767 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
768 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
765 | + } else $recent_ident = ''; |
|
766 | + $SpotterLive->db=null; |
|
767 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
768 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
769 | 769 | } else $recent_ident = ''; |
770 | - } else { |
|
770 | + } else { |
|
771 | 771 | $recent_ident = ''; |
772 | 772 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
773 | - } |
|
774 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
775 | - if($recent_ident == "") |
|
776 | - { |
|
773 | + } |
|
774 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
775 | + if($recent_ident == "") |
|
776 | + { |
|
777 | 777 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
778 | 778 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
779 | 779 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
780 | 780 | //adds the spotter data for the archive |
781 | 781 | $ignoreImport = false; |
782 | 782 | foreach($globalAirportIgnore as $airportIgnore) { |
783 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
783 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
784 | 784 | $ignoreImport = true; |
785 | - } |
|
785 | + } |
|
786 | 786 | } |
787 | 787 | if (count($globalAirportAccept) > 0) { |
788 | - $ignoreImport = true; |
|
789 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
788 | + $ignoreImport = true; |
|
789 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
790 | 790 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
791 | - $ignoreImport = false; |
|
791 | + $ignoreImport = false; |
|
792 | + } |
|
792 | 793 | } |
793 | - } |
|
794 | 794 | } |
795 | 795 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
796 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
796 | + foreach($globalAirlineIgnore as $airlineIgnore) { |
|
797 | 797 | 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)) { |
798 | - $ignoreImport = true; |
|
798 | + $ignoreImport = true; |
|
799 | + } |
|
799 | 800 | } |
800 | - } |
|
801 | 801 | } |
802 | 802 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
803 | - $ignoreImport = true; |
|
804 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
803 | + $ignoreImport = true; |
|
804 | + foreach($globalAirlineAccept as $airlineAccept) { |
|
805 | 805 | 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)) { |
806 | - $ignoreImport = false; |
|
806 | + $ignoreImport = false; |
|
807 | + } |
|
807 | 808 | } |
808 | - } |
|
809 | 809 | } |
810 | 810 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
811 | - $ignoreImport = true; |
|
812 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
811 | + $ignoreImport = true; |
|
812 | + foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
813 | 813 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
814 | - $ignoreImport = false; |
|
814 | + $ignoreImport = false; |
|
815 | + } |
|
815 | 816 | } |
816 | - } |
|
817 | 817 | } |
818 | 818 | |
819 | 819 | if (!$ignoreImport) { |
820 | - $highlight = ''; |
|
821 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
822 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
823 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
824 | - 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'))); |
|
825 | - $timeelapsed = microtime(true); |
|
826 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
820 | + $highlight = ''; |
|
821 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
822 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
823 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
824 | + 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'))); |
|
825 | + $timeelapsed = microtime(true); |
|
826 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
827 | 827 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
828 | - $Spotter = new Spotter($this->db); |
|
829 | - $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']); |
|
830 | - $Spotter->db = null; |
|
831 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
828 | + $Spotter = new Spotter($this->db); |
|
829 | + $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']); |
|
830 | + $Spotter->db = null; |
|
831 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
832 | 832 | } |
833 | - } |
|
834 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
835 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
833 | + } |
|
834 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
835 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
836 | 836 | |
837 | - // Add source stat in DB |
|
838 | - $Stats = new Stats($this->db); |
|
839 | - if (!empty($this->stats)) { |
|
837 | + // Add source stat in DB |
|
838 | + $Stats = new Stats($this->db); |
|
839 | + if (!empty($this->stats)) { |
|
840 | 840 | if ($globalDebug) echo 'Add source stats : '; |
841 | - foreach($this->stats as $date => $data) { |
|
842 | - foreach($data as $source => $sourced) { |
|
843 | - //print_r($sourced); |
|
844 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
845 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
846 | - if (isset($sourced['msg'])) { |
|
847 | - if (time() - $sourced['msg']['date'] > 10) { |
|
848 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
849 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
850 | - unset($this->stats[$date][$source]['msg']); |
|
851 | - } |
|
852 | - } |
|
853 | - } |
|
854 | - if ($date != date('Y-m-d')) { |
|
855 | - unset($this->stats[$date]); |
|
856 | - } |
|
857 | - } |
|
858 | - if ($globalDebug) echo 'Done'."\n"; |
|
841 | + foreach($this->stats as $date => $data) { |
|
842 | + foreach($data as $source => $sourced) { |
|
843 | + //print_r($sourced); |
|
844 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
845 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
846 | + if (isset($sourced['msg'])) { |
|
847 | + if (time() - $sourced['msg']['date'] > 10) { |
|
848 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
849 | + echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
850 | + unset($this->stats[$date][$source]['msg']); |
|
851 | + } |
|
852 | + } |
|
853 | + } |
|
854 | + if ($date != date('Y-m-d')) { |
|
855 | + unset($this->stats[$date]); |
|
856 | + } |
|
857 | + } |
|
858 | + if ($globalDebug) echo 'Done'."\n"; |
|
859 | 859 | |
860 | - } |
|
861 | - $Stats->db = null; |
|
862 | - } |
|
863 | - $this->del(); |
|
860 | + } |
|
861 | + $Stats->db = null; |
|
862 | + } |
|
863 | + $this->del(); |
|
864 | 864 | } elseif ($globalDebug) echo 'Ignore data'."\n"; |
865 | 865 | //$ignoreImport = false; |
866 | 866 | $this->all_flights[$id]['addedSpotter'] = 1; |
@@ -878,41 +878,41 @@ discard block |
||
878 | 878 | */ |
879 | 879 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
880 | 880 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
881 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
882 | - //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
883 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
881 | + if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
882 | + //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
883 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
884 | 884 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
885 | - $SpotterLive = new SpotterLive($this->db); |
|
886 | - $SpotterLive->deleteLiveSpotterData(); |
|
887 | - $SpotterLive->db=null; |
|
885 | + $SpotterLive = new SpotterLive($this->db); |
|
886 | + $SpotterLive->deleteLiveSpotterData(); |
|
887 | + $SpotterLive->db=null; |
|
888 | 888 | } |
889 | - } |
|
890 | - if ($globalDebug) echo " Done\n"; |
|
891 | - $this->last_delete = time(); |
|
889 | + } |
|
890 | + if ($globalDebug) echo " Done\n"; |
|
891 | + $this->last_delete = time(); |
|
892 | 892 | } |
893 | - } else { |
|
893 | + } else { |
|
894 | 894 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
895 | - $this->all_flights[$id]['id'] = $recent_ident; |
|
896 | - $this->all_flights[$id]['addedSpotter'] = 1; |
|
895 | + $this->all_flights[$id]['id'] = $recent_ident; |
|
896 | + $this->all_flights[$id]['addedSpotter'] = 1; |
|
897 | 897 | } |
898 | 898 | if (isset($globalDaemon) && !$globalDaemon) { |
899 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
899 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
900 | 900 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
901 | - $Spotter = new Spotter($this->db); |
|
902 | - $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']); |
|
903 | - $Spotter->db = null; |
|
901 | + $Spotter = new Spotter($this->db); |
|
902 | + $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']); |
|
903 | + $Spotter->db = null; |
|
904 | + } |
|
904 | 905 | } |
905 | - } |
|
906 | 906 | } |
907 | 907 | |
908 | - } |
|
908 | + } |
|
909 | 909 | } |
910 | - } |
|
911 | - //adds the spotter LIVE data |
|
912 | - //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
913 | - //echo "\nAdd in Live !! \n"; |
|
914 | - //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"; |
|
915 | - if ($globalDebug) { |
|
910 | + } |
|
911 | + //adds the spotter LIVE data |
|
912 | + //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
913 | + //echo "\nAdd in Live !! \n"; |
|
914 | + //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"; |
|
915 | + if ($globalDebug) { |
|
916 | 916 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
917 | 917 | 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"; |
918 | 918 | 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"; |
@@ -920,60 +920,60 @@ discard block |
||
920 | 920 | 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"; |
921 | 921 | 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"; |
922 | 922 | } |
923 | - } |
|
924 | - $ignoreImport = false; |
|
925 | - if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
926 | - if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
923 | + } |
|
924 | + $ignoreImport = false; |
|
925 | + if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
926 | + if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
927 | 927 | |
928 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
929 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
930 | - $ignoreImport = true; |
|
928 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
929 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
930 | + $ignoreImport = true; |
|
931 | + } |
|
931 | 932 | } |
932 | - } |
|
933 | - if (count($globalAirportAccept) > 0) { |
|
934 | - $ignoreImport = true; |
|
935 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
936 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
933 | + if (count($globalAirportAccept) > 0) { |
|
934 | + $ignoreImport = true; |
|
935 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
936 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
937 | 937 | $ignoreImport = false; |
938 | - } |
|
938 | + } |
|
939 | 939 | } |
940 | - } |
|
941 | - if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
940 | + } |
|
941 | + if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
942 | 942 | foreach($globalAirlineIgnore as $airlineIgnore) { |
943 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
943 | + 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)) { |
|
944 | 944 | $ignoreImport = true; |
945 | - } |
|
945 | + } |
|
946 | 946 | } |
947 | - } |
|
948 | - if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
947 | + } |
|
948 | + if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
949 | 949 | $ignoreImport = true; |
950 | 950 | foreach($globalAirlineAccept as $airlineAccept) { |
951 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
951 | + 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)) { |
|
952 | 952 | $ignoreImport = false; |
953 | - } |
|
953 | + } |
|
954 | + } |
|
954 | 955 | } |
955 | - } |
|
956 | - if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
956 | + if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
957 | 957 | $ignoreImport = true; |
958 | 958 | foreach($globalPilotIdAccept as $pilotIdAccept) { |
959 | - if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
960 | - $ignoreImport = false; |
|
961 | - } |
|
959 | + if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
960 | + $ignoreImport = false; |
|
961 | + } |
|
962 | + } |
|
962 | 963 | } |
963 | - } |
|
964 | 964 | |
965 | - if (!$ignoreImport) { |
|
965 | + if (!$ignoreImport) { |
|
966 | 966 | 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'])) { |
967 | 967 | 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'))); |
968 | 968 | $timeelapsed = microtime(true); |
969 | 969 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
970 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
970 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
971 | 971 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
972 | 972 | $SpotterLive = new SpotterLive($this->db); |
973 | 973 | $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']); |
974 | 974 | $SpotterLive->db = null; |
975 | 975 | if ($globalDebug) echo $result."\n"; |
976 | - } |
|
976 | + } |
|
977 | 977 | } |
978 | 978 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
979 | 979 | $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']); |
@@ -985,7 +985,7 @@ discard block |
||
985 | 985 | //if ($line['format_source'] != 'aprs') { |
986 | 986 | //if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) { |
987 | 987 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
988 | - if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
|
988 | + if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
|
989 | 989 | $source = $this->all_flights[$id]['source_name']; |
990 | 990 | if ($source == '') $source = $this->all_flights[$id]['format_source']; |
991 | 991 | if (!isset($this->source_location[$source])) { |
@@ -1011,7 +1011,7 @@ discard block |
||
1011 | 1011 | if ($stats_heading == 16) $stats_heading = 0; |
1012 | 1012 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
1013 | 1013 | for ($i=0;$i<=15;$i++) { |
1014 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
1014 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
1015 | 1015 | } |
1016 | 1016 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
1017 | 1017 | } else { |
@@ -1024,17 +1024,17 @@ discard block |
||
1024 | 1024 | //var_dump($this->stats); |
1025 | 1025 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
1026 | 1026 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
1027 | - end($this->stats[$current_date][$source]['hist']); |
|
1028 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
1027 | + end($this->stats[$current_date][$source]['hist']); |
|
1028 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
1029 | 1029 | } else $mini = 0; |
1030 | 1030 | for ($i=$mini;$i<=$distance;$i+=10) { |
1031 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
1031 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
1032 | 1032 | } |
1033 | 1033 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
1034 | 1034 | } else { |
1035 | 1035 | $this->stats[$current_date][$source]['hist'][$distance] += 1; |
1036 | 1036 | } |
1037 | - } |
|
1037 | + } |
|
1038 | 1038 | } |
1039 | 1039 | |
1040 | 1040 | $this->all_flights[$id]['lastupdate'] = time(); |
@@ -1044,7 +1044,7 @@ discard block |
||
1044 | 1044 | //$this->del(); |
1045 | 1045 | |
1046 | 1046 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
1047 | - if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
1047 | + if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
1048 | 1048 | if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
1049 | 1049 | $SpotterLive = new SpotterLive($this->db); |
1050 | 1050 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
@@ -1052,19 +1052,19 @@ discard block |
||
1052 | 1052 | //SpotterLive->deleteLiveSpotterData(); |
1053 | 1053 | if ($globalDebug) echo " Done\n"; |
1054 | 1054 | $this->last_delete_hourly = time(); |
1055 | - } else { |
|
1055 | + } else { |
|
1056 | 1056 | $this->del(); |
1057 | 1057 | $this->last_delete_hourly = time(); |
1058 | - } |
|
1058 | + } |
|
1059 | 1059 | } |
1060 | 1060 | |
1061 | - } |
|
1062 | - //$ignoreImport = false; |
|
1061 | + } |
|
1062 | + //$ignoreImport = false; |
|
1063 | 1063 | } |
1064 | 1064 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
1065 | 1065 | if ($send) return $this->all_flights[$id]; |
1066 | - } |
|
1066 | + } |
|
1067 | + } |
|
1067 | 1068 | } |
1068 | - } |
|
1069 | 1069 | } |
1070 | 1070 | ?> |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | }; |
344 | 344 | |
345 | 345 | <?php |
346 | - if (isset($globalTSK) && $globalTSK && isset($_GET['tsk'])) { |
|
346 | + if (isset($globalTSK) && $globalTSK && isset($_GET['tsk'])) { |
|
347 | 347 | ?> |
348 | 348 | function tskPopup (feature, layer) { |
349 | 349 | var output = ''; |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | }; |
379 | 379 | update_tsk(); |
380 | 380 | <?php |
381 | - } |
|
381 | + } |
|
382 | 382 | ?> |
383 | 383 | map.on('moveend', function() { |
384 | 384 | //if (map.getZoom() > 7) { |
@@ -394,10 +394,10 @@ discard block |
||
394 | 394 | setInterval(function(){update_locationsLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>); |
395 | 395 | |
396 | 396 | <?php |
397 | - // Add support for custom json via $globalMapJson |
|
398 | - if (isset($globalMapJson) && is_array($globalMapJson)) { |
|
397 | + // Add support for custom json via $globalMapJson |
|
398 | + if (isset($globalMapJson) && is_array($globalMapJson)) { |
|
399 | 399 | foreach ($globalMapJson as $json) { |
400 | - if (isset($json['url'])) { |
|
400 | + if (isset($json['url'])) { |
|
401 | 401 | ?> |
402 | 402 | update_genLayer('<?php print $json['url']; ?>'); |
403 | 403 | <?php |
@@ -406,9 +406,9 @@ discard block |
||
406 | 406 | setInterval(function(){update_genLayer('<?php print $json['url']; ?>')}, <?php print $json['refresh']; ?>); |
407 | 407 | <?php |
408 | 408 | } |
409 | - } |
|
409 | + } |
|
410 | + } |
|
410 | 411 | } |
411 | - } |
|
412 | 412 | |
413 | 413 | ?> |
414 | 414 | //adds the bootstrap tooltip to the map icons |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
17 | 17 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
18 | 18 | if (isset($globalMarine) && $globalMarine) { |
19 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
20 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
19 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
20 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | if (!isset($globalDebug)) $globalDebug = FALSE; |
@@ -25,46 +25,46 @@ discard block |
||
25 | 25 | // Check if schema is at latest version |
26 | 26 | $Connection = new Connection(); |
27 | 27 | if ($Connection->connectionExists() === false) { |
28 | - echo "Can't connect to your database. Check DB is running, user/password and database logs."; |
|
29 | - exit(); |
|
28 | + echo "Can't connect to your database. Check DB is running, user/password and database logs."; |
|
29 | + exit(); |
|
30 | 30 | } |
31 | 31 | if ($Connection->latest() === false) { |
32 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
33 | - exit(); |
|
32 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
33 | + exit(); |
|
34 | 34 | } |
35 | 35 | if (PHP_SAPI != 'cli') { |
36 | - echo "This script MUST be called from console, not a web browser."; |
|
36 | + echo "This script MUST be called from console, not a web browser."; |
|
37 | 37 | // exit(); |
38 | 38 | } |
39 | 39 | |
40 | 40 | // This is to be compatible with old version of settings.php |
41 | 41 | if (!isset($globalSources)) { |
42 | - if (isset($globalSBS1Hosts)) { |
|
43 | - //$hosts = $globalSBS1Hosts; |
|
44 | - foreach ($globalSBS1Hosts as $host) { |
|
45 | - $globalSources[] = array('host' => $host); |
|
46 | - } |
|
47 | - } else { |
|
48 | - if (!isset($globalSBS1Host)) { |
|
49 | - echo '$globalSources MUST be defined !'; |
|
50 | - die; |
|
42 | + if (isset($globalSBS1Hosts)) { |
|
43 | + //$hosts = $globalSBS1Hosts; |
|
44 | + foreach ($globalSBS1Hosts as $host) { |
|
45 | + $globalSources[] = array('host' => $host); |
|
46 | + } |
|
47 | + } else { |
|
48 | + if (!isset($globalSBS1Host)) { |
|
49 | + echo '$globalSources MUST be defined !'; |
|
50 | + die; |
|
51 | 51 | } |
52 | 52 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
53 | 53 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
54 | - } |
|
54 | + } |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine')); |
58 | 58 | //if (isset($options['s'])) $hosts = array($options['s']); |
59 | 59 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
60 | 60 | if (isset($options['s'])) { |
61 | - $globalSources = array(); |
|
62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
63 | - else $globalSources[] = array('host' => $options['s']); |
|
61 | + $globalSources = array(); |
|
62 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
63 | + else $globalSources[] = array('host' => $options['s']); |
|
64 | 64 | } elseif (isset($options['source'])) { |
65 | - $globalSources = array(); |
|
66 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
67 | - else $globalSources[] = array('host' => $options['source']); |
|
65 | + $globalSources = array(); |
|
66 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
67 | + else $globalSources[] = array('host' => $options['source']); |
|
68 | 68 | } |
69 | 69 | if (isset($options['aprsserverhost'])) { |
70 | 70 | $globalServerAPRS = TRUE; |
@@ -103,8 +103,8 @@ discard block |
||
103 | 103 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
104 | 104 | else $id_source = 1; |
105 | 105 | if (isset($globalServer) && $globalServer) { |
106 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
107 | - $SI=new SpotterServer(); |
|
106 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
107 | + $SI=new SpotterServer(); |
|
108 | 108 | /* |
109 | 109 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
110 | 110 | $SI = new adsb2aprs(); |
@@ -114,14 +114,14 @@ discard block |
||
114 | 114 | |
115 | 115 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
116 | 116 | if (isset($globalMarine) && $globalMarine) { |
117 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
118 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
117 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
118 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
122 | 122 | if (isset($globalMarine) && $globalMarine) { |
123 | - $AIS = new AIS(); |
|
124 | - $MI = new MarineImport($Connection->db); |
|
123 | + $AIS = new AIS(); |
|
124 | + $MI = new MarineImport($Connection->db); |
|
125 | 125 | } |
126 | 126 | //$APRS=new APRS($Connection->db); |
127 | 127 | $SBS=new SBS(); |
@@ -134,12 +134,12 @@ discard block |
||
134 | 134 | //$servertz = system('date +%Z'); |
135 | 135 | // signal handler - playing nice with sockets and dump1090 |
136 | 136 | if (function_exists('pcntl_fork')) { |
137 | - pcntl_signal(SIGINT, function() { |
|
138 | - global $sockets; |
|
139 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
140 | - die("Bye!\n"); |
|
141 | - }); |
|
142 | - pcntl_signal_dispatch(); |
|
137 | + pcntl_signal(SIGINT, function() { |
|
138 | + global $sockets; |
|
139 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
140 | + die("Bye!\n"); |
|
141 | + }); |
|
142 | + pcntl_signal_dispatch(); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | // let's try and connect |
@@ -149,36 +149,36 @@ discard block |
||
149 | 149 | $reset = 0; |
150 | 150 | |
151 | 151 | function connect_all($hosts) { |
152 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
153 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
154 | - $reset++; |
|
155 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
156 | - foreach ($hosts as $id => $value) { |
|
152 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
153 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
154 | + $reset++; |
|
155 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
156 | + foreach ($hosts as $id => $value) { |
|
157 | 157 | $host = $value['host']; |
158 | 158 | $globalSources[$id]['last_exec'] = 0; |
159 | 159 | // Here we check type of source(s) |
160 | 160 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
161 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
162 | - //$formats[$id] = 'deltadbtxt'; |
|
163 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
164 | - //$last_exec['deltadbtxt'] = 0; |
|
165 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
166 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
167 | - //$formats[$id] = 'vatsimtxt'; |
|
168 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
169 | - //$last_exec['vatsimtxt'] = 0; |
|
170 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
171 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
172 | - //$formats[$id] = 'aircraftlistjson'; |
|
173 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
174 | - //$last_exec['aircraftlistjson'] = 0; |
|
175 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
176 | - } else if (preg_match('/opensky/i',$host)) { |
|
177 | - //$formats[$id] = 'aircraftlistjson'; |
|
178 | - $globalSources[$id]['format'] = 'opensky'; |
|
179 | - //$last_exec['aircraftlistjson'] = 0; |
|
180 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
181 | - /* |
|
161 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
162 | + //$formats[$id] = 'deltadbtxt'; |
|
163 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
164 | + //$last_exec['deltadbtxt'] = 0; |
|
165 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
166 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
167 | + //$formats[$id] = 'vatsimtxt'; |
|
168 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
169 | + //$last_exec['vatsimtxt'] = 0; |
|
170 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
171 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
172 | + //$formats[$id] = 'aircraftlistjson'; |
|
173 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
174 | + //$last_exec['aircraftlistjson'] = 0; |
|
175 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
176 | + } else if (preg_match('/opensky/i',$host)) { |
|
177 | + //$formats[$id] = 'aircraftlistjson'; |
|
178 | + $globalSources[$id]['format'] = 'opensky'; |
|
179 | + //$last_exec['aircraftlistjson'] = 0; |
|
180 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
181 | + /* |
|
182 | 182 | // Disabled for now, site change source format |
183 | 183 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
184 | 184 | //$formats[$id] = 'radarvirtueljson'; |
@@ -190,125 +190,125 @@ discard block |
||
190 | 190 | exit(0); |
191 | 191 | } |
192 | 192 | */ |
193 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
194 | - //$formats[$id] = 'planeupdatefaa'; |
|
195 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
196 | - //$last_exec['planeupdatefaa'] = 0; |
|
197 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
198 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
199 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
200 | - exit(0); |
|
201 | - } |
|
202 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
203 | - //$formats[$id] = 'phpvmacars'; |
|
204 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
205 | - //$last_exec['phpvmacars'] = 0; |
|
206 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
207 | - } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
208 | - //$formats[$id] = 'phpvmacars'; |
|
209 | - $globalSources[$id]['format'] = 'vaos'; |
|
210 | - //$last_exec['phpvmacars'] = 0; |
|
211 | - if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
212 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
213 | - //$formats[$id] = 'phpvmacars'; |
|
214 | - $globalSources[$id]['format'] = 'vam'; |
|
215 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
216 | - } else if (preg_match('/whazzup/i',$host)) { |
|
217 | - //$formats[$id] = 'whazzup'; |
|
218 | - $globalSources[$id]['format'] = 'whazzup'; |
|
219 | - //$last_exec['whazzup'] = 0; |
|
220 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
221 | - } else if (preg_match('/blitzortung/i',$host)) { |
|
222 | - $globalSources[$id]['format'] = 'blitzortung'; |
|
223 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
224 | - } else if (preg_match('/airwhere/i',$host)) { |
|
225 | - $globalSources[$id]['format'] = 'airwhere'; |
|
226 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
227 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
228 | - //$formats[$id] = 'pirepsjson'; |
|
229 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
230 | - //$last_exec['pirepsjson'] = 0; |
|
231 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
232 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
233 | - //$formats[$id] = 'fr24json'; |
|
234 | - $globalSources[$id]['format'] = 'fr24json'; |
|
235 | - //$last_exec['fr24json'] = 0; |
|
236 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
237 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
238 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
239 | - exit(0); |
|
240 | - } |
|
241 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
242 | - //$formats[$id] = 'fr24json'; |
|
243 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
244 | - //$last_exec['fr24json'] = 0; |
|
245 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
246 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
247 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
248 | - exit(0); |
|
249 | - } |
|
250 | - //} else if (preg_match('/10001/',$host)) { |
|
251 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
252 | - //$formats[$id] = 'tsv'; |
|
253 | - $globalSources[$id]['format'] = 'tsv'; |
|
254 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
255 | - } |
|
256 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
257 | - if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
258 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
259 | - if ($idf !== false) { |
|
260 | - $httpfeeds[$id] = $idf; |
|
261 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
262 | - } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
263 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
264 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
265 | - $hostport = explode(':',$host); |
|
266 | - if (isset($hostport[1])) { |
|
193 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
194 | + //$formats[$id] = 'planeupdatefaa'; |
|
195 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
196 | + //$last_exec['planeupdatefaa'] = 0; |
|
197 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
198 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
199 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
200 | + exit(0); |
|
201 | + } |
|
202 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
203 | + //$formats[$id] = 'phpvmacars'; |
|
204 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
205 | + //$last_exec['phpvmacars'] = 0; |
|
206 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
207 | + } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
208 | + //$formats[$id] = 'phpvmacars'; |
|
209 | + $globalSources[$id]['format'] = 'vaos'; |
|
210 | + //$last_exec['phpvmacars'] = 0; |
|
211 | + if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
212 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
213 | + //$formats[$id] = 'phpvmacars'; |
|
214 | + $globalSources[$id]['format'] = 'vam'; |
|
215 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
216 | + } else if (preg_match('/whazzup/i',$host)) { |
|
217 | + //$formats[$id] = 'whazzup'; |
|
218 | + $globalSources[$id]['format'] = 'whazzup'; |
|
219 | + //$last_exec['whazzup'] = 0; |
|
220 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
221 | + } else if (preg_match('/blitzortung/i',$host)) { |
|
222 | + $globalSources[$id]['format'] = 'blitzortung'; |
|
223 | + if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
224 | + } else if (preg_match('/airwhere/i',$host)) { |
|
225 | + $globalSources[$id]['format'] = 'airwhere'; |
|
226 | + if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
227 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
228 | + //$formats[$id] = 'pirepsjson'; |
|
229 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
230 | + //$last_exec['pirepsjson'] = 0; |
|
231 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
232 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
233 | + //$formats[$id] = 'fr24json'; |
|
234 | + $globalSources[$id]['format'] = 'fr24json'; |
|
235 | + //$last_exec['fr24json'] = 0; |
|
236 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
237 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
238 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
239 | + exit(0); |
|
240 | + } |
|
241 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
242 | + //$formats[$id] = 'fr24json'; |
|
243 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
244 | + //$last_exec['fr24json'] = 0; |
|
245 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
246 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
247 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
248 | + exit(0); |
|
249 | + } |
|
250 | + //} else if (preg_match('/10001/',$host)) { |
|
251 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
252 | + //$formats[$id] = 'tsv'; |
|
253 | + $globalSources[$id]['format'] = 'tsv'; |
|
254 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
255 | + } |
|
256 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
257 | + if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
258 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
259 | + if ($idf !== false) { |
|
260 | + $httpfeeds[$id] = $idf; |
|
261 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
262 | + } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
263 | + } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
264 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
265 | + $hostport = explode(':',$host); |
|
266 | + if (isset($hostport[1])) { |
|
267 | 267 | $port = $hostport[1]; |
268 | 268 | $hostn = $hostport[0]; |
269 | - } else { |
|
269 | + } else { |
|
270 | 270 | $port = $globalSources[$id]['port']; |
271 | 271 | $hostn = $globalSources[$id]['host']; |
272 | - } |
|
273 | - $Common = new Common(); |
|
274 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
275 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
276 | - } else { |
|
277 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
278 | - } |
|
279 | - if ($s) { |
|
280 | - $sockets[$id] = $s; |
|
281 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
282 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
272 | + } |
|
273 | + $Common = new Common(); |
|
274 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
275 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
276 | + } else { |
|
277 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
278 | + } |
|
279 | + if ($s) { |
|
280 | + $sockets[$id] = $s; |
|
281 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
282 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
283 | 283 | //$formats[$id] = 'aprs'; |
284 | 284 | $globalSources[$id]['format'] = 'aprs'; |
285 | 285 | //$aprs_connect = 0; |
286 | 286 | //$use_aprs = true; |
287 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
287 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
288 | 288 | $globalSources[$id]['format'] = 'vrstcp'; |
289 | - } elseif ($port == '10001') { |
|
290 | - //$formats[$id] = 'tsv'; |
|
291 | - $globalSources[$id]['format'] = 'tsv'; |
|
292 | - } elseif ($port == '30002') { |
|
293 | - //$formats[$id] = 'raw'; |
|
294 | - $globalSources[$id]['format'] = 'raw'; |
|
295 | - } elseif ($port == '5001') { |
|
296 | - //$formats[$id] = 'raw'; |
|
297 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
298 | - } elseif ($port == '30005') { |
|
289 | + } elseif ($port == '10001') { |
|
290 | + //$formats[$id] = 'tsv'; |
|
291 | + $globalSources[$id]['format'] = 'tsv'; |
|
292 | + } elseif ($port == '30002') { |
|
293 | + //$formats[$id] = 'raw'; |
|
294 | + $globalSources[$id]['format'] = 'raw'; |
|
295 | + } elseif ($port == '5001') { |
|
296 | + //$formats[$id] = 'raw'; |
|
297 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
298 | + } elseif ($port == '30005') { |
|
299 | 299 | // Not yet supported |
300 | - //$formats[$id] = 'beast'; |
|
301 | - $globalSources[$id]['format'] = 'beast'; |
|
302 | - //} else $formats[$id] = 'sbs'; |
|
303 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
304 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
300 | + //$formats[$id] = 'beast'; |
|
301 | + $globalSources[$id]['format'] = 'beast'; |
|
302 | + //} else $formats[$id] = 'sbs'; |
|
303 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
304 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
305 | 305 | } |
306 | 306 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
307 | - } else { |
|
307 | + } else { |
|
308 | 308 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
309 | - } |
|
310 | - } |
|
311 | - } |
|
309 | + } |
|
310 | + } |
|
311 | + } |
|
312 | 312 | } |
313 | 313 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
314 | 314 | |
@@ -331,9 +331,9 @@ discard block |
||
331 | 331 | //connect_all($globalSources); |
332 | 332 | |
333 | 333 | if (isset($globalProxy) && $globalProxy) { |
334 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
334 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
335 | 335 | } else { |
336 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
336 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | // APRS Configuration |
@@ -342,21 +342,21 @@ discard block |
||
342 | 342 | die; |
343 | 343 | } |
344 | 344 | foreach ($globalSources as $key => $source) { |
345 | - if (!isset($source['format'])) { |
|
346 | - $globalSources[$key]['format'] = 'auto'; |
|
347 | - } |
|
348 | - if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
349 | - unset($globalSources[$key]); |
|
350 | - } |
|
345 | + if (!isset($source['format'])) { |
|
346 | + $globalSources[$key]['format'] = 'auto'; |
|
347 | + } |
|
348 | + if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
349 | + unset($globalSources[$key]); |
|
350 | + } |
|
351 | 351 | } |
352 | 352 | connect_all($globalSources); |
353 | 353 | foreach ($globalSources as $key => $source) { |
354 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
354 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
355 | 355 | $aprs_connect = 0; |
356 | 356 | $use_aprs = true; |
357 | 357 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
358 | 358 | break; |
359 | - } |
|
359 | + } |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | if ($use_aprs) { |
@@ -397,131 +397,131 @@ discard block |
||
397 | 397 | |
398 | 398 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
399 | 399 | while ($i > 0) { |
400 | - if (!$globalDaemon) $i = $endtime-time(); |
|
401 | - // Delete old ATC |
|
402 | - if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
400 | + if (!$globalDaemon) $i = $endtime-time(); |
|
401 | + // Delete old ATC |
|
402 | + if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
403 | 403 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
404 | - $ATC->deleteOldATC(); |
|
405 | - } |
|
404 | + $ATC->deleteOldATC(); |
|
405 | + } |
|
406 | 406 | |
407 | - if (count($last_exec) == count($globalSources)) { |
|
407 | + if (count($last_exec) == count($globalSources)) { |
|
408 | 408 | $max = $globalMinFetch; |
409 | 409 | foreach ($last_exec as $last) { |
410 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
410 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
411 | 411 | } |
412 | 412 | if ($max != $globalMinFetch) { |
413 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
414 | - sleep($globalMinFetch-$max+2); |
|
413 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
414 | + sleep($globalMinFetch-$max+2); |
|
415 | + } |
|
415 | 416 | } |
416 | - } |
|
417 | 417 | |
418 | 418 | |
419 | - //foreach ($formats as $id => $value) { |
|
420 | - foreach ($globalSources as $id => $value) { |
|
419 | + //foreach ($formats as $id => $value) { |
|
420 | + foreach ($globalSources as $id => $value) { |
|
421 | 421 | date_default_timezone_set('UTC'); |
422 | 422 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
423 | 423 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
424 | 424 | if ($value['format'] == 'deltadbtxt' && |
425 | - ( |
|
425 | + ( |
|
426 | 426 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
427 | 427 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
428 | - ) |
|
428 | + ) |
|
429 | 429 | ) { |
430 | - //$buffer = $Common->getData($hosts[$id]); |
|
431 | - $buffer = $Common->getData($value['host']); |
|
432 | - if ($buffer != '') $reset = 0; |
|
433 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
434 | - $buffer = explode('\n',$buffer); |
|
435 | - foreach ($buffer as $line) { |
|
436 | - if ($line != '' && count($line) > 7) { |
|
437 | - $line = explode(',', $line); |
|
438 | - $data = array(); |
|
439 | - $data['hex'] = $line[1]; // hex |
|
440 | - $data['ident'] = $line[2]; // ident |
|
441 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
442 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
443 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
444 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
445 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
446 | - $data['verticalrate'] = ''; // vertical rate |
|
447 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
448 | - $data['emergency'] = ''; // emergency |
|
449 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
450 | - $data['format_source'] = 'deltadbtxt'; |
|
451 | - $data['id_source'] = $id_source; |
|
452 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
453 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
454 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
455 | - $SI->add($data); |
|
456 | - unset($data); |
|
457 | - } |
|
458 | - } |
|
459 | - $last_exec[$id]['last'] = time(); |
|
430 | + //$buffer = $Common->getData($hosts[$id]); |
|
431 | + $buffer = $Common->getData($value['host']); |
|
432 | + if ($buffer != '') $reset = 0; |
|
433 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
434 | + $buffer = explode('\n',$buffer); |
|
435 | + foreach ($buffer as $line) { |
|
436 | + if ($line != '' && count($line) > 7) { |
|
437 | + $line = explode(',', $line); |
|
438 | + $data = array(); |
|
439 | + $data['hex'] = $line[1]; // hex |
|
440 | + $data['ident'] = $line[2]; // ident |
|
441 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
442 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
443 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
444 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
445 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
446 | + $data['verticalrate'] = ''; // vertical rate |
|
447 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
448 | + $data['emergency'] = ''; // emergency |
|
449 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
450 | + $data['format_source'] = 'deltadbtxt'; |
|
451 | + $data['id_source'] = $id_source; |
|
452 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
453 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
454 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
455 | + $SI->add($data); |
|
456 | + unset($data); |
|
457 | + } |
|
458 | + } |
|
459 | + $last_exec[$id]['last'] = time(); |
|
460 | 460 | } elseif ($value['format'] == 'aisnmeatxt' && |
461 | - ( |
|
461 | + ( |
|
462 | 462 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
463 | 463 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
464 | - ) |
|
464 | + ) |
|
465 | 465 | ) { |
466 | - date_default_timezone_set('CET'); |
|
467 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
468 | - date_default_timezone_set('UTC'); |
|
469 | - if ($buffer != '') $reset = 0; |
|
470 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
471 | - $buffer = explode('\n',$buffer); |
|
472 | - foreach ($buffer as $line) { |
|
466 | + date_default_timezone_set('CET'); |
|
467 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
468 | + date_default_timezone_set('UTC'); |
|
469 | + if ($buffer != '') $reset = 0; |
|
470 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
471 | + $buffer = explode('\n',$buffer); |
|
472 | + foreach ($buffer as $line) { |
|
473 | 473 | if ($line != '') { |
474 | - //echo "'".$line."'\n"; |
|
475 | - $add = false; |
|
476 | - $ais_data = $AIS->parse_line(trim($line)); |
|
477 | - $data = array(); |
|
478 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
479 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
480 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
481 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
482 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
483 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
484 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
485 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
486 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
487 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
488 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
489 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
490 | - if (isset($ais_data['timestamp'])) { |
|
474 | + //echo "'".$line."'\n"; |
|
475 | + $add = false; |
|
476 | + $ais_data = $AIS->parse_line(trim($line)); |
|
477 | + $data = array(); |
|
478 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
479 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
480 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
481 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
482 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
483 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
484 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
485 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
486 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
487 | + if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
488 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
489 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
490 | + if (isset($ais_data['timestamp'])) { |
|
491 | 491 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
492 | 492 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
493 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
494 | - $add = true; |
|
493 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
494 | + $add = true; |
|
495 | 495 | } |
496 | - } else { |
|
496 | + } else { |
|
497 | 497 | $data['datetime'] = date('Y-m-d H:i:s'); |
498 | 498 | $add = true; |
499 | - } |
|
500 | - $data['format_source'] = 'aisnmeatxt'; |
|
501 | - $data['id_source'] = $id_source; |
|
502 | - //print_r($data); |
|
503 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
504 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
505 | - unset($data); |
|
499 | + } |
|
500 | + $data['format_source'] = 'aisnmeatxt'; |
|
501 | + $data['id_source'] = $id_source; |
|
502 | + //print_r($data); |
|
503 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
504 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
505 | + unset($data); |
|
506 | 506 | } |
507 | - } |
|
508 | - $last_exec[$id]['last'] = time(); |
|
507 | + } |
|
508 | + $last_exec[$id]['last'] = time(); |
|
509 | 509 | } elseif ($value['format'] == 'aisnmeahttp') { |
510 | - $arr = $httpfeeds; |
|
511 | - $w = $e = null; |
|
510 | + $arr = $httpfeeds; |
|
511 | + $w = $e = null; |
|
512 | 512 | |
513 | - if (isset($arr[$id])) { |
|
513 | + if (isset($arr[$id])) { |
|
514 | 514 | $nn = stream_select($arr,$w,$e,$timeout); |
515 | 515 | if ($nn > 0) { |
516 | - foreach ($httpfeeds as $feed) { |
|
516 | + foreach ($httpfeeds as $feed) { |
|
517 | 517 | $buffer = stream_get_line($feed,2000,"\n"); |
518 | 518 | if ($buffer === FALSE) { |
519 | - connect_all($globalSources); |
|
519 | + connect_all($globalSources); |
|
520 | 520 | } |
521 | 521 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
522 | 522 | $buffer = explode('\n',$buffer); |
523 | 523 | foreach ($buffer as $line) { |
524 | - if ($line != '') { |
|
524 | + if ($line != '') { |
|
525 | 525 | $ais_data = $AIS->parse_line(trim($line)); |
526 | 526 | $data = array(); |
527 | 527 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
@@ -539,117 +539,117 @@ discard block |
||
539 | 539 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
540 | 540 | if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
541 | 541 | if (isset($ais_data['timestamp'])) { |
542 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
542 | + $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
543 | 543 | } else { |
544 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
544 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
545 | 545 | } |
546 | 546 | $data['format_source'] = 'aisnmeahttp'; |
547 | 547 | $data['id_source'] = $id_source; |
548 | 548 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
549 | 549 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
550 | 550 | unset($data); |
551 | - } |
|
551 | + } |
|
552 | + } |
|
552 | 553 | } |
553 | - } |
|
554 | 554 | } else { |
555 | - $format = $value['format']; |
|
556 | - if (isset($tt[$format])) $tt[$format]++; |
|
557 | - else $tt[$format] = 0; |
|
558 | - if ($tt[$format] > 30) { |
|
555 | + $format = $value['format']; |
|
556 | + if (isset($tt[$format])) $tt[$format]++; |
|
557 | + else $tt[$format] = 0; |
|
558 | + if ($tt[$format] > 30) { |
|
559 | 559 | if ($globalDebug) echo 'Reconnect...'."\n"; |
560 | 560 | sleep(2); |
561 | 561 | //$sourceeen[] = $value; |
562 | 562 | //connect_all($sourceeen); |
563 | 563 | //$sourceeen = array(); |
564 | 564 | connect_all($globalSources); |
565 | - } |
|
565 | + } |
|
566 | + } |
|
566 | 567 | } |
567 | - } |
|
568 | 568 | } elseif ($value['format'] == 'myshiptracking' && |
569 | - ( |
|
569 | + ( |
|
570 | 570 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
571 | 571 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
572 | - ) |
|
572 | + ) |
|
573 | 573 | ) { |
574 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
575 | - if ($buffer != '') { |
|
574 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
575 | + if ($buffer != '') { |
|
576 | 576 | //echo $buffer; |
577 | 577 | $all_data = json_decode($buffer,true); |
578 | 578 | //print_r($all_data); |
579 | 579 | if (isset($all_data[0]['DATA'])) { |
580 | - foreach ($all_data[0]['DATA'] as $line) { |
|
580 | + foreach ($all_data[0]['DATA'] as $line) { |
|
581 | 581 | if ($line != '') { |
582 | - $data = array(); |
|
583 | - $data['ident'] = $line['NAME']; |
|
584 | - $data['mmsi'] = $line['MMSI']; |
|
585 | - if (strlen($data['mmsi']) > 9) { |
|
582 | + $data = array(); |
|
583 | + $data['ident'] = $line['NAME']; |
|
584 | + $data['mmsi'] = $line['MMSI']; |
|
585 | + if (strlen($data['mmsi']) > 9) { |
|
586 | 586 | $data['mmsi'] = substr($data['mmsi'],-9); |
587 | - } |
|
588 | - $data['speed'] = $line['SOG']; |
|
589 | - $data['heading'] = $line['COG']; |
|
590 | - $data['latitude'] = $line['LAT']; |
|
591 | - $data['longitude'] = $line['LNG']; |
|
592 | - // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
593 | - //$data['type_id'] = $line['TYPE']; |
|
594 | - $data['imo'] = $line['IMO']; |
|
595 | - if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
596 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
597 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
598 | - $data['format_source'] = 'myshiptracking'; |
|
599 | - $data['id_source'] = $id_source; |
|
600 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
601 | - $MI->add($data); |
|
602 | - unset($data); |
|
587 | + } |
|
588 | + $data['speed'] = $line['SOG']; |
|
589 | + $data['heading'] = $line['COG']; |
|
590 | + $data['latitude'] = $line['LAT']; |
|
591 | + $data['longitude'] = $line['LNG']; |
|
592 | + // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
593 | + //$data['type_id'] = $line['TYPE']; |
|
594 | + $data['imo'] = $line['IMO']; |
|
595 | + if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
596 | + if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
597 | + $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
598 | + $data['format_source'] = 'myshiptracking'; |
|
599 | + $data['id_source'] = $id_source; |
|
600 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
601 | + $MI->add($data); |
|
602 | + unset($data); |
|
603 | + } |
|
603 | 604 | } |
604 | - } |
|
605 | 605 | } |
606 | - } |
|
607 | - $last_exec[$id]['last'] = time(); |
|
606 | + } |
|
607 | + $last_exec[$id]['last'] = time(); |
|
608 | 608 | } elseif ($value['format'] == 'boatbeaconapp' && |
609 | - ( |
|
609 | + ( |
|
610 | 610 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
611 | 611 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
612 | - ) |
|
612 | + ) |
|
613 | 613 | ) { |
614 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
615 | - if ($buffer != '') { |
|
614 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
615 | + if ($buffer != '') { |
|
616 | 616 | $all_data = json_decode($buffer,true); |
617 | 617 | if (isset($all_data[0]['mmsi'])) { |
618 | - foreach ($all_data as $line) { |
|
618 | + foreach ($all_data as $line) { |
|
619 | 619 | if ($line != '') { |
620 | - $data = array(); |
|
621 | - $data['ident'] = $line['shipname']; |
|
622 | - $data['callsign'] = $line['callsign']; |
|
623 | - $data['mmsi'] = substr($line['mmsi'],-9); |
|
624 | - $data['speed'] = $line['sog']; |
|
625 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
626 | - $data['latitude'] = $line['latitude']; |
|
627 | - $data['longitude'] = $line['longitude']; |
|
628 | - $data['type_id'] = $line['shiptype']; |
|
629 | - $data['arrival_code'] = $line['destination']; |
|
630 | - $data['datetime'] = $line['time']; |
|
631 | - $data['format_source'] = 'boatbeaconapp'; |
|
632 | - $data['id_source'] = $id_source; |
|
633 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
634 | - $MI->add($data); |
|
635 | - unset($data); |
|
620 | + $data = array(); |
|
621 | + $data['ident'] = $line['shipname']; |
|
622 | + $data['callsign'] = $line['callsign']; |
|
623 | + $data['mmsi'] = substr($line['mmsi'],-9); |
|
624 | + $data['speed'] = $line['sog']; |
|
625 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
626 | + $data['latitude'] = $line['latitude']; |
|
627 | + $data['longitude'] = $line['longitude']; |
|
628 | + $data['type_id'] = $line['shiptype']; |
|
629 | + $data['arrival_code'] = $line['destination']; |
|
630 | + $data['datetime'] = $line['time']; |
|
631 | + $data['format_source'] = 'boatbeaconapp'; |
|
632 | + $data['id_source'] = $id_source; |
|
633 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
634 | + $MI->add($data); |
|
635 | + unset($data); |
|
636 | + } |
|
636 | 637 | } |
637 | - } |
|
638 | 638 | } |
639 | 639 | |
640 | - } |
|
641 | - $last_exec[$id]['last'] = time(); |
|
640 | + } |
|
641 | + $last_exec[$id]['last'] = time(); |
|
642 | 642 | } elseif ($value['format'] == 'boatnerd' && |
643 | - ( |
|
643 | + ( |
|
644 | 644 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
645 | 645 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
646 | - ) |
|
646 | + ) |
|
647 | 647 | ) { |
648 | - $buffer = $Common->getData($value['host']); |
|
649 | - if ($buffer != '') { |
|
648 | + $buffer = $Common->getData($value['host']); |
|
649 | + if ($buffer != '') { |
|
650 | 650 | $all_data = json_decode($buffer,true); |
651 | 651 | if (isset($all_data['features'][0]['id'])) { |
652 | - foreach ($all_data['features'] as $line) { |
|
652 | + foreach ($all_data['features'] as $line) { |
|
653 | 653 | print_r($line); |
654 | 654 | $data = array(); |
655 | 655 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
@@ -669,80 +669,80 @@ discard block |
||
669 | 669 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
670 | 670 | if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
671 | 671 | unset($data); |
672 | - } |
|
672 | + } |
|
673 | 673 | } |
674 | 674 | |
675 | - } |
|
676 | - $last_exec[$id]['last'] = time(); |
|
675 | + } |
|
676 | + $last_exec[$id]['last'] = time(); |
|
677 | 677 | } elseif ($value['format'] == 'shipplotter' && |
678 | - ( |
|
678 | + ( |
|
679 | 679 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
680 | 680 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
681 | - ) |
|
681 | + ) |
|
682 | 682 | ) { |
683 | - echo 'download...'; |
|
684 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
685 | - echo 'done !'."\n"; |
|
686 | - // FIXME: Need more work |
|
687 | - if ($buffer != '') $reset = 0; |
|
688 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
689 | - $buffer = explode('\n',$buffer); |
|
690 | - foreach ($buffer as $line) { |
|
683 | + echo 'download...'; |
|
684 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
685 | + echo 'done !'."\n"; |
|
686 | + // FIXME: Need more work |
|
687 | + if ($buffer != '') $reset = 0; |
|
688 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
689 | + $buffer = explode('\n',$buffer); |
|
690 | + foreach ($buffer as $line) { |
|
691 | 691 | if ($line != '') { |
692 | - $data = array(); |
|
693 | - echo $line."\n"; |
|
694 | - $data['mmsi'] = (int)substr($line,0,9); |
|
695 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
696 | - $data['status_id'] = substr($line,21,2); |
|
697 | - $data['type_id'] = substr($line,24,3); |
|
698 | - $data['latitude'] = substr($line,29,9); |
|
699 | - $data['longitude'] = substr($line,41,9); |
|
700 | - $data['speed'] = round(substr($line,51,5)); |
|
701 | - //$data['course'] = substr($line,57,5); |
|
702 | - $data['heading'] = round(substr($line,63,3)); |
|
703 | - //$data['draft'] = substr($line,67,4); |
|
704 | - //$data['length'] = substr($line,72,3); |
|
705 | - //$data['beam'] = substr($line,76,2); |
|
706 | - $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
707 | - //$data['callsign'] = trim(substr($line,100,7); |
|
708 | - $data['arrival_code'] = substr($line,108,20); |
|
709 | - //$data['etaDate'] = substr($line,129,5); |
|
710 | - //$data['etaTime'] = substr($line,135,5); |
|
711 | - $data['format_source'] = 'shipplotter'; |
|
712 | - $data['id_source'] = $id_source; |
|
713 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
714 | - //print_r($data); |
|
715 | - echo 'Add...'."\n"; |
|
716 | - $MI->add($data); |
|
717 | - unset($data); |
|
692 | + $data = array(); |
|
693 | + echo $line."\n"; |
|
694 | + $data['mmsi'] = (int)substr($line,0,9); |
|
695 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
696 | + $data['status_id'] = substr($line,21,2); |
|
697 | + $data['type_id'] = substr($line,24,3); |
|
698 | + $data['latitude'] = substr($line,29,9); |
|
699 | + $data['longitude'] = substr($line,41,9); |
|
700 | + $data['speed'] = round(substr($line,51,5)); |
|
701 | + //$data['course'] = substr($line,57,5); |
|
702 | + $data['heading'] = round(substr($line,63,3)); |
|
703 | + //$data['draft'] = substr($line,67,4); |
|
704 | + //$data['length'] = substr($line,72,3); |
|
705 | + //$data['beam'] = substr($line,76,2); |
|
706 | + $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
707 | + //$data['callsign'] = trim(substr($line,100,7); |
|
708 | + $data['arrival_code'] = substr($line,108,20); |
|
709 | + //$data['etaDate'] = substr($line,129,5); |
|
710 | + //$data['etaTime'] = substr($line,135,5); |
|
711 | + $data['format_source'] = 'shipplotter'; |
|
712 | + $data['id_source'] = $id_source; |
|
713 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
714 | + //print_r($data); |
|
715 | + echo 'Add...'."\n"; |
|
716 | + $MI->add($data); |
|
717 | + unset($data); |
|
718 | 718 | } |
719 | - } |
|
720 | - $last_exec[$id]['last'] = time(); |
|
719 | + } |
|
720 | + $last_exec[$id]['last'] = time(); |
|
721 | 721 | //} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
722 | 722 | } elseif ( |
723 | - ( |
|
723 | + ( |
|
724 | 724 | $value['format'] == 'whazzup' && |
725 | 725 | ( |
726 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
727 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
726 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
727 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
728 | 728 | ) |
729 | - ) || ( |
|
729 | + ) || ( |
|
730 | 730 | $value['format'] == 'vatsimtxt' && |
731 | 731 | ( |
732 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
733 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
732 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
733 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
734 | + ) |
|
734 | 735 | ) |
735 | - ) |
|
736 | 736 | ) { |
737 | - //$buffer = $Common->getData($hosts[$id]); |
|
738 | - $buffer = $Common->getData($value['host']); |
|
739 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
740 | - $buffer = explode('\n',$buffer); |
|
741 | - $reset = 0; |
|
742 | - foreach ($buffer as $line) { |
|
743 | - if ($line != '') { |
|
744 | - $line = explode(':', $line); |
|
745 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
737 | + //$buffer = $Common->getData($hosts[$id]); |
|
738 | + $buffer = $Common->getData($value['host']); |
|
739 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
740 | + $buffer = explode('\n',$buffer); |
|
741 | + $reset = 0; |
|
742 | + foreach ($buffer as $line) { |
|
743 | + if ($line != '') { |
|
744 | + $line = explode(':', $line); |
|
745 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
746 | 746 | $data = array(); |
747 | 747 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
748 | 748 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -755,37 +755,37 @@ discard block |
||
755 | 755 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
756 | 756 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
757 | 757 | $data['latitude'] = $line[5]; // lat |
758 | - $data['longitude'] = $line[6]; // long |
|
759 | - $data['verticalrate'] = ''; // vertical rate |
|
760 | - $data['squawk'] = ''; // squawk |
|
761 | - $data['emergency'] = ''; // emergency |
|
762 | - $data['waypoints'] = $line[30]; |
|
758 | + $data['longitude'] = $line[6]; // long |
|
759 | + $data['verticalrate'] = ''; // vertical rate |
|
760 | + $data['squawk'] = ''; // squawk |
|
761 | + $data['emergency'] = ''; // emergency |
|
762 | + $data['waypoints'] = $line[30]; |
|
763 | 763 | $data['datetime'] = date('Y-m-d H:i:s'); |
764 | 764 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
765 | 765 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
766 | - $data['departure_airport_icao'] = $line[11]; |
|
767 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
768 | - $data['arrival_airport_icao'] = $line[13]; |
|
766 | + $data['departure_airport_icao'] = $line[11]; |
|
767 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
768 | + $data['arrival_airport_icao'] = $line[13]; |
|
769 | 769 | $data['frequency'] = $line[4]; |
770 | 770 | $data['type'] = $line[18]; |
771 | 771 | $data['range'] = $line[19]; |
772 | 772 | if (isset($line[35])) $data['info'] = $line[35]; |
773 | - $data['id_source'] = $id_source; |
|
774 | - //$data['arrival_airport_time'] = ; |
|
775 | - if ($line[9] != '') { |
|
776 | - $aircraft_data = explode('/',$line[9]); |
|
777 | - if (isset($aircraft_data[1])) { |
|
778 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
779 | - } |
|
780 | - } |
|
781 | - /* |
|
773 | + $data['id_source'] = $id_source; |
|
774 | + //$data['arrival_airport_time'] = ; |
|
775 | + if ($line[9] != '') { |
|
776 | + $aircraft_data = explode('/',$line[9]); |
|
777 | + if (isset($aircraft_data[1])) { |
|
778 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
779 | + } |
|
780 | + } |
|
781 | + /* |
|
782 | 782 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; |
783 | 783 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
784 | 784 | */ |
785 | - $data['format_source'] = $value['format']; |
|
785 | + $data['format_source'] = $value['format']; |
|
786 | 786 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
787 | 787 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
788 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
788 | + if ($line[3] == 'PILOT') $SI->add($data); |
|
789 | 789 | elseif ($line[3] == 'ATC') { |
790 | 790 | //print_r($data); |
791 | 791 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -806,21 +806,21 @@ discard block |
||
806 | 806 | else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
807 | 807 | } |
808 | 808 | } |
809 | - unset($data); |
|
810 | - } |
|
811 | - } |
|
812 | - } |
|
813 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
814 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
815 | - $last_exec[$id]['last'] = time(); |
|
816 | - } elseif ($value['format'] == 'airwhere' && |
|
817 | - ( |
|
818 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
819 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
820 | - ) |
|
821 | - ) { |
|
822 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
823 | - if ($buffer != '') { |
|
809 | + unset($data); |
|
810 | + } |
|
811 | + } |
|
812 | + } |
|
813 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
814 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
815 | + $last_exec[$id]['last'] = time(); |
|
816 | + } elseif ($value['format'] == 'airwhere' && |
|
817 | + ( |
|
818 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
819 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
820 | + ) |
|
821 | + ) { |
|
822 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
823 | + if ($buffer != '') { |
|
824 | 824 | $all_data = simplexml_load_string($buffer); |
825 | 825 | foreach($all_data->children() as $childdata) { |
826 | 826 | $data = array(); |
@@ -842,10 +842,10 @@ discard block |
||
842 | 842 | $SI->add($data); |
843 | 843 | unset($data); |
844 | 844 | } |
845 | - } |
|
846 | - $Source->deleteOldLocationByType('gs'); |
|
847 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
848 | - if ($buffer != '') { |
|
845 | + } |
|
846 | + $Source->deleteOldLocationByType('gs'); |
|
847 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
848 | + if ($buffer != '') { |
|
849 | 849 | $all_data = simplexml_load_string($buffer); |
850 | 850 | foreach($all_data->children() as $childdata) { |
851 | 851 | $data = array(); |
@@ -863,8 +863,8 @@ discard block |
||
863 | 863 | } |
864 | 864 | unset($data); |
865 | 865 | } |
866 | - } |
|
867 | - $last_exec[$id]['last'] = time(); |
|
866 | + } |
|
867 | + $last_exec[$id]['last'] = time(); |
|
868 | 868 | /* |
869 | 869 | } if ($value['format'] == 'aircraftlistjson') { |
870 | 870 | print_r($globalSources); |
@@ -872,17 +872,17 @@ discard block |
||
872 | 872 | echo $globalMinFetch; |
873 | 873 | */ |
874 | 874 | } elseif ($value['format'] == 'aircraftlistjson' && |
875 | - ( |
|
875 | + ( |
|
876 | 876 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
877 | 877 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
878 | - ) |
|
878 | + ) |
|
879 | 879 | ) { |
880 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
881 | - if ($buffer != '') { |
|
882 | - $all_data = json_decode($buffer,true); |
|
880 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
881 | + if ($buffer != '') { |
|
882 | + $all_data = json_decode($buffer,true); |
|
883 | 883 | if (isset($all_data['acList'])) { |
884 | - $reset = 0; |
|
885 | - foreach ($all_data['acList'] as $line) { |
|
884 | + $reset = 0; |
|
885 | + foreach ($all_data['acList'] as $line) { |
|
886 | 886 | $data = array(); |
887 | 887 | $data['hex'] = $line['Icao']; // hex |
888 | 888 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -905,10 +905,10 @@ discard block |
||
905 | 905 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
906 | 906 | if (isset($data['latitude'])) $SI->add($data); |
907 | 907 | unset($data); |
908 | - } |
|
908 | + } |
|
909 | 909 | } elseif (is_array($all_data)) { |
910 | - $reset = 0; |
|
911 | - foreach ($all_data as $line) { |
|
910 | + $reset = 0; |
|
911 | + foreach ($all_data as $line) { |
|
912 | 912 | $data = array(); |
913 | 913 | $data['hex'] = $line['hex']; // hex |
914 | 914 | $data['ident'] = $line['flight']; // ident |
@@ -928,218 +928,218 @@ discard block |
||
928 | 928 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
929 | 929 | $SI->add($data); |
930 | 930 | unset($data); |
931 | - } |
|
931 | + } |
|
932 | 932 | } |
933 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
934 | - //$last_exec['aircraftlistjson'] = time(); |
|
935 | - $last_exec[$id]['last'] = time(); |
|
936 | - //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
937 | - } elseif ($value['format'] == 'planeupdatefaa' && |
|
938 | - ( |
|
939 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
940 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
941 | - ) |
|
942 | - ) { |
|
943 | - $buffer = $Common->getData($value['host']); |
|
944 | - $all_data = json_decode($buffer,true); |
|
945 | - if (isset($all_data['planes'])) { |
|
933 | + } elseif ($globalDebug) echo 'No data'."\n"; |
|
934 | + //$last_exec['aircraftlistjson'] = time(); |
|
935 | + $last_exec[$id]['last'] = time(); |
|
936 | + //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
937 | + } elseif ($value['format'] == 'planeupdatefaa' && |
|
938 | + ( |
|
939 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
940 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
941 | + ) |
|
942 | + ) { |
|
943 | + $buffer = $Common->getData($value['host']); |
|
944 | + $all_data = json_decode($buffer,true); |
|
945 | + if (isset($all_data['planes'])) { |
|
946 | 946 | $reset = 0; |
947 | 947 | foreach ($all_data['planes'] as $key => $line) { |
948 | - $data = array(); |
|
949 | - $data['hex'] = $key; // hex |
|
950 | - $data['ident'] = $line[3]; // ident |
|
951 | - $data['altitude'] = $line[6]; // altitude |
|
952 | - $data['speed'] = $line[8]; // speed |
|
953 | - $data['heading'] = $line[7]; // heading |
|
954 | - $data['latitude'] = $line[4]; // lat |
|
955 | - $data['longitude'] = $line[5]; // long |
|
956 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
957 | - $data['squawk'] = $line[10]; // squawk |
|
958 | - $data['emergency'] = ''; // emergency |
|
959 | - $data['registration'] = $line[2]; |
|
960 | - $data['aircraft_icao'] = $line[0]; |
|
961 | - $deparr = explode('-',$line[1]); |
|
962 | - if (count($deparr) == 2) { |
|
948 | + $data = array(); |
|
949 | + $data['hex'] = $key; // hex |
|
950 | + $data['ident'] = $line[3]; // ident |
|
951 | + $data['altitude'] = $line[6]; // altitude |
|
952 | + $data['speed'] = $line[8]; // speed |
|
953 | + $data['heading'] = $line[7]; // heading |
|
954 | + $data['latitude'] = $line[4]; // lat |
|
955 | + $data['longitude'] = $line[5]; // long |
|
956 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
957 | + $data['squawk'] = $line[10]; // squawk |
|
958 | + $data['emergency'] = ''; // emergency |
|
959 | + $data['registration'] = $line[2]; |
|
960 | + $data['aircraft_icao'] = $line[0]; |
|
961 | + $deparr = explode('-',$line[1]); |
|
962 | + if (count($deparr) == 2) { |
|
963 | 963 | $data['departure_airport_icao'] = $deparr[0]; |
964 | 964 | $data['arrival_airport_icao'] = $deparr[1]; |
965 | - } |
|
966 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
967 | - $data['format_source'] = 'planeupdatefaa'; |
|
968 | - $data['id_source'] = $id_source; |
|
969 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
970 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
971 | - $SI->add($data); |
|
972 | - unset($data); |
|
965 | + } |
|
966 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
967 | + $data['format_source'] = 'planeupdatefaa'; |
|
968 | + $data['id_source'] = $id_source; |
|
969 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
970 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
971 | + $SI->add($data); |
|
972 | + unset($data); |
|
973 | + } |
|
973 | 974 | } |
974 | - } |
|
975 | - //$last_exec['planeupdatefaa'] = time(); |
|
976 | - $last_exec[$id]['last'] = time(); |
|
975 | + //$last_exec['planeupdatefaa'] = time(); |
|
976 | + $last_exec[$id]['last'] = time(); |
|
977 | 977 | } elseif ($value['format'] == 'opensky' && |
978 | - ( |
|
978 | + ( |
|
979 | 979 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
980 | 980 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
981 | - ) |
|
981 | + ) |
|
982 | 982 | ) { |
983 | - $buffer = $Common->getData($value['host']); |
|
984 | - $all_data = json_decode($buffer,true); |
|
985 | - if (isset($all_data['states'])) { |
|
983 | + $buffer = $Common->getData($value['host']); |
|
984 | + $all_data = json_decode($buffer,true); |
|
985 | + if (isset($all_data['states'])) { |
|
986 | 986 | $reset = 0; |
987 | 987 | foreach ($all_data['states'] as $key => $line) { |
988 | - $data = array(); |
|
989 | - $data['hex'] = $line[0]; // hex |
|
990 | - $data['ident'] = trim($line[1]); // ident |
|
991 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
992 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
993 | - $data['heading'] = round($line[10]); // heading |
|
994 | - $data['latitude'] = $line[6]; // lat |
|
995 | - $data['longitude'] = $line[5]; // long |
|
996 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
997 | - //$data['squawk'] = $line[10]; // squawk |
|
998 | - //$data['emergency'] = ''; // emergency |
|
999 | - //$data['registration'] = $line[2]; |
|
1000 | - //$data['aircraft_icao'] = $line[0]; |
|
1001 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
1002 | - $data['format_source'] = 'opensky'; |
|
1003 | - $data['id_source'] = $id_source; |
|
1004 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1005 | - $SI->add($data); |
|
1006 | - unset($data); |
|
988 | + $data = array(); |
|
989 | + $data['hex'] = $line[0]; // hex |
|
990 | + $data['ident'] = trim($line[1]); // ident |
|
991 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
992 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
993 | + $data['heading'] = round($line[10]); // heading |
|
994 | + $data['latitude'] = $line[6]; // lat |
|
995 | + $data['longitude'] = $line[5]; // long |
|
996 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
997 | + //$data['squawk'] = $line[10]; // squawk |
|
998 | + //$data['emergency'] = ''; // emergency |
|
999 | + //$data['registration'] = $line[2]; |
|
1000 | + //$data['aircraft_icao'] = $line[0]; |
|
1001 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
1002 | + $data['format_source'] = 'opensky'; |
|
1003 | + $data['id_source'] = $id_source; |
|
1004 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1005 | + $SI->add($data); |
|
1006 | + unset($data); |
|
1007 | + } |
|
1007 | 1008 | } |
1008 | - } |
|
1009 | - //$last_exec['planeupdatefaa'] = time(); |
|
1010 | - $last_exec[$id]['last'] = time(); |
|
1009 | + //$last_exec['planeupdatefaa'] = time(); |
|
1010 | + $last_exec[$id]['last'] = time(); |
|
1011 | 1011 | //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
1012 | 1012 | } elseif ($value['format'] == 'fr24json' && |
1013 | - ( |
|
1013 | + ( |
|
1014 | 1014 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1015 | 1015 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1016 | - ) |
|
1016 | + ) |
|
1017 | 1017 | ) { |
1018 | - //$buffer = $Common->getData($hosts[$id]); |
|
1019 | - $buffer = $Common->getData($value['host']); |
|
1020 | - $all_data = json_decode($buffer,true); |
|
1021 | - if (!empty($all_data)) $reset = 0; |
|
1022 | - foreach ($all_data as $key => $line) { |
|
1018 | + //$buffer = $Common->getData($hosts[$id]); |
|
1019 | + $buffer = $Common->getData($value['host']); |
|
1020 | + $all_data = json_decode($buffer,true); |
|
1021 | + if (!empty($all_data)) $reset = 0; |
|
1022 | + foreach ($all_data as $key => $line) { |
|
1023 | 1023 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
1024 | - $data = array(); |
|
1025 | - $data['hex'] = $line[0]; |
|
1026 | - $data['ident'] = $line[16]; //$line[13] |
|
1027 | - $data['altitude'] = $line[4]; // altitude |
|
1028 | - $data['speed'] = $line[5]; // speed |
|
1029 | - $data['heading'] = $line[3]; // heading |
|
1030 | - $data['latitude'] = $line[1]; // lat |
|
1031 | - $data['longitude'] = $line[2]; // long |
|
1032 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
1033 | - $data['squawk'] = $line[6]; // squawk |
|
1034 | - $data['aircraft_icao'] = $line[8]; |
|
1035 | - $data['registration'] = $line[9]; |
|
1036 | - $data['departure_airport_iata'] = $line[11]; |
|
1037 | - $data['arrival_airport_iata'] = $line[12]; |
|
1038 | - $data['emergency'] = ''; // emergency |
|
1039 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
1040 | - $data['format_source'] = 'fr24json'; |
|
1041 | - $data['id_source'] = $id_source; |
|
1042 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1043 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1044 | - $SI->add($data); |
|
1045 | - unset($data); |
|
1024 | + $data = array(); |
|
1025 | + $data['hex'] = $line[0]; |
|
1026 | + $data['ident'] = $line[16]; //$line[13] |
|
1027 | + $data['altitude'] = $line[4]; // altitude |
|
1028 | + $data['speed'] = $line[5]; // speed |
|
1029 | + $data['heading'] = $line[3]; // heading |
|
1030 | + $data['latitude'] = $line[1]; // lat |
|
1031 | + $data['longitude'] = $line[2]; // long |
|
1032 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
1033 | + $data['squawk'] = $line[6]; // squawk |
|
1034 | + $data['aircraft_icao'] = $line[8]; |
|
1035 | + $data['registration'] = $line[9]; |
|
1036 | + $data['departure_airport_iata'] = $line[11]; |
|
1037 | + $data['arrival_airport_iata'] = $line[12]; |
|
1038 | + $data['emergency'] = ''; // emergency |
|
1039 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
1040 | + $data['format_source'] = 'fr24json'; |
|
1041 | + $data['id_source'] = $id_source; |
|
1042 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1043 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1044 | + $SI->add($data); |
|
1045 | + unset($data); |
|
1046 | 1046 | } |
1047 | - } |
|
1048 | - //$last_exec['fr24json'] = time(); |
|
1049 | - $last_exec[$id]['last'] = time(); |
|
1047 | + } |
|
1048 | + //$last_exec['fr24json'] = time(); |
|
1049 | + $last_exec[$id]['last'] = time(); |
|
1050 | 1050 | //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
1051 | 1051 | } elseif ($value['format'] == 'radarvirtueljson' && |
1052 | - ( |
|
1052 | + ( |
|
1053 | 1053 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1054 | 1054 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1055 | - ) |
|
1055 | + ) |
|
1056 | 1056 | ) { |
1057 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
1058 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1059 | - //echo $buffer; |
|
1060 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1061 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1062 | - $all_data = json_decode($buffer,true); |
|
1063 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
1057 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
1058 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1059 | + //echo $buffer; |
|
1060 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1061 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1062 | + $all_data = json_decode($buffer,true); |
|
1063 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
1064 | 1064 | die(json_last_error_msg()); |
1065 | - } |
|
1066 | - if (isset($all_data['mrkrs'])) { |
|
1065 | + } |
|
1066 | + if (isset($all_data['mrkrs'])) { |
|
1067 | 1067 | $reset = 0; |
1068 | 1068 | foreach ($all_data['mrkrs'] as $key => $line) { |
1069 | - if (isset($line['inf'])) { |
|
1069 | + if (isset($line['inf'])) { |
|
1070 | 1070 | $data = array(); |
1071 | 1071 | $data['hex'] = $line['inf']['ia']; |
1072 | 1072 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
1073 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
1074 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1075 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1076 | - $data['latitude'] = $line['pt'][0]; // lat |
|
1077 | - $data['longitude'] = $line['pt'][1]; // long |
|
1078 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
1079 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1080 | - //$data['aircraft_icao'] = $line[8]; |
|
1081 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1073 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
1074 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1075 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1076 | + $data['latitude'] = $line['pt'][0]; // lat |
|
1077 | + $data['longitude'] = $line['pt'][1]; // long |
|
1078 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
1079 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1080 | + //$data['aircraft_icao'] = $line[8]; |
|
1081 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1082 | 1082 | //$data['departure_airport_iata'] = $line[11]; |
1083 | 1083 | //$data['arrival_airport_iata'] = $line[12]; |
1084 | - //$data['emergency'] = ''; // emergency |
|
1084 | + //$data['emergency'] = ''; // emergency |
|
1085 | 1085 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
1086 | - $data['format_source'] = 'radarvirtueljson'; |
|
1087 | - $data['id_source'] = $id_source; |
|
1086 | + $data['format_source'] = 'radarvirtueljson'; |
|
1087 | + $data['id_source'] = $id_source; |
|
1088 | 1088 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
1089 | 1089 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1090 | 1090 | $SI->add($data); |
1091 | 1091 | unset($data); |
1092 | - } |
|
1092 | + } |
|
1093 | 1093 | } |
1094 | - } |
|
1095 | - //$last_exec['radarvirtueljson'] = time(); |
|
1096 | - $last_exec[$id]['last'] = time(); |
|
1094 | + } |
|
1095 | + //$last_exec['radarvirtueljson'] = time(); |
|
1096 | + $last_exec[$id]['last'] = time(); |
|
1097 | 1097 | //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
1098 | 1098 | } elseif ($value['format'] == 'pirepsjson' && |
1099 | - ( |
|
1099 | + ( |
|
1100 | 1100 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1101 | 1101 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1102 | - ) |
|
1102 | + ) |
|
1103 | 1103 | ) { |
1104 | - //$buffer = $Common->getData($hosts[$id]); |
|
1105 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
1106 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
1104 | + //$buffer = $Common->getData($hosts[$id]); |
|
1105 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
1106 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
1107 | 1107 | |
1108 | - if (isset($all_data['pireps'])) { |
|
1108 | + if (isset($all_data['pireps'])) { |
|
1109 | 1109 | $reset = 0; |
1110 | - foreach ($all_data['pireps'] as $line) { |
|
1111 | - $data = array(); |
|
1112 | - $data['id'] = $line['id']; |
|
1113 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1114 | - $data['ident'] = $line['callsign']; // ident |
|
1115 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1116 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1117 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1118 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1119 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1120 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1121 | - $data['latitude'] = $line['lat']; // lat |
|
1122 | - $data['longitude'] = $line['lon']; // long |
|
1123 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
1124 | - //$data['squawk'] = $line['squawk']; // squawk |
|
1125 | - //$data['emergency'] = ''; // emergency |
|
1126 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1127 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1128 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1129 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
1130 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1131 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1132 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1133 | - else $data['info'] = ''; |
|
1134 | - $data['format_source'] = 'pireps'; |
|
1135 | - $data['id_source'] = $id_source; |
|
1136 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1137 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1138 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1139 | - if ($line['icon'] == 'plane') { |
|
1110 | + foreach ($all_data['pireps'] as $line) { |
|
1111 | + $data = array(); |
|
1112 | + $data['id'] = $line['id']; |
|
1113 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1114 | + $data['ident'] = $line['callsign']; // ident |
|
1115 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1116 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1117 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1118 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1119 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1120 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1121 | + $data['latitude'] = $line['lat']; // lat |
|
1122 | + $data['longitude'] = $line['lon']; // long |
|
1123 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
1124 | + //$data['squawk'] = $line['squawk']; // squawk |
|
1125 | + //$data['emergency'] = ''; // emergency |
|
1126 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1127 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1128 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1129 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
1130 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1131 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1132 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1133 | + else $data['info'] = ''; |
|
1134 | + $data['format_source'] = 'pireps'; |
|
1135 | + $data['id_source'] = $id_source; |
|
1136 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1137 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1138 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1139 | + if ($line['icon'] == 'plane') { |
|
1140 | 1140 | $SI->add($data); |
1141 | - // print_r($data); |
|
1142 | - } elseif ($line['icon'] == 'ct') { |
|
1141 | + // print_r($data); |
|
1142 | + } elseif ($line['icon'] == 'ct') { |
|
1143 | 1143 | $data['info'] = str_replace('^§','<br />',$data['info']); |
1144 | 1144 | $data['info'] = str_replace('&sect;','',$data['info']); |
1145 | 1145 | $typec = substr($data['ident'],-3); |
@@ -1154,209 +1154,209 @@ discard block |
||
1154 | 1154 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
1155 | 1155 | else $data['type'] = 'Observer'; |
1156 | 1156 | if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
1157 | - } |
|
1158 | - unset($data); |
|
1157 | + } |
|
1158 | + unset($data); |
|
1159 | + } |
|
1159 | 1160 | } |
1160 | - } |
|
1161 | - //$last_exec['pirepsjson'] = time(); |
|
1162 | - $last_exec[$id]['last'] = time(); |
|
1161 | + //$last_exec['pirepsjson'] = time(); |
|
1162 | + $last_exec[$id]['last'] = time(); |
|
1163 | 1163 | //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
1164 | 1164 | } elseif ($value['format'] == 'phpvmacars' && |
1165 | - ( |
|
1165 | + ( |
|
1166 | 1166 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1167 | 1167 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1168 | - ) |
|
1168 | + ) |
|
1169 | 1169 | ) { |
1170 | - //$buffer = $Common->getData($hosts[$id]); |
|
1171 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1172 | - $buffer = $Common->getData($value['host']); |
|
1173 | - $all_data = json_decode($buffer,true); |
|
1174 | - if ($buffer != '' && is_array($all_data)) { |
|
1170 | + //$buffer = $Common->getData($hosts[$id]); |
|
1171 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1172 | + $buffer = $Common->getData($value['host']); |
|
1173 | + $all_data = json_decode($buffer,true); |
|
1174 | + if ($buffer != '' && is_array($all_data)) { |
|
1175 | 1175 | $reset = 0; |
1176 | 1176 | foreach ($all_data as $line) { |
1177 | - $data = array(); |
|
1178 | - //$data['id'] = $line['id']; // id not usable |
|
1179 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1180 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1181 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1182 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1183 | - $data['ident'] = $line['flightnum']; // ident |
|
1184 | - $data['altitude'] = $line['alt']; // altitude |
|
1185 | - $data['speed'] = $line['gs']; // speed |
|
1186 | - $data['heading'] = $line['heading']; // heading |
|
1187 | - $data['latitude'] = $line['lat']; // lat |
|
1188 | - $data['longitude'] = $line['lng']; // long |
|
1189 | - $data['verticalrate'] = ''; // verticale rate |
|
1190 | - $data['squawk'] = ''; // squawk |
|
1191 | - $data['emergency'] = ''; // emergency |
|
1192 | - //$data['datetime'] = $line['lastupdate']; |
|
1193 | - //$data['last_update'] = $line['lastupdate']; |
|
1194 | - if (isset($value['timezone'])) { |
|
1195 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1196 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1197 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1198 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1199 | - $data['departure_airport_icao'] = $line['depicao']; |
|
1200 | - $data['departure_airport_time'] = $line['deptime']; |
|
1201 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
1202 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
1203 | - if (isset($line['registration'])) { |
|
1204 | - $data['registration'] = $line['registration']; |
|
1205 | - //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
|
1206 | - } else $data['registration'] = $line['aircraft']; |
|
1207 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1208 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1209 | - if (isset($line['aircraftname'])) { |
|
1177 | + $data = array(); |
|
1178 | + //$data['id'] = $line['id']; // id not usable |
|
1179 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1180 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1181 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1182 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1183 | + $data['ident'] = $line['flightnum']; // ident |
|
1184 | + $data['altitude'] = $line['alt']; // altitude |
|
1185 | + $data['speed'] = $line['gs']; // speed |
|
1186 | + $data['heading'] = $line['heading']; // heading |
|
1187 | + $data['latitude'] = $line['lat']; // lat |
|
1188 | + $data['longitude'] = $line['lng']; // long |
|
1189 | + $data['verticalrate'] = ''; // verticale rate |
|
1190 | + $data['squawk'] = ''; // squawk |
|
1191 | + $data['emergency'] = ''; // emergency |
|
1192 | + //$data['datetime'] = $line['lastupdate']; |
|
1193 | + //$data['last_update'] = $line['lastupdate']; |
|
1194 | + if (isset($value['timezone'])) { |
|
1195 | + $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1196 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1197 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1198 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1199 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1200 | + $data['departure_airport_time'] = $line['deptime']; |
|
1201 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1202 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
1203 | + if (isset($line['registration'])) { |
|
1204 | + $data['registration'] = $line['registration']; |
|
1205 | + //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
|
1206 | + } else $data['registration'] = $line['aircraft']; |
|
1207 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1208 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1209 | + if (isset($line['aircraftname'])) { |
|
1210 | 1210 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1211 | 1211 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1212 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1213 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1214 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1215 | - else { |
|
1216 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1217 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1218 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1219 | - } |
|
1220 | - } |
|
1221 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1222 | - $data['id_source'] = $id_source; |
|
1223 | - $data['format_source'] = 'phpvmacars'; |
|
1224 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1225 | - $SI->add($data); |
|
1226 | - unset($data); |
|
1212 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
1213 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1214 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1215 | + else { |
|
1216 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
1217 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1218 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1219 | + } |
|
1220 | + } |
|
1221 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1222 | + $data['id_source'] = $id_source; |
|
1223 | + $data['format_source'] = 'phpvmacars'; |
|
1224 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1225 | + $SI->add($data); |
|
1226 | + unset($data); |
|
1227 | 1227 | } |
1228 | 1228 | if ($globalDebug) echo 'No more data...'."\n"; |
1229 | 1229 | unset($buffer); |
1230 | 1230 | unset($all_data); |
1231 | - } |
|
1232 | - //$last_exec['phpvmacars'] = time(); |
|
1233 | - $last_exec[$id]['last'] = time(); |
|
1231 | + } |
|
1232 | + //$last_exec['phpvmacars'] = time(); |
|
1233 | + $last_exec[$id]['last'] = time(); |
|
1234 | 1234 | } elseif ($value['format'] == 'vaos' && |
1235 | - ( |
|
1235 | + ( |
|
1236 | 1236 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1237 | 1237 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1238 | - ) |
|
1238 | + ) |
|
1239 | 1239 | ) { |
1240 | - //$buffer = $Common->getData($hosts[$id]); |
|
1241 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1242 | - $buffer = $Common->getData($value['host']); |
|
1243 | - $all_data = json_decode($buffer,true); |
|
1244 | - if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
|
1240 | + //$buffer = $Common->getData($hosts[$id]); |
|
1241 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1242 | + $buffer = $Common->getData($value['host']); |
|
1243 | + $all_data = json_decode($buffer,true); |
|
1244 | + if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
|
1245 | 1245 | $reset = 0; |
1246 | 1246 | foreach ($all_data['ACARSData'] as $line) { |
1247 | - //print_r($line); |
|
1248 | - $data = array(); |
|
1249 | - //$data['id'] = $line['id']; // id not usable |
|
1250 | - $data['id'] = $line['id']; |
|
1251 | - //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1252 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
1253 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
1254 | - $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
1255 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1256 | - $data['altitude'] = $line['altitude']; // altitude |
|
1257 | - $data['speed'] = $line['groundspeed']; // speed |
|
1258 | - $data['heading'] = $line['heading']; // heading |
|
1259 | - $data['latitude'] = $line['lat']; // lat |
|
1260 | - $data['longitude'] = $line['lon']; // long |
|
1261 | - //$data['verticalrate'] = ''; // verticale rate |
|
1262 | - //$data['squawk'] = ''; // squawk |
|
1263 | - //$data['emergency'] = ''; // emergency |
|
1264 | - if (isset($value['timezone'])) { |
|
1265 | - $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
1266 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1267 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1268 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1247 | + //print_r($line); |
|
1248 | + $data = array(); |
|
1249 | + //$data['id'] = $line['id']; // id not usable |
|
1250 | + $data['id'] = $line['id']; |
|
1251 | + //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1252 | + if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
1253 | + if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
1254 | + $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
1255 | + if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1256 | + $data['altitude'] = $line['altitude']; // altitude |
|
1257 | + $data['speed'] = $line['groundspeed']; // speed |
|
1258 | + $data['heading'] = $line['heading']; // heading |
|
1259 | + $data['latitude'] = $line['lat']; // lat |
|
1260 | + $data['longitude'] = $line['lon']; // long |
|
1261 | + //$data['verticalrate'] = ''; // verticale rate |
|
1262 | + //$data['squawk'] = ''; // squawk |
|
1263 | + //$data['emergency'] = ''; // emergency |
|
1264 | + if (isset($value['timezone'])) { |
|
1265 | + $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
1266 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1267 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1268 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1269 | 1269 | |
1270 | - $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
|
1271 | - $data['departure_airport_time'] = $line['bid']['deptime']; |
|
1272 | - $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao']; |
|
1273 | - $data['arrival_airport_time'] = $line['bid']['arrtime']; |
|
1274 | - $data['registration'] = $line['bid']['aircraft']['registration']; |
|
1270 | + $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
|
1271 | + $data['departure_airport_time'] = $line['bid']['deptime']; |
|
1272 | + $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao']; |
|
1273 | + $data['arrival_airport_time'] = $line['bid']['arrtime']; |
|
1274 | + $data['registration'] = $line['bid']['aircraft']['registration']; |
|
1275 | 1275 | |
1276 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1277 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
1278 | - $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
|
1276 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1277 | + if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
1278 | + $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
|
1279 | 1279 | |
1280 | - $data['id_source'] = $id_source; |
|
1281 | - $data['format_source'] = 'vaos'; |
|
1282 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1283 | - $SI->add($data); |
|
1284 | - unset($data); |
|
1280 | + $data['id_source'] = $id_source; |
|
1281 | + $data['format_source'] = 'vaos'; |
|
1282 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1283 | + $SI->add($data); |
|
1284 | + unset($data); |
|
1285 | 1285 | } |
1286 | 1286 | if ($globalDebug) echo 'No more data...'."\n"; |
1287 | 1287 | unset($buffer); |
1288 | 1288 | unset($all_data); |
1289 | - } |
|
1290 | - //$last_exec['phpvmacars'] = time(); |
|
1291 | - $last_exec[$id]['last'] = time(); |
|
1289 | + } |
|
1290 | + //$last_exec['phpvmacars'] = time(); |
|
1291 | + $last_exec[$id]['last'] = time(); |
|
1292 | 1292 | } elseif ($value['format'] == 'vam' && |
1293 | - ( |
|
1293 | + ( |
|
1294 | 1294 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1295 | 1295 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1296 | - ) |
|
1296 | + ) |
|
1297 | 1297 | ) { |
1298 | - //$buffer = $Common->getData($hosts[$id]); |
|
1299 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1300 | - $buffer = $Common->getData($value['host']); |
|
1301 | - $all_data = json_decode($buffer,true); |
|
1302 | - if ($buffer != '' && is_array($all_data)) { |
|
1298 | + //$buffer = $Common->getData($hosts[$id]); |
|
1299 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1300 | + $buffer = $Common->getData($value['host']); |
|
1301 | + $all_data = json_decode($buffer,true); |
|
1302 | + if ($buffer != '' && is_array($all_data)) { |
|
1303 | 1303 | $reset = 0; |
1304 | 1304 | foreach ($all_data as $line) { |
1305 | - $data = array(); |
|
1306 | - //$data['id'] = $line['id']; // id not usable |
|
1307 | - $data['id'] = trim($line['flight_id']); |
|
1308 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1309 | - $data['pilot_name'] = $line['pilot_name']; |
|
1310 | - $data['pilot_id'] = $line['pilot_id']; |
|
1311 | - $data['ident'] = trim($line['callsign']); // ident |
|
1312 | - $data['altitude'] = $line['altitude']; // altitude |
|
1313 | - $data['speed'] = $line['gs']; // speed |
|
1314 | - $data['heading'] = $line['heading']; // heading |
|
1315 | - $data['latitude'] = $line['latitude']; // lat |
|
1316 | - $data['longitude'] = $line['longitude']; // long |
|
1317 | - $data['verticalrate'] = ''; // verticale rate |
|
1318 | - $data['squawk'] = ''; // squawk |
|
1319 | - $data['emergency'] = ''; // emergency |
|
1320 | - //$data['datetime'] = $line['lastupdate']; |
|
1321 | - $data['last_update'] = $line['last_update']; |
|
1322 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1323 | - $data['departure_airport_icao'] = $line['departure']; |
|
1324 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
1325 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
1326 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1327 | - //$data['registration'] = $line['aircraft']; |
|
1328 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1329 | - $data['aircraft_icao'] = $line['plane_type']; |
|
1330 | - $data['id_source'] = $id_source; |
|
1331 | - $data['format_source'] = 'vam'; |
|
1332 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1333 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1334 | - $SI->add($data); |
|
1335 | - unset($data); |
|
1305 | + $data = array(); |
|
1306 | + //$data['id'] = $line['id']; // id not usable |
|
1307 | + $data['id'] = trim($line['flight_id']); |
|
1308 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1309 | + $data['pilot_name'] = $line['pilot_name']; |
|
1310 | + $data['pilot_id'] = $line['pilot_id']; |
|
1311 | + $data['ident'] = trim($line['callsign']); // ident |
|
1312 | + $data['altitude'] = $line['altitude']; // altitude |
|
1313 | + $data['speed'] = $line['gs']; // speed |
|
1314 | + $data['heading'] = $line['heading']; // heading |
|
1315 | + $data['latitude'] = $line['latitude']; // lat |
|
1316 | + $data['longitude'] = $line['longitude']; // long |
|
1317 | + $data['verticalrate'] = ''; // verticale rate |
|
1318 | + $data['squawk'] = ''; // squawk |
|
1319 | + $data['emergency'] = ''; // emergency |
|
1320 | + //$data['datetime'] = $line['lastupdate']; |
|
1321 | + $data['last_update'] = $line['last_update']; |
|
1322 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1323 | + $data['departure_airport_icao'] = $line['departure']; |
|
1324 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
1325 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
1326 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1327 | + //$data['registration'] = $line['aircraft']; |
|
1328 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1329 | + $data['aircraft_icao'] = $line['plane_type']; |
|
1330 | + $data['id_source'] = $id_source; |
|
1331 | + $data['format_source'] = 'vam'; |
|
1332 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1333 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1334 | + $SI->add($data); |
|
1335 | + unset($data); |
|
1336 | 1336 | } |
1337 | 1337 | if ($globalDebug) echo 'No more data...'."\n"; |
1338 | 1338 | unset($buffer); |
1339 | 1339 | unset($all_data); |
1340 | - } |
|
1341 | - //$last_exec['phpvmacars'] = time(); |
|
1342 | - $last_exec[$id]['last'] = time(); |
|
1340 | + } |
|
1341 | + //$last_exec['phpvmacars'] = time(); |
|
1342 | + $last_exec[$id]['last'] = time(); |
|
1343 | 1343 | } elseif ($value['format'] == 'blitzortung' && |
1344 | - ( |
|
1344 | + ( |
|
1345 | 1345 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1346 | 1346 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1347 | - ) |
|
1347 | + ) |
|
1348 | 1348 | ) { |
1349 | - //$buffer = $Common->getData($hosts[$id]); |
|
1350 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1351 | - $buffer = $Common->getData($value['host']); |
|
1352 | - $all_data = json_decode($buffer,true); |
|
1353 | - if ($buffer != '') { |
|
1349 | + //$buffer = $Common->getData($hosts[$id]); |
|
1350 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1351 | + $buffer = $Common->getData($value['host']); |
|
1352 | + $all_data = json_decode($buffer,true); |
|
1353 | + if ($buffer != '') { |
|
1354 | 1354 | $Source->deleteLocationBySource('blitzortung'); |
1355 | 1355 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
1356 | 1356 | $buffer = explode('\n',$buffer); |
1357 | 1357 | foreach ($buffer as $buffer_line) { |
1358 | - $line = json_decode($buffer_line,true); |
|
1359 | - if (isset($line['time'])) { |
|
1358 | + $line = json_decode($buffer_line,true); |
|
1359 | + if (isset($line['time'])) { |
|
1360 | 1360 | $data = array(); |
1361 | 1361 | $data['altitude'] = $line['alt']; // altitude |
1362 | 1362 | $data['latitude'] = $line['lat']; // lat |
@@ -1368,96 +1368,96 @@ discard block |
||
1368 | 1368 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1369 | 1369 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
1370 | 1370 | unset($data); |
1371 | - } |
|
1371 | + } |
|
1372 | 1372 | } |
1373 | 1373 | if ($globalDebug) echo 'No more data...'."\n"; |
1374 | 1374 | unset($buffer); |
1375 | - } |
|
1376 | - $last_exec[$id]['last'] = time(); |
|
1375 | + } |
|
1376 | + $last_exec[$id]['last'] = time(); |
|
1377 | 1377 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
1378 | 1378 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { |
1379 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1380 | - //$last_exec[$id]['last'] = time(); |
|
1379 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1380 | + //$last_exec[$id]['last'] = time(); |
|
1381 | 1381 | |
1382 | - //$read = array( $sockets[$id] ); |
|
1383 | - $read = $sockets; |
|
1384 | - $write = NULL; |
|
1385 | - $e = NULL; |
|
1386 | - $n = socket_select($read, $write, $e, $timeout); |
|
1387 | - if ($e != NULL) var_dump($e); |
|
1388 | - if ($n > 0) { |
|
1382 | + //$read = array( $sockets[$id] ); |
|
1383 | + $read = $sockets; |
|
1384 | + $write = NULL; |
|
1385 | + $e = NULL; |
|
1386 | + $n = socket_select($read, $write, $e, $timeout); |
|
1387 | + if ($e != NULL) var_dump($e); |
|
1388 | + if ($n > 0) { |
|
1389 | 1389 | $reset = 0; |
1390 | 1390 | foreach ($read as $nb => $r) { |
1391 | - //$value = $formats[$nb]; |
|
1392 | - $format = $globalSources[$nb]['format']; |
|
1393 | - if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1391 | + //$value = $formats[$nb]; |
|
1392 | + $format = $globalSources[$nb]['format']; |
|
1393 | + if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1394 | 1394 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
1395 | - } elseif ($format == 'vrstcp') { |
|
1395 | + } elseif ($format == 'vrstcp') { |
|
1396 | 1396 | $buffer = @socket_read($r, 6000); |
1397 | - } else { |
|
1397 | + } else { |
|
1398 | 1398 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
1399 | - } |
|
1400 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1401 | - //echo $buffer."\n"; |
|
1402 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
1403 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1404 | - $error = false; |
|
1405 | - //$SI::del(); |
|
1406 | - if ($buffer !== FALSE) { |
|
1399 | + } |
|
1400 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1401 | + //echo $buffer."\n"; |
|
1402 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
1403 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1404 | + $error = false; |
|
1405 | + //$SI::del(); |
|
1406 | + if ($buffer !== FALSE) { |
|
1407 | 1407 | if ($format == 'vrstcp') { |
1408 | - $buffer = explode('},{',$buffer); |
|
1408 | + $buffer = explode('},{',$buffer); |
|
1409 | 1409 | } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
1410 | - } |
|
1411 | - // SBS format is CSV format |
|
1412 | - if ($buffer !== FALSE && $buffer !== '') { |
|
1410 | + } |
|
1411 | + // SBS format is CSV format |
|
1412 | + if ($buffer !== FALSE && $buffer !== '') { |
|
1413 | 1413 | $tt[$format] = 0; |
1414 | 1414 | if ($format == 'acarssbs3') { |
1415 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1416 | - $ACARS->add(trim($buffer)); |
|
1417 | - $ACARS->deleteLiveAcarsData(); |
|
1415 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1416 | + $ACARS->add(trim($buffer)); |
|
1417 | + $ACARS->deleteLiveAcarsData(); |
|
1418 | 1418 | } elseif ($format == 'raw') { |
1419 | - // AVR format |
|
1420 | - $data = $SBS->parse($buffer); |
|
1421 | - if (is_array($data)) { |
|
1419 | + // AVR format |
|
1420 | + $data = $SBS->parse($buffer); |
|
1421 | + if (is_array($data)) { |
|
1422 | 1422 | $data['datetime'] = date('Y-m-d H:i:s'); |
1423 | 1423 | $data['format_source'] = 'raw'; |
1424 | 1424 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1425 | 1425 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1426 | 1426 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1427 | 1427 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1428 | - } |
|
1428 | + } |
|
1429 | 1429 | } elseif ($format == 'ais') { |
1430 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
1431 | - $data = array(); |
|
1432 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1433 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1434 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1435 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1436 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1437 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1438 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1439 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1440 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1441 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1442 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1443 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1444 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1445 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1446 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1447 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1430 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
1431 | + $data = array(); |
|
1432 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1433 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1434 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1435 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1436 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1437 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1438 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1439 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1440 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1441 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1442 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1443 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1444 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1445 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1446 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1447 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1448 | 1448 | |
1449 | - if (isset($ais_data['timestamp'])) { |
|
1449 | + if (isset($ais_data['timestamp'])) { |
|
1450 | 1450 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
1451 | - } else { |
|
1451 | + } else { |
|
1452 | 1452 | $data['datetime'] = date('Y-m-d H:i:s'); |
1453 | - } |
|
1454 | - $data['format_source'] = 'aisnmea'; |
|
1455 | - $data['id_source'] = $id_source; |
|
1456 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1457 | - unset($data); |
|
1458 | - } elseif ($format == 'flightgearsp') { |
|
1459 | - //echo $buffer."\n"; |
|
1460 | - if (strlen($buffer) > 5) { |
|
1453 | + } |
|
1454 | + $data['format_source'] = 'aisnmea'; |
|
1455 | + $data['id_source'] = $id_source; |
|
1456 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1457 | + unset($data); |
|
1458 | + } elseif ($format == 'flightgearsp') { |
|
1459 | + //echo $buffer."\n"; |
|
1460 | + if (strlen($buffer) > 5) { |
|
1461 | 1461 | $line = explode(',',$buffer); |
1462 | 1462 | $data = array(); |
1463 | 1463 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1474,38 +1474,38 @@ discard block |
||
1474 | 1474 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1475 | 1475 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1476 | 1476 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1477 | - } |
|
1478 | - } elseif ($format == 'acars') { |
|
1479 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1480 | - $ACARS->add(trim($buffer)); |
|
1481 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1482 | - $ACARS->deleteLiveAcarsData(); |
|
1477 | + } |
|
1478 | + } elseif ($format == 'acars') { |
|
1479 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1480 | + $ACARS->add(trim($buffer)); |
|
1481 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1482 | + $ACARS->deleteLiveAcarsData(); |
|
1483 | 1483 | } elseif ($format == 'flightgearmp') { |
1484 | - if (substr($buffer,0,1) != '#') { |
|
1484 | + if (substr($buffer,0,1) != '#') { |
|
1485 | 1485 | $data = array(); |
1486 | 1486 | //echo $buffer."\n"; |
1487 | 1487 | $line = explode(' ',$buffer); |
1488 | 1488 | if (count($line) == 11) { |
1489 | - $userserver = explode('@',$line[0]); |
|
1490 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1491 | - $data['ident'] = $userserver[0]; |
|
1492 | - $data['registration'] = $userserver[0]; |
|
1493 | - $data['latitude'] = $line[4]; |
|
1494 | - $data['longitude'] = $line[5]; |
|
1495 | - $data['altitude'] = $line[6]; |
|
1496 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1497 | - $aircraft_type = $line[10]; |
|
1498 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1499 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1500 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1501 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1489 | + $userserver = explode('@',$line[0]); |
|
1490 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1491 | + $data['ident'] = $userserver[0]; |
|
1492 | + $data['registration'] = $userserver[0]; |
|
1493 | + $data['latitude'] = $line[4]; |
|
1494 | + $data['longitude'] = $line[5]; |
|
1495 | + $data['altitude'] = $line[6]; |
|
1496 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1497 | + $aircraft_type = $line[10]; |
|
1498 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1499 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1500 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1501 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1502 | + } |
|
1502 | 1503 | } |
1503 | - } |
|
1504 | 1504 | } elseif ($format == 'beast') { |
1505 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1506 | - die; |
|
1505 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1506 | + die; |
|
1507 | 1507 | } elseif ($format == 'vrstcp') { |
1508 | - foreach($buffer as $all_data) { |
|
1508 | + foreach($buffer as $all_data) { |
|
1509 | 1509 | $line = json_decode('{'.$all_data.'}',true); |
1510 | 1510 | $data = array(); |
1511 | 1511 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1525,153 +1525,153 @@ discard block |
||
1525 | 1525 | */ |
1526 | 1526 | $data['datetime'] = date('Y-m-d H:i:s'); |
1527 | 1527 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
1528 | - $data['format_source'] = 'vrstcp'; |
|
1528 | + $data['format_source'] = 'vrstcp'; |
|
1529 | 1529 | $data['id_source'] = $id_source; |
1530 | 1530 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1531 | 1531 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1532 | 1532 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1533 | 1533 | unset($data); |
1534 | - } |
|
1534 | + } |
|
1535 | 1535 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
1536 | - $line = explode("\t", $buffer); |
|
1537 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1536 | + $line = explode("\t", $buffer); |
|
1537 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
1538 | 1538 | $key = $line[$k]; |
1539 | - $lined[$key] = $line[$k+1]; |
|
1540 | - } |
|
1541 | - if (count($lined) > 3) { |
|
1542 | - $data['hex'] = $lined['hexid']; |
|
1543 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1544 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1545 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1546 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1547 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1548 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1549 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1550 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1551 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1552 | - $data['id_source'] = $id_source; |
|
1553 | - $data['format_source'] = 'tsv'; |
|
1554 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1555 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1539 | + $lined[$key] = $line[$k+1]; |
|
1540 | + } |
|
1541 | + if (count($lined) > 3) { |
|
1542 | + $data['hex'] = $lined['hexid']; |
|
1543 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1544 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
1545 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1546 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1547 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1548 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1549 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1550 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1551 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1552 | + $data['id_source'] = $id_source; |
|
1553 | + $data['format_source'] = 'tsv'; |
|
1554 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1555 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1556 | 1556 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1557 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1558 | - unset($lined); |
|
1559 | - unset($data); |
|
1560 | - } else $error = true; |
|
1557 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1558 | + unset($lined); |
|
1559 | + unset($data); |
|
1560 | + } else $error = true; |
|
1561 | 1561 | } elseif ($format == 'aprs' && $use_aprs) { |
1562 | - if ($aprs_connect == 0) { |
|
1562 | + if ($aprs_connect == 0) { |
|
1563 | 1563 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
1564 | 1564 | $aprs_connect = 1; |
1565 | - } |
|
1565 | + } |
|
1566 | 1566 | |
1567 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1567 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1568 | 1568 | $aprs_last_tx = time(); |
1569 | 1569 | $data_aprs = "# Keep alive"; |
1570 | 1570 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1571 | - } |
|
1571 | + } |
|
1572 | 1572 | |
1573 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1574 | - //echo 'APRS data : '.$buffer."\n"; |
|
1575 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1576 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1577 | - //echo $buffer."\n"; |
|
1578 | - date_default_timezone_set('UTC'); |
|
1579 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1573 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1574 | + //echo 'APRS data : '.$buffer."\n"; |
|
1575 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
1576 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
1577 | + //echo $buffer."\n"; |
|
1578 | + date_default_timezone_set('UTC'); |
|
1579 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1580 | 1580 | $line = $APRS->parse($buffer); |
1581 | 1581 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1582 | 1582 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
1583 | - $aprs_last_tx = time(); |
|
1584 | - $data = array(); |
|
1585 | - //print_r($line); |
|
1586 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1587 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1588 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1589 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1590 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
1591 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
1592 | - if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
1593 | - if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
1594 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1595 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1596 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1597 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1598 | - $data['latitude'] = $line['latitude']; |
|
1599 | - $data['longitude'] = $line['longitude']; |
|
1600 | - //$data['verticalrate'] = $line[16]; |
|
1601 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1602 | - //else $data['speed'] = 0; |
|
1603 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1604 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1605 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1606 | - //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1583 | + $aprs_last_tx = time(); |
|
1584 | + $data = array(); |
|
1585 | + //print_r($line); |
|
1586 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1587 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1588 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1589 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1590 | + if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
1591 | + if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
1592 | + if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
1593 | + if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
1594 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1595 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1596 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1597 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1598 | + $data['latitude'] = $line['latitude']; |
|
1599 | + $data['longitude'] = $line['longitude']; |
|
1600 | + //$data['verticalrate'] = $line[16]; |
|
1601 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1602 | + //else $data['speed'] = 0; |
|
1603 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1604 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1605 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1606 | + //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1607 | 1607 | |
1608 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
1609 | - //else echo 'No heading...'."\n"; |
|
1610 | - //else $data['heading'] = 0; |
|
1611 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1612 | - //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1613 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1614 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1615 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1616 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1617 | - $data['id_source'] = $id_source; |
|
1618 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1619 | - else $data['format_source'] = 'aprs'; |
|
1620 | - $data['source_name'] = $line['source']; |
|
1621 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1622 | - else $data['source_type'] = 'flarm'; |
|
1623 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1624 | - $currentdate = date('Y-m-d H:i:s'); |
|
1625 | - $aprsdate = strtotime($data['datetime']); |
|
1626 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1627 | - // Accept data if time <= system time + 20s |
|
1628 | - //if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1629 | - if (($data['source_type'] == 'modes') || isset($line['stealth']) && (!isset($data['hex']) || $data['hex'] != 'FFFFFF') && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1608 | + if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
1609 | + //else echo 'No heading...'."\n"; |
|
1610 | + //else $data['heading'] = 0; |
|
1611 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1612 | + //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1613 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1614 | + elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1615 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1616 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1617 | + $data['id_source'] = $id_source; |
|
1618 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1619 | + else $data['format_source'] = 'aprs'; |
|
1620 | + $data['source_name'] = $line['source']; |
|
1621 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1622 | + else $data['source_type'] = 'flarm'; |
|
1623 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1624 | + $currentdate = date('Y-m-d H:i:s'); |
|
1625 | + $aprsdate = strtotime($data['datetime']); |
|
1626 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1627 | + // Accept data if time <= system time + 20s |
|
1628 | + //if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1629 | + if (($data['source_type'] == 'modes') || isset($line['stealth']) && (!isset($data['hex']) || $data['hex'] != 'FFFFFF') && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1630 | 1630 | $send = $SI->add($data); |
1631 | - } elseif ($data['source_type'] == 'ais') { |
|
1631 | + } elseif ($data['source_type'] == 'ais') { |
|
1632 | 1632 | $data['type'] = ''; |
1633 | 1633 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
1634 | - } elseif (isset($line['stealth'])) { |
|
1634 | + } elseif (isset($line['stealth'])) { |
|
1635 | 1635 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
1636 | 1636 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
1637 | - } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1638 | - //$line['symbol'] == 'Balloon' || |
|
1639 | - $line['symbol'] == 'Glider' || |
|
1640 | - $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1641 | - if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1642 | - if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1643 | - $send = $SI->add($data); |
|
1644 | - } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1645 | - $line['symbol'] == 'Yacht (Sail)' || |
|
1646 | - $line['symbol'] == 'Ship (Power Boat)')) { |
|
1647 | - $send = $MI->add($data); |
|
1648 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1649 | - $line['symbol'] == 'Car' || |
|
1650 | - $line['symbol'] == 'Ambulance' || |
|
1651 | - $line['symbol'] == 'Van' || |
|
1652 | - $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || |
|
1653 | - $line['symbol'] == 'Motorcycle' || |
|
1654 | - $line['symbol'] == 'Tractor' || |
|
1655 | - $line['symbol'] == 'Police' || |
|
1656 | - $line['symbol'] == 'Bike' || |
|
1657 | - $line['symbol'] == 'Jogger' || |
|
1658 | - $line['symbol'] == 'Horse' || |
|
1659 | - $line['symbol'] == 'Bus' || |
|
1660 | - $line['symbol'] == 'Jeep' || |
|
1661 | - $line['symbol'] == 'Recreational Vehicle' || |
|
1662 | - $line['symbol'] == 'Yacht (Sail)' || |
|
1663 | - $line['symbol'] == 'Ship (Power Boat)' || |
|
1664 | - $line['symbol'] == 'Firetruck' || |
|
1665 | - $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || |
|
1666 | - $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || |
|
1667 | - $line['symbol'] == 'SUV' || |
|
1668 | - $line['symbol'] == 'Snowmobile' || |
|
1669 | - $line['symbol'] == 'Mobile Satellite Station')) { |
|
1670 | - //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
|
1637 | + } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1638 | + //$line['symbol'] == 'Balloon' || |
|
1639 | + $line['symbol'] == 'Glider' || |
|
1640 | + $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1641 | + if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1642 | + if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1643 | + $send = $SI->add($data); |
|
1644 | + } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1645 | + $line['symbol'] == 'Yacht (Sail)' || |
|
1646 | + $line['symbol'] == 'Ship (Power Boat)')) { |
|
1647 | + $send = $MI->add($data); |
|
1648 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1649 | + $line['symbol'] == 'Car' || |
|
1650 | + $line['symbol'] == 'Ambulance' || |
|
1651 | + $line['symbol'] == 'Van' || |
|
1652 | + $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || |
|
1653 | + $line['symbol'] == 'Motorcycle' || |
|
1654 | + $line['symbol'] == 'Tractor' || |
|
1655 | + $line['symbol'] == 'Police' || |
|
1656 | + $line['symbol'] == 'Bike' || |
|
1657 | + $line['symbol'] == 'Jogger' || |
|
1658 | + $line['symbol'] == 'Horse' || |
|
1659 | + $line['symbol'] == 'Bus' || |
|
1660 | + $line['symbol'] == 'Jeep' || |
|
1661 | + $line['symbol'] == 'Recreational Vehicle' || |
|
1662 | + $line['symbol'] == 'Yacht (Sail)' || |
|
1663 | + $line['symbol'] == 'Ship (Power Boat)' || |
|
1664 | + $line['symbol'] == 'Firetruck' || |
|
1665 | + $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || |
|
1666 | + $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || |
|
1667 | + $line['symbol'] == 'SUV' || |
|
1668 | + $line['symbol'] == 'Snowmobile' || |
|
1669 | + $line['symbol'] == 'Mobile Satellite Station')) { |
|
1670 | + //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
|
1671 | 1671 | // } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
1672 | 1672 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1673 | 1673 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
1674 | - } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1674 | + } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1675 | 1675 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
1676 | 1676 | $Source->deleteOldLocationByType('gs'); |
1677 | 1677 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
@@ -1679,7 +1679,7 @@ discard block |
||
1679 | 1679 | } else { |
1680 | 1680 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
1681 | 1681 | } |
1682 | - } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
1682 | + } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
1683 | 1683 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1684 | 1684 | if ($globalDebug) echo '# Weather Station added'."\n"; |
1685 | 1685 | $Source->deleteOldLocationByType('wx'); |
@@ -1689,7 +1689,7 @@ discard block |
||
1689 | 1689 | } else { |
1690 | 1690 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
1691 | 1691 | } |
1692 | - } elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) { |
|
1692 | + } elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) { |
|
1693 | 1693 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1694 | 1694 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1695 | 1695 | $Source->deleteOldLocationByType('lightning'); |
@@ -1698,11 +1698,11 @@ discard block |
||
1698 | 1698 | } else { |
1699 | 1699 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
1700 | 1700 | } |
1701 | - } elseif ($globalDebug) { |
|
1702 | - echo '/!\ Not added: '.$buffer."\n"; |
|
1703 | - print_r($line); |
|
1704 | - } |
|
1705 | - unset($data); |
|
1701 | + } elseif ($globalDebug) { |
|
1702 | + echo '/!\ Not added: '.$buffer."\n"; |
|
1703 | + print_r($line); |
|
1704 | + } |
|
1705 | + unset($data); |
|
1706 | 1706 | } |
1707 | 1707 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
1708 | 1708 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
@@ -1721,12 +1721,12 @@ discard block |
||
1721 | 1721 | } elseif (!isset($globalSources[$nb]['last_weather_clean'])) { |
1722 | 1722 | $globalSources[$nb]['last_weather_clean'] = time(); |
1723 | 1723 | } |
1724 | - } |
|
1724 | + } |
|
1725 | 1725 | } else { |
1726 | - $line = explode(',', $buffer); |
|
1727 | - if (count($line) > 20) { |
|
1728 | - $data['hex'] = $line[4]; |
|
1729 | - /* |
|
1726 | + $line = explode(',', $buffer); |
|
1727 | + if (count($line) > 20) { |
|
1728 | + $data['hex'] = $line[4]; |
|
1729 | + /* |
|
1730 | 1730 | $data['datetime'] = $line[6].' '.$line[7]; |
1731 | 1731 | date_default_timezone_set($globalTimezone); |
1732 | 1732 | $datetime = new DateTime($data['datetime']); |
@@ -1734,30 +1734,30 @@ discard block |
||
1734 | 1734 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1735 | 1735 | date_default_timezone_set('UTC'); |
1736 | 1736 | */ |
1737 | - // Force datetime to current UTC datetime |
|
1738 | - date_default_timezone_set('UTC'); |
|
1739 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1740 | - $data['ident'] = trim($line[10]); |
|
1741 | - $data['latitude'] = $line[14]; |
|
1742 | - $data['longitude'] = $line[15]; |
|
1743 | - $data['verticalrate'] = $line[16]; |
|
1744 | - $data['emergency'] = $line[20]; |
|
1745 | - $data['speed'] = $line[12]; |
|
1746 | - $data['squawk'] = $line[17]; |
|
1747 | - $data['altitude'] = $line[11]; |
|
1748 | - $data['heading'] = $line[13]; |
|
1749 | - $data['ground'] = $line[21]; |
|
1750 | - $data['emergency'] = $line[19]; |
|
1751 | - $data['format_source'] = 'sbs'; |
|
1737 | + // Force datetime to current UTC datetime |
|
1738 | + date_default_timezone_set('UTC'); |
|
1739 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1740 | + $data['ident'] = trim($line[10]); |
|
1741 | + $data['latitude'] = $line[14]; |
|
1742 | + $data['longitude'] = $line[15]; |
|
1743 | + $data['verticalrate'] = $line[16]; |
|
1744 | + $data['emergency'] = $line[20]; |
|
1745 | + $data['speed'] = $line[12]; |
|
1746 | + $data['squawk'] = $line[17]; |
|
1747 | + $data['altitude'] = $line[11]; |
|
1748 | + $data['heading'] = $line[13]; |
|
1749 | + $data['ground'] = $line[21]; |
|
1750 | + $data['emergency'] = $line[19]; |
|
1751 | + $data['format_source'] = 'sbs'; |
|
1752 | 1752 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1753 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1753 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1754 | 1754 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1755 | - $data['id_source'] = $id_source; |
|
1756 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1757 | - else $error = true; |
|
1758 | - unset($data); |
|
1759 | - } else $error = true; |
|
1760 | - if ($error) { |
|
1755 | + $data['id_source'] = $id_source; |
|
1756 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1757 | + else $error = true; |
|
1758 | + unset($data); |
|
1759 | + } else $error = true; |
|
1760 | + if ($error) { |
|
1761 | 1761 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
1762 | 1762 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
1763 | 1763 | } else { |
@@ -1773,13 +1773,13 @@ discard block |
||
1773 | 1773 | connect_all($sourceer); |
1774 | 1774 | $sourceer = array(); |
1775 | 1775 | } |
1776 | - } |
|
1776 | + } |
|
1777 | 1777 | } |
1778 | 1778 | // Sleep for xxx microseconds |
1779 | 1779 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
1780 | - } else { |
|
1780 | + } else { |
|
1781 | 1781 | if ($format == 'flightgearmp') { |
1782 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1782 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1783 | 1783 | //@socket_close($r); |
1784 | 1784 | sleep($globalMinFetch); |
1785 | 1785 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1788,9 +1788,9 @@ discard block |
||
1788 | 1788 | break; |
1789 | 1789 | |
1790 | 1790 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1791 | - if (isset($tt[$format])) $tt[$format]++; |
|
1792 | - else $tt[$format] = 0; |
|
1793 | - if ($tt[$format] > 30 || $buffer === FALSE) { |
|
1791 | + if (isset($tt[$format])) $tt[$format]++; |
|
1792 | + else $tt[$format] = 0; |
|
1793 | + if ($tt[$format] > 30 || $buffer === FALSE) { |
|
1794 | 1794 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
1795 | 1795 | //@socket_close($r); |
1796 | 1796 | sleep(2); |
@@ -1801,24 +1801,24 @@ discard block |
||
1801 | 1801 | //connect_all($globalSources); |
1802 | 1802 | $tt[$format]=0; |
1803 | 1803 | break; |
1804 | - } |
|
1805 | - //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
1804 | + } |
|
1805 | + //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
1806 | + } |
|
1806 | 1807 | } |
1807 | - } |
|
1808 | 1808 | } |
1809 | - } else { |
|
1809 | + } else { |
|
1810 | 1810 | $error = socket_strerror(socket_last_error()); |
1811 | 1811 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1812 | 1812 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
1813 | 1813 | if (isset($globalDebug)) echo "Restarting...\n"; |
1814 | 1814 | // Restart the script if possible |
1815 | 1815 | if (is_array($sockets)) { |
1816 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
1816 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
1817 | 1817 | |
1818 | - foreach ($sockets as $sock) { |
|
1818 | + foreach ($sockets as $sock) { |
|
1819 | 1819 | @socket_shutdown($sock,2); |
1820 | 1820 | @socket_close($sock); |
1821 | - } |
|
1821 | + } |
|
1822 | 1822 | |
1823 | 1823 | } |
1824 | 1824 | if ($globalDebug) echo "Waiting..."; |
@@ -1833,15 +1833,15 @@ discard block |
||
1833 | 1833 | if ($globalDebug) echo "Restart all connections..."; |
1834 | 1834 | connect_all($globalSources); |
1835 | 1835 | } |
1836 | - } |
|
1836 | + } |
|
1837 | 1837 | } |
1838 | 1838 | if ($globalDaemon === false) { |
1839 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1840 | - if (isset($SI)) $SI->checkAll(); |
|
1841 | - if (isset($TI)) $TI->checkAll(); |
|
1842 | - if (isset($MI)) $MI->checkAll(); |
|
1839 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
1840 | + if (isset($SI)) $SI->checkAll(); |
|
1841 | + if (isset($TI)) $TI->checkAll(); |
|
1842 | + if (isset($MI)) $MI->checkAll(); |
|
1843 | + } |
|
1843 | 1844 | } |
1844 | - } |
|
1845 | 1845 | } |
1846 | 1846 | |
1847 | 1847 | ?> |
@@ -329,15 +329,15 @@ discard block |
||
329 | 329 | } |
330 | 330 | |
331 | 331 | <?php |
332 | - if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
332 | + if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
333 | 333 | ?> |
334 | 334 | var loc_geojson = Cesium.loadJson("<?php print $globalURL; ?>/location-geojson.php?coord="+bbox()); |
335 | 335 | <?php |
336 | - } else { |
|
336 | + } else { |
|
337 | 337 | ?> |
338 | 338 | var loc_geojson = Cesium.loadJson("<?php print $globalURL; ?>/location-geojson.php"); |
339 | 339 | <?php |
340 | - } |
|
340 | + } |
|
341 | 341 | ?> |
342 | 342 | loc_geojson.then(function(geojsondata) { |
343 | 343 | loc = new Cesium.CustomDataSource('location'); |
@@ -560,11 +560,11 @@ discard block |
||
560 | 560 | } |
561 | 561 | |
562 | 562 | <?php |
563 | - if (isset($globalTSK) && $globalTSK && isset($_GET['tsk'])) { |
|
563 | + if (isset($globalTSK) && $globalTSK && isset($_GET['tsk'])) { |
|
564 | 564 | ?> |
565 | 565 | update_tsk(); |
566 | 566 | <?php |
567 | - } |
|
567 | + } |
|
568 | 568 | ?> |
569 | 569 | |
570 | 570 | update_locationsLayer(); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | <?php }; if (isset($globalSatellite) && $globalSatellite) { ?><td><div id="ibxsatellite"><h4><?php echo _("Satellites Displayed"); ?></h4><br /><i class="fa fa-spinner fa-pulse fa-fw"></i></div></td><?php } ?> |
48 | 48 | </tr></table></div> |
49 | 49 | <?php |
50 | - if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) { |
|
50 | + if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) { |
|
51 | 51 | ?> |
52 | 52 | <script src="<?php echo $globalURL; ?>/js/map.3d.js.php<?php if (isset($tsk)) print '?tsk='.$tsk; ?>"></script> |
53 | 53 | <?php |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | <script src="<?php echo $globalURL; ?>/js/map-marine.3d.js.php"></script> |
72 | 72 | <?php |
73 | 73 | } |
74 | - } |
|
74 | + } |
|
75 | 75 | ?> |
76 | 76 | |
77 | 77 | <div id="sidebar" class="sidebar collapsed"> |
@@ -82,34 +82,34 @@ discard block |
||
82 | 82 | <li><a href="#" onclick="getUserLocation(); return false;" title="<?php echo _("Plot your Location"); ?>"><i class="fa fa-map-marker"></i></a></li> |
83 | 83 | <li><a href="#" onclick="getCompassDirection(); return false;" title="<?php echo _("Compass Mode"); ?>"><i class="fa fa-compass"></i></a></li> |
84 | 84 | <?php |
85 | - if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
85 | + if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
86 | 86 | if (isset($globalArchive) && $globalArchive == TRUE) { |
87 | 87 | ?> |
88 | 88 | <li><a href="#archive" role="tab" title="<?php echo _("Archive"); ?>"><i class="fa fa-archive"></i></a></li> |
89 | 89 | <?php |
90 | 90 | } |
91 | - } |
|
91 | + } |
|
92 | 92 | ?> |
93 | 93 | <li><a href="#home" role="tab" title="<?php echo _("Layers"); ?>"><i class="fa fa-map"></i></a></li> |
94 | 94 | <li><a href="#filters" role="tab" title="<?php echo _("Filters"); ?>"><i class="fa fa-filter"></i></a></li> |
95 | 95 | <li><a href="#settings" role="tab" title="<?php echo _("Settings"); ?>"><i class="fa fa-gears"></i></a></li> |
96 | 96 | <?php |
97 | - if (isset($globalMap3D) && $globalMap3D) { |
|
97 | + if (isset($globalMap3D) && $globalMap3D) { |
|
98 | 98 | if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
99 | 99 | ?> |
100 | 100 | <li><a href="#" onclick="show3D(); return false;" role="tab" title="3D"><b>3D</b></a></li> |
101 | 101 | <?php |
102 | - if (isset($globalSatellite) && $globalSatellite) { |
|
102 | + if (isset($globalSatellite) && $globalSatellite) { |
|
103 | 103 | ?> |
104 | 104 | <li><a href="#satellites" role="tab" title="<?php echo _("Satellites"); ?>"><i class="satellite"></i></a></li> |
105 | 105 | <?php |
106 | - } |
|
106 | + } |
|
107 | 107 | } else { |
108 | 108 | ?> |
109 | 109 | <li><a href="#" onclick="show2D(); return false;" role="tab" title="2D"><b>2D</b></a></li> |
110 | 110 | <?php |
111 | 111 | } |
112 | - } |
|
112 | + } |
|
113 | 113 | ?> |
114 | 114 | </ul> |
115 | 115 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | ?> |
185 | 185 | </div> |
186 | 186 | <?php |
187 | - if (isset($globalArchive) && $globalArchive == TRUE) { |
|
187 | + if (isset($globalArchive) && $globalArchive == TRUE) { |
|
188 | 188 | ?> |
189 | 189 | <div class="sidebar-pane" id="archive"> |
190 | 190 | <h1 class="sidebar-header"><?php echo _("Playback"); ?> <i>Bêta</i><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | </form> |
244 | 244 | </div> |
245 | 245 | <?php |
246 | - } |
|
246 | + } |
|
247 | 247 | ?> |
248 | 248 | <div class="sidebar-pane" id="settings"> |
249 | 249 | <h1 class="sidebar-header"><?php echo _("Settings"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
@@ -254,56 +254,56 @@ discard block |
||
254 | 254 | <?php |
255 | 255 | if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider; |
256 | 256 | else $MapType = $_COOKIE['MapType']; |
257 | - ?> |
|
257 | + ?> |
|
258 | 258 | <?php |
259 | 259 | if (isset($globalBingMapKey) && $globalBingMapKey != '') { |
260 | - ?> |
|
260 | + ?> |
|
261 | 261 | <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option> |
262 | 262 | <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option> |
263 | 263 | <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option> |
264 | 264 | <?php |
265 | 265 | } |
266 | - ?> |
|
266 | + ?> |
|
267 | 267 | <?php |
268 | - if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
269 | - ?> |
|
268 | + if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
269 | + ?> |
|
270 | 270 | <?php |
271 | - if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') { |
|
272 | - ?> |
|
271 | + if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') { |
|
272 | + ?> |
|
273 | 273 | <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option> |
274 | 274 | <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option> |
275 | 275 | <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option> |
276 | 276 | <?php |
277 | - } |
|
278 | - ?> |
|
277 | + } |
|
278 | + ?> |
|
279 | 279 | <?php |
280 | - if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') { |
|
281 | - ?> |
|
280 | + if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') { |
|
281 | + ?> |
|
282 | 282 | <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option> |
283 | 283 | <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option> |
284 | 284 | <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option> |
285 | 285 | <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option> |
286 | 286 | <?php |
287 | - } |
|
288 | - ?> |
|
287 | + } |
|
288 | + ?> |
|
289 | 289 | <?php |
290 | - if (isset($globalMapQuestKey) && $globalMapQuestKey != '') { |
|
291 | - ?> |
|
290 | + if (isset($globalMapQuestKey) && $globalMapQuestKey != '') { |
|
291 | + ?> |
|
292 | 292 | <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option> |
293 | 293 | <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option> |
294 | 294 | <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option> |
295 | 295 | <?php |
296 | - } |
|
297 | - ?> |
|
296 | + } |
|
297 | + ?> |
|
298 | 298 | <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option> |
299 | 299 | <?php |
300 | 300 | } |
301 | - ?> |
|
301 | + ?> |
|
302 | 302 | <?php |
303 | - if (isset($globalMapboxToken) && $globalMapboxToken != '') { |
|
303 | + if (isset($globalMapboxToken) && $globalMapboxToken != '') { |
|
304 | 304 | if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default'; |
305 | 305 | else $MapBoxId = $_COOKIE['MapTypeId']; |
306 | - ?> |
|
306 | + ?> |
|
307 | 307 | <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option> |
308 | 308 | <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option> |
309 | 309 | <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option> |
@@ -317,13 +317,13 @@ discard block |
||
317 | 317 | <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option> |
318 | 318 | <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option> |
319 | 319 | <?php |
320 | - } |
|
321 | - ?> |
|
320 | + } |
|
321 | + ?> |
|
322 | 322 | <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option> |
323 | 323 | </select> |
324 | 324 | </li> |
325 | 325 | <?php |
326 | - if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
326 | + if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
327 | 327 | ?> |
328 | 328 | <li><?php echo _("Type of Terrain:"); ?> |
329 | 329 | <select class="selectpicker" onchange="terrainType(this);"> |
@@ -334,10 +334,10 @@ discard block |
||
334 | 334 | </select> |
335 | 335 | </li> |
336 | 336 | <?php |
337 | - } |
|
337 | + } |
|
338 | 338 | ?> |
339 | 339 | <?php |
340 | - if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
340 | + if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
341 | 341 | ?> |
342 | 342 | <?php |
343 | 343 | if (!isset($globalAircraft) || $globalAircraft === TRUE) { |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | <li><div class="checkbox"><label><input type="checkbox" name="satelliteestimation" value="1" onclick="clickSatelliteEstimation(this)" <?php if ((isset($_COOKIE['satelliteestimation']) && $_COOKIE['satelliteestimation'] == 'true') || (!isset($_COOKIE['satelliteestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['satelliteestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Satellites animate between updates"); ?></label></div></li> |
355 | 355 | <?php |
356 | 356 | } |
357 | - } |
|
357 | + } |
|
358 | 358 | ?> |
359 | 359 | <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true' || !isset($_COOKIE['displayairports'])) print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li> |
360 | 360 | <li><div class="checkbox"><label><input type="checkbox" name="displaygroundstation" value="1" onclick="clickDisplayGroundStation(this)" <?php if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') || (!isset($_COOKIE['show_GroundStation']) && (isset($globalMapGroundStation) && $globalMapGroundStation === TRUE))) print 'checked'; ?> ><?php echo _("Display ground station on map"); ?></label></div></li> |
@@ -366,81 +366,81 @@ discard block |
||
366 | 366 | <li><div class="checkbox"><label><input type="checkbox" name="displayfires" value="1" onclick="clickDisplayFires(this)" <?php if ((isset($_COOKIE['show_Fires']) && $_COOKIE['show_Fires'] == 'true') || (!isset($_COOKIE['show_Fires']) && (isset($globalMapFires) && $globalMapFires === TRUE))) print 'checked'; ?> ><?php echo _("Display fires on map"); ?></label></div></li> |
367 | 367 | <?php |
368 | 368 | } |
369 | - if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
369 | + if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
370 | 370 | ?> |
371 | 371 | <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li> |
372 | 372 | <?php |
373 | - } |
|
374 | - if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) { |
|
373 | + } |
|
374 | + if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) { |
|
375 | 375 | ?> |
376 | 376 | <li><div class="checkbox"><label><input type="checkbox" name="displaysanta" value="1" onclick="clickSanta(this)"><i class="fa fa-snowflake-o" aria-hidden="true"></i> <?php echo _("Show Santa Claus now"); ?> <i class="fa fa-snowflake-o" aria-hidden="true"></i></label></div></li> |
377 | 377 | <?php |
378 | - } |
|
378 | + } |
|
379 | 379 | ?> |
380 | 380 | <?php |
381 | 381 | if (function_exists('array_column')) { |
382 | - if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) { |
|
383 | - ?> |
|
382 | + if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) { |
|
383 | + ?> |
|
384 | 384 | <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li> |
385 | 385 | <?php |
386 | - } |
|
386 | + } |
|
387 | 387 | } elseif (isset($globalSources)) { |
388 | - $dispolar = false; |
|
389 | - foreach ($globalSources as $testsource) { |
|
390 | - if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true; |
|
391 | - } |
|
392 | - if ($dispolar) { |
|
393 | - ?> |
|
388 | + $dispolar = false; |
|
389 | + foreach ($globalSources as $testsource) { |
|
390 | + if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true; |
|
391 | + } |
|
392 | + if ($dispolar) { |
|
393 | + ?> |
|
394 | 394 | <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li> |
395 | 395 | <?php |
396 | - } |
|
397 | - } |
|
398 | - ?> |
|
396 | + } |
|
397 | + } |
|
398 | + ?> |
|
399 | 399 | <?php |
400 | - if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
400 | + if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
401 | 401 | ?> |
402 | 402 | |
403 | 403 | <?php |
404 | 404 | if (!isset($globalAircraft) || $globalAircraft === TRUE) { |
405 | - if (extension_loaded('gd') && function_exists('gd_info')) { |
|
406 | - ?> |
|
405 | + if (extension_loaded('gd') && function_exists('gd_info')) { |
|
406 | + ?> |
|
407 | 407 | <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') print 'checked'; ?> ><?php echo _("Aircraft icon color based on altitude"); ?></li> |
408 | 408 | <?php |
409 | 409 | if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') { |
410 | - ?> |
|
410 | + ?> |
|
411 | 411 | <li><?php echo _("Aircraft icon color:"); ?> |
412 | 412 | <input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>"> |
413 | 413 | </li> |
414 | 414 | <?php |
415 | 415 | } |
416 | - } |
|
417 | - } |
|
418 | - ?> |
|
416 | + } |
|
417 | + } |
|
418 | + ?> |
|
419 | 419 | <?php |
420 | 420 | if (isset($globalMarine) && $globalMarine === TRUE) { |
421 | - if (extension_loaded('gd') && function_exists('gd_info')) { |
|
422 | - ?> |
|
421 | + if (extension_loaded('gd') && function_exists('gd_info')) { |
|
422 | + ?> |
|
423 | 423 | <li><?php echo _("Marine icon color:"); ?> |
424 | 424 | <input type="color" name="marinecolor" id="html5colorpicker" onchange="MarineiconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print '1a3151'; ?>"> |
425 | 425 | </li> |
426 | 426 | <?php |
427 | - } |
|
428 | - } |
|
429 | - ?> |
|
427 | + } |
|
428 | + } |
|
429 | + ?> |
|
430 | 430 | <?php |
431 | 431 | if (isset($globalTracker) && $globalTracker === TRUE) { |
432 | - if (extension_loaded('gd') && function_exists('gd_info')) { |
|
433 | - ?> |
|
432 | + if (extension_loaded('gd') && function_exists('gd_info')) { |
|
433 | + ?> |
|
434 | 434 | <li><?php echo _("Tracker icon color:"); ?> |
435 | 435 | <input type="color" name="trackercolor" id="html5colorpicker" onchange="TrackericonColor(trackercolor.value);" value="#<?php if (isset($_COOKIE['TrackerIconColor'])) print $_COOKIE['TrackerIconColor']; elseif (isset($globalTrackerIconColor)) print $globalTrackerIconColor; else print '1a3151'; ?>"> |
436 | 436 | </li> |
437 | 437 | <?php |
438 | - } |
|
439 | - } |
|
440 | - ?> |
|
438 | + } |
|
439 | + } |
|
440 | + ?> |
|
441 | 441 | <?php |
442 | 442 | if (!isset($globalAircraft) || $globalAircraft === TRUE) { |
443 | - ?> |
|
443 | + ?> |
|
444 | 444 | <li><?php echo _("Show airport icon at zoom level:"); ?> |
445 | 445 | <div class="range"> |
446 | 446 | <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?>"> |
@@ -449,9 +449,9 @@ discard block |
||
449 | 449 | </li> |
450 | 450 | <?php |
451 | 451 | } |
452 | - ?> |
|
452 | + ?> |
|
453 | 453 | <?php |
454 | - } elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') { |
|
454 | + } elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') { |
|
455 | 455 | ?> |
456 | 456 | <?php |
457 | 457 | if (!isset($globalAircraft) || $globalAircraft === TRUE) { |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | </li> |
484 | 484 | <?php |
485 | 485 | } |
486 | - } |
|
486 | + } |
|
487 | 487 | ?> |
488 | 488 | <li><?php echo _("Distance unit:"); ?> |
489 | 489 | <select class="selectpicker" onchange="unitdistance(this);"> |
@@ -516,19 +516,19 @@ discard block |
||
516 | 516 | <ul> |
517 | 517 | <?php |
518 | 518 | if (!isset($globalAircraft) || $globalAircraft) { |
519 | - ?> |
|
519 | + ?> |
|
520 | 520 | <?php |
521 | 521 | if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) { |
522 | - ?> |
|
522 | + ?> |
|
523 | 523 | <?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?> |
524 | 524 | <?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?> |
525 | 525 | <?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?> |
526 | 526 | <?php |
527 | 527 | } |
528 | - ?> |
|
528 | + ?> |
|
529 | 529 | <?php |
530 | 530 | if (!(isset($globalVA) && $globalVA) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) { |
531 | - ?> |
|
531 | + ?> |
|
532 | 532 | <?php if (isset($globalSBS1) && $globalSBS1) { ?> |
533 | 533 | <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li> |
534 | 534 | <?php } ?> |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | <?php } ?> |
538 | 538 | <?php |
539 | 539 | } |
540 | - ?> |
|
540 | + ?> |
|
541 | 541 | <li><?php echo _("Display airlines:"); ?> |
542 | 542 | <br/> |
543 | 543 | <select class="selectpicker" multiple onchange="airlines(this);" id="display_airlines"> |
@@ -557,14 +557,14 @@ discard block |
||
557 | 557 | echo '<option value="'.$airline['airline_icao'].'">'.$airline_name.'</option>'; |
558 | 558 | } |
559 | 559 | } |
560 | - ?> |
|
560 | + ?> |
|
561 | 561 | </select> |
562 | 562 | </li> |
563 | 563 | <?php |
564 | 564 | $Spotter = new Spotter(); |
565 | 565 | $allalliancenames = $Spotter->getAllAllianceNames(); |
566 | 566 | if (!empty($allalliancenames)) { |
567 | - ?> |
|
567 | + ?> |
|
568 | 568 | <li><?php echo _("Display alliance:"); ?> |
569 | 569 | <br/> |
570 | 570 | <select class="selectpicker" onchange="alliance(this);" id="display_alliance"> |
@@ -578,18 +578,18 @@ discard block |
||
578 | 578 | echo '<option value="'.$alliance_name.'">'.$alliance_name.'</option>'; |
579 | 579 | } |
580 | 580 | } |
581 | - ?> |
|
581 | + ?> |
|
582 | 582 | </select> |
583 | 583 | </li> |
584 | 584 | <?php |
585 | 585 | } |
586 | - ?> |
|
586 | + ?> |
|
587 | 587 | <?php |
588 | 588 | } |
589 | - ?> |
|
589 | + ?> |
|
590 | 590 | <?php |
591 | 591 | if (isset($globalAPRS) && $globalAPRS) { |
592 | - ?> |
|
592 | + ?> |
|
593 | 593 | <li><?php echo _("Display APRS sources name:"); ?> |
594 | 594 | <select class="selectpicker" multiple onchange="sources(this);"> |
595 | 595 | <?php |
@@ -613,18 +613,18 @@ discard block |
||
613 | 613 | echo '<option value="'.$src['name'].'">'.$src['name'].'</option>'; |
614 | 614 | } |
615 | 615 | } |
616 | - ?> |
|
616 | + ?> |
|
617 | 617 | </select> |
618 | 618 | </li> |
619 | 619 | <?php |
620 | 620 | } |
621 | - ?> |
|
621 | + ?> |
|
622 | 622 | <?php |
623 | 623 | if (!isset($globalAircraft) || $globalAircraft) { |
624 | - ?> |
|
624 | + ?> |
|
625 | 625 | <?php |
626 | - if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS)) { |
|
627 | - ?> |
|
626 | + if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS)) { |
|
627 | + ?> |
|
628 | 628 | <li><?php echo _("Display airlines of type:"); ?><br/> |
629 | 629 | <select class="selectpicker" onchange="airlinestype(this);"> |
630 | 630 | <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option> |
@@ -634,21 +634,21 @@ discard block |
||
634 | 634 | </select> |
635 | 635 | </li> |
636 | 636 | <?php |
637 | - } |
|
638 | - ?> |
|
637 | + } |
|
638 | + ?> |
|
639 | 639 | <?php |
640 | 640 | } |
641 | - ?> |
|
641 | + ?> |
|
642 | 642 | <?php |
643 | 643 | if (isset($globalMarine) && $globalMarine) { |
644 | - ?> |
|
644 | + ?> |
|
645 | 645 | <li> |
646 | 646 | <?php echo _("Display vessels with MMSI:"); ?> |
647 | 647 | <input type="text" name="mmsifilter" onchange="mmsifilter();" id="mmsifilter" value="<?php if (isset($_COOKIE['filter_mmsi'])) print $_COOKIE['filter_mmsi']; ?>" /> |
648 | 648 | </li> |
649 | 649 | <?php |
650 | 650 | } |
651 | - ?> |
|
651 | + ?> |
|
652 | 652 | <li> |
653 | 653 | <?php echo _("Display with ident:"); ?> |
654 | 654 | <input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" /> |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | </form> |
662 | 662 | </div> |
663 | 663 | <?php |
664 | - if (isset($globalSatellite) && $globalSatellite) { |
|
664 | + if (isset($globalSatellite) && $globalSatellite) { |
|
665 | 665 | ?> |
666 | 666 | <div class="sidebar-pane" id="satellites"> |
667 | 667 | <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
@@ -701,14 +701,14 @@ discard block |
||
701 | 701 | print '<option value="'.$type['tle_type'].'">'.$type_name.'</option>'; |
702 | 702 | } |
703 | 703 | } |
704 | - ?> |
|
704 | + ?> |
|
705 | 705 | </select> |
706 | 706 | </li> |
707 | 707 | </ul> |
708 | 708 | </form> |
709 | 709 | </div> |
710 | 710 | <?php |
711 | - } |
|
711 | + } |
|
712 | 712 | ?> |
713 | 713 | </div> |
714 | 714 | </div> |