@@ -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'] != '' && substr($line['hex'],0,1) != '~' && $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'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
248 | 248 | |
249 | 249 | // Increment message number |
250 | 250 | if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
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'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
288 | - //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) { |
@@ -348,9 +348,9 @@ discard block |
||
348 | 348 | } |
349 | 349 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
350 | 350 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
351 | - if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
351 | + if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
352 | 352 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
353 | - } else { |
|
353 | + } else { |
|
354 | 354 | if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
355 | 355 | elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
356 | 356 | /* |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | print_r($line); |
360 | 360 | */ |
361 | 361 | return ''; |
362 | - } |
|
362 | + } |
|
363 | 363 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
364 | 364 | if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
365 | 365 | return ''; |
@@ -375,21 +375,21 @@ discard block |
||
375 | 375 | } |
376 | 376 | |
377 | 377 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG' && $line['registration'] != 'NA') { |
378 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
378 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
379 | 379 | } |
380 | 380 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
381 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
381 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
382 | 382 | } |
383 | 383 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
384 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
384 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
385 | 385 | } |
386 | 386 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
387 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
387 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
391 | 391 | |
392 | - if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
392 | + if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
393 | 393 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
394 | 394 | if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
395 | 395 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
@@ -398,23 +398,23 @@ discard block |
||
398 | 398 | elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
399 | 399 | elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
400 | 400 | } else { |
401 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
402 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
401 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
402 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
403 | 403 | $timeelapsed = microtime(true); |
404 | - $Spotter = new Spotter($this->db); |
|
405 | - $fromsource = NULL; |
|
406 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
407 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
404 | + $Spotter = new Spotter($this->db); |
|
405 | + $fromsource = NULL; |
|
406 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
407 | + elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
408 | 408 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
409 | 409 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
410 | 410 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
411 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
411 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
412 | 412 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
413 | 413 | $Spotter->db = null; |
414 | 414 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
415 | - } |
|
415 | + } |
|
416 | 416 | } |
417 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
417 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
418 | 418 | |
419 | 419 | /* |
420 | 420 | if (!isset($line['id'])) { |
@@ -424,63 +424,63 @@ discard block |
||
424 | 424 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
425 | 425 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
426 | 426 | */ |
427 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
427 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
428 | 428 | |
429 | - //$putinarchive = true; |
|
430 | - if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
429 | + //$putinarchive = true; |
|
430 | + if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
431 | 431 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
432 | - } |
|
433 | - if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
432 | + } |
|
433 | + if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
434 | 434 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
435 | - } |
|
436 | - if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
437 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
438 | - } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
435 | + } |
|
436 | + if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
437 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
438 | + } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
439 | 439 | $timeelapsed = microtime(true); |
440 | 440 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
441 | 441 | $Spotter = new Spotter($this->db); |
442 | 442 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
443 | 443 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
444 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
444 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
445 | 445 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
446 | - } |
|
447 | - } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
446 | + } |
|
447 | + } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
448 | 448 | $timeelapsed = microtime(true); |
449 | 449 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
450 | - $Spotter = new Spotter($this->db); |
|
451 | - $route = $Spotter->getRouteInfo(trim($line['ident'])); |
|
452 | - if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) { |
|
450 | + $Spotter = new Spotter($this->db); |
|
451 | + $route = $Spotter->getRouteInfo(trim($line['ident'])); |
|
452 | + if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) { |
|
453 | 453 | $Translation = new Translation($this->db); |
454 | 454 | $ident = $Translation->checkTranslation(trim($line['ident'])); |
455 | 455 | $route = $Spotter->getRouteInfo($ident); |
456 | 456 | $Translation->db = null; |
457 | - } |
|
458 | - $Spotter->db = null; |
|
459 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
460 | - } |
|
457 | + } |
|
458 | + $Spotter->db = null; |
|
459 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
460 | + } |
|
461 | 461 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
462 | - //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
463 | - if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
462 | + //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
463 | + if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
464 | 464 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop'])); |
465 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
466 | - } |
|
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 | + } |
|
467 | 467 | } |
468 | 468 | if (!isset($globalFork)) $globalFork = TRUE; |
469 | 469 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
470 | 470 | if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
471 | 471 | } |
472 | - } |
|
472 | + } |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) { |
476 | 476 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
477 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
478 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
479 | - //$dataFound = true; |
|
477 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
478 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
479 | + //$dataFound = true; |
|
480 | 480 | } else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
481 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
482 | - if ($distance > 1000 && $distance < 10000) { |
|
483 | - // use datetime |
|
481 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
482 | + if ($distance > 1000 && $distance < 10000) { |
|
483 | + // use datetime |
|
484 | 484 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
485 | 485 | $speed = $speed*3.6; |
486 | 486 | if ($speed < 1000) { |
@@ -489,49 +489,49 @@ discard block |
||
489 | 489 | } else { |
490 | 490 | if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
491 | 491 | } |
492 | - } |
|
492 | + } |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | |
496 | 496 | |
497 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
498 | - if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
|
499 | - if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
500 | - return false; |
|
501 | - } |
|
502 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
503 | - else unset($timediff); |
|
504 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
505 | - else unset($timediff_archive); |
|
506 | - if ($this->tmd > 5 |
|
507 | - || (isset($line['format_source']) |
|
508 | - && $line['format_source'] == 'airwhere' |
|
509 | - && ((!isset($this->all_flights[$id]['latitude']) |
|
510 | - || !isset($this->all_flights[$id]['longitude'])) |
|
511 | - || (isset($this->all_flights[$id]['latitude']) |
|
512 | - && isset($this->all_flights[$id]['longitude']) |
|
513 | - && $this->all_flights[$id]['latitude'] != $line['latitude'] |
|
514 | - && $this->all_flights[$id]['longitude'] != $line['longitude'] |
|
515 | - ) |
|
516 | - ) |
|
517 | - ) |
|
518 | - || (isset($globalVA) && $globalVA) |
|
519 | - || (isset($globalIVAO) && $globalIVAO) |
|
520 | - || (isset($globalVATSIM) && $globalVATSIM) |
|
521 | - || (isset($globalphpVMS) && $globalphpVMS) |
|
522 | - || (isset($globalVAM) && $globalVAM) |
|
523 | - || !isset($timediff) |
|
524 | - || $timediff > $globalLiveInterval |
|
525 | - || $globalArchive |
|
526 | - || ($timediff > 30 |
|
527 | - && isset($this->all_flights[$id]['latitude']) |
|
528 | - && isset($this->all_flights[$id]['longitude']) |
|
529 | - && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
530 | - ) |
|
531 | - ) { |
|
497 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
498 | + if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
|
499 | + if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
500 | + return false; |
|
501 | + } |
|
502 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
503 | + else unset($timediff); |
|
504 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
505 | + else unset($timediff_archive); |
|
506 | + if ($this->tmd > 5 |
|
507 | + || (isset($line['format_source']) |
|
508 | + && $line['format_source'] == 'airwhere' |
|
509 | + && ((!isset($this->all_flights[$id]['latitude']) |
|
510 | + || !isset($this->all_flights[$id]['longitude'])) |
|
511 | + || (isset($this->all_flights[$id]['latitude']) |
|
512 | + && isset($this->all_flights[$id]['longitude']) |
|
513 | + && $this->all_flights[$id]['latitude'] != $line['latitude'] |
|
514 | + && $this->all_flights[$id]['longitude'] != $line['longitude'] |
|
515 | + ) |
|
516 | + ) |
|
517 | + ) |
|
518 | + || (isset($globalVA) && $globalVA) |
|
519 | + || (isset($globalIVAO) && $globalIVAO) |
|
520 | + || (isset($globalVATSIM) && $globalVATSIM) |
|
521 | + || (isset($globalphpVMS) && $globalphpVMS) |
|
522 | + || (isset($globalVAM) && $globalVAM) |
|
523 | + || !isset($timediff) |
|
524 | + || $timediff > $globalLiveInterval |
|
525 | + || $globalArchive |
|
526 | + || ($timediff > 30 |
|
527 | + && isset($this->all_flights[$id]['latitude']) |
|
528 | + && isset($this->all_flights[$id]['longitude']) |
|
529 | + && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
530 | + ) |
|
531 | + ) { |
|
532 | 532 | |
533 | 533 | if ((isset($timediff) && !isset($timediff_archive)) || (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude']))) { |
534 | - if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
|
534 | + if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
|
535 | 535 | || (isset($line['format_source']) && $line['format_source'] == 'airwhere') |
536 | 536 | || !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
537 | 537 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -539,9 +539,9 @@ discard block |
||
539 | 539 | $this->all_flights[$id]['putinarchive'] = true; |
540 | 540 | $this->tmd = 0; |
541 | 541 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
542 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
543 | - $timeelapsed = microtime(true); |
|
544 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
542 | + if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
543 | + $timeelapsed = microtime(true); |
|
544 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
545 | 545 | $Spotter = new Spotter($this->db); |
546 | 546 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
547 | 547 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
@@ -549,11 +549,11 @@ discard block |
||
549 | 549 | $Spotter->db = null; |
550 | 550 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
551 | 551 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
552 | - } |
|
552 | + } |
|
553 | 553 | } |
554 | 554 | $this->all_flights[$id]['time_last_archive_coord'] = time(); |
555 | - } |
|
556 | - /* |
|
555 | + } |
|
556 | + /* |
|
557 | 557 | else { |
558 | 558 | if (!isset($timediff)) echo 'NO TIMEDIFF'; |
559 | 559 | else { |
@@ -567,16 +567,16 @@ discard block |
||
567 | 567 | } |
568 | 568 | |
569 | 569 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
570 | - //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) { |
|
570 | + //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 | 571 | if (!isset($this->all_flights[$id]['archive_latitude'])) { |
572 | 572 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
573 | 573 | $this->all_flights[$id]['time_last_coord'] = time(); |
574 | 574 | } |
575 | 575 | //if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
576 | 576 | if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
577 | - $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
578 | - $dataFound = true; |
|
579 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
577 | + $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
578 | + $dataFound = true; |
|
579 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
580 | 580 | } |
581 | 581 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
582 | 582 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
@@ -587,24 +587,24 @@ discard block |
||
587 | 587 | //$putinarchive = true; |
588 | 588 | } |
589 | 589 | */ |
590 | - /* |
|
590 | + /* |
|
591 | 591 | } elseif (isset($this->all_flights[$id]['latitude'])) { |
592 | 592 | 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"; |
593 | 593 | } |
594 | 594 | */ |
595 | 595 | } |
596 | 596 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
597 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
598 | - //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) { |
|
597 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
598 | + //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) { |
|
599 | 599 | if (!isset($this->all_flights[$id]['archive_longitude'])) { |
600 | 600 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
601 | 601 | $this->all_flights[$id]['time_last_coord'] = time(); |
602 | 602 | } |
603 | 603 | //if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
604 | 604 | if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
605 | - $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
606 | - $dataFound = true; |
|
607 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
605 | + $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
606 | + $dataFound = true; |
|
607 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
608 | 608 | } |
609 | 609 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
610 | 610 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
@@ -622,67 +622,67 @@ discard block |
||
622 | 622 | */ |
623 | 623 | } |
624 | 624 | |
625 | - } else if ($globalDebug && $timediff > 30) { |
|
625 | + } else if ($globalDebug && $timediff > 30) { |
|
626 | 626 | $this->tmd = $this->tmd + 1; |
627 | 627 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
628 | 628 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
629 | 629 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
630 | 630 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
631 | - } |
|
631 | + } |
|
632 | 632 | } |
633 | 633 | if (isset($line['last_update']) && $line['last_update'] != '') { |
634 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
635 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
634 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
635 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
636 | 636 | } |
637 | 637 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
638 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
639 | - //$dataFound = true; |
|
638 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
639 | + //$dataFound = true; |
|
640 | 640 | } |
641 | 641 | if (isset($line['format_source']) && $line['format_source'] != '') { |
642 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
642 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
643 | 643 | } |
644 | 644 | if (isset($line['source_name']) && $line['source_name'] != '') { |
645 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
645 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
646 | 646 | } |
647 | 647 | if (isset($line['emergency']) && $line['emergency'] != '') { |
648 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
649 | - //$dataFound = true; |
|
648 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
649 | + //$dataFound = true; |
|
650 | 650 | } |
651 | 651 | if (isset($line['ground']) && $line['ground'] != '') { |
652 | - if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
652 | + if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
653 | 653 | // Here we force archive of flight because after ground it's a new one (or should be) |
654 | 654 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
655 | 655 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
656 | 656 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
657 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
657 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
658 | 658 | elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
659 | - } |
|
660 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
661 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
662 | - //$dataFound = true; |
|
659 | + } |
|
660 | + if ($line['ground'] != 1) $line['ground'] = 0; |
|
661 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
662 | + //$dataFound = true; |
|
663 | 663 | } |
664 | 664 | if (isset($line['squawk']) && $line['squawk'] != '') { |
665 | - if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
|
666 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
667 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
668 | - $highlight = ''; |
|
669 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
670 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
671 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
672 | - if ($highlight != '') { |
|
665 | + if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
|
666 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
667 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
668 | + $highlight = ''; |
|
669 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
670 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
671 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
672 | + if ($highlight != '') { |
|
673 | 673 | $timeelapsed = microtime(true); |
674 | 674 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
675 | - $Spotter = new Spotter($this->db); |
|
676 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
677 | - $Spotter->db = null; |
|
678 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
675 | + $Spotter = new Spotter($this->db); |
|
676 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
677 | + $Spotter->db = null; |
|
678 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
679 | 679 | } |
680 | 680 | //$putinarchive = true; |
681 | 681 | //$highlight = ''; |
682 | - } |
|
682 | + } |
|
683 | 683 | |
684 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
685 | - //$dataFound = true; |
|
684 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
685 | + //$dataFound = true; |
|
686 | 686 | } |
687 | 687 | |
688 | 688 | if (isset($line['altitude']) && $line['altitude'] != '') { |
@@ -693,13 +693,13 @@ discard block |
||
693 | 693 | $line['altitude'] = $line['altitude'] - $geoid; |
694 | 694 | } |
695 | 695 | } |
696 | - //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
696 | + //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
697 | 697 | if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
698 | 698 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
699 | 699 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
700 | 700 | //$dataFound = true; |
701 | - //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
702 | - if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
|
701 | + //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
702 | + if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
|
703 | 703 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
704 | 704 | if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
705 | 705 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
@@ -708,27 +708,27 @@ discard block |
||
708 | 708 | elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
709 | 709 | elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
710 | 710 | } |
711 | - } |
|
712 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
711 | + } |
|
712 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
713 | 713 | } |
714 | 714 | |
715 | 715 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
716 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
716 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
717 | 717 | } |
718 | 718 | |
719 | 719 | if (isset($line['heading']) && $line['heading'] != '') { |
720 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
721 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
722 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
723 | - //$dataFound = true; |
|
720 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
721 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
722 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
723 | + //$dataFound = true; |
|
724 | 724 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
725 | - $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
726 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
727 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
728 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
725 | + $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
726 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
727 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
728 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
729 | 729 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
730 | - // If not enough messages and ACARS set heading to 0 |
|
731 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
730 | + // If not enough messages and ACARS set heading to 0 |
|
731 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
732 | 732 | } |
733 | 733 | if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
734 | 734 | elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
@@ -741,125 +741,125 @@ discard block |
||
741 | 741 | //if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
742 | 742 | //if ($dataFound === true && isset($this->all_flights[$id]['hex'])) { |
743 | 743 | if ($dataFound === true && isset($this->all_flights[$id]['id'])) { |
744 | - $this->all_flights[$id]['lastupdate'] = time(); |
|
745 | - if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
746 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
747 | - //print_r($this->all_flights); |
|
748 | - //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
749 | - //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
750 | - if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
744 | + $this->all_flights[$id]['lastupdate'] = time(); |
|
745 | + if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
746 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
747 | + //print_r($this->all_flights); |
|
748 | + //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
749 | + //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
750 | + if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
751 | 751 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
752 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
753 | - $timeelapsed = microtime(true); |
|
754 | - $SpotterLive = new SpotterLive($this->db); |
|
755 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
752 | + if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
753 | + $timeelapsed = microtime(true); |
|
754 | + $SpotterLive = new SpotterLive($this->db); |
|
755 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
756 | 756 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
757 | 757 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
758 | - } elseif (isset($line['id'])) { |
|
758 | + } elseif (isset($line['id'])) { |
|
759 | 759 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
760 | 760 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
761 | - } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
761 | + } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
762 | 762 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
763 | 763 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
764 | - } else $recent_ident = ''; |
|
765 | - $SpotterLive->db=null; |
|
766 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
767 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
764 | + } else $recent_ident = ''; |
|
765 | + $SpotterLive->db=null; |
|
766 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
767 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
768 | 768 | } else $recent_ident = ''; |
769 | - } else { |
|
769 | + } else { |
|
770 | 770 | $recent_ident = ''; |
771 | 771 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
772 | - } |
|
773 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
774 | - if($recent_ident == "") |
|
775 | - { |
|
772 | + } |
|
773 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
774 | + if($recent_ident == "") |
|
775 | + { |
|
776 | 776 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
777 | 777 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
778 | 778 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
779 | 779 | //adds the spotter data for the archive |
780 | 780 | $ignoreImport = false; |
781 | 781 | foreach($globalAirportIgnore as $airportIgnore) { |
782 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
782 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
783 | 783 | $ignoreImport = true; |
784 | - } |
|
784 | + } |
|
785 | 785 | } |
786 | 786 | if (count($globalAirportAccept) > 0) { |
787 | - $ignoreImport = true; |
|
788 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
787 | + $ignoreImport = true; |
|
788 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
789 | 789 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
790 | - $ignoreImport = false; |
|
790 | + $ignoreImport = false; |
|
791 | + } |
|
791 | 792 | } |
792 | - } |
|
793 | 793 | } |
794 | 794 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
795 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
795 | + foreach($globalAirlineIgnore as $airlineIgnore) { |
|
796 | 796 | if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
797 | - $ignoreImport = true; |
|
797 | + $ignoreImport = true; |
|
798 | + } |
|
798 | 799 | } |
799 | - } |
|
800 | 800 | } |
801 | 801 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
802 | - $ignoreImport = true; |
|
803 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
802 | + $ignoreImport = true; |
|
803 | + foreach($globalAirlineAccept as $airlineAccept) { |
|
804 | 804 | if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
805 | - $ignoreImport = false; |
|
805 | + $ignoreImport = false; |
|
806 | + } |
|
806 | 807 | } |
807 | - } |
|
808 | 808 | } |
809 | 809 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
810 | - $ignoreImport = true; |
|
811 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
810 | + $ignoreImport = true; |
|
811 | + foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
812 | 812 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
813 | - $ignoreImport = false; |
|
813 | + $ignoreImport = false; |
|
814 | + } |
|
814 | 815 | } |
815 | - } |
|
816 | 816 | } |
817 | 817 | |
818 | 818 | if (!$ignoreImport) { |
819 | - $highlight = ''; |
|
820 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
821 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
822 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
823 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
824 | - $timeelapsed = microtime(true); |
|
825 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
819 | + $highlight = ''; |
|
820 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
821 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
822 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
823 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
824 | + $timeelapsed = microtime(true); |
|
825 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
826 | 826 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
827 | - $Spotter = new Spotter($this->db); |
|
828 | - $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
829 | - $Spotter->db = null; |
|
830 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
827 | + $Spotter = new Spotter($this->db); |
|
828 | + $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
829 | + $Spotter->db = null; |
|
830 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
831 | 831 | } |
832 | - } |
|
833 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
834 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
832 | + } |
|
833 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
834 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
835 | 835 | |
836 | - // Add source stat in DB |
|
837 | - $Stats = new Stats($this->db); |
|
838 | - if (!empty($this->stats)) { |
|
836 | + // Add source stat in DB |
|
837 | + $Stats = new Stats($this->db); |
|
838 | + if (!empty($this->stats)) { |
|
839 | 839 | if ($globalDebug) echo 'Add source stats : '; |
840 | - foreach($this->stats as $date => $data) { |
|
841 | - foreach($data as $source => $sourced) { |
|
842 | - //print_r($sourced); |
|
843 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
844 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
845 | - if (isset($sourced['msg'])) { |
|
846 | - if (time() - $sourced['msg']['date'] > 10) { |
|
847 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
848 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
849 | - unset($this->stats[$date][$source]['msg']); |
|
850 | - } |
|
851 | - } |
|
852 | - } |
|
853 | - if ($date != date('Y-m-d')) { |
|
854 | - unset($this->stats[$date]); |
|
855 | - } |
|
856 | - } |
|
857 | - if ($globalDebug) echo 'Done'."\n"; |
|
840 | + foreach($this->stats as $date => $data) { |
|
841 | + foreach($data as $source => $sourced) { |
|
842 | + //print_r($sourced); |
|
843 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
844 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
845 | + if (isset($sourced['msg'])) { |
|
846 | + if (time() - $sourced['msg']['date'] > 10) { |
|
847 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
848 | + echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
849 | + unset($this->stats[$date][$source]['msg']); |
|
850 | + } |
|
851 | + } |
|
852 | + } |
|
853 | + if ($date != date('Y-m-d')) { |
|
854 | + unset($this->stats[$date]); |
|
855 | + } |
|
856 | + } |
|
857 | + if ($globalDebug) echo 'Done'."\n"; |
|
858 | 858 | |
859 | - } |
|
860 | - $Stats->db = null; |
|
861 | - } |
|
862 | - $this->del(); |
|
859 | + } |
|
860 | + $Stats->db = null; |
|
861 | + } |
|
862 | + $this->del(); |
|
863 | 863 | } elseif ($globalDebug) echo 'Ignore data'."\n"; |
864 | 864 | //$ignoreImport = false; |
865 | 865 | $this->all_flights[$id]['addedSpotter'] = 1; |
@@ -877,41 +877,41 @@ discard block |
||
877 | 877 | */ |
878 | 878 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
879 | 879 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
880 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
881 | - //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
882 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
880 | + if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
881 | + //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
882 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
883 | 883 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
884 | - $SpotterLive = new SpotterLive($this->db); |
|
885 | - $SpotterLive->deleteLiveSpotterData(); |
|
886 | - $SpotterLive->db=null; |
|
884 | + $SpotterLive = new SpotterLive($this->db); |
|
885 | + $SpotterLive->deleteLiveSpotterData(); |
|
886 | + $SpotterLive->db=null; |
|
887 | 887 | } |
888 | - } |
|
889 | - if ($globalDebug) echo " Done\n"; |
|
890 | - $this->last_delete = time(); |
|
888 | + } |
|
889 | + if ($globalDebug) echo " Done\n"; |
|
890 | + $this->last_delete = time(); |
|
891 | 891 | } |
892 | - } else { |
|
892 | + } else { |
|
893 | 893 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
894 | - $this->all_flights[$id]['id'] = $recent_ident; |
|
895 | - $this->all_flights[$id]['addedSpotter'] = 1; |
|
894 | + $this->all_flights[$id]['id'] = $recent_ident; |
|
895 | + $this->all_flights[$id]['addedSpotter'] = 1; |
|
896 | 896 | } |
897 | 897 | if (isset($globalDaemon) && !$globalDaemon) { |
898 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
898 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
899 | 899 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
900 | - $Spotter = new Spotter($this->db); |
|
901 | - $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
902 | - $Spotter->db = null; |
|
900 | + $Spotter = new Spotter($this->db); |
|
901 | + $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
902 | + $Spotter->db = null; |
|
903 | + } |
|
903 | 904 | } |
904 | - } |
|
905 | 905 | } |
906 | 906 | |
907 | - } |
|
907 | + } |
|
908 | 908 | } |
909 | - } |
|
910 | - //adds the spotter LIVE data |
|
911 | - //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
912 | - //echo "\nAdd in Live !! \n"; |
|
913 | - //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"; |
|
914 | - if ($globalDebug) { |
|
909 | + } |
|
910 | + //adds the spotter LIVE data |
|
911 | + //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
912 | + //echo "\nAdd in Live !! \n"; |
|
913 | + //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"; |
|
914 | + if ($globalDebug) { |
|
915 | 915 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
916 | 916 | 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"; |
917 | 917 | 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"; |
@@ -919,60 +919,60 @@ discard block |
||
919 | 919 | 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"; |
920 | 920 | 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"; |
921 | 921 | } |
922 | - } |
|
923 | - $ignoreImport = false; |
|
924 | - if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
925 | - if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
922 | + } |
|
923 | + $ignoreImport = false; |
|
924 | + if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
925 | + if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
926 | 926 | |
927 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
928 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
929 | - $ignoreImport = true; |
|
927 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
928 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
929 | + $ignoreImport = true; |
|
930 | + } |
|
930 | 931 | } |
931 | - } |
|
932 | - if (count($globalAirportAccept) > 0) { |
|
933 | - $ignoreImport = true; |
|
934 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
935 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
932 | + if (count($globalAirportAccept) > 0) { |
|
933 | + $ignoreImport = true; |
|
934 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
935 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
936 | 936 | $ignoreImport = false; |
937 | - } |
|
937 | + } |
|
938 | 938 | } |
939 | - } |
|
940 | - if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
939 | + } |
|
940 | + if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
941 | 941 | foreach($globalAirlineIgnore as $airlineIgnore) { |
942 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
942 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
943 | 943 | $ignoreImport = true; |
944 | - } |
|
944 | + } |
|
945 | 945 | } |
946 | - } |
|
947 | - if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
946 | + } |
|
947 | + if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
948 | 948 | $ignoreImport = true; |
949 | 949 | foreach($globalAirlineAccept as $airlineAccept) { |
950 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
950 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
951 | 951 | $ignoreImport = false; |
952 | - } |
|
952 | + } |
|
953 | + } |
|
953 | 954 | } |
954 | - } |
|
955 | - if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
955 | + if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
956 | 956 | $ignoreImport = true; |
957 | 957 | foreach($globalPilotIdAccept as $pilotIdAccept) { |
958 | - if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
959 | - $ignoreImport = false; |
|
960 | - } |
|
958 | + if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
959 | + $ignoreImport = false; |
|
960 | + } |
|
961 | + } |
|
961 | 962 | } |
962 | - } |
|
963 | 963 | |
964 | - if (!$ignoreImport) { |
|
964 | + if (!$ignoreImport) { |
|
965 | 965 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
966 | 966 | if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
967 | 967 | $timeelapsed = microtime(true); |
968 | 968 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
969 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
969 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
970 | 970 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
971 | 971 | $SpotterLive = new SpotterLive($this->db); |
972 | 972 | $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
973 | 973 | $SpotterLive->db = null; |
974 | 974 | if ($globalDebug) echo $result."\n"; |
975 | - } |
|
975 | + } |
|
976 | 976 | } |
977 | 977 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
978 | 978 | $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
@@ -984,7 +984,7 @@ discard block |
||
984 | 984 | //if ($line['format_source'] != 'aprs') { |
985 | 985 | //if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) { |
986 | 986 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
987 | - if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
|
987 | + if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
|
988 | 988 | $source = $this->all_flights[$id]['source_name']; |
989 | 989 | if ($source == '') $source = $this->all_flights[$id]['format_source']; |
990 | 990 | if (!isset($this->source_location[$source])) { |
@@ -1010,7 +1010,7 @@ discard block |
||
1010 | 1010 | if ($stats_heading == 16) $stats_heading = 0; |
1011 | 1011 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
1012 | 1012 | for ($i=0;$i<=15;$i++) { |
1013 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
1013 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
1014 | 1014 | } |
1015 | 1015 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
1016 | 1016 | } else { |
@@ -1023,17 +1023,17 @@ discard block |
||
1023 | 1023 | //var_dump($this->stats); |
1024 | 1024 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
1025 | 1025 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
1026 | - end($this->stats[$current_date][$source]['hist']); |
|
1027 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
1026 | + end($this->stats[$current_date][$source]['hist']); |
|
1027 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
1028 | 1028 | } else $mini = 0; |
1029 | 1029 | for ($i=$mini;$i<=$distance;$i+=10) { |
1030 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
1030 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
1031 | 1031 | } |
1032 | 1032 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
1033 | 1033 | } else { |
1034 | 1034 | $this->stats[$current_date][$source]['hist'][$distance] += 1; |
1035 | 1035 | } |
1036 | - } |
|
1036 | + } |
|
1037 | 1037 | } |
1038 | 1038 | |
1039 | 1039 | $this->all_flights[$id]['lastupdate'] = time(); |
@@ -1043,7 +1043,7 @@ discard block |
||
1043 | 1043 | //$this->del(); |
1044 | 1044 | |
1045 | 1045 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
1046 | - if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
1046 | + if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
1047 | 1047 | if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
1048 | 1048 | $SpotterLive = new SpotterLive($this->db); |
1049 | 1049 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
@@ -1051,19 +1051,19 @@ discard block |
||
1051 | 1051 | //SpotterLive->deleteLiveSpotterData(); |
1052 | 1052 | if ($globalDebug) echo " Done\n"; |
1053 | 1053 | $this->last_delete_hourly = time(); |
1054 | - } else { |
|
1054 | + } else { |
|
1055 | 1055 | $this->del(); |
1056 | 1056 | $this->last_delete_hourly = time(); |
1057 | - } |
|
1057 | + } |
|
1058 | 1058 | } |
1059 | 1059 | |
1060 | - } |
|
1061 | - //$ignoreImport = false; |
|
1060 | + } |
|
1061 | + //$ignoreImport = false; |
|
1062 | 1062 | } |
1063 | 1063 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
1064 | 1064 | if ($send) return $this->all_flights[$id]; |
1065 | - } |
|
1065 | + } |
|
1066 | + } |
|
1066 | 1067 | } |
1067 | - } |
|
1068 | 1068 | } |
1069 | 1069 | ?> |
@@ -34,12 +34,12 @@ 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) { |
|
37 | + foreach ($sourcestat as $srcst) { |
|
38 | 38 | $type = $srcst['stats_type']; |
39 | 39 | if ($type == 'polar' || $type == 'hist') { |
40 | 40 | $source = $srcst['source_name']; |
41 | 41 | $data = $srcst['source_data']; |
42 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
42 | + $this->stats[$currentdate][$source][$type] = json_decode($data, true); |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | } |
@@ -51,14 +51,14 @@ discard block |
||
51 | 51 | if (isset($globalGeoid) && $globalGeoid) { |
52 | 52 | try { |
53 | 53 | $GeoidClass = new GeoidHeight(); |
54 | - } catch(Exception $e) { |
|
54 | + } catch (Exception $e) { |
|
55 | 55 | if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n"; |
56 | 56 | $GeoidClass = FALSE; |
57 | 57 | } |
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
61 | - public function get_Schedule($id,$ident) { |
|
61 | + public function get_Schedule($id, $ident) { |
|
62 | 62 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
63 | 63 | // Get schedule here, so it's done only one time |
64 | 64 | |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | $schedule = $Schedule->fetchSchedule($operator); |
84 | 84 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
85 | 85 | if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
86 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
87 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
86 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime'])); |
|
87 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
88 | 88 | // Should also check if route schedule = route from DB |
89 | 89 | if ($schedule['DepartureAirportIATA'] != '') { |
90 | 90 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | } |
105 | 105 | } |
106 | 106 | } |
107 | - $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
107 | + $Schedule->addSchedule($operator, $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time'], $schedule['Source']); |
|
108 | 108 | } |
109 | 109 | } else $scheduleexist = true; |
110 | 110 | } else $scheduleexist = true; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | if ($scheduleexist) { |
113 | 113 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
114 | 114 | $sch = $Schedule->getSchedule($operator); |
115 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
115 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport' => $sch['arrival_airport_icao'], 'departure_airport' => $sch['departure_airport_icao'], 'departure_airport_time' => $sch['departure_airport_time'], 'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
116 | 116 | } |
117 | 117 | $Spotter->db = null; |
118 | 118 | $Schedule->db = null; |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
140 | 140 | $Spotter = new Spotter($this->db); |
141 | 141 | $real_arrival = $this->arrival($key); |
142 | - if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
142 | + if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | $airport_time = ''; |
154 | 154 | if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
155 | 155 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
156 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
156 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist); |
|
157 | 157 | if (isset($closestAirports[0])) { |
158 | 158 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
159 | 159 | $airport_icao = $closestAirports[0]['icao']; |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | break; |
169 | 169 | } |
170 | 170 | } |
171 | - } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
171 | + } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) { |
|
172 | 172 | $airport_icao = $closestAirports[0]['icao']; |
173 | 173 | $airport_time = $this->all_flights[$key]['datetime']; |
174 | 174 | } else { |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | } else { |
182 | 182 | if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
183 | 183 | } |
184 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
184 | + return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
193 | 193 | foreach ($this->all_flights as $key => $flight) { |
194 | 194 | if (isset($flight['lastupdate'])) { |
195 | - if ($flight['lastupdate'] < (time()-1800)) { |
|
195 | + if ($flight['lastupdate'] < (time() - 1800)) { |
|
196 | 196 | $this->delKey($key); |
197 | 197 | } |
198 | 198 | } |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | $real_arrival = $this->arrival($key); |
209 | 209 | $Spotter = new Spotter($this->db); |
210 | 210 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
211 | - $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
211 | + $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
212 | 212 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
213 | 213 | } |
214 | 214 | } |
@@ -241,10 +241,10 @@ discard block |
||
241 | 241 | $send = false; |
242 | 242 | |
243 | 243 | // SBS format is CSV format |
244 | - if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
244 | + if (is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
245 | 245 | //print_r($line); |
246 | 246 | if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
247 | - if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
247 | + if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'], 0, 1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
248 | 248 | |
249 | 249 | // Increment message number |
250 | 250 | if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
@@ -277,25 +277,25 @@ discard block |
||
277 | 277 | if (!isset($this->all_flights[$id])) { |
278 | 278 | if ($globalDebug) echo 'New flight...'."\n"; |
279 | 279 | $this->all_flights[$id] = array(); |
280 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
281 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
|
282 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
280 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
281 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'altitude_previous' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => true, 'source_type' => '')); |
|
282 | + if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time())); |
|
283 | 283 | if (!isset($line['id'])) { |
284 | 284 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
285 | 285 | // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
286 | 286 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
287 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
287 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
288 | 288 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
289 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
289 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
290 | 290 | if ($globalAllFlights !== FALSE) $dataFound = true; |
291 | 291 | } |
292 | 292 | if (isset($line['source_type']) && $line['source_type'] != '') { |
293 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
293 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type'])); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | //print_r($this->all_flights); |
297 | 297 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
298 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
298 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex']))); |
|
299 | 299 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
300 | 300 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
301 | 301 | //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
@@ -304,20 +304,20 @@ discard block |
||
304 | 304 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
305 | 305 | $Spotter = new Spotter($this->db); |
306 | 306 | if (isset($this->all_flights[$id]['source_type'])) { |
307 | - $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
|
307 | + $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']); |
|
308 | 308 | } else { |
309 | 309 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
310 | 310 | } |
311 | 311 | $Spotter->db = null; |
312 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
313 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
312 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
313 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
314 | 314 | } |
315 | 315 | } |
316 | 316 | if ($globalAllFlights !== FALSE) $dataFound = true; |
317 | 317 | if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
318 | 318 | } |
319 | 319 | if (isset($line['id']) && !isset($line['hex'])) { |
320 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
320 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => '')); |
|
321 | 321 | } |
322 | 322 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
323 | 323 | $icao = $line['aircraft_icao']; |
@@ -326,14 +326,14 @@ discard block |
||
326 | 326 | if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
327 | 327 | $Spotter->db = null; |
328 | 328 | } |
329 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao)); |
|
329 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $icao)); |
|
330 | 330 | } elseif (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) { |
331 | 331 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
332 | 332 | // Get aircraft ICAO from aircraft name |
333 | 333 | $Spotter = new Spotter($this->db); |
334 | 334 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
335 | 335 | $Spotter->db = null; |
336 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
336 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
337 | 337 | } |
338 | 338 | } |
339 | 339 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
@@ -341,15 +341,15 @@ discard block |
||
341 | 341 | elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
342 | 342 | elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
343 | 343 | elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
344 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
344 | + if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
345 | 345 | } |
346 | 346 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
347 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
347 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA')); |
|
348 | 348 | } |
349 | 349 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
350 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
|
350 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
351 | 351 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
352 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
|
352 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime'])); |
|
353 | 353 | } else { |
354 | 354 | if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
355 | 355 | elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
@@ -360,31 +360,31 @@ discard block |
||
360 | 360 | */ |
361 | 361 | return ''; |
362 | 362 | } |
363 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
|
363 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) { |
|
364 | 364 | if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
365 | 365 | return ''; |
366 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
|
366 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) { |
|
367 | 367 | if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
368 | 368 | return ''; |
369 | 369 | } elseif (!isset($line['datetime'])) { |
370 | 370 | date_default_timezone_set('UTC'); |
371 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
371 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
372 | 372 | } else { |
373 | 373 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
374 | 374 | return ''; |
375 | 375 | } |
376 | 376 | |
377 | 377 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG' && $line['registration'] != 'NA') { |
378 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
378 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration'])); |
|
379 | 379 | } |
380 | 380 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
381 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
381 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints'])); |
|
382 | 382 | } |
383 | 383 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
384 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
384 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => trim($line['pilot_id']))); |
|
385 | 385 | } |
386 | 386 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
387 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
387 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => trim($line['pilot_name']))); |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
@@ -392,13 +392,13 @@ discard block |
||
392 | 392 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
393 | 393 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
394 | 394 | if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
395 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
396 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
397 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
398 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
399 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
395 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
396 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
397 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
398 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
399 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
400 | 400 | } else { |
401 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
401 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
402 | 402 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
403 | 403 | $timeelapsed = microtime(true); |
404 | 404 | $Spotter = new Spotter($this->db); |
@@ -408,13 +408,13 @@ discard block |
||
408 | 408 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
409 | 409 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
410 | 410 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
411 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
411 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource); |
|
412 | 412 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
413 | 413 | $Spotter->db = null; |
414 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
414 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
415 | 415 | } |
416 | 416 | } |
417 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
417 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
418 | 418 | |
419 | 419 | /* |
420 | 420 | if (!isset($line['id'])) { |
@@ -424,25 +424,25 @@ discard block |
||
424 | 424 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
425 | 425 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
426 | 426 | */ |
427 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
427 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
428 | 428 | |
429 | 429 | //$putinarchive = true; |
430 | 430 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
431 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
|
431 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time'])); |
|
432 | 432 | } |
433 | 433 | if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
434 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
434 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
435 | 435 | } |
436 | 436 | if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
437 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
437 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => '')); |
|
438 | 438 | } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
439 | 439 | $timeelapsed = microtime(true); |
440 | 440 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
441 | 441 | $Spotter = new Spotter($this->db); |
442 | 442 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
443 | 443 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
444 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
445 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
444 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => '')); |
|
445 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
446 | 446 | } |
447 | 447 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
448 | 448 | $timeelapsed = microtime(true); |
@@ -456,35 +456,35 @@ discard block |
||
456 | 456 | $Translation->db = null; |
457 | 457 | } |
458 | 458 | $Spotter->db = null; |
459 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
459 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
460 | 460 | } |
461 | 461 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
462 | 462 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
463 | 463 | if ($route['fromairport_icao'] != $route['toairport_icao']) { |
464 | 464 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop'])); |
465 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
465 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $route['fromairport_icao'], 'arrival_airport' => $route['toairport_icao'], 'route_stop' => $route['routestop'])); |
|
466 | 466 | } |
467 | 467 | } |
468 | 468 | if (!isset($globalFork)) $globalFork = TRUE; |
469 | 469 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
470 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
470 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident'])); |
|
471 | 471 | } |
472 | 472 | } |
473 | 473 | } |
474 | 474 | |
475 | 475 | if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) { |
476 | 476 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
477 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
478 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
477 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed']))); |
|
478 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true)); |
|
479 | 479 | //$dataFound = true; |
480 | 480 | } else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
481 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
481 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'); |
|
482 | 482 | if ($distance > 1000 && $distance < 10000) { |
483 | 483 | // use datetime |
484 | 484 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
485 | 485 | $speed = $speed*3.6; |
486 | 486 | if ($speed < 1000) { |
487 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
487 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed))); |
|
488 | 488 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
489 | 489 | } else { |
490 | 490 | if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
@@ -499,9 +499,9 @@ discard block |
||
499 | 499 | if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
500 | 500 | return false; |
501 | 501 | } |
502 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
502 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']); |
|
503 | 503 | else unset($timediff); |
504 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
504 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time() - $this->all_flights[$id]['time_last_archive_coord']); |
|
505 | 505 | else unset($timediff_archive); |
506 | 506 | if ($this->tmd > 5 |
507 | 507 | || (isset($line['format_source']) |
@@ -526,14 +526,14 @@ discard block |
||
526 | 526 | || ($timediff > 30 |
527 | 527 | && isset($this->all_flights[$id]['latitude']) |
528 | 528 | && isset($this->all_flights[$id]['longitude']) |
529 | - && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
529 | + && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')) |
|
530 | 530 | ) |
531 | 531 | ) { |
532 | 532 | |
533 | 533 | if ((isset($timediff) && !isset($timediff_archive)) || (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude']))) { |
534 | 534 | if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
535 | 535 | || (isset($line['format_source']) && $line['format_source'] == 'airwhere') |
536 | - || !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
536 | + || !$Common->checkLine($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) { |
|
537 | 537 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
538 | 538 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
539 | 539 | $this->all_flights[$id]['putinarchive'] = true; |
@@ -543,11 +543,11 @@ discard block |
||
543 | 543 | $timeelapsed = microtime(true); |
544 | 544 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
545 | 545 | $Spotter = new Spotter($this->db); |
546 | - $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
546 | + $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
547 | 547 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
548 | 548 | else $this->all_flights[$id]['over_country'] = ''; |
549 | 549 | $Spotter->db = null; |
550 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
550 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
551 | 551 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
552 | 552 | } |
553 | 553 | } |
@@ -573,13 +573,13 @@ discard block |
||
573 | 573 | $this->all_flights[$id]['time_last_coord'] = time(); |
574 | 574 | } |
575 | 575 | //if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
576 | - if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
|
576 | + if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > 0.0001)) { |
|
577 | 577 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
578 | 578 | $dataFound = true; |
579 | 579 | $this->all_flights[$id]['time_last_coord'] = time(); |
580 | 580 | } |
581 | 581 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
582 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
|
582 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude'])); |
|
583 | 583 | /* |
584 | 584 | if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) { |
585 | 585 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -601,13 +601,13 @@ discard block |
||
601 | 601 | $this->all_flights[$id]['time_last_coord'] = time(); |
602 | 602 | } |
603 | 603 | //if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
604 | - if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
|
604 | + if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > 0.0001)) { |
|
605 | 605 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
606 | 606 | $dataFound = true; |
607 | 607 | $this->all_flights[$id]['time_last_coord'] = time(); |
608 | 608 | } |
609 | 609 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
610 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
|
610 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude'])); |
|
611 | 611 | /* |
612 | 612 | if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) { |
613 | 613 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -625,46 +625,46 @@ discard block |
||
625 | 625 | } else if ($globalDebug && $timediff > 30) { |
626 | 626 | $this->tmd = $this->tmd + 1; |
627 | 627 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
628 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
|
629 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
628 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -"; |
|
629 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
630 | 630 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
631 | 631 | } |
632 | 632 | } |
633 | 633 | if (isset($line['last_update']) && $line['last_update'] != '') { |
634 | 634 | if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
635 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
635 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update'])); |
|
636 | 636 | } |
637 | 637 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
638 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
638 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate'])); |
|
639 | 639 | //$dataFound = true; |
640 | 640 | } |
641 | 641 | if (isset($line['format_source']) && $line['format_source'] != '') { |
642 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
642 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source'])); |
|
643 | 643 | } |
644 | 644 | if (isset($line['source_name']) && $line['source_name'] != '') { |
645 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
645 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name'])); |
|
646 | 646 | } |
647 | 647 | if (isset($line['emergency']) && $line['emergency'] != '') { |
648 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
648 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency'])); |
|
649 | 649 | //$dataFound = true; |
650 | 650 | } |
651 | 651 | if (isset($line['ground']) && $line['ground'] != '') { |
652 | 652 | if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
653 | 653 | // Here we force archive of flight because after ground it's a new one (or should be) |
654 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
655 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
656 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
657 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
658 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
654 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
655 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
656 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
657 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
658 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
659 | 659 | } |
660 | 660 | if ($line['ground'] != 1) $line['ground'] = 0; |
661 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
661 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground'])); |
|
662 | 662 | //$dataFound = true; |
663 | 663 | } |
664 | 664 | if (isset($line['squawk']) && $line['squawk'] != '') { |
665 | 665 | if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
666 | 666 | if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
667 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
667 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
668 | 668 | $highlight = ''; |
669 | 669 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
670 | 670 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
@@ -673,66 +673,66 @@ discard block |
||
673 | 673 | $timeelapsed = microtime(true); |
674 | 674 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
675 | 675 | $Spotter = new Spotter($this->db); |
676 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
676 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight); |
|
677 | 677 | $Spotter->db = null; |
678 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
678 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
679 | 679 | } |
680 | 680 | //$putinarchive = true; |
681 | 681 | //$highlight = ''; |
682 | 682 | } |
683 | 683 | |
684 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
684 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
685 | 685 | //$dataFound = true; |
686 | 686 | } |
687 | 687 | |
688 | 688 | if (isset($line['altitude']) && $line['altitude'] != '') { |
689 | 689 | if (isset($line['altitude_relative']) && isset($GeoidClass) && is_object($GeoidClass)) { |
690 | 690 | if ($line['altitude_relative'] == 'AMSL' || $line['altitude_relative'] == 'MSL') { |
691 | - $geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'])*3.28084,2); |
|
691 | + $geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'])*3.28084, 2); |
|
692 | 692 | //if ($globalDebug) echo '=> Set altitude to WGS84 Ellipsoid, add '.$geoid.' to '.$line['altitude']."\n"; |
693 | 693 | $line['altitude'] = $line['altitude'] - $geoid; |
694 | 694 | } |
695 | 695 | } |
696 | 696 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
697 | - if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
698 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
|
699 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
|
697 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
698 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100))); |
|
699 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude'])); |
|
700 | 700 | //$dataFound = true; |
701 | 701 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
702 | 702 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
703 | 703 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
704 | 704 | if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
705 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
706 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
707 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
708 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
709 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
705 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
706 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
707 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
708 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
709 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
710 | 710 | } |
711 | 711 | } |
712 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
712 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_previous' => $line['altitude'])); |
|
713 | 713 | } |
714 | 714 | |
715 | 715 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
716 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
716 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true)); |
|
717 | 717 | } |
718 | 718 | |
719 | 719 | if (isset($line['heading']) && $line['heading'] != '') { |
720 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
721 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
722 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
720 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
721 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading']))); |
|
722 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true)); |
|
723 | 723 | //$dataFound = true; |
724 | 724 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
725 | - $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
726 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
727 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
725 | + $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
726 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading))); |
|
727 | + if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
728 | 728 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
729 | 729 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
730 | 730 | // If not enough messages and ACARS set heading to 0 |
731 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
731 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0)); |
|
732 | 732 | } |
733 | - if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
734 | - elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
735 | - elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false; |
|
733 | + if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
734 | + elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
735 | + elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false; |
|
736 | 736 | |
737 | 737 | // print_r($this->all_flights[$id]); |
738 | 738 | //gets the callsign from the last hour |
@@ -743,7 +743,7 @@ discard block |
||
743 | 743 | if ($dataFound === true && isset($this->all_flights[$id]['id'])) { |
744 | 744 | $this->all_flights[$id]['lastupdate'] = time(); |
745 | 745 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
746 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
746 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
747 | 747 | //print_r($this->all_flights); |
748 | 748 | //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
749 | 749 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
@@ -754,61 +754,61 @@ discard block |
||
754 | 754 | $SpotterLive = new SpotterLive($this->db); |
755 | 755 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
756 | 756 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
757 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
757 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
758 | 758 | } elseif (isset($line['id'])) { |
759 | 759 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
760 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
760 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
761 | 761 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
762 | 762 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
763 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
763 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
764 | 764 | } else $recent_ident = ''; |
765 | - $SpotterLive->db=null; |
|
765 | + $SpotterLive->db = null; |
|
766 | 766 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
767 | 767 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
768 | 768 | } else $recent_ident = ''; |
769 | 769 | } else { |
770 | 770 | $recent_ident = ''; |
771 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
|
771 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0)); |
|
772 | 772 | } |
773 | 773 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
774 | - if($recent_ident == "") |
|
774 | + if ($recent_ident == "") |
|
775 | 775 | { |
776 | 776 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
777 | 777 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
778 | 778 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
779 | 779 | //adds the spotter data for the archive |
780 | 780 | $ignoreImport = false; |
781 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
781 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
782 | 782 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
783 | 783 | $ignoreImport = true; |
784 | 784 | } |
785 | 785 | } |
786 | 786 | if (count($globalAirportAccept) > 0) { |
787 | 787 | $ignoreImport = true; |
788 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
788 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
789 | 789 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
790 | 790 | $ignoreImport = false; |
791 | 791 | } |
792 | 792 | } |
793 | 793 | } |
794 | 794 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
795 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
796 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
795 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
796 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
797 | 797 | $ignoreImport = true; |
798 | 798 | } |
799 | 799 | } |
800 | 800 | } |
801 | 801 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
802 | 802 | $ignoreImport = true; |
803 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
804 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
803 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
804 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
805 | 805 | $ignoreImport = false; |
806 | 806 | } |
807 | 807 | } |
808 | 808 | } |
809 | 809 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
810 | 810 | $ignoreImport = true; |
811 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
811 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
812 | 812 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
813 | 813 | $ignoreImport = false; |
814 | 814 | } |
@@ -820,32 +820,32 @@ discard block |
||
820 | 820 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
821 | 821 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
822 | 822 | if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
823 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
823 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
824 | 824 | $timeelapsed = microtime(true); |
825 | 825 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
826 | 826 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
827 | 827 | $Spotter = new Spotter($this->db); |
828 | - $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
828 | + $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $highlight, $this->all_flights[$id]['hex'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['source_type']); |
|
829 | 829 | $Spotter->db = null; |
830 | 830 | if ($globalDebug && isset($result)) echo $result."\n"; |
831 | 831 | } |
832 | 832 | } |
833 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
833 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
834 | 834 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
835 | 835 | |
836 | 836 | // Add source stat in DB |
837 | 837 | $Stats = new Stats($this->db); |
838 | 838 | if (!empty($this->stats)) { |
839 | 839 | if ($globalDebug) echo 'Add source stats : '; |
840 | - foreach($this->stats as $date => $data) { |
|
841 | - foreach($data as $source => $sourced) { |
|
840 | + foreach ($this->stats as $date => $data) { |
|
841 | + foreach ($data as $source => $sourced) { |
|
842 | 842 | //print_r($sourced); |
843 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
844 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
843 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date); |
|
844 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date); |
|
845 | 845 | if (isset($sourced['msg'])) { |
846 | 846 | if (time() - $sourced['msg']['date'] > 10) { |
847 | 847 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
848 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
848 | + echo $Stats->addStatSource($nbmsg, $source, 'msg', $date); |
|
849 | 849 | unset($this->stats[$date][$source]['msg']); |
850 | 850 | } |
851 | 851 | } |
@@ -883,14 +883,14 @@ discard block |
||
883 | 883 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
884 | 884 | $SpotterLive = new SpotterLive($this->db); |
885 | 885 | $SpotterLive->deleteLiveSpotterData(); |
886 | - $SpotterLive->db=null; |
|
886 | + $SpotterLive->db = null; |
|
887 | 887 | } |
888 | 888 | } |
889 | 889 | if ($globalDebug) echo " Done\n"; |
890 | 890 | $this->last_delete = time(); |
891 | 891 | } |
892 | 892 | } else { |
893 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
|
893 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
|
894 | 894 | $this->all_flights[$id]['id'] = $recent_ident; |
895 | 895 | $this->all_flights[$id]['addedSpotter'] = 1; |
896 | 896 | } |
@@ -898,7 +898,7 @@ discard block |
||
898 | 898 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
899 | 899 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
900 | 900 | $Spotter = new Spotter($this->db); |
901 | - $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
901 | + $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']); |
|
902 | 902 | $Spotter->db = null; |
903 | 903 | } |
904 | 904 | } |
@@ -924,37 +924,37 @@ discard block |
||
924 | 924 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
925 | 925 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
926 | 926 | |
927 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
927 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
928 | 928 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
929 | 929 | $ignoreImport = true; |
930 | 930 | } |
931 | 931 | } |
932 | 932 | if (count($globalAirportAccept) > 0) { |
933 | 933 | $ignoreImport = true; |
934 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
934 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
935 | 935 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
936 | 936 | $ignoreImport = false; |
937 | 937 | } |
938 | 938 | } |
939 | 939 | } |
940 | 940 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
941 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
942 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
941 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
942 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
943 | 943 | $ignoreImport = true; |
944 | 944 | } |
945 | 945 | } |
946 | 946 | } |
947 | 947 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
948 | 948 | $ignoreImport = true; |
949 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
950 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
949 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
950 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
951 | 951 | $ignoreImport = false; |
952 | 952 | } |
953 | 953 | } |
954 | 954 | } |
955 | 955 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
956 | 956 | $ignoreImport = true; |
957 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
957 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
958 | 958 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
959 | 959 | $ignoreImport = false; |
960 | 960 | } |
@@ -962,23 +962,23 @@ discard block |
||
962 | 962 | } |
963 | 963 | |
964 | 964 | if (!$ignoreImport) { |
965 | - if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
966 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
965 | + if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
966 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
967 | 967 | $timeelapsed = microtime(true); |
968 | 968 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
969 | 969 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
970 | 970 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
971 | 971 | $SpotterLive = new SpotterLive($this->db); |
972 | - $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
|
972 | + $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']); |
|
973 | 973 | $SpotterLive->db = null; |
974 | 974 | if ($globalDebug) echo $result."\n"; |
975 | 975 | } |
976 | 976 | } |
977 | 977 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
978 | - $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
|
978 | + $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']); |
|
979 | 979 | } |
980 | 980 | $this->all_flights[$id]['putinarchive'] = false; |
981 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
981 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
982 | 982 | |
983 | 983 | // Put statistics in $this->stats variable |
984 | 984 | //if ($line['format_source'] != 'aprs') { |
@@ -997,19 +997,19 @@ discard block |
||
997 | 997 | $latitude = $globalCenterLatitude; |
998 | 998 | $longitude = $globalCenterLongitude; |
999 | 999 | } |
1000 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
1000 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
1001 | 1001 | } else { |
1002 | 1002 | $latitude = $this->source_location[$source]['latitude']; |
1003 | 1003 | $longitude = $this->source_location[$source]['longitude']; |
1004 | 1004 | } |
1005 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
1005 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
1006 | 1006 | //$stats_heading = $stats_heading%22.5; |
1007 | 1007 | $stats_heading = round($stats_heading/22.5); |
1008 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
1008 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
1009 | 1009 | $current_date = date('Y-m-d'); |
1010 | 1010 | if ($stats_heading == 16) $stats_heading = 0; |
1011 | 1011 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
1012 | - for ($i=0;$i<=15;$i++) { |
|
1012 | + for ($i = 0; $i <= 15; $i++) { |
|
1013 | 1013 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
1014 | 1014 | } |
1015 | 1015 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -1024,9 +1024,9 @@ discard block |
||
1024 | 1024 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
1025 | 1025 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
1026 | 1026 | end($this->stats[$current_date][$source]['hist']); |
1027 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
1027 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
1028 | 1028 | } else $mini = 0; |
1029 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
1029 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
1030 | 1030 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
1031 | 1031 | } |
1032 | 1032 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -1039,7 +1039,7 @@ discard block |
||
1039 | 1039 | $this->all_flights[$id]['lastupdate'] = time(); |
1040 | 1040 | if ($this->all_flights[$id]['putinarchive']) $send = true; |
1041 | 1041 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
1042 | - } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1042 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
1043 | 1043 | //$this->del(); |
1044 | 1044 | |
1045 | 1045 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
@@ -52,7 +52,9 @@ discard block |
||
52 | 52 | try { |
53 | 53 | $GeoidClass = new GeoidHeight(); |
54 | 54 | } catch(Exception $e) { |
55 | - if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n"; |
|
55 | + if ($globalDebug) { |
|
56 | + echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n"; |
|
57 | + } |
|
56 | 58 | $GeoidClass = FALSE; |
57 | 59 | } |
58 | 60 | } |
@@ -71,7 +73,9 @@ discard block |
||
71 | 73 | $dbc = $this->db; |
72 | 74 | $this->all_flights[$id]['schedule_check'] = true; |
73 | 75 | if ($globalSchedulesFetch) { |
74 | - if ($globalDebug) echo 'Getting schedule info...'."\n"; |
|
76 | + if ($globalDebug) { |
|
77 | + echo 'Getting schedule info...'."\n"; |
|
78 | + } |
|
75 | 79 | $Spotter = new Spotter($dbc); |
76 | 80 | $Schedule = new Schedule($dbc); |
77 | 81 | $Translation = new Translation($dbc); |
@@ -82,7 +86,9 @@ discard block |
||
82 | 86 | if ($Schedule->checkSchedule($operator) == 0) { |
83 | 87 | $schedule = $Schedule->fetchSchedule($operator); |
84 | 88 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
85 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
89 | + if ($globalDebug) { |
|
90 | + echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
91 | + } |
|
86 | 92 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
87 | 93 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
88 | 94 | // Should also check if route schedule = route from DB |
@@ -91,7 +97,9 @@ discard block |
||
91 | 97 | $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
92 | 98 | if (trim($airport_icao) != '') { |
93 | 99 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
94 | - if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
100 | + if ($globalDebug) { |
|
101 | + echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
102 | + } |
|
95 | 103 | } |
96 | 104 | } |
97 | 105 | } |
@@ -100,17 +108,25 @@ discard block |
||
100 | 108 | $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
101 | 109 | if (trim($airport_icao) != '') { |
102 | 110 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
103 | - if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
111 | + if ($globalDebug) { |
|
112 | + echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
113 | + } |
|
104 | 114 | } |
105 | 115 | } |
106 | 116 | } |
107 | 117 | $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 | 118 | } |
109 | - } else $scheduleexist = true; |
|
110 | - } else $scheduleexist = true; |
|
119 | + } else { |
|
120 | + $scheduleexist = true; |
|
121 | + } |
|
122 | + } else { |
|
123 | + $scheduleexist = true; |
|
124 | + } |
|
111 | 125 | // close connection, at least one way will work ? |
112 | 126 | if ($scheduleexist) { |
113 | - if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
127 | + if ($globalDebug) { |
|
128 | + echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
129 | + } |
|
114 | 130 | $sch = $Schedule->getSchedule($operator); |
115 | 131 | $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 | 132 | } |
@@ -132,14 +148,18 @@ discard block |
||
132 | 148 | |
133 | 149 | public function checkAll() { |
134 | 150 | global $globalDebug, $globalNoImport; |
135 | - if ($globalDebug) echo "Update last seen flights data...\n"; |
|
151 | + if ($globalDebug) { |
|
152 | + echo "Update last seen flights data...\n"; |
|
153 | + } |
|
136 | 154 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
137 | 155 | foreach ($this->all_flights as $key => $flight) { |
138 | 156 | if (isset($this->all_flights[$key]['id'])) { |
139 | 157 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
140 | 158 | $Spotter = new Spotter($this->db); |
141 | 159 | $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']); |
|
160 | + if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) { |
|
161 | + $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']); |
|
162 | + } |
|
143 | 163 | } |
144 | 164 | } |
145 | 165 | } |
@@ -147,24 +167,32 @@ discard block |
||
147 | 167 | |
148 | 168 | public function arrival($key) { |
149 | 169 | global $globalClosestMinDist, $globalDebug; |
150 | - if ($globalDebug) echo 'Update arrival...'."\n"; |
|
170 | + if ($globalDebug) { |
|
171 | + echo 'Update arrival...'."\n"; |
|
172 | + } |
|
151 | 173 | $Spotter = new Spotter($this->db); |
152 | 174 | $airport_icao = ''; |
153 | 175 | $airport_time = ''; |
154 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
176 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') { |
|
177 | + $globalClosestMinDist = 50; |
|
178 | + } |
|
155 | 179 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
156 | 180 | $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
157 | 181 | if (isset($closestAirports[0])) { |
158 | 182 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
159 | 183 | $airport_icao = $closestAirports[0]['icao']; |
160 | 184 | $airport_time = $this->all_flights[$key]['datetime']; |
161 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
185 | + if ($globalDebug) { |
|
186 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
187 | + } |
|
162 | 188 | } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
163 | 189 | foreach ($closestAirports as $airport) { |
164 | 190 | if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
165 | 191 | $airport_icao = $airport['icao']; |
166 | 192 | $airport_time = $this->all_flights[$key]['datetime']; |
167 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
193 | + if ($globalDebug) { |
|
194 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
195 | + } |
|
168 | 196 | break; |
169 | 197 | } |
170 | 198 | } |
@@ -172,14 +200,20 @@ discard block |
||
172 | 200 | $airport_icao = $closestAirports[0]['icao']; |
173 | 201 | $airport_time = $this->all_flights[$key]['datetime']; |
174 | 202 | } else { |
175 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
203 | + if ($globalDebug) { |
|
204 | + echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
205 | + } |
|
176 | 206 | } |
177 | 207 | } 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"; |
|
208 | + if ($globalDebug) { |
|
209 | + echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
210 | + } |
|
179 | 211 | } |
180 | 212 | |
181 | 213 | } else { |
182 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
214 | + if ($globalDebug) { |
|
215 | + echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
216 | + } |
|
183 | 217 | } |
184 | 218 | return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
185 | 219 | } |
@@ -189,7 +223,9 @@ discard block |
||
189 | 223 | public function del() { |
190 | 224 | global $globalDebug, $globalNoImport, $globalNoDB; |
191 | 225 | // Delete old infos |
192 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
226 | + if ($globalDebug) { |
|
227 | + echo 'Delete old values and update latest data...'."\n"; |
|
228 | + } |
|
193 | 229 | foreach ($this->all_flights as $key => $flight) { |
194 | 230 | if (isset($flight['lastupdate'])) { |
195 | 231 | if ($flight['lastupdate'] < (time()-1800)) { |
@@ -203,13 +239,17 @@ discard block |
||
203 | 239 | global $globalDebug, $globalNoImport, $globalNoDB; |
204 | 240 | // Delete old infos |
205 | 241 | if (isset($this->all_flights[$key]['id'])) { |
206 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
242 | + if ($globalDebug) { |
|
243 | + echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
244 | + } |
|
207 | 245 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
208 | 246 | $real_arrival = $this->arrival($key); |
209 | 247 | $Spotter = new Spotter($this->db); |
210 | 248 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
211 | 249 | $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
212 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
250 | + if ($globalDebug && $result != 'success') { |
|
251 | + echo '!!! ERROR : '.$result."\n"; |
|
252 | + } |
|
213 | 253 | } |
214 | 254 | } |
215 | 255 | } |
@@ -219,9 +259,13 @@ discard block |
||
219 | 259 | public function add($line) { |
220 | 260 | 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 | 261 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
222 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.01'; |
|
223 | - if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') $globalAircraftMaxUpdate = 3000; |
|
224 | -/* |
|
262 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
263 | + $globalCoordMinChange = '0.01'; |
|
264 | + } |
|
265 | + if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') { |
|
266 | + $globalAircraftMaxUpdate = 3000; |
|
267 | + } |
|
268 | + /* |
|
225 | 269 | $Spotter = new Spotter(); |
226 | 270 | $dbc = $Spotter->db; |
227 | 271 | $SpotterLive = new SpotterLive($dbc); |
@@ -243,19 +287,28 @@ discard block |
||
243 | 287 | // SBS format is CSV format |
244 | 288 | if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
245 | 289 | //print_r($line); |
246 | - if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
290 | + if (isset($line['hex'])) { |
|
291 | + $line['hex'] = strtoupper($line['hex']); |
|
292 | + } |
|
247 | 293 | if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
248 | 294 | |
249 | 295 | // Increment message number |
250 | 296 | if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
251 | 297 | $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']; |
|
298 | + if (isset($line['source_name'])) { |
|
299 | + $source = $line['source_name']; |
|
300 | + } else { |
|
301 | + $source = ''; |
|
302 | + } |
|
303 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
304 | + $source = $line['format_source']; |
|
305 | + } |
|
255 | 306 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
256 | 307 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
257 | 308 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
258 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
309 | + } else { |
|
310 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
311 | + } |
|
259 | 312 | } |
260 | 313 | |
261 | 314 | /* |
@@ -271,23 +324,38 @@ discard block |
||
271 | 324 | //$this->db = $dbc; |
272 | 325 | |
273 | 326 | //$hex = trim($line['hex']); |
274 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
275 | - else $id = trim($line['id']); |
|
327 | + if (!isset($line['id'])) { |
|
328 | + $id = trim($line['hex']); |
|
329 | + } else { |
|
330 | + $id = trim($line['id']); |
|
331 | + } |
|
276 | 332 | |
277 | 333 | if (!isset($this->all_flights[$id])) { |
278 | - if ($globalDebug) echo 'New flight...'."\n"; |
|
334 | + if ($globalDebug) { |
|
335 | + echo 'New flight...'."\n"; |
|
336 | + } |
|
279 | 337 | $this->all_flights[$id] = array(); |
280 | 338 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
281 | 339 | $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())); |
|
340 | + if (isset($globalDaemon) && $globalDaemon === FALSE) { |
|
341 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
342 | + } |
|
283 | 343 | if (!isset($line['id'])) { |
284 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
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'))); |
|
344 | + if (!isset($globalDaemon)) { |
|
345 | + $globalDaemon = TRUE; |
|
346 | + } |
|
347 | + // 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 | 348 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
287 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
349 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
350 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
351 | + } |
|
288 | 352 | //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; |
|
353 | + } else { |
|
354 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
355 | + } |
|
356 | + if ($globalAllFlights !== FALSE) { |
|
357 | + $dataFound = true; |
|
358 | + } |
|
291 | 359 | } |
292 | 360 | if (isset($line['source_type']) && $line['source_type'] != '') { |
293 | 361 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
@@ -309,12 +377,20 @@ discard block |
||
309 | 377 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
310 | 378 | } |
311 | 379 | $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)); |
|
380 | + if ($globalDebugTimeElapsed) { |
|
381 | + echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
382 | + } |
|
383 | + if ($aircraft_icao != '') { |
|
384 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
385 | + } |
|
314 | 386 | } |
315 | 387 | } |
316 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
317 | - if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
388 | + if ($globalAllFlights !== FALSE) { |
|
389 | + $dataFound = true; |
|
390 | + } |
|
391 | + if ($globalDebug) { |
|
392 | + echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
393 | + } |
|
318 | 394 | } |
319 | 395 | if (isset($line['id']) && !isset($line['hex'])) { |
320 | 396 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
@@ -323,7 +399,9 @@ discard block |
||
323 | 399 | $icao = $line['aircraft_icao']; |
324 | 400 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
325 | 401 | $Spotter = new Spotter($this->db); |
326 | - if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
|
402 | + if (isset($Spotter->aircraft_correct_icaotype[$icao])) { |
|
403 | + $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
|
404 | + } |
|
327 | 405 | $Spotter->db = null; |
328 | 406 | } |
329 | 407 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao)); |
@@ -333,15 +411,24 @@ discard block |
||
333 | 411 | $Spotter = new Spotter($this->db); |
334 | 412 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
335 | 413 | $Spotter->db = null; |
336 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
414 | + if ($aircraft_icao != '') { |
|
415 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
416 | + } |
|
337 | 417 | } |
338 | 418 | } |
339 | 419 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
340 | - if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
341 | - elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
342 | - elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
343 | - elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
344 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
420 | + if ($line['aircraft_type'] == 'PARA_GLIDER') { |
|
421 | + $aircraft_icao = 'GLID'; |
|
422 | + } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') { |
|
423 | + $aircraft_icao = 'UHEL'; |
|
424 | + } elseif ($line['aircraft_type'] == 'TOW_PLANE') { |
|
425 | + $aircraft_icao = 'TOWPLANE'; |
|
426 | + } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') { |
|
427 | + $aircraft_icao = 'POWAIRC'; |
|
428 | + } |
|
429 | + if (isset($aircraft_icao)) { |
|
430 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
431 | + } |
|
345 | 432 | } |
346 | 433 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
347 | 434 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
@@ -351,8 +438,11 @@ discard block |
||
351 | 438 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
352 | 439 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
353 | 440 | } else { |
354 | - if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
355 | - 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"; |
|
441 | + if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
442 | + echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
443 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
444 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
445 | + } |
|
356 | 446 | /* |
357 | 447 | echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']); |
358 | 448 | print_r($this->all_flights[$id]); |
@@ -361,16 +451,22 @@ discard block |
||
361 | 451 | return ''; |
362 | 452 | } |
363 | 453 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
364 | - if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
454 | + if ($globalDebug) { |
|
455 | + echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
456 | + } |
|
365 | 457 | return ''; |
366 | 458 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
367 | - if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
459 | + if ($globalDebug) { |
|
460 | + echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
461 | + } |
|
368 | 462 | return ''; |
369 | 463 | } elseif (!isset($line['datetime'])) { |
370 | 464 | date_default_timezone_set('UTC'); |
371 | 465 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
372 | 466 | } else { |
373 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
467 | + if ($globalDebug) { |
|
468 | + echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
469 | + } |
|
374 | 470 | return ''; |
375 | 471 | } |
376 | 472 | |
@@ -391,30 +487,48 @@ discard block |
||
391 | 487 | |
392 | 488 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
393 | 489 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
394 | - if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
|
490 | + if ($globalDebug) { |
|
491 | + echo '---!!!! New ident, reset aircraft data...'."\n"; |
|
492 | + } |
|
395 | 493 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
396 | 494 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
397 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
398 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
399 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
495 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
496 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
497 | + } elseif (isset($line['id'])) { |
|
498 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
499 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
500 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
501 | + } |
|
400 | 502 | } else { |
401 | 503 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
402 | 504 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
403 | 505 | $timeelapsed = microtime(true); |
404 | 506 | $Spotter = new Spotter($this->db); |
405 | 507 | $fromsource = NULL; |
406 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
407 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
408 | - elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
409 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
410 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
508 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
509 | + $fromsource = $globalAirlinesSource; |
|
510 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') { |
|
511 | + $fromsource = 'vatsim'; |
|
512 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') { |
|
513 | + $fromsource = 'ivao'; |
|
514 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
515 | + $fromsource = 'vatsim'; |
|
516 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
517 | + $fromsource = 'ivao'; |
|
518 | + } |
|
411 | 519 | $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
412 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
520 | + if ($globalDebug && $result != 'success') { |
|
521 | + echo '!!! ERROR : '.$result."\n"; |
|
522 | + } |
|
413 | 523 | $Spotter->db = null; |
414 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
524 | + if ($globalDebugTimeElapsed) { |
|
525 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
526 | + } |
|
415 | 527 | } |
416 | 528 | } |
417 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
529 | + } else { |
|
530 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
531 | + } |
|
418 | 532 | |
419 | 533 | /* |
420 | 534 | if (!isset($line['id'])) { |
@@ -424,7 +538,9 @@ discard block |
||
424 | 538 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
425 | 539 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
426 | 540 | */ |
427 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
541 | + if (!isset($this->all_flights[$id]['id'])) { |
|
542 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
543 | + } |
|
428 | 544 | |
429 | 545 | //$putinarchive = true; |
430 | 546 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
@@ -442,7 +558,9 @@ discard block |
||
442 | 558 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
443 | 559 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
444 | 560 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
445 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
561 | + if ($globalDebugTimeElapsed) { |
|
562 | + echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
563 | + } |
|
446 | 564 | } |
447 | 565 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
448 | 566 | $timeelapsed = microtime(true); |
@@ -456,7 +574,9 @@ discard block |
||
456 | 574 | $Translation->db = null; |
457 | 575 | } |
458 | 576 | $Spotter->db = null; |
459 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
577 | + if ($globalDebugTimeElapsed) { |
|
578 | + echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
579 | + } |
|
460 | 580 | } |
461 | 581 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
462 | 582 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
@@ -465,9 +585,13 @@ discard block |
||
465 | 585 | $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 | 586 | } |
467 | 587 | } |
468 | - if (!isset($globalFork)) $globalFork = TRUE; |
|
588 | + if (!isset($globalFork)) { |
|
589 | + $globalFork = TRUE; |
|
590 | + } |
|
469 | 591 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
470 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
592 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) { |
|
593 | + $this->get_Schedule($id,trim($line['ident'])); |
|
594 | + } |
|
471 | 595 | } |
472 | 596 | } |
473 | 597 | } |
@@ -485,9 +609,13 @@ discard block |
||
485 | 609 | $speed = $speed*3.6; |
486 | 610 | if ($speed < 1000) { |
487 | 611 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
488 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
612 | + if ($globalDebug) { |
|
613 | + echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
614 | + } |
|
489 | 615 | } else { |
490 | - if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
616 | + if ($globalDebug) { |
|
617 | + echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
618 | + } |
|
491 | 619 | } |
492 | 620 | } |
493 | 621 | } |
@@ -496,13 +624,21 @@ discard block |
||
496 | 624 | |
497 | 625 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
498 | 626 | if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
499 | - if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
627 | + if ($globalDebug) { |
|
628 | + echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
629 | + } |
|
500 | 630 | return false; |
501 | 631 | } |
502 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
503 | - else unset($timediff); |
|
504 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
505 | - else unset($timediff_archive); |
|
632 | + if (isset($this->all_flights[$id]['time_last_coord'])) { |
|
633 | + $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
634 | + } else { |
|
635 | + unset($timediff); |
|
636 | + } |
|
637 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) { |
|
638 | + $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
639 | + } else { |
|
640 | + unset($timediff_archive); |
|
641 | + } |
|
506 | 642 | if ($this->tmd > 5 |
507 | 643 | || (isset($line['format_source']) |
508 | 644 | && $line['format_source'] == 'airwhere' |
@@ -539,16 +675,25 @@ discard block |
||
539 | 675 | $this->all_flights[$id]['putinarchive'] = true; |
540 | 676 | $this->tmd = 0; |
541 | 677 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
542 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
678 | + if ($globalDebug) { |
|
679 | + echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
680 | + } |
|
543 | 681 | $timeelapsed = microtime(true); |
544 | 682 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
545 | 683 | $Spotter = new Spotter($this->db); |
546 | 684 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
547 | - if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
548 | - else $this->all_flights[$id]['over_country'] = ''; |
|
685 | + if (!empty($all_country)) { |
|
686 | + $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
687 | + } else { |
|
688 | + $this->all_flights[$id]['over_country'] = ''; |
|
689 | + } |
|
549 | 690 | $Spotter->db = null; |
550 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
551 | - if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
691 | + if ($globalDebugTimeElapsed) { |
|
692 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
693 | + } |
|
694 | + if ($globalDebug) { |
|
695 | + echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
696 | + } |
|
552 | 697 | } |
553 | 698 | } |
554 | 699 | $this->all_flights[$id]['time_last_archive_coord'] = time(); |
@@ -594,7 +739,9 @@ discard block |
||
594 | 739 | */ |
595 | 740 | } |
596 | 741 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
597 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
742 | + if ($line['longitude'] > 180) { |
|
743 | + $line['longitude'] = $line['longitude'] - 360; |
|
744 | + } |
|
598 | 745 | //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) { |
599 | 746 | if (!isset($this->all_flights[$id]['archive_longitude'])) { |
600 | 747 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -631,7 +778,9 @@ discard block |
||
631 | 778 | } |
632 | 779 | } |
633 | 780 | if (isset($line['last_update']) && $line['last_update'] != '') { |
634 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
781 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) { |
|
782 | + $dataFound = true; |
|
783 | + } |
|
635 | 784 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
636 | 785 | } |
637 | 786 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
@@ -653,35 +802,53 @@ discard block |
||
653 | 802 | // Here we force archive of flight because after ground it's a new one (or should be) |
654 | 803 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
655 | 804 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
656 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
657 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
658 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
805 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
806 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
807 | + } elseif (isset($line['id'])) { |
|
808 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
809 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
810 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
811 | + } |
|
812 | + } |
|
813 | + if ($line['ground'] != 1) { |
|
814 | + $line['ground'] = 0; |
|
659 | 815 | } |
660 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
661 | 816 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
662 | 817 | //$dataFound = true; |
663 | 818 | } |
664 | 819 | if (isset($line['squawk']) && $line['squawk'] != '') { |
665 | 820 | if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
666 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
821 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) { |
|
822 | + $this->all_flights[$id]['putinarchive'] = true; |
|
823 | + } |
|
667 | 824 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
668 | 825 | $highlight = ''; |
669 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
670 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
671 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
826 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
827 | + $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
828 | + } |
|
829 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
830 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
831 | + } |
|
832 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
833 | + $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
834 | + } |
|
672 | 835 | if ($highlight != '') { |
673 | 836 | $timeelapsed = microtime(true); |
674 | 837 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
675 | 838 | $Spotter = new Spotter($this->db); |
676 | 839 | $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
677 | 840 | $Spotter->db = null; |
678 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
841 | + if ($globalDebugTimeElapsed) { |
|
842 | + echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
843 | + } |
|
679 | 844 | } |
680 | 845 | //$putinarchive = true; |
681 | 846 | //$highlight = ''; |
682 | 847 | } |
683 | 848 | |
684 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
849 | + } else { |
|
850 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
851 | + } |
|
685 | 852 | //$dataFound = true; |
686 | 853 | } |
687 | 854 | |
@@ -694,19 +861,27 @@ discard block |
||
694 | 861 | } |
695 | 862 | } |
696 | 863 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
697 | - if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
864 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) { |
|
865 | + $this->all_flights[$id]['putinarchive'] = true; |
|
866 | + } |
|
698 | 867 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
699 | 868 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
700 | 869 | //$dataFound = true; |
701 | 870 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
702 | 871 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
703 | 872 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
704 | - if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
|
873 | + if ($globalDebug) { |
|
874 | + echo '--- Reset because of altitude'."\n"; |
|
875 | + } |
|
705 | 876 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
706 | 877 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
707 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
708 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
709 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
878 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
879 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
880 | + } elseif (isset($line['id'])) { |
|
881 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
882 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
883 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
884 | + } |
|
710 | 885 | } |
711 | 886 | } |
712 | 887 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
@@ -717,22 +892,32 @@ discard block |
||
717 | 892 | } |
718 | 893 | |
719 | 894 | if (isset($line['heading']) && $line['heading'] != '') { |
720 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
895 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) { |
|
896 | + $this->all_flights[$id]['putinarchive'] = true; |
|
897 | + } |
|
721 | 898 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
722 | 899 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
723 | 900 | //$dataFound = true; |
724 | 901 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
725 | 902 | $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
726 | 903 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
727 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
728 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
904 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) { |
|
905 | + $this->all_flights[$id]['putinarchive'] = true; |
|
906 | + } |
|
907 | + if ($globalDebug) { |
|
908 | + echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
909 | + } |
|
729 | 910 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
730 | 911 | // If not enough messages and ACARS set heading to 0 |
731 | 912 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
732 | 913 | } |
733 | - if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
734 | - elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
735 | - elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false; |
|
914 | + if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) { |
|
915 | + $dataFound = false; |
|
916 | + } elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) { |
|
917 | + $dataFound = false; |
|
918 | + } elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) { |
|
919 | + $dataFound = false; |
|
920 | + } |
|
736 | 921 | |
737 | 922 | // print_r($this->all_flights[$id]); |
738 | 923 | //gets the callsign from the last hour |
@@ -749,23 +934,38 @@ discard block |
||
749 | 934 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
750 | 935 | if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
751 | 936 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
752 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
937 | + if ($globalDebug) { |
|
938 | + echo "Check if aircraft is already in DB..."; |
|
939 | + } |
|
753 | 940 | $timeelapsed = microtime(true); |
754 | 941 | $SpotterLive = new SpotterLive($this->db); |
755 | 942 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
756 | 943 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
757 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
944 | + if ($globalDebugTimeElapsed) { |
|
945 | + echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
946 | + } |
|
758 | 947 | } elseif (isset($line['id'])) { |
759 | 948 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
760 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
949 | + if ($globalDebugTimeElapsed) { |
|
950 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
951 | + } |
|
761 | 952 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
762 | 953 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
763 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
764 | - } else $recent_ident = ''; |
|
954 | + if ($globalDebugTimeElapsed) { |
|
955 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
956 | + } |
|
957 | + } else { |
|
958 | + $recent_ident = ''; |
|
959 | + } |
|
765 | 960 | $SpotterLive->db=null; |
766 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
767 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
768 | - } else $recent_ident = ''; |
|
961 | + if ($globalDebug && $recent_ident == '') { |
|
962 | + echo " Not in DB.\n"; |
|
963 | + } elseif ($globalDebug && $recent_ident != '') { |
|
964 | + echo " Already in DB.\n"; |
|
965 | + } |
|
966 | + } else { |
|
967 | + $recent_ident = ''; |
|
968 | + } |
|
769 | 969 | } else { |
770 | 970 | $recent_ident = ''; |
771 | 971 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
@@ -773,7 +973,9 @@ discard block |
||
773 | 973 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
774 | 974 | if($recent_ident == "") |
775 | 975 | { |
776 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
976 | + if ($globalDebug) { |
|
977 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
978 | + } |
|
777 | 979 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
778 | 980 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
779 | 981 | //adds the spotter data for the archive |
@@ -817,31 +1019,49 @@ discard block |
||
817 | 1019 | |
818 | 1020 | if (!$ignoreImport) { |
819 | 1021 | $highlight = ''; |
820 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
821 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
822 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
823 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
1022 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
1023 | + $highlight = 'Squawk 7500 : Hijack'; |
|
1024 | + } |
|
1025 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
1026 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
1027 | + } |
|
1028 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
1029 | + $highlight = 'Squawk 7700 : Emergency'; |
|
1030 | + } |
|
1031 | + if (!isset($this->all_flights[$id]['id'])) { |
|
1032 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
1033 | + } |
|
824 | 1034 | $timeelapsed = microtime(true); |
825 | 1035 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
826 | 1036 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
827 | 1037 | $Spotter = new Spotter($this->db); |
828 | 1038 | $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
829 | 1039 | $Spotter->db = null; |
830 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
1040 | + if ($globalDebug && isset($result)) { |
|
1041 | + echo $result."\n"; |
|
1042 | + } |
|
831 | 1043 | } |
832 | 1044 | } |
833 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1045 | + if ($globalDebugTimeElapsed) { |
|
1046 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1047 | + } |
|
834 | 1048 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
835 | 1049 | |
836 | 1050 | // Add source stat in DB |
837 | 1051 | $Stats = new Stats($this->db); |
838 | 1052 | if (!empty($this->stats)) { |
839 | - if ($globalDebug) echo 'Add source stats : '; |
|
1053 | + if ($globalDebug) { |
|
1054 | + echo 'Add source stats : '; |
|
1055 | + } |
|
840 | 1056 | foreach($this->stats as $date => $data) { |
841 | 1057 | foreach($data as $source => $sourced) { |
842 | 1058 | //print_r($sourced); |
843 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
844 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
1059 | + if (isset($sourced['polar'])) { |
|
1060 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
1061 | + } |
|
1062 | + if (isset($sourced['hist'])) { |
|
1063 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
1064 | + } |
|
845 | 1065 | if (isset($sourced['msg'])) { |
846 | 1066 | if (time() - $sourced['msg']['date'] > 10) { |
847 | 1067 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -854,13 +1074,17 @@ discard block |
||
854 | 1074 | unset($this->stats[$date]); |
855 | 1075 | } |
856 | 1076 | } |
857 | - if ($globalDebug) echo 'Done'."\n"; |
|
1077 | + if ($globalDebug) { |
|
1078 | + echo 'Done'."\n"; |
|
1079 | + } |
|
858 | 1080 | |
859 | 1081 | } |
860 | 1082 | $Stats->db = null; |
861 | 1083 | } |
862 | 1084 | $this->del(); |
863 | - } elseif ($globalDebug) echo 'Ignore data'."\n"; |
|
1085 | + } elseif ($globalDebug) { |
|
1086 | + echo 'Ignore data'."\n"; |
|
1087 | + } |
|
864 | 1088 | //$ignoreImport = false; |
865 | 1089 | $this->all_flights[$id]['addedSpotter'] = 1; |
866 | 1090 | //print_r($this->all_flights[$id]); |
@@ -877,7 +1101,9 @@ discard block |
||
877 | 1101 | */ |
878 | 1102 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
879 | 1103 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
880 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
1104 | + if ($globalDebug) { |
|
1105 | + echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
1106 | + } |
|
881 | 1107 | //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
882 | 1108 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
883 | 1109 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -886,7 +1112,9 @@ discard block |
||
886 | 1112 | $SpotterLive->db=null; |
887 | 1113 | } |
888 | 1114 | } |
889 | - if ($globalDebug) echo " Done\n"; |
|
1115 | + if ($globalDebug) { |
|
1116 | + echo " Done\n"; |
|
1117 | + } |
|
890 | 1118 | $this->last_delete = time(); |
891 | 1119 | } |
892 | 1120 | } else { |
@@ -913,11 +1141,17 @@ discard block |
||
913 | 1141 | //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"; |
914 | 1142 | if ($globalDebug) { |
915 | 1143 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
916 | - 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"; |
|
917 | - 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"; |
|
1144 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
1145 | + 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"; |
|
1146 | + } else { |
|
1147 | + 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"; |
|
1148 | + } |
|
918 | 1149 | } else { |
919 | - 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"; |
|
920 | - 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"; |
|
1150 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
1151 | + 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"; |
|
1152 | + } else { |
|
1153 | + 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"; |
|
1154 | + } |
|
921 | 1155 | } |
922 | 1156 | } |
923 | 1157 | $ignoreImport = false; |
@@ -963,22 +1197,30 @@ discard block |
||
963 | 1197 | |
964 | 1198 | if (!$ignoreImport) { |
965 | 1199 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
966 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
1200 | + if (!isset($this->all_flights[$id]['id'])) { |
|
1201 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
1202 | + } |
|
967 | 1203 | $timeelapsed = microtime(true); |
968 | 1204 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
969 | 1205 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
970 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
1206 | + if ($globalDebug) { |
|
1207 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
1208 | + } |
|
971 | 1209 | $SpotterLive = new SpotterLive($this->db); |
972 | 1210 | $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
973 | 1211 | $SpotterLive->db = null; |
974 | - if ($globalDebug) echo $result."\n"; |
|
1212 | + if ($globalDebug) { |
|
1213 | + echo $result."\n"; |
|
1214 | + } |
|
975 | 1215 | } |
976 | 1216 | } |
977 | 1217 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
978 | 1218 | $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
979 | 1219 | } |
980 | 1220 | $this->all_flights[$id]['putinarchive'] = false; |
981 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1221 | + if ($globalDebugTimeElapsed) { |
|
1222 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1223 | + } |
|
982 | 1224 | |
983 | 1225 | // Put statistics in $this->stats variable |
984 | 1226 | //if ($line['format_source'] != 'aprs') { |
@@ -986,7 +1228,9 @@ discard block |
||
986 | 1228 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
987 | 1229 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
988 | 1230 | $source = $this->all_flights[$id]['source_name']; |
989 | - if ($source == '') $source = $this->all_flights[$id]['format_source']; |
|
1231 | + if ($source == '') { |
|
1232 | + $source = $this->all_flights[$id]['format_source']; |
|
1233 | + } |
|
990 | 1234 | if (!isset($this->source_location[$source])) { |
991 | 1235 | $Location = new Source($this->db); |
992 | 1236 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -1007,7 +1251,9 @@ discard block |
||
1007 | 1251 | $stats_heading = round($stats_heading/22.5); |
1008 | 1252 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
1009 | 1253 | $current_date = date('Y-m-d'); |
1010 | - if ($stats_heading == 16) $stats_heading = 0; |
|
1254 | + if ($stats_heading == 16) { |
|
1255 | + $stats_heading = 0; |
|
1256 | + } |
|
1011 | 1257 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
1012 | 1258 | for ($i=0;$i<=15;$i++) { |
1013 | 1259 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -1025,7 +1271,9 @@ discard block |
||
1025 | 1271 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
1026 | 1272 | end($this->stats[$current_date][$source]['hist']); |
1027 | 1273 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
1028 | - } else $mini = 0; |
|
1274 | + } else { |
|
1275 | + $mini = 0; |
|
1276 | + } |
|
1029 | 1277 | for ($i=$mini;$i<=$distance;$i+=10) { |
1030 | 1278 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
1031 | 1279 | } |
@@ -1037,19 +1285,27 @@ discard block |
||
1037 | 1285 | } |
1038 | 1286 | |
1039 | 1287 | $this->all_flights[$id]['lastupdate'] = time(); |
1040 | - if ($this->all_flights[$id]['putinarchive']) $send = true; |
|
1288 | + if ($this->all_flights[$id]['putinarchive']) { |
|
1289 | + $send = true; |
|
1290 | + } |
|
1041 | 1291 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
1042 | - } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1292 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
1293 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1294 | + } |
|
1043 | 1295 | //$this->del(); |
1044 | 1296 | |
1045 | 1297 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
1046 | 1298 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
1047 | - if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
1299 | + if ($globalDebug) { |
|
1300 | + echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
1301 | + } |
|
1048 | 1302 | $SpotterLive = new SpotterLive($this->db); |
1049 | 1303 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
1050 | 1304 | $SpotterLive->db = null; |
1051 | 1305 | //SpotterLive->deleteLiveSpotterData(); |
1052 | - if ($globalDebug) echo " Done\n"; |
|
1306 | + if ($globalDebug) { |
|
1307 | + echo " Done\n"; |
|
1308 | + } |
|
1053 | 1309 | $this->last_delete_hourly = time(); |
1054 | 1310 | } else { |
1055 | 1311 | $this->del(); |
@@ -1061,7 +1317,9 @@ discard block |
||
1061 | 1317 | //$ignoreImport = false; |
1062 | 1318 | } |
1063 | 1319 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
1064 | - if ($send) return $this->all_flights[$id]; |
|
1320 | + if ($send) { |
|
1321 | + return $this->all_flights[$id]; |
|
1322 | + } |
|
1065 | 1323 | } |
1066 | 1324 | } |
1067 | 1325 | } |
@@ -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,41 +149,41 @@ 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('/aircraft.json$/i',$host)) { |
|
177 | - //$formats[$id] = 'aircraftjson'; |
|
178 | - $globalSources[$id]['format'] = 'aircraftjson'; |
|
179 | - //$last_exec['aircraftlistjson'] = 0; |
|
180 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
181 | - } else if (preg_match('/opensky/i',$host)) { |
|
182 | - //$formats[$id] = 'aircraftlistjson'; |
|
183 | - $globalSources[$id]['format'] = 'opensky'; |
|
184 | - //$last_exec['aircraftlistjson'] = 0; |
|
185 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
186 | - /* |
|
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('/aircraft.json$/i',$host)) { |
|
177 | + //$formats[$id] = 'aircraftjson'; |
|
178 | + $globalSources[$id]['format'] = 'aircraftjson'; |
|
179 | + //$last_exec['aircraftlistjson'] = 0; |
|
180 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
181 | + } else if (preg_match('/opensky/i',$host)) { |
|
182 | + //$formats[$id] = 'aircraftlistjson'; |
|
183 | + $globalSources[$id]['format'] = 'opensky'; |
|
184 | + //$last_exec['aircraftlistjson'] = 0; |
|
185 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
186 | + /* |
|
187 | 187 | // Disabled for now, site change source format |
188 | 188 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
189 | 189 | //$formats[$id] = 'radarvirtueljson'; |
@@ -195,125 +195,125 @@ discard block |
||
195 | 195 | exit(0); |
196 | 196 | } |
197 | 197 | */ |
198 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
199 | - //$formats[$id] = 'planeupdatefaa'; |
|
200 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
201 | - //$last_exec['planeupdatefaa'] = 0; |
|
202 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
203 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
204 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
205 | - exit(0); |
|
206 | - } |
|
207 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
208 | - //$formats[$id] = 'phpvmacars'; |
|
209 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
210 | - //$last_exec['phpvmacars'] = 0; |
|
211 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
212 | - } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
213 | - //$formats[$id] = 'phpvmacars'; |
|
214 | - $globalSources[$id]['format'] = 'vaos'; |
|
215 | - //$last_exec['phpvmacars'] = 0; |
|
216 | - if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
217 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
218 | - //$formats[$id] = 'phpvmacars'; |
|
219 | - $globalSources[$id]['format'] = 'vam'; |
|
220 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
221 | - } else if (preg_match('/whazzup/i',$host)) { |
|
222 | - //$formats[$id] = 'whazzup'; |
|
223 | - $globalSources[$id]['format'] = 'whazzup'; |
|
224 | - //$last_exec['whazzup'] = 0; |
|
225 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
226 | - } else if (preg_match('/blitzortung/i',$host)) { |
|
227 | - $globalSources[$id]['format'] = 'blitzortung'; |
|
228 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
229 | - } else if (preg_match('/airwhere/i',$host)) { |
|
230 | - $globalSources[$id]['format'] = 'airwhere'; |
|
231 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
232 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
233 | - //$formats[$id] = 'pirepsjson'; |
|
234 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
235 | - //$last_exec['pirepsjson'] = 0; |
|
236 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
237 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
238 | - //$formats[$id] = 'fr24json'; |
|
239 | - $globalSources[$id]['format'] = 'fr24json'; |
|
240 | - //$last_exec['fr24json'] = 0; |
|
241 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
242 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
243 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
244 | - exit(0); |
|
245 | - } |
|
246 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
247 | - //$formats[$id] = 'fr24json'; |
|
248 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
249 | - //$last_exec['fr24json'] = 0; |
|
250 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
251 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
252 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
253 | - exit(0); |
|
254 | - } |
|
255 | - //} else if (preg_match('/10001/',$host)) { |
|
256 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
257 | - //$formats[$id] = 'tsv'; |
|
258 | - $globalSources[$id]['format'] = 'tsv'; |
|
259 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
260 | - } |
|
261 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
262 | - if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
263 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
264 | - if ($idf !== false) { |
|
265 | - $httpfeeds[$id] = $idf; |
|
266 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
267 | - } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
268 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
269 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
270 | - $hostport = explode(':',$host); |
|
271 | - if (isset($hostport[1])) { |
|
198 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
199 | + //$formats[$id] = 'planeupdatefaa'; |
|
200 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
201 | + //$last_exec['planeupdatefaa'] = 0; |
|
202 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
203 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
204 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
205 | + exit(0); |
|
206 | + } |
|
207 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
208 | + //$formats[$id] = 'phpvmacars'; |
|
209 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
210 | + //$last_exec['phpvmacars'] = 0; |
|
211 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
212 | + } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
213 | + //$formats[$id] = 'phpvmacars'; |
|
214 | + $globalSources[$id]['format'] = 'vaos'; |
|
215 | + //$last_exec['phpvmacars'] = 0; |
|
216 | + if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
217 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
218 | + //$formats[$id] = 'phpvmacars'; |
|
219 | + $globalSources[$id]['format'] = 'vam'; |
|
220 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
221 | + } else if (preg_match('/whazzup/i',$host)) { |
|
222 | + //$formats[$id] = 'whazzup'; |
|
223 | + $globalSources[$id]['format'] = 'whazzup'; |
|
224 | + //$last_exec['whazzup'] = 0; |
|
225 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
226 | + } else if (preg_match('/blitzortung/i',$host)) { |
|
227 | + $globalSources[$id]['format'] = 'blitzortung'; |
|
228 | + if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
229 | + } else if (preg_match('/airwhere/i',$host)) { |
|
230 | + $globalSources[$id]['format'] = 'airwhere'; |
|
231 | + if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
232 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
233 | + //$formats[$id] = 'pirepsjson'; |
|
234 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
235 | + //$last_exec['pirepsjson'] = 0; |
|
236 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
237 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
238 | + //$formats[$id] = 'fr24json'; |
|
239 | + $globalSources[$id]['format'] = 'fr24json'; |
|
240 | + //$last_exec['fr24json'] = 0; |
|
241 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
242 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
243 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
244 | + exit(0); |
|
245 | + } |
|
246 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
247 | + //$formats[$id] = 'fr24json'; |
|
248 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
249 | + //$last_exec['fr24json'] = 0; |
|
250 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
251 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
252 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
253 | + exit(0); |
|
254 | + } |
|
255 | + //} else if (preg_match('/10001/',$host)) { |
|
256 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
257 | + //$formats[$id] = 'tsv'; |
|
258 | + $globalSources[$id]['format'] = 'tsv'; |
|
259 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
260 | + } |
|
261 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
262 | + if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
263 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
264 | + if ($idf !== false) { |
|
265 | + $httpfeeds[$id] = $idf; |
|
266 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
267 | + } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
268 | + } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
269 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
270 | + $hostport = explode(':',$host); |
|
271 | + if (isset($hostport[1])) { |
|
272 | 272 | $port = $hostport[1]; |
273 | 273 | $hostn = $hostport[0]; |
274 | - } else { |
|
274 | + } else { |
|
275 | 275 | $port = $globalSources[$id]['port']; |
276 | 276 | $hostn = $globalSources[$id]['host']; |
277 | - } |
|
278 | - $Common = new Common(); |
|
279 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
280 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
281 | - } else { |
|
282 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
283 | - } |
|
284 | - if ($s) { |
|
285 | - $sockets[$id] = $s; |
|
286 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
287 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
277 | + } |
|
278 | + $Common = new Common(); |
|
279 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
280 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
281 | + } else { |
|
282 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
283 | + } |
|
284 | + if ($s) { |
|
285 | + $sockets[$id] = $s; |
|
286 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
287 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
288 | 288 | //$formats[$id] = 'aprs'; |
289 | 289 | $globalSources[$id]['format'] = 'aprs'; |
290 | 290 | //$aprs_connect = 0; |
291 | 291 | //$use_aprs = true; |
292 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
292 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
293 | 293 | $globalSources[$id]['format'] = 'vrstcp'; |
294 | - } elseif ($port == '10001') { |
|
295 | - //$formats[$id] = 'tsv'; |
|
296 | - $globalSources[$id]['format'] = 'tsv'; |
|
297 | - } elseif ($port == '30002') { |
|
298 | - //$formats[$id] = 'raw'; |
|
299 | - $globalSources[$id]['format'] = 'raw'; |
|
300 | - } elseif ($port == '5001') { |
|
301 | - //$formats[$id] = 'raw'; |
|
302 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
303 | - } elseif ($port == '30005') { |
|
294 | + } elseif ($port == '10001') { |
|
295 | + //$formats[$id] = 'tsv'; |
|
296 | + $globalSources[$id]['format'] = 'tsv'; |
|
297 | + } elseif ($port == '30002') { |
|
298 | + //$formats[$id] = 'raw'; |
|
299 | + $globalSources[$id]['format'] = 'raw'; |
|
300 | + } elseif ($port == '5001') { |
|
301 | + //$formats[$id] = 'raw'; |
|
302 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
303 | + } elseif ($port == '30005') { |
|
304 | 304 | // Not yet supported |
305 | - //$formats[$id] = 'beast'; |
|
306 | - $globalSources[$id]['format'] = 'beast'; |
|
307 | - //} else $formats[$id] = 'sbs'; |
|
308 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
309 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
305 | + //$formats[$id] = 'beast'; |
|
306 | + $globalSources[$id]['format'] = 'beast'; |
|
307 | + //} else $formats[$id] = 'sbs'; |
|
308 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
309 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
310 | 310 | } |
311 | 311 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
312 | - } else { |
|
312 | + } else { |
|
313 | 313 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
314 | - } |
|
315 | - } |
|
316 | - } |
|
314 | + } |
|
315 | + } |
|
316 | + } |
|
317 | 317 | } |
318 | 318 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
319 | 319 | |
@@ -336,9 +336,9 @@ discard block |
||
336 | 336 | //connect_all($globalSources); |
337 | 337 | |
338 | 338 | if (isset($globalProxy) && $globalProxy) { |
339 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
339 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
340 | 340 | } else { |
341 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
341 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | // APRS Configuration |
@@ -347,21 +347,21 @@ discard block |
||
347 | 347 | die; |
348 | 348 | } |
349 | 349 | foreach ($globalSources as $key => $source) { |
350 | - if (!isset($source['format'])) { |
|
351 | - $globalSources[$key]['format'] = 'auto'; |
|
352 | - } |
|
353 | - if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
354 | - unset($globalSources[$key]); |
|
355 | - } |
|
350 | + if (!isset($source['format'])) { |
|
351 | + $globalSources[$key]['format'] = 'auto'; |
|
352 | + } |
|
353 | + if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
354 | + unset($globalSources[$key]); |
|
355 | + } |
|
356 | 356 | } |
357 | 357 | connect_all($globalSources); |
358 | 358 | foreach ($globalSources as $key => $source) { |
359 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
359 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
360 | 360 | $aprs_connect = 0; |
361 | 361 | $use_aprs = true; |
362 | 362 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
363 | 363 | break; |
364 | - } |
|
364 | + } |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | if ($use_aprs) { |
@@ -402,133 +402,133 @@ discard block |
||
402 | 402 | |
403 | 403 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
404 | 404 | while ($i > 0) { |
405 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
405 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
406 | 406 | |
407 | - if (!$globalDaemon) $i = $endtime-time(); |
|
408 | - // Delete old ATC |
|
409 | - if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
407 | + if (!$globalDaemon) $i = $endtime-time(); |
|
408 | + // Delete old ATC |
|
409 | + if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
410 | 410 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
411 | - $ATC->deleteOldATC(); |
|
412 | - } |
|
411 | + $ATC->deleteOldATC(); |
|
412 | + } |
|
413 | 413 | |
414 | - if (count($last_exec) == count($globalSources)) { |
|
414 | + if (count($last_exec) == count($globalSources)) { |
|
415 | 415 | $max = $globalMinFetch; |
416 | 416 | foreach ($last_exec as $last) { |
417 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
417 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
418 | 418 | } |
419 | 419 | if ($max < $globalMinFetch) { |
420 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
421 | - sleep($globalMinFetch-$max+2); |
|
420 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
421 | + sleep($globalMinFetch-$max+2); |
|
422 | + } |
|
422 | 423 | } |
423 | - } |
|
424 | 424 | |
425 | 425 | |
426 | - //foreach ($formats as $id => $value) { |
|
427 | - foreach ($globalSources as $id => $value) { |
|
426 | + //foreach ($formats as $id => $value) { |
|
427 | + foreach ($globalSources as $id => $value) { |
|
428 | 428 | date_default_timezone_set('UTC'); |
429 | 429 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
430 | 430 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
431 | 431 | if ($value['format'] === 'deltadbtxt' && |
432 | - ( |
|
432 | + ( |
|
433 | 433 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
434 | 434 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
435 | - ) |
|
435 | + ) |
|
436 | 436 | ) { |
437 | - //$buffer = $Common->getData($hosts[$id]); |
|
438 | - $buffer = $Common->getData($value['host']); |
|
439 | - if ($buffer != '') $reset = 0; |
|
440 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
441 | - $buffer = explode('\n',$buffer); |
|
442 | - foreach ($buffer as $line) { |
|
443 | - if ($line != '' && count($line) > 7) { |
|
444 | - $line = explode(',', $line); |
|
445 | - $data = array(); |
|
446 | - $data['hex'] = $line[1]; // hex |
|
447 | - $data['ident'] = $line[2]; // ident |
|
448 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
449 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
450 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
451 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
452 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
453 | - $data['verticalrate'] = ''; // vertical rate |
|
454 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
455 | - $data['emergency'] = ''; // emergency |
|
456 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
457 | - $data['format_source'] = 'deltadbtxt'; |
|
458 | - $data['id_source'] = $id_source; |
|
459 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
460 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
461 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
462 | - $SI->add($data); |
|
463 | - unset($data); |
|
464 | - } |
|
465 | - } |
|
466 | - $last_exec[$id]['last'] = time(); |
|
437 | + //$buffer = $Common->getData($hosts[$id]); |
|
438 | + $buffer = $Common->getData($value['host']); |
|
439 | + if ($buffer != '') $reset = 0; |
|
440 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
441 | + $buffer = explode('\n',$buffer); |
|
442 | + foreach ($buffer as $line) { |
|
443 | + if ($line != '' && count($line) > 7) { |
|
444 | + $line = explode(',', $line); |
|
445 | + $data = array(); |
|
446 | + $data['hex'] = $line[1]; // hex |
|
447 | + $data['ident'] = $line[2]; // ident |
|
448 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
449 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
450 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
451 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
452 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
453 | + $data['verticalrate'] = ''; // vertical rate |
|
454 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
455 | + $data['emergency'] = ''; // emergency |
|
456 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
457 | + $data['format_source'] = 'deltadbtxt'; |
|
458 | + $data['id_source'] = $id_source; |
|
459 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
460 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
461 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
462 | + $SI->add($data); |
|
463 | + unset($data); |
|
464 | + } |
|
465 | + } |
|
466 | + $last_exec[$id]['last'] = time(); |
|
467 | 467 | } elseif ($value['format'] === 'aisnmeatxt' && |
468 | - ( |
|
468 | + ( |
|
469 | 469 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
470 | 470 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
471 | - ) |
|
471 | + ) |
|
472 | 472 | ) { |
473 | - date_default_timezone_set('CET'); |
|
474 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
475 | - date_default_timezone_set('UTC'); |
|
476 | - if ($buffer != '') $reset = 0; |
|
477 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
478 | - $buffer = explode('\n',$buffer); |
|
479 | - foreach ($buffer as $line) { |
|
473 | + date_default_timezone_set('CET'); |
|
474 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
475 | + date_default_timezone_set('UTC'); |
|
476 | + if ($buffer != '') $reset = 0; |
|
477 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
478 | + $buffer = explode('\n',$buffer); |
|
479 | + foreach ($buffer as $line) { |
|
480 | 480 | if ($line != '') { |
481 | - //echo "'".$line."'\n"; |
|
482 | - $add = false; |
|
483 | - $ais_data = $AIS->parse_line(trim($line)); |
|
484 | - $data = array(); |
|
485 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
486 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
487 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
488 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
489 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
490 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
491 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
492 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
493 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
494 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
495 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
496 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
497 | - if (isset($ais_data['timestamp'])) { |
|
481 | + //echo "'".$line."'\n"; |
|
482 | + $add = false; |
|
483 | + $ais_data = $AIS->parse_line(trim($line)); |
|
484 | + $data = array(); |
|
485 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
486 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
487 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
488 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
489 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
490 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
491 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
492 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
493 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
494 | + if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
495 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
496 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
497 | + if (isset($ais_data['timestamp'])) { |
|
498 | 498 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
499 | 499 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
500 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
501 | - $add = true; |
|
500 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
501 | + $add = true; |
|
502 | 502 | } |
503 | - } else { |
|
503 | + } else { |
|
504 | 504 | $data['datetime'] = date('Y-m-d H:i:s'); |
505 | 505 | $add = true; |
506 | - } |
|
507 | - $data['format_source'] = 'aisnmeatxt'; |
|
508 | - $data['id_source'] = $id_source; |
|
509 | - //print_r($data); |
|
510 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
511 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
512 | - unset($data); |
|
506 | + } |
|
507 | + $data['format_source'] = 'aisnmeatxt'; |
|
508 | + $data['id_source'] = $id_source; |
|
509 | + //print_r($data); |
|
510 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
511 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
512 | + unset($data); |
|
513 | 513 | } |
514 | - } |
|
515 | - $last_exec[$id]['last'] = time(); |
|
514 | + } |
|
515 | + $last_exec[$id]['last'] = time(); |
|
516 | 516 | } elseif ($value['format'] === 'aisnmeahttp') { |
517 | - $arr = $httpfeeds; |
|
518 | - $w = $e = null; |
|
517 | + $arr = $httpfeeds; |
|
518 | + $w = $e = null; |
|
519 | 519 | |
520 | - if (isset($arr[$id])) { |
|
520 | + if (isset($arr[$id])) { |
|
521 | 521 | $nn = stream_select($arr,$w,$e,$timeout); |
522 | 522 | if ($nn > 0) { |
523 | - foreach ($httpfeeds as $feed) { |
|
523 | + foreach ($httpfeeds as $feed) { |
|
524 | 524 | $buffer = stream_get_line($feed,2000,"\n"); |
525 | 525 | if ($buffer === FALSE) { |
526 | - connect_all($globalSources); |
|
526 | + connect_all($globalSources); |
|
527 | 527 | } |
528 | 528 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
529 | 529 | $buffer = explode('\n',$buffer); |
530 | 530 | foreach ($buffer as $line) { |
531 | - if ($line != '') { |
|
531 | + if ($line != '') { |
|
532 | 532 | $ais_data = $AIS->parse_line(trim($line)); |
533 | 533 | $data = array(); |
534 | 534 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
@@ -546,117 +546,117 @@ discard block |
||
546 | 546 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
547 | 547 | if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
548 | 548 | if (isset($ais_data['timestamp'])) { |
549 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
549 | + $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
550 | 550 | } else { |
551 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
551 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
552 | 552 | } |
553 | 553 | $data['format_source'] = 'aisnmeahttp'; |
554 | 554 | $data['id_source'] = $id_source; |
555 | 555 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
556 | 556 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
557 | 557 | unset($data); |
558 | - } |
|
558 | + } |
|
559 | + } |
|
559 | 560 | } |
560 | - } |
|
561 | 561 | } else { |
562 | - $format = $value['format']; |
|
563 | - if (isset($tt[$format])) $tt[$format]++; |
|
564 | - else $tt[$format] = 0; |
|
565 | - if ($tt[$format] > 30) { |
|
562 | + $format = $value['format']; |
|
563 | + if (isset($tt[$format])) $tt[$format]++; |
|
564 | + else $tt[$format] = 0; |
|
565 | + if ($tt[$format] > 30) { |
|
566 | 566 | if ($globalDebug) echo 'Reconnect...'."\n"; |
567 | 567 | sleep(2); |
568 | 568 | //$sourceeen[] = $value; |
569 | 569 | //connect_all($sourceeen); |
570 | 570 | //$sourceeen = array(); |
571 | 571 | connect_all($globalSources); |
572 | - } |
|
572 | + } |
|
573 | + } |
|
573 | 574 | } |
574 | - } |
|
575 | 575 | } elseif ($value['format'] === 'myshiptracking' && |
576 | - ( |
|
576 | + ( |
|
577 | 577 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
578 | 578 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
579 | - ) |
|
579 | + ) |
|
580 | 580 | ) { |
581 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
582 | - if ($buffer != '') { |
|
581 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
582 | + if ($buffer != '') { |
|
583 | 583 | //echo $buffer; |
584 | 584 | $all_data = json_decode($buffer,true); |
585 | 585 | //print_r($all_data); |
586 | 586 | if (isset($all_data[0]['DATA'])) { |
587 | - foreach ($all_data[0]['DATA'] as $line) { |
|
587 | + foreach ($all_data[0]['DATA'] as $line) { |
|
588 | 588 | if ($line != '') { |
589 | - $data = array(); |
|
590 | - $data['ident'] = $line['NAME']; |
|
591 | - $data['mmsi'] = $line['MMSI']; |
|
592 | - if (strlen($data['mmsi']) > 9) { |
|
589 | + $data = array(); |
|
590 | + $data['ident'] = $line['NAME']; |
|
591 | + $data['mmsi'] = $line['MMSI']; |
|
592 | + if (strlen($data['mmsi']) > 9) { |
|
593 | 593 | $data['mmsi'] = substr($data['mmsi'],-9); |
594 | - } |
|
595 | - $data['speed'] = $line['SOG']; |
|
596 | - $data['heading'] = $line['COG']; |
|
597 | - $data['latitude'] = $line['LAT']; |
|
598 | - $data['longitude'] = $line['LNG']; |
|
599 | - // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
600 | - //$data['type_id'] = $line['TYPE']; |
|
601 | - $data['imo'] = $line['IMO']; |
|
602 | - if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
603 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
604 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
605 | - $data['format_source'] = 'myshiptracking'; |
|
606 | - $data['id_source'] = $id_source; |
|
607 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
608 | - $MI->add($data); |
|
609 | - unset($data); |
|
594 | + } |
|
595 | + $data['speed'] = $line['SOG']; |
|
596 | + $data['heading'] = $line['COG']; |
|
597 | + $data['latitude'] = $line['LAT']; |
|
598 | + $data['longitude'] = $line['LNG']; |
|
599 | + // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
600 | + //$data['type_id'] = $line['TYPE']; |
|
601 | + $data['imo'] = $line['IMO']; |
|
602 | + if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
603 | + if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
604 | + $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
605 | + $data['format_source'] = 'myshiptracking'; |
|
606 | + $data['id_source'] = $id_source; |
|
607 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
608 | + $MI->add($data); |
|
609 | + unset($data); |
|
610 | 610 | } |
611 | - } |
|
611 | + } |
|
612 | + } |
|
612 | 613 | } |
613 | - } |
|
614 | - $last_exec[$id]['last'] = time(); |
|
614 | + $last_exec[$id]['last'] = time(); |
|
615 | 615 | } elseif ($value['format'] === 'boatbeaconapp' && |
616 | - ( |
|
616 | + ( |
|
617 | 617 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
618 | 618 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
619 | - ) |
|
619 | + ) |
|
620 | 620 | ) { |
621 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
622 | - if ($buffer != '') { |
|
621 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
622 | + if ($buffer != '') { |
|
623 | 623 | $all_data = json_decode($buffer,true); |
624 | 624 | if (isset($all_data[0]['mmsi'])) { |
625 | - foreach ($all_data as $line) { |
|
625 | + foreach ($all_data as $line) { |
|
626 | 626 | if ($line != '') { |
627 | - $data = array(); |
|
628 | - $data['ident'] = $line['shipname']; |
|
629 | - $data['callsign'] = $line['callsign']; |
|
630 | - $data['mmsi'] = substr($line['mmsi'],-9); |
|
631 | - $data['speed'] = $line['sog']; |
|
632 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
633 | - $data['latitude'] = $line['latitude']; |
|
634 | - $data['longitude'] = $line['longitude']; |
|
635 | - $data['type_id'] = $line['shiptype']; |
|
636 | - $data['arrival_code'] = $line['destination']; |
|
637 | - $data['datetime'] = $line['time']; |
|
638 | - $data['format_source'] = 'boatbeaconapp'; |
|
639 | - $data['id_source'] = $id_source; |
|
640 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
641 | - $MI->add($data); |
|
642 | - unset($data); |
|
627 | + $data = array(); |
|
628 | + $data['ident'] = $line['shipname']; |
|
629 | + $data['callsign'] = $line['callsign']; |
|
630 | + $data['mmsi'] = substr($line['mmsi'],-9); |
|
631 | + $data['speed'] = $line['sog']; |
|
632 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
633 | + $data['latitude'] = $line['latitude']; |
|
634 | + $data['longitude'] = $line['longitude']; |
|
635 | + $data['type_id'] = $line['shiptype']; |
|
636 | + $data['arrival_code'] = $line['destination']; |
|
637 | + $data['datetime'] = $line['time']; |
|
638 | + $data['format_source'] = 'boatbeaconapp'; |
|
639 | + $data['id_source'] = $id_source; |
|
640 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
641 | + $MI->add($data); |
|
642 | + unset($data); |
|
643 | + } |
|
643 | 644 | } |
644 | - } |
|
645 | 645 | } |
646 | 646 | |
647 | - } |
|
648 | - $last_exec[$id]['last'] = time(); |
|
647 | + } |
|
648 | + $last_exec[$id]['last'] = time(); |
|
649 | 649 | } elseif ($value['format'] === 'boatnerd' && |
650 | - ( |
|
650 | + ( |
|
651 | 651 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
652 | 652 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
653 | - ) |
|
653 | + ) |
|
654 | 654 | ) { |
655 | - $buffer = $Common->getData($value['host']); |
|
656 | - if ($buffer != '') { |
|
655 | + $buffer = $Common->getData($value['host']); |
|
656 | + if ($buffer != '') { |
|
657 | 657 | $all_data = json_decode($buffer,true); |
658 | 658 | if (isset($all_data['features'][0]['id'])) { |
659 | - foreach ($all_data['features'] as $line) { |
|
659 | + foreach ($all_data['features'] as $line) { |
|
660 | 660 | print_r($line); |
661 | 661 | $data = array(); |
662 | 662 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
@@ -676,80 +676,80 @@ discard block |
||
676 | 676 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
677 | 677 | if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
678 | 678 | unset($data); |
679 | - } |
|
679 | + } |
|
680 | 680 | } |
681 | 681 | |
682 | - } |
|
683 | - $last_exec[$id]['last'] = time(); |
|
682 | + } |
|
683 | + $last_exec[$id]['last'] = time(); |
|
684 | 684 | } elseif ($value['format'] === 'shipplotter' && |
685 | - ( |
|
685 | + ( |
|
686 | 686 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
687 | 687 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
688 | - ) |
|
688 | + ) |
|
689 | 689 | ) { |
690 | - echo 'download...'; |
|
691 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
692 | - echo 'done !'."\n"; |
|
693 | - // FIXME: Need more work |
|
694 | - if ($buffer != '') $reset = 0; |
|
695 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
696 | - $buffer = explode('\n',$buffer); |
|
697 | - foreach ($buffer as $line) { |
|
690 | + echo 'download...'; |
|
691 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
692 | + echo 'done !'."\n"; |
|
693 | + // FIXME: Need more work |
|
694 | + if ($buffer != '') $reset = 0; |
|
695 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
696 | + $buffer = explode('\n',$buffer); |
|
697 | + foreach ($buffer as $line) { |
|
698 | 698 | if ($line != '') { |
699 | - $data = array(); |
|
700 | - echo $line."\n"; |
|
701 | - $data['mmsi'] = (int)substr($line,0,9); |
|
702 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
703 | - $data['status_id'] = substr($line,21,2); |
|
704 | - $data['type_id'] = substr($line,24,3); |
|
705 | - $data['latitude'] = substr($line,29,9); |
|
706 | - $data['longitude'] = substr($line,41,9); |
|
707 | - $data['speed'] = round(substr($line,51,5)); |
|
708 | - //$data['course'] = substr($line,57,5); |
|
709 | - $data['heading'] = round(substr($line,63,3)); |
|
710 | - //$data['draft'] = substr($line,67,4); |
|
711 | - //$data['length'] = substr($line,72,3); |
|
712 | - //$data['beam'] = substr($line,76,2); |
|
713 | - $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
714 | - //$data['callsign'] = trim(substr($line,100,7); |
|
715 | - $data['arrival_code'] = substr($line,108,20); |
|
716 | - //$data['etaDate'] = substr($line,129,5); |
|
717 | - //$data['etaTime'] = substr($line,135,5); |
|
718 | - $data['format_source'] = 'shipplotter'; |
|
719 | - $data['id_source'] = $id_source; |
|
720 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
721 | - //print_r($data); |
|
722 | - echo 'Add...'."\n"; |
|
723 | - $MI->add($data); |
|
724 | - unset($data); |
|
699 | + $data = array(); |
|
700 | + echo $line."\n"; |
|
701 | + $data['mmsi'] = (int)substr($line,0,9); |
|
702 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
703 | + $data['status_id'] = substr($line,21,2); |
|
704 | + $data['type_id'] = substr($line,24,3); |
|
705 | + $data['latitude'] = substr($line,29,9); |
|
706 | + $data['longitude'] = substr($line,41,9); |
|
707 | + $data['speed'] = round(substr($line,51,5)); |
|
708 | + //$data['course'] = substr($line,57,5); |
|
709 | + $data['heading'] = round(substr($line,63,3)); |
|
710 | + //$data['draft'] = substr($line,67,4); |
|
711 | + //$data['length'] = substr($line,72,3); |
|
712 | + //$data['beam'] = substr($line,76,2); |
|
713 | + $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
714 | + //$data['callsign'] = trim(substr($line,100,7); |
|
715 | + $data['arrival_code'] = substr($line,108,20); |
|
716 | + //$data['etaDate'] = substr($line,129,5); |
|
717 | + //$data['etaTime'] = substr($line,135,5); |
|
718 | + $data['format_source'] = 'shipplotter'; |
|
719 | + $data['id_source'] = $id_source; |
|
720 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
721 | + //print_r($data); |
|
722 | + echo 'Add...'."\n"; |
|
723 | + $MI->add($data); |
|
724 | + unset($data); |
|
725 | 725 | } |
726 | - } |
|
727 | - $last_exec[$id]['last'] = time(); |
|
726 | + } |
|
727 | + $last_exec[$id]['last'] = time(); |
|
728 | 728 | //} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
729 | 729 | } elseif ( |
730 | - ( |
|
730 | + ( |
|
731 | 731 | $value['format'] === 'whazzup' && |
732 | 732 | ( |
733 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
734 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
733 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
734 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
735 | 735 | ) |
736 | - ) || ( |
|
736 | + ) || ( |
|
737 | 737 | $value['format'] === 'vatsimtxt' && |
738 | 738 | ( |
739 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
740 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
739 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
740 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
741 | + ) |
|
741 | 742 | ) |
742 | - ) |
|
743 | 743 | ) { |
744 | - //$buffer = $Common->getData($hosts[$id]); |
|
745 | - $buffer = $Common->getData($value['host']); |
|
746 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
747 | - $buffer = explode('\n',$buffer); |
|
748 | - $reset = 0; |
|
749 | - foreach ($buffer as $line) { |
|
750 | - if ($line != '') { |
|
751 | - $line = explode(':', $line); |
|
752 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
744 | + //$buffer = $Common->getData($hosts[$id]); |
|
745 | + $buffer = $Common->getData($value['host']); |
|
746 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
747 | + $buffer = explode('\n',$buffer); |
|
748 | + $reset = 0; |
|
749 | + foreach ($buffer as $line) { |
|
750 | + if ($line != '') { |
|
751 | + $line = explode(':', $line); |
|
752 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
753 | 753 | $data = array(); |
754 | 754 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
755 | 755 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -762,37 +762,37 @@ discard block |
||
762 | 762 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
763 | 763 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
764 | 764 | $data['latitude'] = $line[5]; // lat |
765 | - $data['longitude'] = $line[6]; // long |
|
766 | - $data['verticalrate'] = ''; // vertical rate |
|
767 | - $data['squawk'] = ''; // squawk |
|
768 | - $data['emergency'] = ''; // emergency |
|
769 | - $data['waypoints'] = $line[30]; |
|
765 | + $data['longitude'] = $line[6]; // long |
|
766 | + $data['verticalrate'] = ''; // vertical rate |
|
767 | + $data['squawk'] = ''; // squawk |
|
768 | + $data['emergency'] = ''; // emergency |
|
769 | + $data['waypoints'] = $line[30]; |
|
770 | 770 | $data['datetime'] = date('Y-m-d H:i:s'); |
771 | 771 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
772 | 772 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
773 | - $data['departure_airport_icao'] = $line[11]; |
|
774 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
775 | - $data['arrival_airport_icao'] = $line[13]; |
|
773 | + $data['departure_airport_icao'] = $line[11]; |
|
774 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
775 | + $data['arrival_airport_icao'] = $line[13]; |
|
776 | 776 | $data['frequency'] = $line[4]; |
777 | 777 | $data['type'] = $line[18]; |
778 | 778 | $data['range'] = $line[19]; |
779 | 779 | if (isset($line[35])) $data['info'] = $line[35]; |
780 | - $data['id_source'] = $id_source; |
|
781 | - //$data['arrival_airport_time'] = ; |
|
782 | - if ($line[9] != '') { |
|
783 | - $aircraft_data = explode('/',$line[9]); |
|
784 | - if (isset($aircraft_data[1])) { |
|
785 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
786 | - } |
|
787 | - } |
|
788 | - /* |
|
780 | + $data['id_source'] = $id_source; |
|
781 | + //$data['arrival_airport_time'] = ; |
|
782 | + if ($line[9] != '') { |
|
783 | + $aircraft_data = explode('/',$line[9]); |
|
784 | + if (isset($aircraft_data[1])) { |
|
785 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
786 | + } |
|
787 | + } |
|
788 | + /* |
|
789 | 789 | if ($value === 'whazzup') $data['format_source'] = 'whazzup'; |
790 | 790 | elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
791 | 791 | */ |
792 | - $data['format_source'] = $value['format']; |
|
792 | + $data['format_source'] = $value['format']; |
|
793 | 793 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
794 | 794 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
795 | - if ($line[3] === 'PILOT') $SI->add($data); |
|
795 | + if ($line[3] === 'PILOT') $SI->add($data); |
|
796 | 796 | elseif ($line[3] === 'ATC') { |
797 | 797 | //print_r($data); |
798 | 798 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -813,21 +813,21 @@ discard block |
||
813 | 813 | 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']); |
814 | 814 | } |
815 | 815 | } |
816 | - unset($data); |
|
817 | - } |
|
818 | - } |
|
819 | - } |
|
820 | - //if ($value === 'whazzup') $last_exec['whazzup'] = time(); |
|
821 | - //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
822 | - $last_exec[$id]['last'] = time(); |
|
823 | - } elseif ($value['format'] === 'airwhere' && |
|
824 | - ( |
|
825 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
826 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
827 | - ) |
|
828 | - ) { |
|
829 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
830 | - if ($buffer != '') { |
|
816 | + unset($data); |
|
817 | + } |
|
818 | + } |
|
819 | + } |
|
820 | + //if ($value === 'whazzup') $last_exec['whazzup'] = time(); |
|
821 | + //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
822 | + $last_exec[$id]['last'] = time(); |
|
823 | + } elseif ($value['format'] === 'airwhere' && |
|
824 | + ( |
|
825 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
826 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
827 | + ) |
|
828 | + ) { |
|
829 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
830 | + if ($buffer != '') { |
|
831 | 831 | $all_data = simplexml_load_string($buffer); |
832 | 832 | foreach($all_data->children() as $childdata) { |
833 | 833 | $data = array(); |
@@ -849,10 +849,10 @@ discard block |
||
849 | 849 | $SI->add($data); |
850 | 850 | unset($data); |
851 | 851 | } |
852 | - } |
|
853 | - $Source->deleteOldLocationByType('gs'); |
|
854 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
855 | - if ($buffer != '') { |
|
852 | + } |
|
853 | + $Source->deleteOldLocationByType('gs'); |
|
854 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
855 | + if ($buffer != '') { |
|
856 | 856 | $all_data = simplexml_load_string($buffer); |
857 | 857 | foreach($all_data->children() as $childdata) { |
858 | 858 | $data = array(); |
@@ -870,8 +870,8 @@ discard block |
||
870 | 870 | } |
871 | 871 | unset($data); |
872 | 872 | } |
873 | - } |
|
874 | - $last_exec[$id]['last'] = time(); |
|
873 | + } |
|
874 | + $last_exec[$id]['last'] = time(); |
|
875 | 875 | /* |
876 | 876 | } if ($value['format'] === 'aircraftlistjson') { |
877 | 877 | print_r($globalSources); |
@@ -879,17 +879,17 @@ discard block |
||
879 | 879 | echo $globalMinFetch; |
880 | 880 | */ |
881 | 881 | } elseif ($value['format'] === 'aircraftlistjson' && |
882 | - ( |
|
882 | + ( |
|
883 | 883 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
884 | 884 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
885 | - ) |
|
885 | + ) |
|
886 | 886 | ) { |
887 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
888 | - if ($buffer != '') { |
|
889 | - $all_data = json_decode($buffer,true); |
|
887 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
888 | + if ($buffer != '') { |
|
889 | + $all_data = json_decode($buffer,true); |
|
890 | 890 | if (isset($all_data['acList'])) { |
891 | - $reset = 0; |
|
892 | - foreach ($all_data['acList'] as $line) { |
|
891 | + $reset = 0; |
|
892 | + foreach ($all_data['acList'] as $line) { |
|
893 | 893 | $data = array(); |
894 | 894 | $data['hex'] = $line['Icao']; // hex |
895 | 895 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -912,10 +912,10 @@ discard block |
||
912 | 912 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
913 | 913 | if (isset($data['latitude'])) $SI->add($data); |
914 | 914 | unset($data); |
915 | - } |
|
915 | + } |
|
916 | 916 | } elseif (is_array($all_data)) { |
917 | - $reset = 0; |
|
918 | - foreach ($all_data as $line) { |
|
917 | + $reset = 0; |
|
918 | + foreach ($all_data as $line) { |
|
919 | 919 | $data = array(); |
920 | 920 | $data['hex'] = $line['hex']; // hex |
921 | 921 | $data['ident'] = $line['flight']; // ident |
@@ -935,257 +935,257 @@ discard block |
||
935 | 935 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
936 | 936 | $SI->add($data); |
937 | 937 | unset($data); |
938 | - } |
|
938 | + } |
|
939 | 939 | } |
940 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
941 | - //$last_exec['aircraftlistjson'] = time(); |
|
942 | - $last_exec[$id]['last'] = time(); |
|
943 | - //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
944 | - } elseif ($value['format'] === 'planeupdatefaa' && |
|
945 | - ( |
|
946 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
947 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
948 | - ) |
|
949 | - ) { |
|
950 | - $buffer = $Common->getData($value['host']); |
|
951 | - $all_data = json_decode($buffer,true); |
|
952 | - if (isset($all_data['planes'])) { |
|
940 | + } elseif ($globalDebug) echo 'No data'."\n"; |
|
941 | + //$last_exec['aircraftlistjson'] = time(); |
|
942 | + $last_exec[$id]['last'] = time(); |
|
943 | + //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
944 | + } elseif ($value['format'] === 'planeupdatefaa' && |
|
945 | + ( |
|
946 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
947 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
948 | + ) |
|
949 | + ) { |
|
950 | + $buffer = $Common->getData($value['host']); |
|
951 | + $all_data = json_decode($buffer,true); |
|
952 | + if (isset($all_data['planes'])) { |
|
953 | 953 | $reset = 0; |
954 | 954 | foreach ($all_data['planes'] as $key => $line) { |
955 | - $data = array(); |
|
956 | - $data['hex'] = $key; // hex |
|
957 | - $data['ident'] = $line[3]; // ident |
|
958 | - $data['altitude'] = $line[6]; // altitude |
|
959 | - $data['speed'] = $line[8]; // speed |
|
960 | - $data['heading'] = $line[7]; // heading |
|
961 | - $data['latitude'] = $line[4]; // lat |
|
962 | - $data['longitude'] = $line[5]; // long |
|
963 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
964 | - $data['squawk'] = $line[10]; // squawk |
|
965 | - $data['emergency'] = ''; // emergency |
|
966 | - $data['registration'] = $line[2]; |
|
967 | - $data['aircraft_icao'] = $line[0]; |
|
968 | - $deparr = explode('-',$line[1]); |
|
969 | - if (count($deparr) === 2) { |
|
955 | + $data = array(); |
|
956 | + $data['hex'] = $key; // hex |
|
957 | + $data['ident'] = $line[3]; // ident |
|
958 | + $data['altitude'] = $line[6]; // altitude |
|
959 | + $data['speed'] = $line[8]; // speed |
|
960 | + $data['heading'] = $line[7]; // heading |
|
961 | + $data['latitude'] = $line[4]; // lat |
|
962 | + $data['longitude'] = $line[5]; // long |
|
963 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
964 | + $data['squawk'] = $line[10]; // squawk |
|
965 | + $data['emergency'] = ''; // emergency |
|
966 | + $data['registration'] = $line[2]; |
|
967 | + $data['aircraft_icao'] = $line[0]; |
|
968 | + $deparr = explode('-',$line[1]); |
|
969 | + if (count($deparr) === 2) { |
|
970 | 970 | $data['departure_airport_icao'] = $deparr[0]; |
971 | 971 | $data['arrival_airport_icao'] = $deparr[1]; |
972 | - } |
|
973 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
974 | - $data['format_source'] = 'planeupdatefaa'; |
|
975 | - $data['id_source'] = $id_source; |
|
976 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
977 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
978 | - $SI->add($data); |
|
979 | - unset($data); |
|
972 | + } |
|
973 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
974 | + $data['format_source'] = 'planeupdatefaa'; |
|
975 | + $data['id_source'] = $id_source; |
|
976 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
977 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
978 | + $SI->add($data); |
|
979 | + unset($data); |
|
980 | 980 | } |
981 | - } |
|
982 | - //$last_exec['planeupdatefaa'] = time(); |
|
983 | - $last_exec[$id]['last'] = time(); |
|
981 | + } |
|
982 | + //$last_exec['planeupdatefaa'] = time(); |
|
983 | + $last_exec[$id]['last'] = time(); |
|
984 | 984 | } elseif ($value['format'] === 'opensky' && |
985 | - ( |
|
985 | + ( |
|
986 | 986 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
987 | 987 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
988 | - ) |
|
988 | + ) |
|
989 | 989 | ) { |
990 | - $buffer = $Common->getData($value['host']); |
|
991 | - $all_data = json_decode($buffer,true); |
|
992 | - if (isset($all_data['states'])) { |
|
990 | + $buffer = $Common->getData($value['host']); |
|
991 | + $all_data = json_decode($buffer,true); |
|
992 | + if (isset($all_data['states'])) { |
|
993 | 993 | $reset = 0; |
994 | 994 | foreach ($all_data['states'] as $key => $line) { |
995 | - $data = array(); |
|
996 | - $data['hex'] = $line[0]; // hex |
|
997 | - $data['ident'] = trim($line[1]); // ident |
|
998 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
999 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
1000 | - $data['heading'] = round($line[10]); // heading |
|
1001 | - $data['latitude'] = $line[6]; // lat |
|
1002 | - $data['longitude'] = $line[5]; // long |
|
1003 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
1004 | - //$data['squawk'] = $line[10]; // squawk |
|
1005 | - //$data['emergency'] = ''; // emergency |
|
1006 | - //$data['registration'] = $line[2]; |
|
1007 | - //$data['aircraft_icao'] = $line[0]; |
|
1008 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
1009 | - $data['format_source'] = 'opensky'; |
|
1010 | - $data['id_source'] = $id_source; |
|
1011 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1012 | - $SI->add($data); |
|
1013 | - unset($data); |
|
995 | + $data = array(); |
|
996 | + $data['hex'] = $line[0]; // hex |
|
997 | + $data['ident'] = trim($line[1]); // ident |
|
998 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
999 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
1000 | + $data['heading'] = round($line[10]); // heading |
|
1001 | + $data['latitude'] = $line[6]; // lat |
|
1002 | + $data['longitude'] = $line[5]; // long |
|
1003 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
1004 | + //$data['squawk'] = $line[10]; // squawk |
|
1005 | + //$data['emergency'] = ''; // emergency |
|
1006 | + //$data['registration'] = $line[2]; |
|
1007 | + //$data['aircraft_icao'] = $line[0]; |
|
1008 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
1009 | + $data['format_source'] = 'opensky'; |
|
1010 | + $data['id_source'] = $id_source; |
|
1011 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1012 | + $SI->add($data); |
|
1013 | + unset($data); |
|
1014 | 1014 | } |
1015 | - } |
|
1016 | - //$last_exec['planeupdatefaa'] = time(); |
|
1017 | - $last_exec[$id]['last'] = time(); |
|
1015 | + } |
|
1016 | + //$last_exec['planeupdatefaa'] = time(); |
|
1017 | + $last_exec[$id]['last'] = time(); |
|
1018 | 1018 | } elseif ($value['format'] === 'aircraftjson' && |
1019 | - ( |
|
1019 | + ( |
|
1020 | 1020 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1021 | 1021 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1022 | - ) |
|
1022 | + ) |
|
1023 | 1023 | ) { |
1024 | - $buffer = $Common->getData($value['host']); |
|
1025 | - $all_data = json_decode($buffer,true); |
|
1026 | - if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) { |
|
1024 | + $buffer = $Common->getData($value['host']); |
|
1025 | + $all_data = json_decode($buffer,true); |
|
1026 | + if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) { |
|
1027 | 1027 | $reset = 0; |
1028 | 1028 | foreach ($all_data['aircraft'] as $key => $line) { |
1029 | - $data = array(); |
|
1030 | - // add support for ground vehicule with ~ in front of hex |
|
1031 | - if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
1032 | - if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
1033 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1034 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1035 | - if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
1036 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1037 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1038 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1039 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1040 | - //$data['emergency'] = ''; // emergency |
|
1041 | - //$data['registration'] = $line[2]; |
|
1042 | - //$data['aircraft_icao'] = $line[0]; |
|
1043 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1044 | - $data['format_source'] = 'aircraftjson'; |
|
1045 | - $data['id_source'] = $id_source; |
|
1046 | - if (isset($value['name']) && $value['name'] != '') { |
|
1047 | - if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
1048 | - else $data['source_name'] = $value['name']; |
|
1049 | - } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
1050 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1051 | - $SI->add($data); |
|
1052 | - unset($data); |
|
1029 | + $data = array(); |
|
1030 | + // add support for ground vehicule with ~ in front of hex |
|
1031 | + if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
1032 | + if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
1033 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1034 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1035 | + if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
1036 | + if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1037 | + if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1038 | + if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1039 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1040 | + //$data['emergency'] = ''; // emergency |
|
1041 | + //$data['registration'] = $line[2]; |
|
1042 | + //$data['aircraft_icao'] = $line[0]; |
|
1043 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1044 | + $data['format_source'] = 'aircraftjson'; |
|
1045 | + $data['id_source'] = $id_source; |
|
1046 | + if (isset($value['name']) && $value['name'] != '') { |
|
1047 | + if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
1048 | + else $data['source_name'] = $value['name']; |
|
1049 | + } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
1050 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1051 | + $SI->add($data); |
|
1052 | + unset($data); |
|
1053 | 1053 | } |
1054 | - } |
|
1055 | - //$last_exec['planeupdatefaa'] = time(); |
|
1056 | - $last_exec[$id]['last'] = time(); |
|
1054 | + } |
|
1055 | + //$last_exec['planeupdatefaa'] = time(); |
|
1056 | + $last_exec[$id]['last'] = time(); |
|
1057 | 1057 | //} elseif ($value === 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
1058 | 1058 | } elseif ($value['format'] === 'fr24json' && |
1059 | - ( |
|
1059 | + ( |
|
1060 | 1060 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1061 | 1061 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1062 | - ) |
|
1062 | + ) |
|
1063 | 1063 | ) { |
1064 | - //$buffer = $Common->getData($hosts[$id]); |
|
1065 | - $buffer = $Common->getData($value['host']); |
|
1066 | - $all_data = json_decode($buffer,true); |
|
1067 | - if (!empty($all_data)) $reset = 0; |
|
1068 | - foreach ($all_data as $key => $line) { |
|
1064 | + //$buffer = $Common->getData($hosts[$id]); |
|
1065 | + $buffer = $Common->getData($value['host']); |
|
1066 | + $all_data = json_decode($buffer,true); |
|
1067 | + if (!empty($all_data)) $reset = 0; |
|
1068 | + foreach ($all_data as $key => $line) { |
|
1069 | 1069 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
1070 | - $data = array(); |
|
1071 | - $data['hex'] = $line[0]; |
|
1072 | - $data['ident'] = $line[16]; //$line[13] |
|
1073 | - $data['altitude'] = $line[4]; // altitude |
|
1074 | - $data['speed'] = $line[5]; // speed |
|
1075 | - $data['heading'] = $line[3]; // heading |
|
1076 | - $data['latitude'] = $line[1]; // lat |
|
1077 | - $data['longitude'] = $line[2]; // long |
|
1078 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
1079 | - $data['squawk'] = $line[6]; // squawk |
|
1080 | - $data['aircraft_icao'] = $line[8]; |
|
1081 | - $data['registration'] = $line[9]; |
|
1082 | - $data['departure_airport_iata'] = $line[11]; |
|
1083 | - $data['arrival_airport_iata'] = $line[12]; |
|
1084 | - $data['emergency'] = ''; // emergency |
|
1085 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
1086 | - $data['format_source'] = 'fr24json'; |
|
1087 | - $data['id_source'] = $id_source; |
|
1088 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1089 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1090 | - $SI->add($data); |
|
1091 | - unset($data); |
|
1070 | + $data = array(); |
|
1071 | + $data['hex'] = $line[0]; |
|
1072 | + $data['ident'] = $line[16]; //$line[13] |
|
1073 | + $data['altitude'] = $line[4]; // altitude |
|
1074 | + $data['speed'] = $line[5]; // speed |
|
1075 | + $data['heading'] = $line[3]; // heading |
|
1076 | + $data['latitude'] = $line[1]; // lat |
|
1077 | + $data['longitude'] = $line[2]; // long |
|
1078 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
1079 | + $data['squawk'] = $line[6]; // squawk |
|
1080 | + $data['aircraft_icao'] = $line[8]; |
|
1081 | + $data['registration'] = $line[9]; |
|
1082 | + $data['departure_airport_iata'] = $line[11]; |
|
1083 | + $data['arrival_airport_iata'] = $line[12]; |
|
1084 | + $data['emergency'] = ''; // emergency |
|
1085 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
1086 | + $data['format_source'] = 'fr24json'; |
|
1087 | + $data['id_source'] = $id_source; |
|
1088 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1089 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1090 | + $SI->add($data); |
|
1091 | + unset($data); |
|
1092 | + } |
|
1092 | 1093 | } |
1093 | - } |
|
1094 | - //$last_exec['fr24json'] = time(); |
|
1095 | - $last_exec[$id]['last'] = time(); |
|
1094 | + //$last_exec['fr24json'] = time(); |
|
1095 | + $last_exec[$id]['last'] = time(); |
|
1096 | 1096 | //} elseif ($value === 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
1097 | 1097 | } elseif ($value['format'] === 'radarvirtueljson' && |
1098 | - ( |
|
1098 | + ( |
|
1099 | 1099 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1100 | 1100 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1101 | - ) |
|
1101 | + ) |
|
1102 | 1102 | ) { |
1103 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
1104 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1105 | - //echo $buffer; |
|
1106 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1107 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1108 | - $all_data = json_decode($buffer,true); |
|
1109 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
1103 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
1104 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1105 | + //echo $buffer; |
|
1106 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1107 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1108 | + $all_data = json_decode($buffer,true); |
|
1109 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
1110 | 1110 | die(json_last_error_msg()); |
1111 | - } |
|
1112 | - if (isset($all_data['mrkrs'])) { |
|
1111 | + } |
|
1112 | + if (isset($all_data['mrkrs'])) { |
|
1113 | 1113 | $reset = 0; |
1114 | 1114 | foreach ($all_data['mrkrs'] as $key => $line) { |
1115 | - if (isset($line['inf'])) { |
|
1115 | + if (isset($line['inf'])) { |
|
1116 | 1116 | $data = array(); |
1117 | 1117 | $data['hex'] = $line['inf']['ia']; |
1118 | 1118 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
1119 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
1120 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1121 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1122 | - $data['latitude'] = $line['pt'][0]; // lat |
|
1123 | - $data['longitude'] = $line['pt'][1]; // long |
|
1124 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
1125 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1126 | - //$data['aircraft_icao'] = $line[8]; |
|
1127 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1119 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
1120 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1121 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1122 | + $data['latitude'] = $line['pt'][0]; // lat |
|
1123 | + $data['longitude'] = $line['pt'][1]; // long |
|
1124 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
1125 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1126 | + //$data['aircraft_icao'] = $line[8]; |
|
1127 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1128 | 1128 | //$data['departure_airport_iata'] = $line[11]; |
1129 | 1129 | //$data['arrival_airport_iata'] = $line[12]; |
1130 | - //$data['emergency'] = ''; // emergency |
|
1130 | + //$data['emergency'] = ''; // emergency |
|
1131 | 1131 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
1132 | - $data['format_source'] = 'radarvirtueljson'; |
|
1133 | - $data['id_source'] = $id_source; |
|
1132 | + $data['format_source'] = 'radarvirtueljson'; |
|
1133 | + $data['id_source'] = $id_source; |
|
1134 | 1134 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
1135 | 1135 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1136 | 1136 | $SI->add($data); |
1137 | 1137 | unset($data); |
1138 | - } |
|
1138 | + } |
|
1139 | + } |
|
1139 | 1140 | } |
1140 | - } |
|
1141 | - //$last_exec['radarvirtueljson'] = time(); |
|
1142 | - $last_exec[$id]['last'] = time(); |
|
1141 | + //$last_exec['radarvirtueljson'] = time(); |
|
1142 | + $last_exec[$id]['last'] = time(); |
|
1143 | 1143 | //} elseif ($value === 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
1144 | 1144 | } elseif ($value['format'] === 'pirepsjson' && |
1145 | - ( |
|
1145 | + ( |
|
1146 | 1146 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1147 | 1147 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1148 | - ) |
|
1148 | + ) |
|
1149 | 1149 | ) { |
1150 | - //$buffer = $Common->getData($hosts[$id]); |
|
1151 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
1152 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
1150 | + //$buffer = $Common->getData($hosts[$id]); |
|
1151 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
1152 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
1153 | 1153 | |
1154 | - if (isset($all_data['pireps'])) { |
|
1154 | + if (isset($all_data['pireps'])) { |
|
1155 | 1155 | $reset = 0; |
1156 | - foreach ($all_data['pireps'] as $line) { |
|
1157 | - $data = array(); |
|
1158 | - $data['id'] = $line['id']; |
|
1159 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1160 | - $data['ident'] = $line['callsign']; // ident |
|
1161 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1162 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1163 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1164 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1165 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1166 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1167 | - $data['latitude'] = $line['lat']; // lat |
|
1168 | - $data['longitude'] = $line['lon']; // long |
|
1169 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
1170 | - //$data['squawk'] = $line['squawk']; // squawk |
|
1171 | - //$data['emergency'] = ''; // emergency |
|
1172 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1173 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1174 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1175 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
1176 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1177 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1178 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1179 | - else $data['info'] = ''; |
|
1180 | - $data['format_source'] = 'pireps'; |
|
1181 | - $data['id_source'] = $id_source; |
|
1182 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1183 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1184 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1185 | - if ($line['icon'] === 'plane') { |
|
1156 | + foreach ($all_data['pireps'] as $line) { |
|
1157 | + $data = array(); |
|
1158 | + $data['id'] = $line['id']; |
|
1159 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1160 | + $data['ident'] = $line['callsign']; // ident |
|
1161 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1162 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1163 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1164 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1165 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1166 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1167 | + $data['latitude'] = $line['lat']; // lat |
|
1168 | + $data['longitude'] = $line['lon']; // long |
|
1169 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
1170 | + //$data['squawk'] = $line['squawk']; // squawk |
|
1171 | + //$data['emergency'] = ''; // emergency |
|
1172 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1173 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1174 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1175 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
1176 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1177 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1178 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1179 | + else $data['info'] = ''; |
|
1180 | + $data['format_source'] = 'pireps'; |
|
1181 | + $data['id_source'] = $id_source; |
|
1182 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1183 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1184 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1185 | + if ($line['icon'] === 'plane') { |
|
1186 | 1186 | $SI->add($data); |
1187 | - // print_r($data); |
|
1188 | - } elseif ($line['icon'] === 'ct') { |
|
1187 | + // print_r($data); |
|
1188 | + } elseif ($line['icon'] === 'ct') { |
|
1189 | 1189 | $data['info'] = str_replace('^§','<br />',$data['info']); |
1190 | 1190 | $data['info'] = str_replace('&sect;','',$data['info']); |
1191 | 1191 | $typec = substr($data['ident'],-3); |
@@ -1200,209 +1200,209 @@ discard block |
||
1200 | 1200 | elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
1201 | 1201 | else $data['type'] = 'Observer'; |
1202 | 1202 | 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']); |
1203 | - } |
|
1204 | - unset($data); |
|
1203 | + } |
|
1204 | + unset($data); |
|
1205 | + } |
|
1205 | 1206 | } |
1206 | - } |
|
1207 | - //$last_exec['pirepsjson'] = time(); |
|
1208 | - $last_exec[$id]['last'] = time(); |
|
1207 | + //$last_exec['pirepsjson'] = time(); |
|
1208 | + $last_exec[$id]['last'] = time(); |
|
1209 | 1209 | //} elseif ($value === 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
1210 | 1210 | } elseif ($value['format'] === 'phpvmacars' && |
1211 | - ( |
|
1211 | + ( |
|
1212 | 1212 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1213 | 1213 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1214 | - ) |
|
1214 | + ) |
|
1215 | 1215 | ) { |
1216 | - //$buffer = $Common->getData($hosts[$id]); |
|
1217 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1218 | - $buffer = $Common->getData($value['host']); |
|
1219 | - $all_data = json_decode($buffer,true); |
|
1220 | - if ($buffer != '' && is_array($all_data)) { |
|
1216 | + //$buffer = $Common->getData($hosts[$id]); |
|
1217 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1218 | + $buffer = $Common->getData($value['host']); |
|
1219 | + $all_data = json_decode($buffer,true); |
|
1220 | + if ($buffer != '' && is_array($all_data)) { |
|
1221 | 1221 | $reset = 0; |
1222 | 1222 | foreach ($all_data as $line) { |
1223 | - $data = array(); |
|
1224 | - //$data['id'] = $line['id']; // id not usable |
|
1225 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1226 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1227 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1228 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1229 | - $data['ident'] = $line['flightnum']; // ident |
|
1230 | - $data['altitude'] = $line['alt']; // altitude |
|
1231 | - $data['speed'] = $line['gs']; // speed |
|
1232 | - $data['heading'] = $line['heading']; // heading |
|
1233 | - $data['latitude'] = $line['lat']; // lat |
|
1234 | - $data['longitude'] = $line['lng']; // long |
|
1235 | - $data['verticalrate'] = ''; // verticale rate |
|
1236 | - $data['squawk'] = ''; // squawk |
|
1237 | - $data['emergency'] = ''; // emergency |
|
1238 | - //$data['datetime'] = $line['lastupdate']; |
|
1239 | - //$data['last_update'] = $line['lastupdate']; |
|
1240 | - if (isset($value['timezone'])) { |
|
1241 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1242 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1243 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1244 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1245 | - $data['departure_airport_icao'] = $line['depicao']; |
|
1246 | - $data['departure_airport_time'] = $line['deptime']; |
|
1247 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
1248 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
1249 | - if (isset($line['registration'])) { |
|
1250 | - $data['registration'] = $line['registration']; |
|
1251 | - //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
|
1252 | - } else $data['registration'] = $line['aircraft']; |
|
1253 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1254 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1255 | - if (isset($line['aircraftname'])) { |
|
1223 | + $data = array(); |
|
1224 | + //$data['id'] = $line['id']; // id not usable |
|
1225 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1226 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1227 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1228 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1229 | + $data['ident'] = $line['flightnum']; // ident |
|
1230 | + $data['altitude'] = $line['alt']; // altitude |
|
1231 | + $data['speed'] = $line['gs']; // speed |
|
1232 | + $data['heading'] = $line['heading']; // heading |
|
1233 | + $data['latitude'] = $line['lat']; // lat |
|
1234 | + $data['longitude'] = $line['lng']; // long |
|
1235 | + $data['verticalrate'] = ''; // verticale rate |
|
1236 | + $data['squawk'] = ''; // squawk |
|
1237 | + $data['emergency'] = ''; // emergency |
|
1238 | + //$data['datetime'] = $line['lastupdate']; |
|
1239 | + //$data['last_update'] = $line['lastupdate']; |
|
1240 | + if (isset($value['timezone'])) { |
|
1241 | + $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1242 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1243 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1244 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1245 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1246 | + $data['departure_airport_time'] = $line['deptime']; |
|
1247 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1248 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
1249 | + if (isset($line['registration'])) { |
|
1250 | + $data['registration'] = $line['registration']; |
|
1251 | + //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
|
1252 | + } else $data['registration'] = $line['aircraft']; |
|
1253 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1254 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1255 | + if (isset($line['aircraftname'])) { |
|
1256 | 1256 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1257 | 1257 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1258 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1259 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1260 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1261 | - else { |
|
1262 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1263 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1264 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1265 | - } |
|
1266 | - } |
|
1267 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1268 | - $data['id_source'] = $id_source; |
|
1269 | - $data['format_source'] = 'phpvmacars'; |
|
1270 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1271 | - $SI->add($data); |
|
1272 | - unset($data); |
|
1258 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
1259 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1260 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1261 | + else { |
|
1262 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
1263 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1264 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1265 | + } |
|
1266 | + } |
|
1267 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1268 | + $data['id_source'] = $id_source; |
|
1269 | + $data['format_source'] = 'phpvmacars'; |
|
1270 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1271 | + $SI->add($data); |
|
1272 | + unset($data); |
|
1273 | 1273 | } |
1274 | 1274 | if ($globalDebug) echo 'No more data...'."\n"; |
1275 | 1275 | unset($buffer); |
1276 | 1276 | unset($all_data); |
1277 | - } |
|
1278 | - //$last_exec['phpvmacars'] = time(); |
|
1279 | - $last_exec[$id]['last'] = time(); |
|
1277 | + } |
|
1278 | + //$last_exec['phpvmacars'] = time(); |
|
1279 | + $last_exec[$id]['last'] = time(); |
|
1280 | 1280 | } elseif ($value['format'] === 'vaos' && |
1281 | - ( |
|
1281 | + ( |
|
1282 | 1282 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1283 | 1283 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1284 | - ) |
|
1284 | + ) |
|
1285 | 1285 | ) { |
1286 | - //$buffer = $Common->getData($hosts[$id]); |
|
1287 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1288 | - $buffer = $Common->getData($value['host']); |
|
1289 | - $all_data = json_decode($buffer,true); |
|
1290 | - if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
|
1286 | + //$buffer = $Common->getData($hosts[$id]); |
|
1287 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1288 | + $buffer = $Common->getData($value['host']); |
|
1289 | + $all_data = json_decode($buffer,true); |
|
1290 | + if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
|
1291 | 1291 | $reset = 0; |
1292 | 1292 | foreach ($all_data['ACARSData'] as $line) { |
1293 | - //print_r($line); |
|
1294 | - $data = array(); |
|
1295 | - //$data['id'] = $line['id']; // id not usable |
|
1296 | - $data['id'] = $line['id']; |
|
1297 | - //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1298 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
1299 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
1300 | - $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
1301 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1302 | - $data['altitude'] = $line['altitude']; // altitude |
|
1303 | - $data['speed'] = $line['groundspeed']; // speed |
|
1304 | - $data['heading'] = $line['heading']; // heading |
|
1305 | - $data['latitude'] = $line['lat']; // lat |
|
1306 | - $data['longitude'] = $line['lon']; // long |
|
1307 | - //$data['verticalrate'] = ''; // verticale rate |
|
1308 | - //$data['squawk'] = ''; // squawk |
|
1309 | - //$data['emergency'] = ''; // emergency |
|
1310 | - if (isset($value['timezone'])) { |
|
1311 | - $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
1312 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1313 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1314 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1293 | + //print_r($line); |
|
1294 | + $data = array(); |
|
1295 | + //$data['id'] = $line['id']; // id not usable |
|
1296 | + $data['id'] = $line['id']; |
|
1297 | + //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1298 | + if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
1299 | + if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
1300 | + $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
1301 | + if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1302 | + $data['altitude'] = $line['altitude']; // altitude |
|
1303 | + $data['speed'] = $line['groundspeed']; // speed |
|
1304 | + $data['heading'] = $line['heading']; // heading |
|
1305 | + $data['latitude'] = $line['lat']; // lat |
|
1306 | + $data['longitude'] = $line['lon']; // long |
|
1307 | + //$data['verticalrate'] = ''; // verticale rate |
|
1308 | + //$data['squawk'] = ''; // squawk |
|
1309 | + //$data['emergency'] = ''; // emergency |
|
1310 | + if (isset($value['timezone'])) { |
|
1311 | + $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
1312 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1313 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1314 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1315 | 1315 | |
1316 | - $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
|
1317 | - $data['departure_airport_time'] = $line['bid']['deptime']; |
|
1318 | - $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao']; |
|
1319 | - $data['arrival_airport_time'] = $line['bid']['arrtime']; |
|
1320 | - $data['registration'] = $line['bid']['aircraft']['registration']; |
|
1316 | + $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
|
1317 | + $data['departure_airport_time'] = $line['bid']['deptime']; |
|
1318 | + $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao']; |
|
1319 | + $data['arrival_airport_time'] = $line['bid']['arrtime']; |
|
1320 | + $data['registration'] = $line['bid']['aircraft']['registration']; |
|
1321 | 1321 | |
1322 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1323 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
1324 | - $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
|
1322 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1323 | + if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
1324 | + $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
|
1325 | 1325 | |
1326 | - $data['id_source'] = $id_source; |
|
1327 | - $data['format_source'] = 'vaos'; |
|
1328 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1329 | - $SI->add($data); |
|
1330 | - unset($data); |
|
1326 | + $data['id_source'] = $id_source; |
|
1327 | + $data['format_source'] = 'vaos'; |
|
1328 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1329 | + $SI->add($data); |
|
1330 | + unset($data); |
|
1331 | 1331 | } |
1332 | 1332 | if ($globalDebug) echo 'No more data...'."\n"; |
1333 | 1333 | unset($buffer); |
1334 | 1334 | unset($all_data); |
1335 | - } |
|
1336 | - //$last_exec['phpvmacars'] = time(); |
|
1337 | - $last_exec[$id]['last'] = time(); |
|
1335 | + } |
|
1336 | + //$last_exec['phpvmacars'] = time(); |
|
1337 | + $last_exec[$id]['last'] = time(); |
|
1338 | 1338 | } elseif ($value['format'] === 'vam' && |
1339 | - ( |
|
1339 | + ( |
|
1340 | 1340 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1341 | 1341 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1342 | - ) |
|
1342 | + ) |
|
1343 | 1343 | ) { |
1344 | - //$buffer = $Common->getData($hosts[$id]); |
|
1345 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1346 | - $buffer = $Common->getData($value['host']); |
|
1347 | - $all_data = json_decode($buffer,true); |
|
1348 | - if ($buffer != '' && is_array($all_data)) { |
|
1344 | + //$buffer = $Common->getData($hosts[$id]); |
|
1345 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1346 | + $buffer = $Common->getData($value['host']); |
|
1347 | + $all_data = json_decode($buffer,true); |
|
1348 | + if ($buffer != '' && is_array($all_data)) { |
|
1349 | 1349 | $reset = 0; |
1350 | 1350 | foreach ($all_data as $line) { |
1351 | - $data = array(); |
|
1352 | - //$data['id'] = $line['id']; // id not usable |
|
1353 | - $data['id'] = trim($line['flight_id']); |
|
1354 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1355 | - $data['pilot_name'] = $line['pilot_name']; |
|
1356 | - $data['pilot_id'] = $line['pilot_id']; |
|
1357 | - $data['ident'] = trim($line['callsign']); // ident |
|
1358 | - $data['altitude'] = $line['altitude']; // altitude |
|
1359 | - $data['speed'] = $line['gs']; // speed |
|
1360 | - $data['heading'] = $line['heading']; // heading |
|
1361 | - $data['latitude'] = $line['latitude']; // lat |
|
1362 | - $data['longitude'] = $line['longitude']; // long |
|
1363 | - $data['verticalrate'] = ''; // verticale rate |
|
1364 | - $data['squawk'] = ''; // squawk |
|
1365 | - $data['emergency'] = ''; // emergency |
|
1366 | - //$data['datetime'] = $line['lastupdate']; |
|
1367 | - $data['last_update'] = $line['last_update']; |
|
1368 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1369 | - $data['departure_airport_icao'] = $line['departure']; |
|
1370 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
1371 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
1372 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1373 | - //$data['registration'] = $line['aircraft']; |
|
1374 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1375 | - $data['aircraft_icao'] = $line['plane_type']; |
|
1376 | - $data['id_source'] = $id_source; |
|
1377 | - $data['format_source'] = 'vam'; |
|
1378 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1379 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1380 | - $SI->add($data); |
|
1381 | - unset($data); |
|
1351 | + $data = array(); |
|
1352 | + //$data['id'] = $line['id']; // id not usable |
|
1353 | + $data['id'] = trim($line['flight_id']); |
|
1354 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1355 | + $data['pilot_name'] = $line['pilot_name']; |
|
1356 | + $data['pilot_id'] = $line['pilot_id']; |
|
1357 | + $data['ident'] = trim($line['callsign']); // ident |
|
1358 | + $data['altitude'] = $line['altitude']; // altitude |
|
1359 | + $data['speed'] = $line['gs']; // speed |
|
1360 | + $data['heading'] = $line['heading']; // heading |
|
1361 | + $data['latitude'] = $line['latitude']; // lat |
|
1362 | + $data['longitude'] = $line['longitude']; // long |
|
1363 | + $data['verticalrate'] = ''; // verticale rate |
|
1364 | + $data['squawk'] = ''; // squawk |
|
1365 | + $data['emergency'] = ''; // emergency |
|
1366 | + //$data['datetime'] = $line['lastupdate']; |
|
1367 | + $data['last_update'] = $line['last_update']; |
|
1368 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1369 | + $data['departure_airport_icao'] = $line['departure']; |
|
1370 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
1371 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
1372 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1373 | + //$data['registration'] = $line['aircraft']; |
|
1374 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1375 | + $data['aircraft_icao'] = $line['plane_type']; |
|
1376 | + $data['id_source'] = $id_source; |
|
1377 | + $data['format_source'] = 'vam'; |
|
1378 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1379 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1380 | + $SI->add($data); |
|
1381 | + unset($data); |
|
1382 | 1382 | } |
1383 | 1383 | if ($globalDebug) echo 'No more data...'."\n"; |
1384 | 1384 | unset($buffer); |
1385 | 1385 | unset($all_data); |
1386 | - } |
|
1387 | - //$last_exec['phpvmacars'] = time(); |
|
1388 | - $last_exec[$id]['last'] = time(); |
|
1386 | + } |
|
1387 | + //$last_exec['phpvmacars'] = time(); |
|
1388 | + $last_exec[$id]['last'] = time(); |
|
1389 | 1389 | } elseif ($value['format'] === 'blitzortung' && |
1390 | - ( |
|
1390 | + ( |
|
1391 | 1391 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1392 | 1392 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1393 | - ) |
|
1393 | + ) |
|
1394 | 1394 | ) { |
1395 | - //$buffer = $Common->getData($hosts[$id]); |
|
1396 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1397 | - $buffer = $Common->getData($value['host']); |
|
1398 | - $all_data = json_decode($buffer,true); |
|
1399 | - if ($buffer != '') { |
|
1395 | + //$buffer = $Common->getData($hosts[$id]); |
|
1396 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1397 | + $buffer = $Common->getData($value['host']); |
|
1398 | + $all_data = json_decode($buffer,true); |
|
1399 | + if ($buffer != '') { |
|
1400 | 1400 | $Source->deleteLocationBySource('blitzortung'); |
1401 | 1401 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
1402 | 1402 | $buffer = explode('\n',$buffer); |
1403 | 1403 | foreach ($buffer as $buffer_line) { |
1404 | - $line = json_decode($buffer_line,true); |
|
1405 | - if (isset($line['time'])) { |
|
1404 | + $line = json_decode($buffer_line,true); |
|
1405 | + if (isset($line['time'])) { |
|
1406 | 1406 | $data = array(); |
1407 | 1407 | $data['altitude'] = $line['alt']; // altitude |
1408 | 1408 | $data['latitude'] = $line['lat']; // lat |
@@ -1414,94 +1414,94 @@ discard block |
||
1414 | 1414 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1415 | 1415 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
1416 | 1416 | unset($data); |
1417 | - } |
|
1417 | + } |
|
1418 | 1418 | } |
1419 | 1419 | if ($globalDebug) echo 'No more data...'."\n"; |
1420 | 1420 | unset($buffer); |
1421 | - } |
|
1422 | - $last_exec[$id]['last'] = time(); |
|
1421 | + } |
|
1422 | + $last_exec[$id]['last'] = time(); |
|
1423 | 1423 | //} elseif ($value === 'sbs' || $value === 'tsv' || $value === 'raw' || $value === 'aprs' || $value === 'beast') { |
1424 | 1424 | } 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') { |
1425 | - //$last_exec[$id]['last'] = time(); |
|
1426 | - //$read = array( $sockets[$id] ); |
|
1427 | - $read = $sockets; |
|
1428 | - $write = NULL; |
|
1429 | - $e = NULL; |
|
1430 | - $n = socket_select($read, $write, $e, $timeout); |
|
1431 | - if ($e != NULL) var_dump($e); |
|
1432 | - if ($n > 0) { |
|
1425 | + //$last_exec[$id]['last'] = time(); |
|
1426 | + //$read = array( $sockets[$id] ); |
|
1427 | + $read = $sockets; |
|
1428 | + $write = NULL; |
|
1429 | + $e = NULL; |
|
1430 | + $n = socket_select($read, $write, $e, $timeout); |
|
1431 | + if ($e != NULL) var_dump($e); |
|
1432 | + if ($n > 0) { |
|
1433 | 1433 | $reset = 0; |
1434 | 1434 | foreach ($read as $nb => $r) { |
1435 | - //$value = $formats[$nb]; |
|
1436 | - $format = $globalSources[$nb]['format']; |
|
1437 | - if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
|
1435 | + //$value = $formats[$nb]; |
|
1436 | + $format = $globalSources[$nb]['format']; |
|
1437 | + if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
|
1438 | 1438 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
1439 | - } elseif ($format === 'vrstcp') { |
|
1439 | + } elseif ($format === 'vrstcp') { |
|
1440 | 1440 | $buffer = @socket_read($r, 6000); |
1441 | - } else { |
|
1441 | + } else { |
|
1442 | 1442 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
1443 | - } |
|
1444 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1445 | - //echo $buffer."\n"; |
|
1446 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
1447 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1448 | - $error = false; |
|
1449 | - //$SI::del(); |
|
1450 | - if ($buffer !== FALSE) { |
|
1443 | + } |
|
1444 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1445 | + //echo $buffer."\n"; |
|
1446 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
1447 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1448 | + $error = false; |
|
1449 | + //$SI::del(); |
|
1450 | + if ($buffer !== FALSE) { |
|
1451 | 1451 | if ($format === 'vrstcp') { |
1452 | - $buffer = explode('},{',$buffer); |
|
1452 | + $buffer = explode('},{',$buffer); |
|
1453 | 1453 | } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
1454 | - } |
|
1455 | - // SBS format is CSV format |
|
1456 | - if ($buffer !== FALSE && $buffer !== '') { |
|
1454 | + } |
|
1455 | + // SBS format is CSV format |
|
1456 | + if ($buffer !== FALSE && $buffer !== '') { |
|
1457 | 1457 | $tt[$format] = 0; |
1458 | 1458 | if ($format === 'acarssbs3') { |
1459 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1460 | - $ACARS->add(trim($buffer)); |
|
1461 | - $ACARS->deleteLiveAcarsData(); |
|
1459 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1460 | + $ACARS->add(trim($buffer)); |
|
1461 | + $ACARS->deleteLiveAcarsData(); |
|
1462 | 1462 | } elseif ($format === 'raw') { |
1463 | - // AVR format |
|
1464 | - $data = $SBS->parse($buffer); |
|
1465 | - if (is_array($data)) { |
|
1463 | + // AVR format |
|
1464 | + $data = $SBS->parse($buffer); |
|
1465 | + if (is_array($data)) { |
|
1466 | 1466 | $data['datetime'] = date('Y-m-d H:i:s'); |
1467 | 1467 | $data['format_source'] = 'raw'; |
1468 | 1468 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1469 | 1469 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1470 | 1470 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1471 | 1471 | if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1472 | - } |
|
1472 | + } |
|
1473 | 1473 | } elseif ($format === 'ais') { |
1474 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
1475 | - $data = array(); |
|
1476 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1477 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1478 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1479 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1480 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1481 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1482 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1483 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1484 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1485 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1486 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1487 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1488 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1489 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1490 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1491 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1474 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
1475 | + $data = array(); |
|
1476 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1477 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1478 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1479 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1480 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1481 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1482 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1483 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1484 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1485 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1486 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1487 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1488 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1489 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1490 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1491 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1492 | 1492 | |
1493 | - if (isset($ais_data['timestamp'])) { |
|
1493 | + if (isset($ais_data['timestamp'])) { |
|
1494 | 1494 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
1495 | - } else { |
|
1495 | + } else { |
|
1496 | 1496 | $data['datetime'] = date('Y-m-d H:i:s'); |
1497 | - } |
|
1498 | - $data['format_source'] = 'aisnmea'; |
|
1499 | - $data['id_source'] = $id_source; |
|
1500 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
1501 | - unset($data); |
|
1502 | - } elseif ($format === 'flightgearsp') { |
|
1503 | - //echo $buffer."\n"; |
|
1504 | - if (strlen($buffer) > 5) { |
|
1497 | + } |
|
1498 | + $data['format_source'] = 'aisnmea'; |
|
1499 | + $data['id_source'] = $id_source; |
|
1500 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
1501 | + unset($data); |
|
1502 | + } elseif ($format === 'flightgearsp') { |
|
1503 | + //echo $buffer."\n"; |
|
1504 | + if (strlen($buffer) > 5) { |
|
1505 | 1505 | $line = explode(',',$buffer); |
1506 | 1506 | $data = array(); |
1507 | 1507 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1518,38 +1518,38 @@ discard block |
||
1518 | 1518 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1519 | 1519 | if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1520 | 1520 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1521 | - } |
|
1522 | - } elseif ($format === 'acars') { |
|
1523 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1524 | - $ACARS->add(trim($buffer)); |
|
1525 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1526 | - $ACARS->deleteLiveAcarsData(); |
|
1521 | + } |
|
1522 | + } elseif ($format === 'acars') { |
|
1523 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1524 | + $ACARS->add(trim($buffer)); |
|
1525 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1526 | + $ACARS->deleteLiveAcarsData(); |
|
1527 | 1527 | } elseif ($format === 'flightgearmp') { |
1528 | - if (substr($buffer,0,1) != '#') { |
|
1528 | + if (substr($buffer,0,1) != '#') { |
|
1529 | 1529 | $data = array(); |
1530 | 1530 | //echo $buffer."\n"; |
1531 | 1531 | $line = explode(' ',$buffer); |
1532 | 1532 | if (count($line) === 11) { |
1533 | - $userserver = explode('@',$line[0]); |
|
1534 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1535 | - $data['ident'] = $userserver[0]; |
|
1536 | - $data['registration'] = $userserver[0]; |
|
1537 | - $data['latitude'] = $line[4]; |
|
1538 | - $data['longitude'] = $line[5]; |
|
1539 | - $data['altitude'] = $line[6]; |
|
1540 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1541 | - $aircraft_type = $line[10]; |
|
1542 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1543 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1544 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1545 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1533 | + $userserver = explode('@',$line[0]); |
|
1534 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1535 | + $data['ident'] = $userserver[0]; |
|
1536 | + $data['registration'] = $userserver[0]; |
|
1537 | + $data['latitude'] = $line[4]; |
|
1538 | + $data['longitude'] = $line[5]; |
|
1539 | + $data['altitude'] = $line[6]; |
|
1540 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1541 | + $aircraft_type = $line[10]; |
|
1542 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1543 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1544 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1545 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1546 | + } |
|
1546 | 1547 | } |
1547 | - } |
|
1548 | 1548 | } elseif ($format === 'beast') { |
1549 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1550 | - die; |
|
1549 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1550 | + die; |
|
1551 | 1551 | } elseif ($format === 'vrstcp') { |
1552 | - foreach($buffer as $all_data) { |
|
1552 | + foreach($buffer as $all_data) { |
|
1553 | 1553 | $line = json_decode('{'.$all_data.'}',true); |
1554 | 1554 | $data = array(); |
1555 | 1555 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1569,153 +1569,153 @@ discard block |
||
1569 | 1569 | */ |
1570 | 1570 | $data['datetime'] = date('Y-m-d H:i:s'); |
1571 | 1571 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
1572 | - $data['format_source'] = 'vrstcp'; |
|
1572 | + $data['format_source'] = 'vrstcp'; |
|
1573 | 1573 | $data['id_source'] = $id_source; |
1574 | 1574 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1575 | 1575 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1576 | 1576 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1577 | 1577 | unset($data); |
1578 | - } |
|
1578 | + } |
|
1579 | 1579 | } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
1580 | - $line = explode("\t", $buffer); |
|
1581 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1580 | + $line = explode("\t", $buffer); |
|
1581 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
1582 | 1582 | $key = $line[$k]; |
1583 | - $lined[$key] = $line[$k+1]; |
|
1584 | - } |
|
1585 | - if (count($lined) > 3) { |
|
1586 | - $data['hex'] = $lined['hexid']; |
|
1587 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1588 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1589 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1590 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1591 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1592 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1593 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1594 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1595 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1596 | - $data['id_source'] = $id_source; |
|
1597 | - $data['format_source'] = 'tsv'; |
|
1598 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1599 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1583 | + $lined[$key] = $line[$k+1]; |
|
1584 | + } |
|
1585 | + if (count($lined) > 3) { |
|
1586 | + $data['hex'] = $lined['hexid']; |
|
1587 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1588 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
1589 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1590 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1591 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1592 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1593 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1594 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1595 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1596 | + $data['id_source'] = $id_source; |
|
1597 | + $data['format_source'] = 'tsv'; |
|
1598 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1599 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1600 | 1600 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1601 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1602 | - unset($lined); |
|
1603 | - unset($data); |
|
1604 | - } else $error = true; |
|
1601 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1602 | + unset($lined); |
|
1603 | + unset($data); |
|
1604 | + } else $error = true; |
|
1605 | 1605 | } elseif ($format === 'aprs' && $use_aprs) { |
1606 | - if ($aprs_connect === 0) { |
|
1606 | + if ($aprs_connect === 0) { |
|
1607 | 1607 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
1608 | 1608 | $aprs_connect = 1; |
1609 | - } |
|
1609 | + } |
|
1610 | 1610 | |
1611 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1611 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1612 | 1612 | $aprs_last_tx = time(); |
1613 | 1613 | $data_aprs = "# Keep alive"; |
1614 | 1614 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1615 | - } |
|
1615 | + } |
|
1616 | 1616 | |
1617 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1618 | - //echo 'APRS data : '.$buffer."\n"; |
|
1619 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1620 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1621 | - //echo $buffer."\n"; |
|
1622 | - date_default_timezone_set('UTC'); |
|
1623 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1617 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1618 | + //echo 'APRS data : '.$buffer."\n"; |
|
1619 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
1620 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
1621 | + //echo $buffer."\n"; |
|
1622 | + date_default_timezone_set('UTC'); |
|
1623 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1624 | 1624 | $line = $APRS->parse($buffer); |
1625 | 1625 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1626 | 1626 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
1627 | - $aprs_last_tx = time(); |
|
1628 | - $data = array(); |
|
1629 | - //print_r($line); |
|
1630 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1631 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1632 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1633 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1634 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
1635 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
1636 | - if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
1637 | - if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
1638 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1639 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1640 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1641 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1642 | - $data['latitude'] = $line['latitude']; |
|
1643 | - $data['longitude'] = $line['longitude']; |
|
1644 | - //$data['verticalrate'] = $line[16]; |
|
1645 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1646 | - //else $data['speed'] = 0; |
|
1647 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1648 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1649 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1650 | - //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1627 | + $aprs_last_tx = time(); |
|
1628 | + $data = array(); |
|
1629 | + //print_r($line); |
|
1630 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1631 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1632 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1633 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1634 | + if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
1635 | + if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
1636 | + if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
1637 | + if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
1638 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1639 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1640 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1641 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1642 | + $data['latitude'] = $line['latitude']; |
|
1643 | + $data['longitude'] = $line['longitude']; |
|
1644 | + //$data['verticalrate'] = $line[16]; |
|
1645 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1646 | + //else $data['speed'] = 0; |
|
1647 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1648 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1649 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1650 | + //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1651 | 1651 | |
1652 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
1653 | - //else echo 'No heading...'."\n"; |
|
1654 | - //else $data['heading'] = 0; |
|
1655 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1656 | - //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1657 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1658 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1659 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1660 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1661 | - $data['id_source'] = $id_source; |
|
1662 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1663 | - else $data['format_source'] = 'aprs'; |
|
1664 | - $data['source_name'] = $line['source']; |
|
1665 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1666 | - else $data['source_type'] = 'flarm'; |
|
1667 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1668 | - $currentdate = date('Y-m-d H:i:s'); |
|
1669 | - $aprsdate = strtotime($data['datetime']); |
|
1670 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1671 | - // Accept data if time <= system time + 20s |
|
1672 | - //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'])))) { |
|
1673 | - 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'])))) { |
|
1652 | + if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
1653 | + //else echo 'No heading...'."\n"; |
|
1654 | + //else $data['heading'] = 0; |
|
1655 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1656 | + //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1657 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1658 | + elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1659 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1660 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1661 | + $data['id_source'] = $id_source; |
|
1662 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1663 | + else $data['format_source'] = 'aprs'; |
|
1664 | + $data['source_name'] = $line['source']; |
|
1665 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1666 | + else $data['source_type'] = 'flarm'; |
|
1667 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1668 | + $currentdate = date('Y-m-d H:i:s'); |
|
1669 | + $aprsdate = strtotime($data['datetime']); |
|
1670 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1671 | + // Accept data if time <= system time + 20s |
|
1672 | + //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'])))) { |
|
1673 | + 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'])))) { |
|
1674 | 1674 | $send = $SI->add($data); |
1675 | - } elseif ($data['source_type'] === 'ais') { |
|
1675 | + } elseif ($data['source_type'] === 'ais') { |
|
1676 | 1676 | $data['type'] = ''; |
1677 | 1677 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
1678 | - } elseif (isset($line['stealth'])) { |
|
1678 | + } elseif (isset($line['stealth'])) { |
|
1679 | 1679 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
1680 | 1680 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
1681 | - } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1682 | - //$line['symbol'] === 'Balloon' || |
|
1683 | - $line['symbol'] === 'Glider' || |
|
1684 | - $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
|
1685 | - if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1686 | - if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1687 | - $send = $SI->add($data); |
|
1688 | - } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1689 | - $line['symbol'] === 'Yacht (Sail)' || |
|
1690 | - $line['symbol'] === 'Ship (Power Boat)')) { |
|
1691 | - $send = $MI->add($data); |
|
1692 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1693 | - $line['symbol'] === 'Car' || |
|
1694 | - $line['symbol'] === 'Ambulance' || |
|
1695 | - $line['symbol'] === 'Van' || |
|
1696 | - $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || |
|
1697 | - $line['symbol'] === 'Motorcycle' || |
|
1698 | - $line['symbol'] === 'Tractor' || |
|
1699 | - $line['symbol'] === 'Police' || |
|
1700 | - $line['symbol'] === 'Bike' || |
|
1701 | - $line['symbol'] === 'Jogger' || |
|
1702 | - $line['symbol'] === 'Horse' || |
|
1703 | - $line['symbol'] === 'Bus' || |
|
1704 | - $line['symbol'] === 'Jeep' || |
|
1705 | - $line['symbol'] === 'Recreational Vehicle' || |
|
1706 | - $line['symbol'] === 'Yacht (Sail)' || |
|
1707 | - $line['symbol'] === 'Ship (Power Boat)' || |
|
1708 | - $line['symbol'] === 'Firetruck' || |
|
1709 | - $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || |
|
1710 | - $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || |
|
1711 | - $line['symbol'] === 'SUV' || |
|
1712 | - $line['symbol'] === 'Snowmobile' || |
|
1713 | - $line['symbol'] === 'Mobile Satellite Station')) { |
|
1714 | - //} 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') { |
|
1681 | + } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1682 | + //$line['symbol'] === 'Balloon' || |
|
1683 | + $line['symbol'] === 'Glider' || |
|
1684 | + $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
|
1685 | + if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1686 | + if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1687 | + $send = $SI->add($data); |
|
1688 | + } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1689 | + $line['symbol'] === 'Yacht (Sail)' || |
|
1690 | + $line['symbol'] === 'Ship (Power Boat)')) { |
|
1691 | + $send = $MI->add($data); |
|
1692 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1693 | + $line['symbol'] === 'Car' || |
|
1694 | + $line['symbol'] === 'Ambulance' || |
|
1695 | + $line['symbol'] === 'Van' || |
|
1696 | + $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || |
|
1697 | + $line['symbol'] === 'Motorcycle' || |
|
1698 | + $line['symbol'] === 'Tractor' || |
|
1699 | + $line['symbol'] === 'Police' || |
|
1700 | + $line['symbol'] === 'Bike' || |
|
1701 | + $line['symbol'] === 'Jogger' || |
|
1702 | + $line['symbol'] === 'Horse' || |
|
1703 | + $line['symbol'] === 'Bus' || |
|
1704 | + $line['symbol'] === 'Jeep' || |
|
1705 | + $line['symbol'] === 'Recreational Vehicle' || |
|
1706 | + $line['symbol'] === 'Yacht (Sail)' || |
|
1707 | + $line['symbol'] === 'Ship (Power Boat)' || |
|
1708 | + $line['symbol'] === 'Firetruck' || |
|
1709 | + $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || |
|
1710 | + $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || |
|
1711 | + $line['symbol'] === 'SUV' || |
|
1712 | + $line['symbol'] === 'Snowmobile' || |
|
1713 | + $line['symbol'] === 'Mobile Satellite Station')) { |
|
1714 | + //} 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') { |
|
1715 | 1715 | // } 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') { |
1716 | 1716 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1717 | 1717 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
1718 | - } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1718 | + } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1719 | 1719 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
1720 | 1720 | $Source->deleteOldLocationByType('gs'); |
1721 | 1721 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
@@ -1723,7 +1723,7 @@ discard block |
||
1723 | 1723 | } else { |
1724 | 1724 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
1725 | 1725 | } |
1726 | - } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
|
1726 | + } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
|
1727 | 1727 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1728 | 1728 | if ($globalDebug) echo '# Weather Station added'."\n"; |
1729 | 1729 | $Source->deleteOldLocationByType('wx'); |
@@ -1733,7 +1733,7 @@ discard block |
||
1733 | 1733 | } else { |
1734 | 1734 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
1735 | 1735 | } |
1736 | - } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
|
1736 | + } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
|
1737 | 1737 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1738 | 1738 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1739 | 1739 | $Source->deleteOldLocationByType('lightning'); |
@@ -1742,11 +1742,11 @@ discard block |
||
1742 | 1742 | } else { |
1743 | 1743 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
1744 | 1744 | } |
1745 | - } elseif ($globalDebug) { |
|
1746 | - echo '/!\ Not added: '.$buffer."\n"; |
|
1747 | - print_r($line); |
|
1748 | - } |
|
1749 | - unset($data); |
|
1745 | + } elseif ($globalDebug) { |
|
1746 | + echo '/!\ Not added: '.$buffer."\n"; |
|
1747 | + print_r($line); |
|
1748 | + } |
|
1749 | + unset($data); |
|
1750 | 1750 | } |
1751 | 1751 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
1752 | 1752 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
@@ -1765,12 +1765,12 @@ discard block |
||
1765 | 1765 | } elseif (!isset($globalSources[$nb]['last_weather_clean'])) { |
1766 | 1766 | $globalSources[$nb]['last_weather_clean'] = time(); |
1767 | 1767 | } |
1768 | - } |
|
1768 | + } |
|
1769 | 1769 | } else { |
1770 | - $line = explode(',', $buffer); |
|
1771 | - if (count($line) > 20) { |
|
1772 | - $data['hex'] = $line[4]; |
|
1773 | - /* |
|
1770 | + $line = explode(',', $buffer); |
|
1771 | + if (count($line) > 20) { |
|
1772 | + $data['hex'] = $line[4]; |
|
1773 | + /* |
|
1774 | 1774 | $data['datetime'] = $line[6].' '.$line[7]; |
1775 | 1775 | date_default_timezone_set($globalTimezone); |
1776 | 1776 | $datetime = new DateTime($data['datetime']); |
@@ -1778,30 +1778,30 @@ discard block |
||
1778 | 1778 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1779 | 1779 | date_default_timezone_set('UTC'); |
1780 | 1780 | */ |
1781 | - // Force datetime to current UTC datetime |
|
1782 | - date_default_timezone_set('UTC'); |
|
1783 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1784 | - $data['ident'] = trim($line[10]); |
|
1785 | - $data['latitude'] = $line[14]; |
|
1786 | - $data['longitude'] = $line[15]; |
|
1787 | - $data['verticalrate'] = $line[16]; |
|
1788 | - $data['emergency'] = $line[20]; |
|
1789 | - $data['speed'] = $line[12]; |
|
1790 | - $data['squawk'] = $line[17]; |
|
1791 | - $data['altitude'] = $line[11]; |
|
1792 | - $data['heading'] = $line[13]; |
|
1793 | - $data['ground'] = $line[21]; |
|
1794 | - $data['emergency'] = $line[19]; |
|
1795 | - $data['format_source'] = 'sbs'; |
|
1781 | + // Force datetime to current UTC datetime |
|
1782 | + date_default_timezone_set('UTC'); |
|
1783 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1784 | + $data['ident'] = trim($line[10]); |
|
1785 | + $data['latitude'] = $line[14]; |
|
1786 | + $data['longitude'] = $line[15]; |
|
1787 | + $data['verticalrate'] = $line[16]; |
|
1788 | + $data['emergency'] = $line[20]; |
|
1789 | + $data['speed'] = $line[12]; |
|
1790 | + $data['squawk'] = $line[17]; |
|
1791 | + $data['altitude'] = $line[11]; |
|
1792 | + $data['heading'] = $line[13]; |
|
1793 | + $data['ground'] = $line[21]; |
|
1794 | + $data['emergency'] = $line[19]; |
|
1795 | + $data['format_source'] = 'sbs'; |
|
1796 | 1796 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1797 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1797 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1798 | 1798 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1799 | - $data['id_source'] = $id_source; |
|
1800 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1801 | - else $error = true; |
|
1802 | - unset($data); |
|
1803 | - } else $error = true; |
|
1804 | - if ($error) { |
|
1799 | + $data['id_source'] = $id_source; |
|
1800 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1801 | + else $error = true; |
|
1802 | + unset($data); |
|
1803 | + } else $error = true; |
|
1804 | + if ($error) { |
|
1805 | 1805 | if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { |
1806 | 1806 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
1807 | 1807 | } else { |
@@ -1817,13 +1817,13 @@ discard block |
||
1817 | 1817 | connect_all($sourceer); |
1818 | 1818 | $sourceer = array(); |
1819 | 1819 | } |
1820 | - } |
|
1820 | + } |
|
1821 | 1821 | } |
1822 | 1822 | // Sleep for xxx microseconds |
1823 | 1823 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
1824 | - } else { |
|
1824 | + } else { |
|
1825 | 1825 | if ($format === 'flightgearmp') { |
1826 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1826 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1827 | 1827 | //@socket_close($r); |
1828 | 1828 | sleep($globalMinFetch); |
1829 | 1829 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1832,9 +1832,9 @@ discard block |
||
1832 | 1832 | break; |
1833 | 1833 | |
1834 | 1834 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1835 | - if (isset($tt[$format])) $tt[$format]++; |
|
1836 | - else $tt[$format] = 0; |
|
1837 | - if ($tt[$format] > 30 || $buffer === FALSE) { |
|
1835 | + if (isset($tt[$format])) $tt[$format]++; |
|
1836 | + else $tt[$format] = 0; |
|
1837 | + if ($tt[$format] > 30 || $buffer === FALSE) { |
|
1838 | 1838 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
1839 | 1839 | //@socket_close($r); |
1840 | 1840 | sleep(2); |
@@ -1845,24 +1845,24 @@ discard block |
||
1845 | 1845 | //connect_all($globalSources); |
1846 | 1846 | $tt[$format]=0; |
1847 | 1847 | break; |
1848 | - } |
|
1849 | - //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
1848 | + } |
|
1849 | + //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
1850 | + } |
|
1850 | 1851 | } |
1851 | - } |
|
1852 | 1852 | } |
1853 | - } else { |
|
1853 | + } else { |
|
1854 | 1854 | $error = socket_strerror(socket_last_error()); |
1855 | 1855 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1856 | 1856 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
1857 | 1857 | if (isset($globalDebug)) echo "Restarting...\n"; |
1858 | 1858 | // Restart the script if possible |
1859 | 1859 | if (is_array($sockets)) { |
1860 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
1860 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
1861 | 1861 | |
1862 | - foreach ($sockets as $sock) { |
|
1862 | + foreach ($sockets as $sock) { |
|
1863 | 1863 | @socket_shutdown($sock,2); |
1864 | 1864 | @socket_close($sock); |
1865 | - } |
|
1865 | + } |
|
1866 | 1866 | |
1867 | 1867 | } |
1868 | 1868 | if ($globalDebug) echo "Waiting..."; |
@@ -1877,15 +1877,15 @@ discard block |
||
1877 | 1877 | if ($globalDebug) echo "Restart all connections..."; |
1878 | 1878 | connect_all($globalSources); |
1879 | 1879 | } |
1880 | - } |
|
1880 | + } |
|
1881 | 1881 | } |
1882 | 1882 | if ($globalDaemon === false) { |
1883 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1884 | - if (isset($SI)) $SI->checkAll(); |
|
1885 | - if (isset($TI)) $TI->checkAll(); |
|
1886 | - if (isset($MI)) $MI->checkAll(); |
|
1883 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
1884 | + if (isset($SI)) $SI->checkAll(); |
|
1885 | + if (isset($TI)) $TI->checkAll(); |
|
1886 | + if (isset($MI)) $MI->checkAll(); |
|
1887 | + } |
|
1887 | 1888 | } |
1888 | - } |
|
1889 | 1889 | } |
1890 | 1890 | |
1891 | 1891 | ?> |
@@ -14,13 +14,17 @@ discard block |
||
14 | 14 | require_once(dirname(__FILE__).'/../require/class.Source.php'); |
15 | 15 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
17 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
17 | +if (isset($globalTracker) && $globalTracker) { |
|
18 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
19 | +} |
|
18 | 20 | if (isset($globalMarine) && $globalMarine) { |
19 | 21 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
20 | 22 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
21 | 23 | } |
22 | 24 | |
23 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
25 | +if (!isset($globalDebug)) { |
|
26 | + $globalDebug = FALSE; |
|
27 | +} |
|
24 | 28 | |
25 | 29 | // Check if schema is at latest version |
26 | 30 | $Connection = new Connection(); |
@@ -59,66 +63,107 @@ discard block |
||
59 | 63 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
60 | 64 | if (isset($options['s'])) { |
61 | 65 | $globalSources = array(); |
62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
63 | - else $globalSources[] = array('host' => $options['s']); |
|
64 | -} elseif (isset($options['source'])) { |
|
66 | + if (isset($options['format'])) { |
|
67 | + $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
68 | + } else { |
|
69 | + $globalSources[] = array('host' => $options['s']); |
|
70 | + } |
|
71 | + } elseif (isset($options['source'])) { |
|
65 | 72 | $globalSources = array(); |
66 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
67 | - else $globalSources[] = array('host' => $options['source']); |
|
68 | -} |
|
73 | + if (isset($options['format'])) { |
|
74 | + $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
75 | + } else { |
|
76 | + $globalSources[] = array('host' => $options['source']); |
|
77 | + } |
|
78 | + } |
|
69 | 79 | if (isset($options['aprsserverhost'])) { |
70 | 80 | $globalServerAPRS = TRUE; |
71 | 81 | $globalServerAPRShost = $options['aprsserverhost']; |
72 | 82 | } |
73 | -if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport']; |
|
74 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
|
75 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
|
76 | -if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; |
|
83 | +if (isset($options['aprsserverport'])) { |
|
84 | + $globalServerAPRSport = $options['aprsserverport']; |
|
85 | +} |
|
86 | +if (isset($options['aprsserverssid'])) { |
|
87 | + $globalServerAPRSssid = $options['aprsserverssid']; |
|
88 | +} |
|
89 | +if (isset($options['aprsserverpass'])) { |
|
90 | + $globalServerAPRSpass = $options['aprsserverpass']; |
|
91 | +} |
|
92 | +if (isset($options['noaprsserver'])) { |
|
93 | + $globalServerAPRS = FALSE; |
|
94 | +} |
|
77 | 95 | if (isset($options['enable-aircraft'])) { |
78 | - if ($globalDebug) echo 'Enable Aircraft mode'."\n"; |
|
96 | + if ($globalDebug) { |
|
97 | + echo 'Enable Aircraft mode'."\n"; |
|
98 | + } |
|
79 | 99 | $globalAircraft = TRUE; |
80 | 100 | } |
81 | 101 | if (isset($options['disable-aircraft'])) { |
82 | - if ($globalDebug) echo 'Disable Aircraft mode'."\n"; |
|
102 | + if ($globalDebug) { |
|
103 | + echo 'Disable Aircraft mode'."\n"; |
|
104 | + } |
|
83 | 105 | $globalAircraft = FALSE; |
84 | 106 | } |
85 | 107 | if (isset($options['enable-tracker'])) { |
86 | - if ($globalDebug) echo 'Enable Tracker mode'."\n"; |
|
108 | + if ($globalDebug) { |
|
109 | + echo 'Enable Tracker mode'."\n"; |
|
110 | + } |
|
87 | 111 | $globalTracker = TRUE; |
88 | 112 | } |
89 | 113 | if (isset($options['disable-tracker'])) { |
90 | - if ($globalDebug) echo 'Disable Tracker mode'."\n"; |
|
114 | + if ($globalDebug) { |
|
115 | + echo 'Disable Tracker mode'."\n"; |
|
116 | + } |
|
91 | 117 | $globalTracker = FALSE; |
92 | 118 | } |
93 | 119 | if (isset($options['enable-marine'])) { |
94 | - if ($globalDebug) echo 'Enable Marine mode'."\n"; |
|
120 | + if ($globalDebug) { |
|
121 | + echo 'Enable Marine mode'."\n"; |
|
122 | + } |
|
95 | 123 | $globalMarine = TRUE; |
96 | 124 | } |
97 | 125 | if (isset($options['disable-marine'])) { |
98 | - if ($globalDebug) echo 'Disable Marine mode'."\n"; |
|
126 | + if ($globalDebug) { |
|
127 | + echo 'Disable Marine mode'."\n"; |
|
128 | + } |
|
99 | 129 | $globalMarine = FALSE; |
100 | 130 | } |
101 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; |
|
102 | -if (isset($options['server'])) $globalServer = TRUE; |
|
103 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
104 | -else $id_source = 1; |
|
131 | +if (isset($options['nodaemon'])) { |
|
132 | + $globalDaemon = FALSE; |
|
133 | +} |
|
134 | +if (isset($options['server'])) { |
|
135 | + $globalServer = TRUE; |
|
136 | +} |
|
137 | +if (isset($options['idsource'])) { |
|
138 | + $id_source = $options['idsource']; |
|
139 | +} else { |
|
140 | + $id_source = 1; |
|
141 | +} |
|
105 | 142 | if (isset($globalServer) && $globalServer) { |
106 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
143 | + if ($globalDebug) { |
|
144 | + echo "Using Server Mode\n"; |
|
145 | + } |
|
107 | 146 | $SI=new SpotterServer(); |
108 | 147 | /* |
109 | 148 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
110 | 149 | $SI = new adsb2aprs(); |
111 | 150 | $SI->connect(); |
112 | 151 | */ |
113 | -} else $SI=new SpotterImport($Connection->db); |
|
152 | +} else { |
|
153 | + $SI=new SpotterImport($Connection->db); |
|
154 | +} |
|
114 | 155 | |
115 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
156 | +if (isset($globalTracker) && $globalTracker) { |
|
157 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
158 | +} |
|
116 | 159 | if (isset($globalMarine) && $globalMarine) { |
117 | 160 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
118 | 161 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
119 | 162 | } |
120 | 163 | |
121 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
164 | +if (isset($globalTracker) && $globalTracker) { |
|
165 | + $TI = new TrackerImport($Connection->db); |
|
166 | +} |
|
122 | 167 | if (isset($globalMarine) && $globalMarine) { |
123 | 168 | $AIS = new AIS(); |
124 | 169 | $MI = new MarineImport($Connection->db); |
@@ -143,7 +188,9 @@ discard block |
||
143 | 188 | } |
144 | 189 | |
145 | 190 | // let's try and connect |
146 | -if ($globalDebug) echo "Connecting...\n"; |
|
191 | +if ($globalDebug) { |
|
192 | + echo "Connecting...\n"; |
|
193 | +} |
|
147 | 194 | $use_aprs = false; |
148 | 195 | $aprs_full = false; |
149 | 196 | $reset = 0; |
@@ -152,7 +199,9 @@ discard block |
||
152 | 199 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
153 | 200 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
154 | 201 | $reset++; |
155 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
202 | + if ($globalDebug) { |
|
203 | + echo 'Connect to all...'."\n"; |
|
204 | + } |
|
156 | 205 | foreach ($hosts as $id => $value) { |
157 | 206 | $host = $value['host']; |
158 | 207 | $globalSources[$id]['last_exec'] = 0; |
@@ -162,27 +211,37 @@ discard block |
||
162 | 211 | //$formats[$id] = 'deltadbtxt'; |
163 | 212 | $globalSources[$id]['format'] = 'deltadbtxt'; |
164 | 213 | //$last_exec['deltadbtxt'] = 0; |
165 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
214 | + if ($globalDebug) { |
|
215 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
216 | + } |
|
166 | 217 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
167 | 218 | //$formats[$id] = 'vatsimtxt'; |
168 | 219 | $globalSources[$id]['format'] = 'vatsimtxt'; |
169 | 220 | //$last_exec['vatsimtxt'] = 0; |
170 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
221 | + if ($globalDebug) { |
|
222 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
223 | + } |
|
171 | 224 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
172 | 225 | //$formats[$id] = 'aircraftlistjson'; |
173 | 226 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
174 | 227 | //$last_exec['aircraftlistjson'] = 0; |
175 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
228 | + if ($globalDebug) { |
|
229 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
230 | + } |
|
176 | 231 | } else if (preg_match('/aircraft.json$/i',$host)) { |
177 | 232 | //$formats[$id] = 'aircraftjson'; |
178 | 233 | $globalSources[$id]['format'] = 'aircraftjson'; |
179 | 234 | //$last_exec['aircraftlistjson'] = 0; |
180 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
235 | + if ($globalDebug) { |
|
236 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
237 | + } |
|
181 | 238 | } else if (preg_match('/opensky/i',$host)) { |
182 | 239 | //$formats[$id] = 'aircraftlistjson'; |
183 | 240 | $globalSources[$id]['format'] = 'opensky'; |
184 | 241 | //$last_exec['aircraftlistjson'] = 0; |
185 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
242 | + if ($globalDebug) { |
|
243 | + echo "Connect to opensky source (".$host.")...\n"; |
|
244 | + } |
|
186 | 245 | /* |
187 | 246 | // Disabled for now, site change source format |
188 | 247 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
@@ -199,7 +258,9 @@ discard block |
||
199 | 258 | //$formats[$id] = 'planeupdatefaa'; |
200 | 259 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
201 | 260 | //$last_exec['planeupdatefaa'] = 0; |
202 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
261 | + if ($globalDebug) { |
|
262 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
263 | + } |
|
203 | 264 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
204 | 265 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
205 | 266 | exit(0); |
@@ -208,37 +269,53 @@ discard block |
||
208 | 269 | //$formats[$id] = 'phpvmacars'; |
209 | 270 | $globalSources[$id]['format'] = 'phpvmacars'; |
210 | 271 | //$last_exec['phpvmacars'] = 0; |
211 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
272 | + if ($globalDebug) { |
|
273 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
274 | + } |
|
212 | 275 | } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
213 | 276 | //$formats[$id] = 'phpvmacars'; |
214 | 277 | $globalSources[$id]['format'] = 'vaos'; |
215 | 278 | //$last_exec['phpvmacars'] = 0; |
216 | - if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
279 | + if ($globalDebug) { |
|
280 | + echo "Connect to vaos source (".$host.")...\n"; |
|
281 | + } |
|
217 | 282 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
218 | 283 | //$formats[$id] = 'phpvmacars'; |
219 | 284 | $globalSources[$id]['format'] = 'vam'; |
220 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
285 | + if ($globalDebug) { |
|
286 | + echo "Connect to Vam source (".$host.")...\n"; |
|
287 | + } |
|
221 | 288 | } else if (preg_match('/whazzup/i',$host)) { |
222 | 289 | //$formats[$id] = 'whazzup'; |
223 | 290 | $globalSources[$id]['format'] = 'whazzup'; |
224 | 291 | //$last_exec['whazzup'] = 0; |
225 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
292 | + if ($globalDebug) { |
|
293 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
294 | + } |
|
226 | 295 | } else if (preg_match('/blitzortung/i',$host)) { |
227 | 296 | $globalSources[$id]['format'] = 'blitzortung'; |
228 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
297 | + if ($globalDebug) { |
|
298 | + echo "Connect to blitzortung source (".$host.")...\n"; |
|
299 | + } |
|
229 | 300 | } else if (preg_match('/airwhere/i',$host)) { |
230 | 301 | $globalSources[$id]['format'] = 'airwhere'; |
231 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
302 | + if ($globalDebug) { |
|
303 | + echo "Connect to airwhere source (".$host.")...\n"; |
|
304 | + } |
|
232 | 305 | } else if (preg_match('/recentpireps/i',$host)) { |
233 | 306 | //$formats[$id] = 'pirepsjson'; |
234 | 307 | $globalSources[$id]['format'] = 'pirepsjson'; |
235 | 308 | //$last_exec['pirepsjson'] = 0; |
236 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
309 | + if ($globalDebug) { |
|
310 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
311 | + } |
|
237 | 312 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
238 | 313 | //$formats[$id] = 'fr24json'; |
239 | 314 | $globalSources[$id]['format'] = 'fr24json'; |
240 | 315 | //$last_exec['fr24json'] = 0; |
241 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
316 | + if ($globalDebug) { |
|
317 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
318 | + } |
|
242 | 319 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
243 | 320 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
244 | 321 | exit(0); |
@@ -247,7 +324,9 @@ discard block |
||
247 | 324 | //$formats[$id] = 'fr24json'; |
248 | 325 | $globalSources[$id]['format'] = 'myshiptracking'; |
249 | 326 | //$last_exec['fr24json'] = 0; |
250 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
327 | + if ($globalDebug) { |
|
328 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
329 | + } |
|
251 | 330 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
252 | 331 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
253 | 332 | exit(0); |
@@ -256,16 +335,24 @@ discard block |
||
256 | 335 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
257 | 336 | //$formats[$id] = 'tsv'; |
258 | 337 | $globalSources[$id]['format'] = 'tsv'; |
259 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
338 | + if ($globalDebug) { |
|
339 | + echo "Connect to tsv source (".$host.")...\n"; |
|
340 | + } |
|
260 | 341 | } |
261 | 342 | } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
262 | 343 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
263 | 344 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
264 | 345 | if ($idf !== false) { |
265 | 346 | $httpfeeds[$id] = $idf; |
266 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
267 | - } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
268 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
347 | + if ($globalDebug) { |
|
348 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
349 | + } |
|
350 | + } elseif ($globalDebug) { |
|
351 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
352 | + } |
|
353 | + } elseif ($globalDebug) { |
|
354 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
355 | + } |
|
269 | 356 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
270 | 357 | $hostport = explode(':',$host); |
271 | 358 | if (isset($hostport[1])) { |
@@ -305,17 +392,25 @@ discard block |
||
305 | 392 | //$formats[$id] = 'beast'; |
306 | 393 | $globalSources[$id]['format'] = 'beast'; |
307 | 394 | //} else $formats[$id] = 'sbs'; |
308 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
395 | + } else { |
|
396 | + $globalSources[$id]['format'] = 'sbs'; |
|
397 | + } |
|
309 | 398 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
310 | 399 | } |
311 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
400 | + if ($globalDebug) { |
|
401 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
402 | + } |
|
312 | 403 | } else { |
313 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
404 | + if ($globalDebug) { |
|
405 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
406 | + } |
|
314 | 407 | } |
315 | 408 | } |
316 | 409 | } |
317 | 410 | } |
318 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
411 | +if (!isset($globalMinFetch)) { |
|
412 | + $globalMinFetch = 15; |
|
413 | +} |
|
319 | 414 | |
320 | 415 | // Initialize all |
321 | 416 | $status = array(); |
@@ -324,13 +419,19 @@ discard block |
||
324 | 419 | $formats = array(); |
325 | 420 | $last_exec = array(); |
326 | 421 | $time = time(); |
327 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
328 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
329 | -else $timeout = 20; |
|
422 | +if (isset($globalSourcesTimeout)) { |
|
423 | + $timeout = $globalSourcesTimeOut; |
|
424 | +} else if (isset($globalSBS1TimeOut)) { |
|
425 | + $timeout = $globalSBS1TimeOut; |
|
426 | +} else { |
|
427 | + $timeout = 20; |
|
428 | +} |
|
330 | 429 | $errno = ''; |
331 | 430 | $errstr=''; |
332 | 431 | |
333 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
432 | +if (!isset($globalDaemon)) { |
|
433 | + $globalDaemon = TRUE; |
|
434 | +} |
|
334 | 435 | /* Initiate connections to all the hosts simultaneously */ |
335 | 436 | //connect_all($hosts); |
336 | 437 | //connect_all($globalSources); |
@@ -359,7 +460,9 @@ discard block |
||
359 | 460 | if (isset($source['format']) && $source['format'] == 'aprs') { |
360 | 461 | $aprs_connect = 0; |
361 | 462 | $use_aprs = true; |
362 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
463 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
464 | + $aprs_full = true; |
|
465 | + } |
|
363 | 466 | break; |
364 | 467 | } |
365 | 468 | } |
@@ -370,25 +473,46 @@ discard block |
||
370 | 473 | $aprs_connect = 0; |
371 | 474 | $aprs_keep = 120; |
372 | 475 | $aprs_last_tx = time(); |
373 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
374 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
375 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
376 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
377 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
378 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
379 | - if ($aprs_full) $aprs_filter = ''; |
|
380 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
381 | - else $aprs_pass = '-1'; |
|
476 | + if (isset($globalAPRSversion)) { |
|
477 | + $aprs_version = $globalAPRSversion; |
|
478 | + } else { |
|
479 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
480 | + } |
|
481 | + if (isset($globalAPRSssid)) { |
|
482 | + $aprs_ssid = $globalAPRSssid; |
|
483 | + } else { |
|
484 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
485 | + } |
|
486 | + if (isset($globalAPRSfilter)) { |
|
487 | + $aprs_filter = $globalAPRSfilter; |
|
488 | + } else { |
|
489 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
490 | + } |
|
491 | + if ($aprs_full) { |
|
492 | + $aprs_filter = ''; |
|
493 | + } |
|
494 | + if (isset($globalAPRSpass)) { |
|
495 | + $aprs_pass = $globalAPRSpass; |
|
496 | + } else { |
|
497 | + $aprs_pass = '-1'; |
|
498 | + } |
|
382 | 499 | |
383 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
384 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
385 | -} |
|
500 | + if ($aprs_filter != '') { |
|
501 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
502 | + } else { |
|
503 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
504 | + } |
|
505 | + } |
|
386 | 506 | |
387 | 507 | // connected - lets do some work |
388 | 508 | //if ($globalDebug) echo "Connected!\n"; |
389 | 509 | sleep(1); |
390 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
391 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
510 | +if ($globalDebug) { |
|
511 | + echo "SCAN MODE \n\n"; |
|
512 | +} |
|
513 | +if (!isset($globalCronEnd)) { |
|
514 | + $globalCronEnd = 60; |
|
515 | +} |
|
392 | 516 | $endtime = time()+$globalCronEnd; |
393 | 517 | $i = 1; |
394 | 518 | $tt = array(); |
@@ -402,22 +526,32 @@ discard block |
||
402 | 526 | |
403 | 527 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
404 | 528 | while ($i > 0) { |
405 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
529 | + if (function_exists('pcntl_fork')) { |
|
530 | + pcntl_signal_dispatch(); |
|
531 | + } |
|
406 | 532 | |
407 | - if (!$globalDaemon) $i = $endtime-time(); |
|
533 | + if (!$globalDaemon) { |
|
534 | + $i = $endtime-time(); |
|
535 | + } |
|
408 | 536 | // Delete old ATC |
409 | 537 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
410 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
538 | + if ($globalDebug) { |
|
539 | + echo 'Delete old ATC...'."\n"; |
|
540 | + } |
|
411 | 541 | $ATC->deleteOldATC(); |
412 | 542 | } |
413 | 543 | |
414 | 544 | if (count($last_exec) == count($globalSources)) { |
415 | 545 | $max = $globalMinFetch; |
416 | 546 | foreach ($last_exec as $last) { |
417 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
547 | + if ((time() - $last['last']) < $max) { |
|
548 | + $max = time() - $last['last']; |
|
549 | + } |
|
418 | 550 | } |
419 | 551 | if ($max < $globalMinFetch) { |
420 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
552 | + if ($globalDebug) { |
|
553 | + echo 'Sleeping...'."\n"; |
|
554 | + } |
|
421 | 555 | sleep($globalMinFetch-$max+2); |
422 | 556 | } |
423 | 557 | } |
@@ -427,7 +561,9 @@ discard block |
||
427 | 561 | foreach ($globalSources as $id => $value) { |
428 | 562 | date_default_timezone_set('UTC'); |
429 | 563 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
430 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
564 | + if (!isset($last_exec[$id]['last'])) { |
|
565 | + $last_exec[$id]['last'] = 0; |
|
566 | + } |
|
431 | 567 | if ($value['format'] === 'deltadbtxt' && |
432 | 568 | ( |
433 | 569 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
@@ -436,7 +572,9 @@ discard block |
||
436 | 572 | ) { |
437 | 573 | //$buffer = $Common->getData($hosts[$id]); |
438 | 574 | $buffer = $Common->getData($value['host']); |
439 | - if ($buffer != '') $reset = 0; |
|
575 | + if ($buffer != '') { |
|
576 | + $reset = 0; |
|
577 | + } |
|
440 | 578 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
441 | 579 | $buffer = explode('\n',$buffer); |
442 | 580 | foreach ($buffer as $line) { |
@@ -445,20 +583,41 @@ discard block |
||
445 | 583 | $data = array(); |
446 | 584 | $data['hex'] = $line[1]; // hex |
447 | 585 | $data['ident'] = $line[2]; // ident |
448 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
449 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
450 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
451 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
452 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
586 | + if (isset($line[3])) { |
|
587 | + $data['altitude'] = $line[3]; |
|
588 | + } |
|
589 | + // altitude |
|
590 | + if (isset($line[4])) { |
|
591 | + $data['speed'] = $line[4]; |
|
592 | + } |
|
593 | + // speed |
|
594 | + if (isset($line[5])) { |
|
595 | + $data['heading'] = $line[5]; |
|
596 | + } |
|
597 | + // heading |
|
598 | + if (isset($line[6])) { |
|
599 | + $data['latitude'] = $line[6]; |
|
600 | + } |
|
601 | + // lat |
|
602 | + if (isset($line[7])) { |
|
603 | + $data['longitude'] = $line[7]; |
|
604 | + } |
|
605 | + // long |
|
453 | 606 | $data['verticalrate'] = ''; // vertical rate |
454 | 607 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
455 | 608 | $data['emergency'] = ''; // emergency |
456 | 609 | $data['datetime'] = date('Y-m-d H:i:s'); |
457 | 610 | $data['format_source'] = 'deltadbtxt'; |
458 | 611 | $data['id_source'] = $id_source; |
459 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
460 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
461 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
612 | + if (isset($value['name']) && $value['name'] != '') { |
|
613 | + $data['source_name'] = $value['name']; |
|
614 | + } |
|
615 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
616 | + $data['noarchive'] = true; |
|
617 | + } |
|
618 | + if (isset($value['sourcestats'])) { |
|
619 | + $data['sourcestats'] = $value['sourcestats']; |
|
620 | + } |
|
462 | 621 | $SI->add($data); |
463 | 622 | unset($data); |
464 | 623 | } |
@@ -473,7 +632,9 @@ discard block |
||
473 | 632 | date_default_timezone_set('CET'); |
474 | 633 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
475 | 634 | date_default_timezone_set('UTC'); |
476 | - if ($buffer != '') $reset = 0; |
|
635 | + if ($buffer != '') { |
|
636 | + $reset = 0; |
|
637 | + } |
|
477 | 638 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
478 | 639 | $buffer = explode('\n',$buffer); |
479 | 640 | foreach ($buffer as $line) { |
@@ -482,18 +643,42 @@ discard block |
||
482 | 643 | $add = false; |
483 | 644 | $ais_data = $AIS->parse_line(trim($line)); |
484 | 645 | $data = array(); |
485 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
486 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
487 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
488 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
489 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
490 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
491 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
492 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
493 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
494 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
495 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
496 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
646 | + if (isset($ais_data['ident'])) { |
|
647 | + $data['ident'] = $ais_data['ident']; |
|
648 | + } |
|
649 | + if (isset($ais_data['mmsi'])) { |
|
650 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
651 | + } |
|
652 | + if (isset($ais_data['speed'])) { |
|
653 | + $data['speed'] = $ais_data['speed']; |
|
654 | + } |
|
655 | + if (isset($ais_data['heading'])) { |
|
656 | + $data['heading'] = $ais_data['heading']; |
|
657 | + } |
|
658 | + if (isset($ais_data['latitude'])) { |
|
659 | + $data['latitude'] = $ais_data['latitude']; |
|
660 | + } |
|
661 | + if (isset($ais_data['longitude'])) { |
|
662 | + $data['longitude'] = $ais_data['longitude']; |
|
663 | + } |
|
664 | + if (isset($ais_data['status'])) { |
|
665 | + $data['status'] = $ais_data['status']; |
|
666 | + } |
|
667 | + if (isset($ais_data['statusid'])) { |
|
668 | + $data['status_id'] = $ais_data['statusid']; |
|
669 | + } |
|
670 | + if (isset($ais_data['type'])) { |
|
671 | + $data['type'] = $ais_data['type']; |
|
672 | + } |
|
673 | + if (isset($ais_data['typeid'])) { |
|
674 | + $data['type_id'] = $ais_data['typeid']; |
|
675 | + } |
|
676 | + if (isset($ais_data['imo'])) { |
|
677 | + $data['imo'] = $ais_data['imo']; |
|
678 | + } |
|
679 | + if (isset($ais_data['callsign'])) { |
|
680 | + $data['callsign'] = $ais_data['callsign']; |
|
681 | + } |
|
497 | 682 | if (isset($ais_data['timestamp'])) { |
498 | 683 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
499 | 684 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -507,8 +692,12 @@ discard block |
||
507 | 692 | $data['format_source'] = 'aisnmeatxt'; |
508 | 693 | $data['id_source'] = $id_source; |
509 | 694 | //print_r($data); |
510 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
511 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
695 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
696 | + $data['noarchive'] = true; |
|
697 | + } |
|
698 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
699 | + $MI->add($data); |
|
700 | + } |
|
512 | 701 | unset($data); |
513 | 702 | } |
514 | 703 | } |
@@ -531,20 +720,48 @@ discard block |
||
531 | 720 | if ($line != '') { |
532 | 721 | $ais_data = $AIS->parse_line(trim($line)); |
533 | 722 | $data = array(); |
534 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
535 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
536 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
537 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
538 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
539 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
540 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
541 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
542 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
543 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
544 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
545 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
546 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
547 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
723 | + if (isset($ais_data['ident'])) { |
|
724 | + $data['ident'] = $ais_data['ident']; |
|
725 | + } |
|
726 | + if (isset($ais_data['mmsi'])) { |
|
727 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
728 | + } |
|
729 | + if (isset($ais_data['speed'])) { |
|
730 | + $data['speed'] = $ais_data['speed']; |
|
731 | + } |
|
732 | + if (isset($ais_data['heading'])) { |
|
733 | + $data['heading'] = $ais_data['heading']; |
|
734 | + } |
|
735 | + if (isset($ais_data['latitude'])) { |
|
736 | + $data['latitude'] = $ais_data['latitude']; |
|
737 | + } |
|
738 | + if (isset($ais_data['longitude'])) { |
|
739 | + $data['longitude'] = $ais_data['longitude']; |
|
740 | + } |
|
741 | + if (isset($ais_data['status'])) { |
|
742 | + $data['status'] = $ais_data['status']; |
|
743 | + } |
|
744 | + if (isset($ais_data['statusid'])) { |
|
745 | + $data['status_id'] = $ais_data['statusid']; |
|
746 | + } |
|
747 | + if (isset($ais_data['type'])) { |
|
748 | + $data['type'] = $ais_data['type']; |
|
749 | + } |
|
750 | + if (isset($ais_data['typeid'])) { |
|
751 | + $data['type_id'] = $ais_data['typeid']; |
|
752 | + } |
|
753 | + if (isset($ais_data['imo'])) { |
|
754 | + $data['imo'] = $ais_data['imo']; |
|
755 | + } |
|
756 | + if (isset($ais_data['callsign'])) { |
|
757 | + $data['callsign'] = $ais_data['callsign']; |
|
758 | + } |
|
759 | + if (isset($ais_data['destination'])) { |
|
760 | + $data['arrival_code'] = $ais_data['destination']; |
|
761 | + } |
|
762 | + if (isset($ais_data['eta_ts'])) { |
|
763 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
764 | + } |
|
548 | 765 | if (isset($ais_data['timestamp'])) { |
549 | 766 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
550 | 767 | } else { |
@@ -552,18 +769,27 @@ discard block |
||
552 | 769 | } |
553 | 770 | $data['format_source'] = 'aisnmeahttp'; |
554 | 771 | $data['id_source'] = $id_source; |
555 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
556 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
772 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
773 | + $data['noarchive'] = true; |
|
774 | + } |
|
775 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
776 | + $MI->add($data); |
|
777 | + } |
|
557 | 778 | unset($data); |
558 | 779 | } |
559 | 780 | } |
560 | 781 | } |
561 | 782 | } else { |
562 | 783 | $format = $value['format']; |
563 | - if (isset($tt[$format])) $tt[$format]++; |
|
564 | - else $tt[$format] = 0; |
|
784 | + if (isset($tt[$format])) { |
|
785 | + $tt[$format]++; |
|
786 | + } else { |
|
787 | + $tt[$format] = 0; |
|
788 | + } |
|
565 | 789 | if ($tt[$format] > 30) { |
566 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
790 | + if ($globalDebug) { |
|
791 | + echo 'Reconnect...'."\n"; |
|
792 | + } |
|
567 | 793 | sleep(2); |
568 | 794 | //$sourceeen[] = $value; |
569 | 795 | //connect_all($sourceeen); |
@@ -599,12 +825,18 @@ discard block |
||
599 | 825 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
600 | 826 | //$data['type_id'] = $line['TYPE']; |
601 | 827 | $data['imo'] = $line['IMO']; |
602 | - if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
603 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
828 | + if ($line['DEST'] != '') { |
|
829 | + $data['arrival_code'] = $line['DEST']; |
|
830 | + } |
|
831 | + if ($line['ARV'] != '') { |
|
832 | + $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
833 | + } |
|
604 | 834 | $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
605 | 835 | $data['format_source'] = 'myshiptracking'; |
606 | 836 | $data['id_source'] = $id_source; |
607 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
837 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
838 | + $data['noarchive'] = true; |
|
839 | + } |
|
608 | 840 | $MI->add($data); |
609 | 841 | unset($data); |
610 | 842 | } |
@@ -629,7 +861,9 @@ discard block |
||
629 | 861 | $data['callsign'] = $line['callsign']; |
630 | 862 | $data['mmsi'] = substr($line['mmsi'],-9); |
631 | 863 | $data['speed'] = $line['sog']; |
632 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
864 | + if ($line['heading'] != '511') { |
|
865 | + $data['heading'] = $line['heading']; |
|
866 | + } |
|
633 | 867 | $data['latitude'] = $line['latitude']; |
634 | 868 | $data['longitude'] = $line['longitude']; |
635 | 869 | $data['type_id'] = $line['shiptype']; |
@@ -637,7 +871,9 @@ discard block |
||
637 | 871 | $data['datetime'] = $line['time']; |
638 | 872 | $data['format_source'] = 'boatbeaconapp'; |
639 | 873 | $data['id_source'] = $id_source; |
640 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
874 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
875 | + $data['noarchive'] = true; |
|
876 | + } |
|
641 | 877 | $MI->add($data); |
642 | 878 | unset($data); |
643 | 879 | } |
@@ -659,22 +895,44 @@ discard block |
||
659 | 895 | foreach ($all_data['features'] as $line) { |
660 | 896 | print_r($line); |
661 | 897 | $data = array(); |
662 | - if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
|
663 | - if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
|
664 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
665 | - if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo']; |
|
666 | - if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
|
667 | - if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading']; |
|
898 | + if (isset($line['properties']['name'])) { |
|
899 | + $data['ident'] = $line['properties']['name']; |
|
900 | + } |
|
901 | + if (isset($line['properties']['callsign'])) { |
|
902 | + $data['callsign'] = $line['properties']['callsign']; |
|
903 | + } |
|
904 | + if (isset($line['properties']['mmsi'])) { |
|
905 | + $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
906 | + } |
|
907 | + if (isset($line['properties']['imo'])) { |
|
908 | + $data['imo'] = $line['properties']['imo']; |
|
909 | + } |
|
910 | + if (isset($line['properties']['speed'])) { |
|
911 | + $data['speed'] = $line['properties']['speed']; |
|
912 | + } |
|
913 | + if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) { |
|
914 | + $data['heading'] = $line['properties']['heading']; |
|
915 | + } |
|
668 | 916 | $data['latitude'] = $line['geometry']['coordinates'][1]; |
669 | 917 | $data['longitude'] = $line['geometry']['coordinates'][0]; |
670 | - if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType']; |
|
671 | - if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination']; |
|
672 | - if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta']; |
|
918 | + if (isset($line['properties']['vesselType'])) { |
|
919 | + $data['type'] = $line['properties']['vesselType']; |
|
920 | + } |
|
921 | + if (isset($line['properties']['destination'])) { |
|
922 | + $data['arrival_code'] = $line['properties']['destination']; |
|
923 | + } |
|
924 | + if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') { |
|
925 | + $data['arrival_date'] = $line['properties']['eta']; |
|
926 | + } |
|
673 | 927 | $data['format_source'] = 'boatnerd'; |
674 | 928 | $data['id_source'] = $id_source; |
675 | 929 | $data['datetime'] = date('Y-m-d H:i:s'); |
676 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
677 | - if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
|
930 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
931 | + $data['noarchive'] = true; |
|
932 | + } |
|
933 | + if ($line['properties']['vesselType'] != 'Navigation Aid') { |
|
934 | + $MI->add($data); |
|
935 | + } |
|
678 | 936 | unset($data); |
679 | 937 | } |
680 | 938 | } |
@@ -691,7 +949,9 @@ discard block |
||
691 | 949 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
692 | 950 | echo 'done !'."\n"; |
693 | 951 | // FIXME: Need more work |
694 | - if ($buffer != '') $reset = 0; |
|
952 | + if ($buffer != '') { |
|
953 | + $reset = 0; |
|
954 | + } |
|
695 | 955 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
696 | 956 | $buffer = explode('\n',$buffer); |
697 | 957 | foreach ($buffer as $line) { |
@@ -717,7 +977,9 @@ discard block |
||
717 | 977 | //$data['etaTime'] = substr($line,135,5); |
718 | 978 | $data['format_source'] = 'shipplotter'; |
719 | 979 | $data['id_source'] = $id_source; |
720 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
980 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
981 | + $data['noarchive'] = true; |
|
982 | + } |
|
721 | 983 | //print_r($data); |
722 | 984 | echo 'Add...'."\n"; |
723 | 985 | $MI->add($data); |
@@ -751,16 +1013,28 @@ discard block |
||
751 | 1013 | $line = explode(':', $line); |
752 | 1014 | if (count($line) > 30 && $line[0] != 'callsign') { |
753 | 1015 | $data = array(); |
754 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
755 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
1016 | + if (isset($line[37]) && $line[37] != '') { |
|
1017 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
1018 | + } else { |
|
1019 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
1020 | + } |
|
756 | 1021 | $data['pilot_id'] = $line[1]; |
757 | 1022 | $data['pilot_name'] = $line[2]; |
758 | 1023 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
759 | 1024 | $data['ident'] = $line[0]; // ident |
760 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
1025 | + if ($line[7] != '' && $line[7] != 0) { |
|
1026 | + $data['altitude'] = $line[7]; |
|
1027 | + } |
|
1028 | + // altitude |
|
761 | 1029 | $data['speed'] = $line[8]; // speed |
762 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
763 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
1030 | + if (isset($line[45])) { |
|
1031 | + $data['heading'] = $line[45]; |
|
1032 | + } |
|
1033 | + // heading |
|
1034 | + elseif (isset($line[38])) { |
|
1035 | + $data['heading'] = $line[38]; |
|
1036 | + } |
|
1037 | + // heading |
|
764 | 1038 | $data['latitude'] = $line[5]; // lat |
765 | 1039 | $data['longitude'] = $line[6]; // long |
766 | 1040 | $data['verticalrate'] = ''; // vertical rate |
@@ -776,7 +1050,9 @@ discard block |
||
776 | 1050 | $data['frequency'] = $line[4]; |
777 | 1051 | $data['type'] = $line[18]; |
778 | 1052 | $data['range'] = $line[19]; |
779 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
1053 | + if (isset($line[35])) { |
|
1054 | + $data['info'] = $line[35]; |
|
1055 | + } |
|
780 | 1056 | $data['id_source'] = $id_source; |
781 | 1057 | //$data['arrival_airport_time'] = ; |
782 | 1058 | if ($line[9] != '') { |
@@ -790,27 +1066,47 @@ discard block |
||
790 | 1066 | elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
791 | 1067 | */ |
792 | 1068 | $data['format_source'] = $value['format']; |
793 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
794 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
795 | - if ($line[3] === 'PILOT') $SI->add($data); |
|
796 | - elseif ($line[3] === 'ATC') { |
|
1069 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1070 | + $data['noarchive'] = true; |
|
1071 | + } |
|
1072 | + if (isset($value['name']) && $value['name'] != '') { |
|
1073 | + $data['source_name'] = $value['name']; |
|
1074 | + } |
|
1075 | + if ($line[3] === 'PILOT') { |
|
1076 | + $SI->add($data); |
|
1077 | + } elseif ($line[3] === 'ATC') { |
|
797 | 1078 | //print_r($data); |
798 | 1079 | $data['info'] = str_replace('^§','<br />',$data['info']); |
799 | 1080 | $data['info'] = str_replace('&sect;','',$data['info']); |
800 | 1081 | $typec = substr($data['ident'],-3); |
801 | - if ($typec === 'APP') $data['type'] = 'Approach'; |
|
802 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
803 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
|
804 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; |
|
805 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; |
|
806 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; |
|
807 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
|
808 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
809 | - elseif ($data['type'] === '') $data['type'] = 'Observer'; |
|
810 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
1082 | + if ($typec === 'APP') { |
|
1083 | + $data['type'] = 'Approach'; |
|
1084 | + } elseif ($typec === 'TWR') { |
|
1085 | + $data['type'] = 'Tower'; |
|
1086 | + } elseif ($typec === 'OBS') { |
|
1087 | + $data['type'] = 'Observer'; |
|
1088 | + } elseif ($typec === 'GND') { |
|
1089 | + $data['type'] = 'Ground'; |
|
1090 | + } elseif ($typec === 'DEL') { |
|
1091 | + $data['type'] = 'Delivery'; |
|
1092 | + } elseif ($typec === 'DEP') { |
|
1093 | + $data['type'] = 'Departure'; |
|
1094 | + } elseif ($typec === 'FSS') { |
|
1095 | + $data['type'] = 'Flight Service Station'; |
|
1096 | + } elseif ($typec === 'CTR') { |
|
1097 | + $data['type'] = 'Control Radar or Centre'; |
|
1098 | + } elseif ($data['type'] === '') { |
|
1099 | + $data['type'] = 'Observer'; |
|
1100 | + } |
|
1101 | + if (!isset($data['source_name'])) { |
|
1102 | + $data['source_name'] = ''; |
|
1103 | + } |
|
811 | 1104 | if (isset($ATC)) { |
812 | - if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($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']); |
|
813 | - 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']); |
|
1105 | + if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) { |
|
1106 | + echo $ATC->update($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']); |
|
1107 | + } else { |
|
1108 | + 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']); |
|
1109 | + } |
|
814 | 1110 | } |
815 | 1111 | } |
816 | 1112 | unset($data); |
@@ -837,14 +1133,20 @@ discard block |
||
837 | 1133 | $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
838 | 1134 | $data['latitude'] = (float)$line['pktLatitude']; |
839 | 1135 | $data['longitude'] = (float)$line['pktLongitude']; |
840 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
841 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
1136 | + if ((float)$line['pktTrack'] != 0) { |
|
1137 | + $data['heading'] = (float)$line['pktTrack']; |
|
1138 | + } |
|
1139 | + if ((int)$line['pktSpeed'] != 0) { |
|
1140 | + $data['speed'] = (int)$line['pktSpeed']; |
|
1141 | + } |
|
842 | 1142 | $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
843 | 1143 | $data['altitude_relative'] = 'AMSL'; |
844 | 1144 | $data['pilot_id'] = (int)$line['pktPilotID']; |
845 | 1145 | $data['aircraft_icao'] = 'PARAGLIDER'; |
846 | 1146 | $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
847 | - if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
|
1147 | + if (isset($pilot_data[4])) { |
|
1148 | + $data['pilot_name'] = $pilot_data[4]; |
|
1149 | + } |
|
848 | 1150 | $data['format_source'] = $value['format']; |
849 | 1151 | $SI->add($data); |
850 | 1152 | unset($data); |
@@ -892,25 +1194,59 @@ discard block |
||
892 | 1194 | foreach ($all_data['acList'] as $line) { |
893 | 1195 | $data = array(); |
894 | 1196 | $data['hex'] = $line['Icao']; // hex |
895 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
896 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
897 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
898 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
899 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
900 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
1197 | + if (isset($line['Call'])) { |
|
1198 | + $data['ident'] = $line['Call']; |
|
1199 | + } |
|
1200 | + // ident |
|
1201 | + if (isset($line['Alt'])) { |
|
1202 | + $data['altitude'] = $line['Alt']; |
|
1203 | + } |
|
1204 | + // altitude |
|
1205 | + if (isset($line['Spd'])) { |
|
1206 | + $data['speed'] = $line['Spd']; |
|
1207 | + } |
|
1208 | + // speed |
|
1209 | + if (isset($line['Trak'])) { |
|
1210 | + $data['heading'] = $line['Trak']; |
|
1211 | + } |
|
1212 | + // heading |
|
1213 | + if (isset($line['Lat'])) { |
|
1214 | + $data['latitude'] = $line['Lat']; |
|
1215 | + } |
|
1216 | + // lat |
|
1217 | + if (isset($line['Long'])) { |
|
1218 | + $data['longitude'] = $line['Long']; |
|
1219 | + } |
|
1220 | + // long |
|
901 | 1221 | //$data['verticalrate'] = $line['']; // verticale rate |
902 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
1222 | + if (isset($line['Sqk'])) { |
|
1223 | + $data['squawk'] = $line['Sqk']; |
|
1224 | + } |
|
1225 | + // squawk |
|
903 | 1226 | $data['emergency'] = ''; // emergency |
904 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
905 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
906 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1227 | + if (isset($line['Reg'])) { |
|
1228 | + $data['registration'] = $line['Reg']; |
|
1229 | + } |
|
1230 | + if (isset($line['PosTime'])) { |
|
1231 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1232 | + } else { |
|
1233 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1234 | + } |
|
907 | 1235 | //$data['datetime'] = date('Y-m-d H:i:s'); |
908 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
1236 | + if (isset($line['Type'])) { |
|
1237 | + $data['aircraft_icao'] = $line['Type']; |
|
1238 | + } |
|
909 | 1239 | $data['format_source'] = 'aircraftlistjson'; |
910 | 1240 | $data['id_source'] = $id_source; |
911 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
912 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
913 | - if (isset($data['latitude'])) $SI->add($data); |
|
1241 | + if (isset($value['name']) && $value['name'] != '') { |
|
1242 | + $data['source_name'] = $value['name']; |
|
1243 | + } |
|
1244 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1245 | + $data['noarchive'] = true; |
|
1246 | + } |
|
1247 | + if (isset($data['latitude'])) { |
|
1248 | + $SI->add($data); |
|
1249 | + } |
|
914 | 1250 | unset($data); |
915 | 1251 | } |
916 | 1252 | } elseif (is_array($all_data)) { |
@@ -927,17 +1263,26 @@ discard block |
||
927 | 1263 | $data['verticalrate'] = $line['vrt']; // verticale rate |
928 | 1264 | $data['squawk'] = $line['squawk']; // squawk |
929 | 1265 | $data['emergency'] = ''; // emergency |
930 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
931 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1266 | + if (isset($line['PosTime'])) { |
|
1267 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1268 | + } else { |
|
1269 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1270 | + } |
|
932 | 1271 | $data['format_source'] = 'aircraftlistjson'; |
933 | 1272 | $data['id_source'] = $id_source; |
934 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
935 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1273 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1274 | + $data['noarchive'] = true; |
|
1275 | + } |
|
1276 | + if (isset($value['name']) && $value['name'] != '') { |
|
1277 | + $data['source_name'] = $value['name']; |
|
1278 | + } |
|
936 | 1279 | $SI->add($data); |
937 | 1280 | unset($data); |
938 | 1281 | } |
939 | 1282 | } |
940 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
1283 | + } elseif ($globalDebug) { |
|
1284 | + echo 'No data'."\n"; |
|
1285 | + } |
|
941 | 1286 | //$last_exec['aircraftlistjson'] = time(); |
942 | 1287 | $last_exec[$id]['last'] = time(); |
943 | 1288 | //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
@@ -973,8 +1318,12 @@ discard block |
||
973 | 1318 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
974 | 1319 | $data['format_source'] = 'planeupdatefaa'; |
975 | 1320 | $data['id_source'] = $id_source; |
976 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
977 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1321 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1322 | + $data['noarchive'] = true; |
|
1323 | + } |
|
1324 | + if (isset($value['name']) && $value['name'] != '') { |
|
1325 | + $data['source_name'] = $value['name']; |
|
1326 | + } |
|
978 | 1327 | $SI->add($data); |
979 | 1328 | unset($data); |
980 | 1329 | } |
@@ -1008,7 +1357,9 @@ discard block |
||
1008 | 1357 | $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
1009 | 1358 | $data['format_source'] = 'opensky'; |
1010 | 1359 | $data['id_source'] = $id_source; |
1011 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1360 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1361 | + $data['noarchive'] = true; |
|
1362 | + } |
|
1012 | 1363 | $SI->add($data); |
1013 | 1364 | unset($data); |
1014 | 1365 | } |
@@ -1028,15 +1379,42 @@ discard block |
||
1028 | 1379 | foreach ($all_data['aircraft'] as $key => $line) { |
1029 | 1380 | $data = array(); |
1030 | 1381 | // add support for ground vehicule with ~ in front of hex |
1031 | - if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
1032 | - if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
1033 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1034 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1035 | - if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
1036 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1037 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1038 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1039 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1382 | + if (isset($line['hex'])) { |
|
1383 | + $data['hex'] = $line['hex']; |
|
1384 | + } |
|
1385 | + // hex |
|
1386 | + if (isset($line['flight'])) { |
|
1387 | + $data['ident'] = trim($line['flight']); |
|
1388 | + } |
|
1389 | + // ident |
|
1390 | + if (isset($line['altitude'])) { |
|
1391 | + $data['altitude'] = $line['altitude']; |
|
1392 | + } |
|
1393 | + // altitude |
|
1394 | + if (isset($line['speed'])) { |
|
1395 | + $data['speed'] = $line['speed']; |
|
1396 | + } |
|
1397 | + // speed |
|
1398 | + if (isset($line['track'])) { |
|
1399 | + $data['heading'] = $line['track']; |
|
1400 | + } |
|
1401 | + // heading |
|
1402 | + if (isset($line['lat'])) { |
|
1403 | + $data['latitude'] = $line['lat']; |
|
1404 | + } |
|
1405 | + // lat |
|
1406 | + if (isset($line['lon'])) { |
|
1407 | + $data['longitude'] = $line['lon']; |
|
1408 | + } |
|
1409 | + // long |
|
1410 | + if (isset($line['vert_rate'])) { |
|
1411 | + $data['verticalrate'] = $line['vert_rate']; |
|
1412 | + } |
|
1413 | + // verticale rate |
|
1414 | + if (isset($line['squawk'])) { |
|
1415 | + $data['squawk'] = $line['squawk']; |
|
1416 | + } |
|
1417 | + // squawk |
|
1040 | 1418 | //$data['emergency'] = ''; // emergency |
1041 | 1419 | //$data['registration'] = $line[2]; |
1042 | 1420 | //$data['aircraft_icao'] = $line[0]; |
@@ -1044,10 +1422,17 @@ discard block |
||
1044 | 1422 | $data['format_source'] = 'aircraftjson'; |
1045 | 1423 | $data['id_source'] = $id_source; |
1046 | 1424 | if (isset($value['name']) && $value['name'] != '') { |
1047 | - if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
1048 | - else $data['source_name'] = $value['name']; |
|
1049 | - } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
1050 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1425 | + if (isset($line['mlat']) && !empty($line['mlat'])) { |
|
1426 | + $data['source_name'] = $value['name'].'_MLAT'; |
|
1427 | + } else { |
|
1428 | + $data['source_name'] = $value['name']; |
|
1429 | + } |
|
1430 | + } elseif (isset($line['mlat']) && !empty($line['mlat'])) { |
|
1431 | + $data['source_name'] = 'MLAT'; |
|
1432 | + } |
|
1433 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1434 | + $data['noarchive'] = true; |
|
1435 | + } |
|
1051 | 1436 | $SI->add($data); |
1052 | 1437 | unset($data); |
1053 | 1438 | } |
@@ -1064,7 +1449,9 @@ discard block |
||
1064 | 1449 | //$buffer = $Common->getData($hosts[$id]); |
1065 | 1450 | $buffer = $Common->getData($value['host']); |
1066 | 1451 | $all_data = json_decode($buffer,true); |
1067 | - if (!empty($all_data)) $reset = 0; |
|
1452 | + if (!empty($all_data)) { |
|
1453 | + $reset = 0; |
|
1454 | + } |
|
1068 | 1455 | foreach ($all_data as $key => $line) { |
1069 | 1456 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
1070 | 1457 | $data = array(); |
@@ -1085,8 +1472,12 @@ discard block |
||
1085 | 1472 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
1086 | 1473 | $data['format_source'] = 'fr24json'; |
1087 | 1474 | $data['id_source'] = $id_source; |
1088 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1089 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1475 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1476 | + $data['noarchive'] = true; |
|
1477 | + } |
|
1478 | + if (isset($value['name']) && $value['name'] != '') { |
|
1479 | + $data['source_name'] = $value['name']; |
|
1480 | + } |
|
1090 | 1481 | $SI->add($data); |
1091 | 1482 | unset($data); |
1092 | 1483 | } |
@@ -1115,24 +1506,42 @@ discard block |
||
1115 | 1506 | if (isset($line['inf'])) { |
1116 | 1507 | $data = array(); |
1117 | 1508 | $data['hex'] = $line['inf']['ia']; |
1118 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
1509 | + if (isset($line['inf']['cs'])) { |
|
1510 | + $data['ident'] = $line['inf']['cs']; |
|
1511 | + } |
|
1512 | + //$line[13] |
|
1119 | 1513 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
1120 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1121 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1514 | + if (isset($line['inf']['gs'])) { |
|
1515 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
1516 | + } |
|
1517 | + // speed |
|
1518 | + if (isset($line['inf']['tr'])) { |
|
1519 | + $data['heading'] = $line['inf']['tr']; |
|
1520 | + } |
|
1521 | + // heading |
|
1122 | 1522 | $data['latitude'] = $line['pt'][0]; // lat |
1123 | 1523 | $data['longitude'] = $line['pt'][1]; // long |
1124 | 1524 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
1125 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1525 | + if (isset($line['inf']['sq'])) { |
|
1526 | + $data['squawk'] = $line['inf']['sq']; |
|
1527 | + } |
|
1528 | + // squawk |
|
1126 | 1529 | //$data['aircraft_icao'] = $line[8]; |
1127 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1530 | + if (isset($line['inf']['rc'])) { |
|
1531 | + $data['registration'] = $line['inf']['rc']; |
|
1532 | + } |
|
1128 | 1533 | //$data['departure_airport_iata'] = $line[11]; |
1129 | 1534 | //$data['arrival_airport_iata'] = $line[12]; |
1130 | 1535 | //$data['emergency'] = ''; // emergency |
1131 | 1536 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
1132 | 1537 | $data['format_source'] = 'radarvirtueljson'; |
1133 | 1538 | $data['id_source'] = $id_source; |
1134 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1135 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1539 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1540 | + $data['noarchive'] = true; |
|
1541 | + } |
|
1542 | + if (isset($value['name']) && $value['name'] != '') { |
|
1543 | + $data['source_name'] = $value['name']; |
|
1544 | + } |
|
1136 | 1545 | $SI->add($data); |
1137 | 1546 | unset($data); |
1138 | 1547 | } |
@@ -1158,30 +1567,65 @@ discard block |
||
1158 | 1567 | $data['id'] = $line['id']; |
1159 | 1568 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
1160 | 1569 | $data['ident'] = $line['callsign']; // ident |
1161 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1162 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1163 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1164 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1165 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1166 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1570 | + if (isset($line['pilotid'])) { |
|
1571 | + $data['pilot_id'] = $line['pilotid']; |
|
1572 | + } |
|
1573 | + // pilot id |
|
1574 | + if (isset($line['name'])) { |
|
1575 | + $data['pilot_name'] = $line['name']; |
|
1576 | + } |
|
1577 | + // pilot name |
|
1578 | + if (isset($line['alt'])) { |
|
1579 | + $data['altitude'] = $line['alt']; |
|
1580 | + } |
|
1581 | + // altitude |
|
1582 | + if (isset($line['gs'])) { |
|
1583 | + $data['speed'] = $line['gs']; |
|
1584 | + } |
|
1585 | + // speed |
|
1586 | + if (isset($line['heading'])) { |
|
1587 | + $data['heading'] = $line['heading']; |
|
1588 | + } |
|
1589 | + // heading |
|
1590 | + if (isset($line['route'])) { |
|
1591 | + $data['waypoints'] = $line['route']; |
|
1592 | + } |
|
1593 | + // route |
|
1167 | 1594 | $data['latitude'] = $line['lat']; // lat |
1168 | 1595 | $data['longitude'] = $line['lon']; // long |
1169 | 1596 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
1170 | 1597 | //$data['squawk'] = $line['squawk']; // squawk |
1171 | 1598 | //$data['emergency'] = ''; // emergency |
1172 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1173 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1174 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1599 | + if (isset($line['depicao'])) { |
|
1600 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1601 | + } |
|
1602 | + if (isset($line['deptime'])) { |
|
1603 | + $data['departure_airport_time'] = $line['deptime']; |
|
1604 | + } |
|
1605 | + if (isset($line['arricao'])) { |
|
1606 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1607 | + } |
|
1175 | 1608 | //$data['arrival_airport_time'] = $line['arrtime']; |
1176 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1177 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1178 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1179 | - else $data['info'] = ''; |
|
1609 | + if (isset($line['aircraft'])) { |
|
1610 | + $data['aircraft_icao'] = $line['aircraft']; |
|
1611 | + } |
|
1612 | + if (isset($line['transponder'])) { |
|
1613 | + $data['squawk'] = $line['transponder']; |
|
1614 | + } |
|
1615 | + if (isset($line['atis'])) { |
|
1616 | + $data['info'] = $line['atis']; |
|
1617 | + } else { |
|
1618 | + $data['info'] = ''; |
|
1619 | + } |
|
1180 | 1620 | $data['format_source'] = 'pireps'; |
1181 | 1621 | $data['id_source'] = $id_source; |
1182 | 1622 | $data['datetime'] = date('Y-m-d H:i:s'); |
1183 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1184 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1623 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1624 | + $data['noarchive'] = true; |
|
1625 | + } |
|
1626 | + if (isset($value['name']) && $value['name'] != '') { |
|
1627 | + $data['source_name'] = $value['name']; |
|
1628 | + } |
|
1185 | 1629 | if ($line['icon'] === 'plane') { |
1186 | 1630 | $SI->add($data); |
1187 | 1631 | // print_r($data); |
@@ -1190,16 +1634,28 @@ discard block |
||
1190 | 1634 | $data['info'] = str_replace('&sect;','',$data['info']); |
1191 | 1635 | $typec = substr($data['ident'],-3); |
1192 | 1636 | $data['type'] = ''; |
1193 | - if ($typec === 'APP') $data['type'] = 'Approach'; |
|
1194 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
1195 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
|
1196 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; |
|
1197 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; |
|
1198 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; |
|
1199 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
|
1200 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
1201 | - else $data['type'] = 'Observer'; |
|
1202 | - 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']); |
|
1637 | + if ($typec === 'APP') { |
|
1638 | + $data['type'] = 'Approach'; |
|
1639 | + } elseif ($typec === 'TWR') { |
|
1640 | + $data['type'] = 'Tower'; |
|
1641 | + } elseif ($typec === 'OBS') { |
|
1642 | + $data['type'] = 'Observer'; |
|
1643 | + } elseif ($typec === 'GND') { |
|
1644 | + $data['type'] = 'Ground'; |
|
1645 | + } elseif ($typec === 'DEL') { |
|
1646 | + $data['type'] = 'Delivery'; |
|
1647 | + } elseif ($typec === 'DEP') { |
|
1648 | + $data['type'] = 'Departure'; |
|
1649 | + } elseif ($typec === 'FSS') { |
|
1650 | + $data['type'] = 'Flight Service Station'; |
|
1651 | + } elseif ($typec === 'CTR') { |
|
1652 | + $data['type'] = 'Control Radar or Centre'; |
|
1653 | + } else { |
|
1654 | + $data['type'] = 'Observer'; |
|
1655 | + } |
|
1656 | + if (isset($ATC)) { |
|
1657 | + 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']); |
|
1658 | + } |
|
1203 | 1659 | } |
1204 | 1660 | unset($data); |
1205 | 1661 | } |
@@ -1214,7 +1670,9 @@ discard block |
||
1214 | 1670 | ) |
1215 | 1671 | ) { |
1216 | 1672 | //$buffer = $Common->getData($hosts[$id]); |
1217 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1673 | + if ($globalDebug) { |
|
1674 | + echo 'Get Data...'."\n"; |
|
1675 | + } |
|
1218 | 1676 | $buffer = $Common->getData($value['host']); |
1219 | 1677 | $all_data = json_decode($buffer,true); |
1220 | 1678 | if ($buffer != '' && is_array($all_data)) { |
@@ -1222,10 +1680,16 @@ discard block |
||
1222 | 1680 | foreach ($all_data as $line) { |
1223 | 1681 | $data = array(); |
1224 | 1682 | //$data['id'] = $line['id']; // id not usable |
1225 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1683 | + if (isset($line['pilotid'])) { |
|
1684 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1685 | + } |
|
1226 | 1686 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
1227 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1228 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1687 | + if (isset($line['pilotname'])) { |
|
1688 | + $data['pilot_name'] = $line['pilotname']; |
|
1689 | + } |
|
1690 | + if (isset($line['pilotid'])) { |
|
1691 | + $data['pilot_id'] = $line['pilotid']; |
|
1692 | + } |
|
1229 | 1693 | $data['ident'] = $line['flightnum']; // ident |
1230 | 1694 | $data['altitude'] = $line['alt']; // altitude |
1231 | 1695 | $data['speed'] = $line['gs']; // speed |
@@ -1241,7 +1705,9 @@ discard block |
||
1241 | 1705 | $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
1242 | 1706 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1243 | 1707 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1244 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1708 | + } else { |
|
1709 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1710 | + } |
|
1245 | 1711 | $data['departure_airport_icao'] = $line['depicao']; |
1246 | 1712 | $data['departure_airport_time'] = $line['deptime']; |
1247 | 1713 | $data['arrival_airport_icao'] = $line['arricao']; |
@@ -1249,29 +1715,47 @@ discard block |
||
1249 | 1715 | if (isset($line['registration'])) { |
1250 | 1716 | $data['registration'] = $line['registration']; |
1251 | 1717 | //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
1252 | - } else $data['registration'] = $line['aircraft']; |
|
1253 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1254 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1718 | + } else { |
|
1719 | + $data['registration'] = $line['aircraft']; |
|
1720 | + } |
|
1721 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1722 | + $data['noarchive'] = true; |
|
1723 | + } |
|
1724 | + if (isset($line['route'])) { |
|
1725 | + $data['waypoints'] = $line['route']; |
|
1726 | + } |
|
1727 | + // route |
|
1255 | 1728 | if (isset($line['aircraftname'])) { |
1256 | 1729 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1257 | 1730 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1258 | 1731 | $aircraft_data = explode('-',$line['aircraftname']); |
1259 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1260 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1261 | - else { |
|
1732 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { |
|
1733 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
1734 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { |
|
1735 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
1736 | + } else { |
|
1262 | 1737 | $aircraft_data = explode(' ',$line['aircraftname']); |
1263 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1264 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1738 | + if (isset($aircraft_data[1])) { |
|
1739 | + $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1740 | + } else { |
|
1741 | + $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1742 | + } |
|
1265 | 1743 | } |
1266 | 1744 | } |
1267 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1745 | + if (isset($line['route'])) { |
|
1746 | + $data['waypoints'] = $line['route']; |
|
1747 | + } |
|
1268 | 1748 | $data['id_source'] = $id_source; |
1269 | 1749 | $data['format_source'] = 'phpvmacars'; |
1270 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1750 | + if (isset($value['name']) && $value['name'] != '') { |
|
1751 | + $data['source_name'] = $value['name']; |
|
1752 | + } |
|
1271 | 1753 | $SI->add($data); |
1272 | 1754 | unset($data); |
1273 | 1755 | } |
1274 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1756 | + if ($globalDebug) { |
|
1757 | + echo 'No more data...'."\n"; |
|
1758 | + } |
|
1275 | 1759 | unset($buffer); |
1276 | 1760 | unset($all_data); |
1277 | 1761 | } |
@@ -1284,7 +1768,9 @@ discard block |
||
1284 | 1768 | ) |
1285 | 1769 | ) { |
1286 | 1770 | //$buffer = $Common->getData($hosts[$id]); |
1287 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1771 | + if ($globalDebug) { |
|
1772 | + echo 'Get Data...'."\n"; |
|
1773 | + } |
|
1288 | 1774 | $buffer = $Common->getData($value['host']); |
1289 | 1775 | $all_data = json_decode($buffer,true); |
1290 | 1776 | if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
@@ -1295,10 +1781,16 @@ discard block |
||
1295 | 1781 | //$data['id'] = $line['id']; // id not usable |
1296 | 1782 | $data['id'] = $line['id']; |
1297 | 1783 | //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
1298 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
1299 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
1784 | + if (isset($line['user']['username'])) { |
|
1785 | + $data['pilot_name'] = $line['user']['username']; |
|
1786 | + } |
|
1787 | + if (isset($line['user_id'])) { |
|
1788 | + $data['pilot_id'] = $line['user_id']; |
|
1789 | + } |
|
1300 | 1790 | $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
1301 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1791 | + if (is_numeric($data['ident'])) { |
|
1792 | + $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1793 | + } |
|
1302 | 1794 | $data['altitude'] = $line['altitude']; // altitude |
1303 | 1795 | $data['speed'] = $line['groundspeed']; // speed |
1304 | 1796 | $data['heading'] = $line['heading']; // heading |
@@ -1311,7 +1803,9 @@ discard block |
||
1311 | 1803 | $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
1312 | 1804 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1313 | 1805 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1314 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1806 | + } else { |
|
1807 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1808 | + } |
|
1315 | 1809 | |
1316 | 1810 | $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
1317 | 1811 | $data['departure_airport_time'] = $line['bid']['deptime']; |
@@ -1319,17 +1813,26 @@ discard block |
||
1319 | 1813 | $data['arrival_airport_time'] = $line['bid']['arrtime']; |
1320 | 1814 | $data['registration'] = $line['bid']['aircraft']['registration']; |
1321 | 1815 | |
1322 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1323 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
1816 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1817 | + $data['noarchive'] = true; |
|
1818 | + } |
|
1819 | + if (isset($line['bid']['route']) && $line['bid']['route'] != '') { |
|
1820 | + $data['waypoints'] = $line['bid']['route']; |
|
1821 | + } |
|
1822 | + // route |
|
1324 | 1823 | $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
1325 | 1824 | |
1326 | 1825 | $data['id_source'] = $id_source; |
1327 | 1826 | $data['format_source'] = 'vaos'; |
1328 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1827 | + if (isset($value['name']) && $value['name'] != '') { |
|
1828 | + $data['source_name'] = $value['name']; |
|
1829 | + } |
|
1329 | 1830 | $SI->add($data); |
1330 | 1831 | unset($data); |
1331 | 1832 | } |
1332 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1833 | + if ($globalDebug) { |
|
1834 | + echo 'No more data...'."\n"; |
|
1835 | + } |
|
1333 | 1836 | unset($buffer); |
1334 | 1837 | unset($all_data); |
1335 | 1838 | } |
@@ -1342,7 +1845,9 @@ discard block |
||
1342 | 1845 | ) |
1343 | 1846 | ) { |
1344 | 1847 | //$buffer = $Common->getData($hosts[$id]); |
1345 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1848 | + if ($globalDebug) { |
|
1849 | + echo 'Get Data...'."\n"; |
|
1850 | + } |
|
1346 | 1851 | $buffer = $Common->getData($value['host']); |
1347 | 1852 | $all_data = json_decode($buffer,true); |
1348 | 1853 | if ($buffer != '' && is_array($all_data)) { |
@@ -1371,16 +1876,25 @@ discard block |
||
1371 | 1876 | $data['arrival_airport_icao'] = $line['arrival']; |
1372 | 1877 | //$data['arrival_airport_time'] = $line['arrival_time']; |
1373 | 1878 | //$data['registration'] = $line['aircraft']; |
1374 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1879 | + if (isset($line['route'])) { |
|
1880 | + $data['waypoints'] = $line['route']; |
|
1881 | + } |
|
1882 | + // route |
|
1375 | 1883 | $data['aircraft_icao'] = $line['plane_type']; |
1376 | 1884 | $data['id_source'] = $id_source; |
1377 | 1885 | $data['format_source'] = 'vam'; |
1378 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1379 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1886 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1887 | + $data['noarchive'] = true; |
|
1888 | + } |
|
1889 | + if (isset($value['name']) && $value['name'] != '') { |
|
1890 | + $data['source_name'] = $value['name']; |
|
1891 | + } |
|
1380 | 1892 | $SI->add($data); |
1381 | 1893 | unset($data); |
1382 | 1894 | } |
1383 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1895 | + if ($globalDebug) { |
|
1896 | + echo 'No more data...'."\n"; |
|
1897 | + } |
|
1384 | 1898 | unset($buffer); |
1385 | 1899 | unset($all_data); |
1386 | 1900 | } |
@@ -1393,7 +1907,9 @@ discard block |
||
1393 | 1907 | ) |
1394 | 1908 | ) { |
1395 | 1909 | //$buffer = $Common->getData($hosts[$id]); |
1396 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1910 | + if ($globalDebug) { |
|
1911 | + echo 'Get Data...'."\n"; |
|
1912 | + } |
|
1397 | 1913 | $buffer = $Common->getData($value['host']); |
1398 | 1914 | $all_data = json_decode($buffer,true); |
1399 | 1915 | if ($buffer != '') { |
@@ -1411,12 +1927,16 @@ discard block |
||
1411 | 1927 | $data['id_source'] = $id_source; |
1412 | 1928 | $data['format_source'] = 'blitzortung'; |
1413 | 1929 | $SI->add($data); |
1414 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
1930 | + if ($globalDebug) { |
|
1931 | + echo '☈ Lightning added'."\n"; |
|
1932 | + } |
|
1415 | 1933 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
1416 | 1934 | unset($data); |
1417 | 1935 | } |
1418 | 1936 | } |
1419 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1937 | + if ($globalDebug) { |
|
1938 | + echo 'No more data...'."\n"; |
|
1939 | + } |
|
1420 | 1940 | unset($buffer); |
1421 | 1941 | } |
1422 | 1942 | $last_exec[$id]['last'] = time(); |
@@ -1428,7 +1948,9 @@ discard block |
||
1428 | 1948 | $write = NULL; |
1429 | 1949 | $e = NULL; |
1430 | 1950 | $n = socket_select($read, $write, $e, $timeout); |
1431 | - if ($e != NULL) var_dump($e); |
|
1951 | + if ($e != NULL) { |
|
1952 | + var_dump($e); |
|
1953 | + } |
|
1432 | 1954 | if ($n > 0) { |
1433 | 1955 | $reset = 0; |
1434 | 1956 | foreach ($read as $nb => $r) { |
@@ -1450,13 +1972,17 @@ discard block |
||
1450 | 1972 | if ($buffer !== FALSE) { |
1451 | 1973 | if ($format === 'vrstcp') { |
1452 | 1974 | $buffer = explode('},{',$buffer); |
1453 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1975 | + } else { |
|
1976 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1977 | + } |
|
1454 | 1978 | } |
1455 | 1979 | // SBS format is CSV format |
1456 | 1980 | if ($buffer !== FALSE && $buffer !== '') { |
1457 | 1981 | $tt[$format] = 0; |
1458 | 1982 | if ($format === 'acarssbs3') { |
1459 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1983 | + if ($globalDebug) { |
|
1984 | + echo 'ACARS : '.$buffer."\n"; |
|
1985 | + } |
|
1460 | 1986 | $ACARS->add(trim($buffer)); |
1461 | 1987 | $ACARS->deleteLiveAcarsData(); |
1462 | 1988 | } elseif ($format === 'raw') { |
@@ -1465,30 +1991,70 @@ discard block |
||
1465 | 1991 | if (is_array($data)) { |
1466 | 1992 | $data['datetime'] = date('Y-m-d H:i:s'); |
1467 | 1993 | $data['format_source'] = 'raw'; |
1468 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1469 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1470 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1471 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1994 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1995 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1996 | + } |
|
1997 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1998 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1999 | + } |
|
2000 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2001 | + $data['noarchive'] = true; |
|
2002 | + } |
|
2003 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2004 | + $SI->add($data); |
|
2005 | + } |
|
1472 | 2006 | } |
1473 | 2007 | } elseif ($format === 'ais') { |
1474 | 2008 | $ais_data = $AIS->parse_line(trim($buffer)); |
1475 | 2009 | $data = array(); |
1476 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1477 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1478 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1479 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1480 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1481 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1482 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1483 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1484 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1485 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1486 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1487 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1488 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1489 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1490 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1491 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2010 | + if (isset($ais_data['ident'])) { |
|
2011 | + $data['ident'] = $ais_data['ident']; |
|
2012 | + } |
|
2013 | + if (isset($ais_data['mmsi'])) { |
|
2014 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
2015 | + } |
|
2016 | + if (isset($ais_data['speed'])) { |
|
2017 | + $data['speed'] = $ais_data['speed']; |
|
2018 | + } |
|
2019 | + if (isset($ais_data['heading'])) { |
|
2020 | + $data['heading'] = $ais_data['heading']; |
|
2021 | + } |
|
2022 | + if (isset($ais_data['latitude'])) { |
|
2023 | + $data['latitude'] = $ais_data['latitude']; |
|
2024 | + } |
|
2025 | + if (isset($ais_data['longitude'])) { |
|
2026 | + $data['longitude'] = $ais_data['longitude']; |
|
2027 | + } |
|
2028 | + if (isset($ais_data['status'])) { |
|
2029 | + $data['status'] = $ais_data['status']; |
|
2030 | + } |
|
2031 | + if (isset($ais_data['statusid'])) { |
|
2032 | + $data['status_id'] = $ais_data['statusid']; |
|
2033 | + } |
|
2034 | + if (isset($ais_data['type'])) { |
|
2035 | + $data['type'] = $ais_data['type']; |
|
2036 | + } |
|
2037 | + if (isset($ais_data['imo'])) { |
|
2038 | + $data['imo'] = $ais_data['imo']; |
|
2039 | + } |
|
2040 | + if (isset($ais_data['callsign'])) { |
|
2041 | + $data['callsign'] = $ais_data['callsign']; |
|
2042 | + } |
|
2043 | + if (isset($ais_data['destination'])) { |
|
2044 | + $data['arrival_code'] = $ais_data['destination']; |
|
2045 | + } |
|
2046 | + if (isset($ais_data['eta_ts'])) { |
|
2047 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
2048 | + } |
|
2049 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2050 | + $data['noarchive'] = true; |
|
2051 | + } |
|
2052 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2053 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2054 | + } |
|
2055 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2056 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2057 | + } |
|
1492 | 2058 | |
1493 | 2059 | if (isset($ais_data['timestamp'])) { |
1494 | 2060 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1497,7 +2063,9 @@ discard block |
||
1497 | 2063 | } |
1498 | 2064 | $data['format_source'] = 'aisnmea'; |
1499 | 2065 | $data['id_source'] = $id_source; |
1500 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
2066 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
2067 | + $MI->add($data); |
|
2068 | + } |
|
1501 | 2069 | unset($data); |
1502 | 2070 | } elseif ($format === 'flightgearsp') { |
1503 | 2071 | //echo $buffer."\n"; |
@@ -1515,12 +2083,18 @@ discard block |
||
1515 | 2083 | $data['speed'] = round($line[5]*1.94384); |
1516 | 2084 | $data['datetime'] = date('Y-m-d H:i:s'); |
1517 | 2085 | $data['format_source'] = 'flightgearsp'; |
1518 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1519 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
2086 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2087 | + $data['noarchive'] = true; |
|
2088 | + } |
|
2089 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2090 | + $SI->add($data); |
|
2091 | + } |
|
1520 | 2092 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1521 | 2093 | } |
1522 | 2094 | } elseif ($format === 'acars') { |
1523 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
2095 | + if ($globalDebug) { |
|
2096 | + echo 'ACARS : '.$buffer."\n"; |
|
2097 | + } |
|
1524 | 2098 | $ACARS->add(trim($buffer)); |
1525 | 2099 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
1526 | 2100 | $ACARS->deleteLiveAcarsData(); |
@@ -1541,8 +2115,12 @@ discard block |
||
1541 | 2115 | $aircraft_type = $line[10]; |
1542 | 2116 | $aircraft_type = preg_split(':/:',$aircraft_type); |
1543 | 2117 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
1544 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1545 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
2118 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2119 | + $data['noarchive'] = true; |
|
2120 | + } |
|
2121 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2122 | + $SI->add($data); |
|
2123 | + } |
|
1546 | 2124 | } |
1547 | 2125 | } |
1548 | 2126 | } elseif ($format === 'beast') { |
@@ -1552,28 +2130,62 @@ discard block |
||
1552 | 2130 | foreach($buffer as $all_data) { |
1553 | 2131 | $line = json_decode('{'.$all_data.'}',true); |
1554 | 2132 | $data = array(); |
1555 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
1556 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
1557 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
1558 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
1559 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
1560 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
1561 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
2133 | + if (isset($line['Icao'])) { |
|
2134 | + $data['hex'] = $line['Icao']; |
|
2135 | + } |
|
2136 | + // hex |
|
2137 | + if (isset($line['Call'])) { |
|
2138 | + $data['ident'] = $line['Call']; |
|
2139 | + } |
|
2140 | + // ident |
|
2141 | + if (isset($line['Alt'])) { |
|
2142 | + $data['altitude'] = $line['Alt']; |
|
2143 | + } |
|
2144 | + // altitude |
|
2145 | + if (isset($line['Spd'])) { |
|
2146 | + $data['speed'] = $line['Spd']; |
|
2147 | + } |
|
2148 | + // speed |
|
2149 | + if (isset($line['Trak'])) { |
|
2150 | + $data['heading'] = $line['Trak']; |
|
2151 | + } |
|
2152 | + // heading |
|
2153 | + if (isset($line['Lat'])) { |
|
2154 | + $data['latitude'] = $line['Lat']; |
|
2155 | + } |
|
2156 | + // lat |
|
2157 | + if (isset($line['Long'])) { |
|
2158 | + $data['longitude'] = $line['Long']; |
|
2159 | + } |
|
2160 | + // long |
|
1562 | 2161 | //$data['verticalrate'] = $line['']; // verticale rate |
1563 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
2162 | + if (isset($line['Sqk'])) { |
|
2163 | + $data['squawk'] = $line['Sqk']; |
|
2164 | + } |
|
2165 | + // squawk |
|
1564 | 2166 | $data['emergency'] = ''; // emergency |
1565 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
2167 | + if (isset($line['Reg'])) { |
|
2168 | + $data['registration'] = $line['Reg']; |
|
2169 | + } |
|
1566 | 2170 | /* |
1567 | 2171 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
1568 | 2172 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1569 | 2173 | */ |
1570 | 2174 | $data['datetime'] = date('Y-m-d H:i:s'); |
1571 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
2175 | + if (isset($line['Type'])) { |
|
2176 | + $data['aircraft_icao'] = $line['Type']; |
|
2177 | + } |
|
1572 | 2178 | $data['format_source'] = 'vrstcp'; |
1573 | 2179 | $data['id_source'] = $id_source; |
1574 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1575 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1576 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
2180 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2181 | + $data['noarchive'] = true; |
|
2182 | + } |
|
2183 | + if (isset($value['name']) && $value['name'] != '') { |
|
2184 | + $data['source_name'] = $value['name']; |
|
2185 | + } |
|
2186 | + if (isset($data['latitude']) && isset($data['hex'])) { |
|
2187 | + $SI->add($data); |
|
2188 | + } |
|
1577 | 2189 | unset($data); |
1578 | 2190 | } |
1579 | 2191 | } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
@@ -1586,22 +2198,46 @@ discard block |
||
1586 | 2198 | $data['hex'] = $lined['hexid']; |
1587 | 2199 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1588 | 2200 | $data['datetime'] = date('Y-m-d H:i:s');; |
1589 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1590 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1591 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1592 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1593 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1594 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1595 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
2201 | + if (isset($lined['ident'])) { |
|
2202 | + $data['ident'] = $lined['ident']; |
|
2203 | + } |
|
2204 | + if (isset($lined['lat'])) { |
|
2205 | + $data['latitude'] = $lined['lat']; |
|
2206 | + } |
|
2207 | + if (isset($lined['lon'])) { |
|
2208 | + $data['longitude'] = $lined['lon']; |
|
2209 | + } |
|
2210 | + if (isset($lined['speed'])) { |
|
2211 | + $data['speed'] = $lined['speed']; |
|
2212 | + } |
|
2213 | + if (isset($lined['squawk'])) { |
|
2214 | + $data['squawk'] = $lined['squawk']; |
|
2215 | + } |
|
2216 | + if (isset($lined['alt'])) { |
|
2217 | + $data['altitude'] = $lined['alt']; |
|
2218 | + } |
|
2219 | + if (isset($lined['heading'])) { |
|
2220 | + $data['heading'] = $lined['heading']; |
|
2221 | + } |
|
1596 | 2222 | $data['id_source'] = $id_source; |
1597 | 2223 | $data['format_source'] = 'tsv'; |
1598 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1599 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1600 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1601 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
2224 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2225 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2226 | + } |
|
2227 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2228 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2229 | + } |
|
2230 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2231 | + $data['noarchive'] = true; |
|
2232 | + } |
|
2233 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2234 | + $SI->add($data); |
|
2235 | + } |
|
1602 | 2236 | unset($lined); |
1603 | 2237 | unset($data); |
1604 | - } else $error = true; |
|
2238 | + } else { |
|
2239 | + $error = true; |
|
2240 | + } |
|
1605 | 2241 | } elseif ($format === 'aprs' && $use_aprs) { |
1606 | 2242 | if ($aprs_connect === 0) { |
1607 | 2243 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1627,63 +2263,121 @@ discard block |
||
1627 | 2263 | $aprs_last_tx = time(); |
1628 | 2264 | $data = array(); |
1629 | 2265 | //print_r($line); |
1630 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1631 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1632 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1633 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1634 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
1635 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
1636 | - if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
1637 | - if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
1638 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1639 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
2266 | + if (isset($line['address'])) { |
|
2267 | + $data['hex'] = $line['address']; |
|
2268 | + } |
|
2269 | + if (isset($line['mmsi'])) { |
|
2270 | + $data['mmsi'] = $line['mmsi']; |
|
2271 | + } |
|
2272 | + if (isset($line['imo'])) { |
|
2273 | + $data['imo'] = $line['imo']; |
|
2274 | + } |
|
2275 | + if (isset($line['squawk'])) { |
|
2276 | + $data['squawk'] = $line['squawk']; |
|
2277 | + } |
|
2278 | + if (isset($line['arrival_code'])) { |
|
2279 | + $data['arrival_code'] = $line['arrival_code']; |
|
2280 | + } |
|
2281 | + if (isset($line['arrival_date'])) { |
|
2282 | + $data['arrival_date'] = $line['arrival_date']; |
|
2283 | + } |
|
2284 | + if (isset($line['typeid'])) { |
|
2285 | + $data['type_id'] = $line['typeid']; |
|
2286 | + } |
|
2287 | + if (isset($line['statusid'])) { |
|
2288 | + $data['status_id'] = $line['statusid']; |
|
2289 | + } |
|
2290 | + if (isset($line['timestamp'])) { |
|
2291 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
2292 | + } else { |
|
2293 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
2294 | + } |
|
1640 | 2295 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1641 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
2296 | + if (isset($line['ident'])) { |
|
2297 | + $data['ident'] = $line['ident']; |
|
2298 | + } |
|
1642 | 2299 | $data['latitude'] = $line['latitude']; |
1643 | 2300 | $data['longitude'] = $line['longitude']; |
1644 | 2301 | //$data['verticalrate'] = $line[16]; |
1645 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
2302 | + if (isset($line['speed'])) { |
|
2303 | + $data['speed'] = $line['speed']; |
|
2304 | + } |
|
1646 | 2305 | //else $data['speed'] = 0; |
1647 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1648 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1649 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
2306 | + if (isset($line['altitude'])) { |
|
2307 | + $data['altitude'] = $line['altitude']; |
|
2308 | + } |
|
2309 | + if (isset($line['comment'])) { |
|
2310 | + $data['comment'] = $line['comment']; |
|
2311 | + } |
|
2312 | + if (isset($line['symbol'])) { |
|
2313 | + $data['type'] = $line['symbol']; |
|
2314 | + } |
|
1650 | 2315 | //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
1651 | 2316 | |
1652 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
2317 | + if (isset($line['heading']) && isset($line['format_source'])) { |
|
2318 | + $data['heading'] = $line['heading']; |
|
2319 | + } |
|
1653 | 2320 | //else echo 'No heading...'."\n"; |
1654 | 2321 | //else $data['heading'] = 0; |
1655 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
2322 | + if (isset($line['stealth'])) { |
|
2323 | + $data['aircraft_type'] = $line['stealth']; |
|
2324 | + } |
|
1656 | 2325 | //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
1657 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1658 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1659 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1660 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
2326 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) { |
|
2327 | + $data['noarchive'] = true; |
|
2328 | + } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) { |
|
2329 | + $data['noarchive'] = false; |
|
2330 | + } |
|
2331 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2332 | + $data['noarchive'] = true; |
|
2333 | + } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) { |
|
2334 | + $data['noarchive'] = false; |
|
2335 | + } |
|
1661 | 2336 | $data['id_source'] = $id_source; |
1662 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1663 | - else $data['format_source'] = 'aprs'; |
|
2337 | + if (isset($line['format_source'])) { |
|
2338 | + $data['format_source'] = $line['format_source']; |
|
2339 | + } else { |
|
2340 | + $data['format_source'] = 'aprs'; |
|
2341 | + } |
|
1664 | 2342 | $data['source_name'] = $line['source']; |
1665 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1666 | - else $data['source_type'] = 'flarm'; |
|
1667 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2343 | + if (isset($line['source_type'])) { |
|
2344 | + $data['source_type'] = $line['source_type']; |
|
2345 | + } else { |
|
2346 | + $data['source_type'] = 'flarm'; |
|
2347 | + } |
|
2348 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2349 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2350 | + } |
|
1668 | 2351 | $currentdate = date('Y-m-d H:i:s'); |
1669 | 2352 | $aprsdate = strtotime($data['datetime']); |
1670 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
2353 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') { |
|
2354 | + $data['altitude_relative'] = 'AMSL'; |
|
2355 | + } |
|
1671 | 2356 | // Accept data if time <= system time + 20s |
1672 | 2357 | //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'])))) { |
1673 | 2358 | 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'])))) { |
1674 | 2359 | $send = $SI->add($data); |
1675 | 2360 | } elseif ($data['source_type'] === 'ais') { |
1676 | 2361 | $data['type'] = ''; |
1677 | - if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
|
2362 | + if (isset($globalMarine) && $globalMarine) { |
|
2363 | + $send = $MI->add($data); |
|
2364 | + } |
|
1678 | 2365 | } elseif (isset($line['stealth'])) { |
1679 | - if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
1680 | - else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
2366 | + if ($line['stealth'] != 0) { |
|
2367 | + echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
2368 | + } else { |
|
2369 | + echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
2370 | + } |
|
1681 | 2371 | } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
1682 | 2372 | //$line['symbol'] === 'Balloon' || |
1683 | 2373 | $line['symbol'] === 'Glider' || |
1684 | 2374 | $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
1685 | - if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1686 | - if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
2375 | + if ($line['symbol'] === 'Ballon') { |
|
2376 | + $data['aircraft_icao'] = 'BALL'; |
|
2377 | + } |
|
2378 | + if ($line['symbol'] === 'Glider') { |
|
2379 | + $data['aircraft_icao'] = 'PARAGLIDER'; |
|
2380 | + } |
|
1687 | 2381 | $send = $SI->add($data); |
1688 | 2382 | } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
1689 | 2383 | $line['symbol'] === 'Yacht (Sail)' || |
@@ -1714,9 +2408,13 @@ discard block |
||
1714 | 2408 | //} 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') { |
1715 | 2409 | // } 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') { |
1716 | 2410 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1717 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
2411 | + if (isset($globalTracker) && $globalTracker) { |
|
2412 | + $send = $TI->add($data); |
|
2413 | + } |
|
1718 | 2414 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
1719 | - if (!isset($data['altitude'])) $data['altitude'] = 0; |
|
2415 | + if (!isset($data['altitude'])) { |
|
2416 | + $data['altitude'] = 0; |
|
2417 | + } |
|
1720 | 2418 | $Source->deleteOldLocationByType('gs'); |
1721 | 2419 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
1722 | 2420 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
@@ -1725,7 +2423,9 @@ discard block |
||
1725 | 2423 | } |
1726 | 2424 | } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
1727 | 2425 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1728 | - if ($globalDebug) echo '# Weather Station added'."\n"; |
|
2426 | + if ($globalDebug) { |
|
2427 | + echo '# Weather Station added'."\n"; |
|
2428 | + } |
|
1729 | 2429 | $Source->deleteOldLocationByType('wx'); |
1730 | 2430 | $weather_data = json_encode($line); |
1731 | 2431 | if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
@@ -1735,7 +2435,9 @@ discard block |
||
1735 | 2435 | } |
1736 | 2436 | } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
1737 | 2437 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1738 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
2438 | + if ($globalDebug) { |
|
2439 | + echo '☈ Lightning added'."\n"; |
|
2440 | + } |
|
1739 | 2441 | $Source->deleteOldLocationByType('lightning'); |
1740 | 2442 | if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
1741 | 2443 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
@@ -1747,8 +2449,7 @@ discard block |
||
1747 | 2449 | print_r($line); |
1748 | 2450 | } |
1749 | 2451 | unset($data); |
1750 | - } |
|
1751 | - elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
2452 | + } elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
1752 | 2453 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
1753 | 2454 | } |
1754 | 2455 | /* |
@@ -1757,7 +2458,9 @@ discard block |
||
1757 | 2458 | } |
1758 | 2459 | */ |
1759 | 2460 | //elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
1760 | - elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
|
2461 | + elseif ($line === true && $globalDebug) { |
|
2462 | + echo '!! Failed : '.$buffer."!!\n"; |
|
2463 | + } |
|
1761 | 2464 | if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
1762 | 2465 | $Source->deleteOldLocationByType('lightning'); |
1763 | 2466 | $Source->deleteOldLocationByType('wx'); |
@@ -1793,26 +2496,45 @@ discard block |
||
1793 | 2496 | $data['ground'] = $line[21]; |
1794 | 2497 | $data['emergency'] = $line[19]; |
1795 | 2498 | $data['format_source'] = 'sbs'; |
1796 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1797 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1798 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
2499 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2500 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2501 | + } |
|
2502 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2503 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2504 | + } |
|
2505 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2506 | + $data['noarchive'] = true; |
|
2507 | + } |
|
1799 | 2508 | $data['id_source'] = $id_source; |
1800 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1801 | - else $error = true; |
|
2509 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2510 | + $send = $SI->add($data); |
|
2511 | + } else { |
|
2512 | + $error = true; |
|
2513 | + } |
|
1802 | 2514 | unset($data); |
1803 | - } else $error = true; |
|
2515 | + } else { |
|
2516 | + $error = true; |
|
2517 | + } |
|
1804 | 2518 | if ($error) { |
1805 | 2519 | if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { |
1806 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
2520 | + if ($globalDebug) { |
|
2521 | + echo "Not a message. Ignoring... \n"; |
|
2522 | + } |
|
1807 | 2523 | } else { |
1808 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
2524 | + if ($globalDebug) { |
|
2525 | + echo "Wrong line format. Ignoring... \n"; |
|
2526 | + } |
|
1809 | 2527 | if ($globalDebug) { |
1810 | 2528 | echo $buffer; |
1811 | 2529 | //print_r($line); |
1812 | 2530 | } |
1813 | 2531 | //socket_close($r); |
1814 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
1815 | - if ($format === 'aprs') $aprs_connect = 0; |
|
2532 | + if ($globalDebug) { |
|
2533 | + echo "Reconnect after an error...\n"; |
|
2534 | + } |
|
2535 | + if ($format === 'aprs') { |
|
2536 | + $aprs_connect = 0; |
|
2537 | + } |
|
1816 | 2538 | $sourceer[$nb] = $globalSources[$nb]; |
1817 | 2539 | connect_all($sourceer); |
1818 | 2540 | $sourceer = array(); |
@@ -1820,10 +2542,14 @@ discard block |
||
1820 | 2542 | } |
1821 | 2543 | } |
1822 | 2544 | // Sleep for xxx microseconds |
1823 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
2545 | + if (isset($globalSBSSleep)) { |
|
2546 | + usleep($globalSBSSleep); |
|
2547 | + } |
|
1824 | 2548 | } else { |
1825 | 2549 | if ($format === 'flightgearmp') { |
1826 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
2550 | + if ($globalDebug) { |
|
2551 | + echo "Reconnect FlightGear MP..."; |
|
2552 | + } |
|
1827 | 2553 | //@socket_close($r); |
1828 | 2554 | sleep($globalMinFetch); |
1829 | 2555 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1832,10 +2558,15 @@ discard block |
||
1832 | 2558 | break; |
1833 | 2559 | |
1834 | 2560 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1835 | - if (isset($tt[$format])) $tt[$format]++; |
|
1836 | - else $tt[$format] = 0; |
|
2561 | + if (isset($tt[$format])) { |
|
2562 | + $tt[$format]++; |
|
2563 | + } else { |
|
2564 | + $tt[$format] = 0; |
|
2565 | + } |
|
1837 | 2566 | if ($tt[$format] > 30 || $buffer === FALSE) { |
1838 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
2567 | + if ($globalDebug) { |
|
2568 | + echo "ERROR : Reconnect ".$format."..."; |
|
2569 | + } |
|
1839 | 2570 | //@socket_close($r); |
1840 | 2571 | sleep(2); |
1841 | 2572 | $aprs_connect = 0; |
@@ -1853,11 +2584,17 @@ discard block |
||
1853 | 2584 | } else { |
1854 | 2585 | $error = socket_strerror(socket_last_error()); |
1855 | 2586 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1856 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1857 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
2587 | + if ($globalDebug) { |
|
2588 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
2589 | + } |
|
2590 | + if (isset($globalDebug)) { |
|
2591 | + echo "Restarting...\n"; |
|
2592 | + } |
|
1858 | 2593 | // Restart the script if possible |
1859 | 2594 | if (is_array($sockets)) { |
1860 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
2595 | + if ($globalDebug) { |
|
2596 | + echo "Shutdown all sockets..."; |
|
2597 | + } |
|
1861 | 2598 | |
1862 | 2599 | foreach ($sockets as $sock) { |
1863 | 2600 | @socket_shutdown($sock,2); |
@@ -1865,25 +2602,45 @@ discard block |
||
1865 | 2602 | } |
1866 | 2603 | |
1867 | 2604 | } |
1868 | - if ($globalDebug) echo "Waiting..."; |
|
2605 | + if ($globalDebug) { |
|
2606 | + echo "Waiting..."; |
|
2607 | + } |
|
1869 | 2608 | sleep(2); |
1870 | 2609 | $time = time(); |
1871 | 2610 | //connect_all($hosts); |
1872 | 2611 | $aprs_connect = 0; |
1873 | - if ($reset%5 === 0) sleep(20); |
|
1874 | - if ($reset%10 === 0) sleep(100); |
|
1875 | - if ($reset%20 === 0) sleep(200); |
|
1876 | - if ($reset > 100) exit('Too many attempts...'); |
|
1877 | - if ($globalDebug) echo "Restart all connections..."; |
|
2612 | + if ($reset%5 === 0) { |
|
2613 | + sleep(20); |
|
2614 | + } |
|
2615 | + if ($reset%10 === 0) { |
|
2616 | + sleep(100); |
|
2617 | + } |
|
2618 | + if ($reset%20 === 0) { |
|
2619 | + sleep(200); |
|
2620 | + } |
|
2621 | + if ($reset > 100) { |
|
2622 | + exit('Too many attempts...'); |
|
2623 | + } |
|
2624 | + if ($globalDebug) { |
|
2625 | + echo "Restart all connections..."; |
|
2626 | + } |
|
1878 | 2627 | connect_all($globalSources); |
1879 | 2628 | } |
1880 | 2629 | } |
1881 | 2630 | } |
1882 | 2631 | if ($globalDaemon === false) { |
1883 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1884 | - if (isset($SI)) $SI->checkAll(); |
|
1885 | - if (isset($TI)) $TI->checkAll(); |
|
1886 | - if (isset($MI)) $MI->checkAll(); |
|
2632 | + if ($globalDebug) { |
|
2633 | + echo 'Check all...'."\n"; |
|
2634 | + } |
|
2635 | + if (isset($SI)) { |
|
2636 | + $SI->checkAll(); |
|
2637 | + } |
|
2638 | + if (isset($TI)) { |
|
2639 | + $TI->checkAll(); |
|
2640 | + } |
|
2641 | + if (isset($MI)) { |
|
2642 | + $MI->checkAll(); |
|
2643 | + } |
|
1887 | 2644 | } |
1888 | 2645 | } |
1889 | 2646 | } |