@@ -16,20 +16,20 @@ discard block |
||
16 | 16 | require_once(dirname(__FILE__).'/class.Source.php'); |
17 | 17 | require_once(dirname(__FILE__).'/class.GeoidHeight.php'); |
18 | 18 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
19 | - require_once(dirname(__FILE__).'/class.APRS.php'); |
|
19 | + require_once(dirname(__FILE__).'/class.APRS.php'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | class SpotterImport { |
23 | - private $all_flights = array(); |
|
24 | - private $last_delete_hourly = 0; |
|
25 | - private $last_delete = 0; |
|
26 | - private $stats = array(); |
|
27 | - private $tmd = 0; |
|
28 | - private $source_location = array(); |
|
29 | - public $db = null; |
|
30 | - public $nb = 0; |
|
23 | + private $all_flights = array(); |
|
24 | + private $last_delete_hourly = 0; |
|
25 | + private $last_delete = 0; |
|
26 | + private $stats = array(); |
|
27 | + private $tmd = 0; |
|
28 | + private $source_location = array(); |
|
29 | + public $db = null; |
|
30 | + public $nb = 0; |
|
31 | 31 | |
32 | - public function __construct($dbc = null) { |
|
32 | + public function __construct($dbc = null) { |
|
33 | 33 | global $globalBeta, $globalServerAPRS, $APRSSpotter, $globalNoDB, $GeoidClass, $globalDebug, $globalGeoid; |
34 | 34 | if (!(isset($globalNoDB) && $globalNoDB)) { |
35 | 35 | $Connection = new Connection($dbc); |
@@ -41,14 +41,14 @@ discard block |
||
41 | 41 | $currentdate = date('Y-m-d'); |
42 | 42 | $sourcestat = $Stats->getStatsSource($currentdate); |
43 | 43 | if (!empty($sourcestat)) { |
44 | - foreach($sourcestat as $srcst) { |
|
45 | - $type = $srcst['stats_type']; |
|
44 | + foreach($sourcestat as $srcst) { |
|
45 | + $type = $srcst['stats_type']; |
|
46 | 46 | if ($type == 'polar' || $type == 'hist') { |
47 | - $source = $srcst['source_name']; |
|
48 | - $data = $srcst['source_data']; |
|
49 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
50 | - } |
|
51 | - } |
|
47 | + $source = $srcst['source_name']; |
|
48 | + $data = $srcst['source_data']; |
|
49 | + $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
50 | + } |
|
51 | + } |
|
52 | 52 | } |
53 | 53 | } |
54 | 54 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | $GeoidClass = FALSE; |
64 | 64 | } |
65 | 65 | } |
66 | - } |
|
66 | + } |
|
67 | 67 | |
68 | - public function get_Schedule($id,$ident) { |
|
68 | + public function get_Schedule($id,$ident) { |
|
69 | 69 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
70 | 70 | // Get schedule here, so it's done only one time |
71 | 71 | |
@@ -85,43 +85,43 @@ discard block |
||
85 | 85 | $operator = $Spotter->getOperator($ident); |
86 | 86 | $scheduleexist = false; |
87 | 87 | if ($Schedule->checkSchedule($operator) == 0) { |
88 | - $operator = $Translation->checkTranslation($ident); |
|
89 | - if ($Schedule->checkSchedule($operator) == 0) { |
|
88 | + $operator = $Translation->checkTranslation($ident); |
|
89 | + if ($Schedule->checkSchedule($operator) == 0) { |
|
90 | 90 | $schedule = $Schedule->fetchSchedule($operator); |
91 | 91 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
92 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
93 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
94 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
95 | - // Should also check if route schedule = route from DB |
|
96 | - if ($schedule['DepartureAirportIATA'] != '') { |
|
92 | + if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
93 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
94 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
95 | + // Should also check if route schedule = route from DB |
|
96 | + if ($schedule['DepartureAirportIATA'] != '') { |
|
97 | 97 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
98 | - $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
99 | - if (trim($airport_icao) != '') { |
|
98 | + $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
99 | + if (trim($airport_icao) != '') { |
|
100 | 100 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
101 | 101 | if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
102 | - } |
|
102 | + } |
|
103 | + } |
|
103 | 104 | } |
104 | - } |
|
105 | - if ($schedule['ArrivalAirportIATA'] != '') { |
|
105 | + if ($schedule['ArrivalAirportIATA'] != '') { |
|
106 | 106 | if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) { |
107 | - $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
108 | - if (trim($airport_icao) != '') { |
|
107 | + $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
108 | + if (trim($airport_icao) != '') { |
|
109 | 109 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
110 | 110 | if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
111 | - } |
|
111 | + } |
|
112 | 112 | } |
113 | - } |
|
114 | - $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
113 | + } |
|
114 | + $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
115 | 115 | } |
116 | - } else $scheduleexist = true; |
|
116 | + } else $scheduleexist = true; |
|
117 | 117 | } else $scheduleexist = true; |
118 | 118 | // close connection, at least one way will work ? |
119 | - if ($scheduleexist) { |
|
119 | + if ($scheduleexist) { |
|
120 | 120 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
121 | - $sch = $Schedule->getSchedule($operator); |
|
121 | + $sch = $Schedule->getSchedule($operator); |
|
122 | 122 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
123 | 123 | if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']); |
124 | - } |
|
124 | + } |
|
125 | 125 | $Spotter->db = null; |
126 | 126 | $Schedule->db = null; |
127 | 127 | $Translation->db = null; |
@@ -136,65 +136,65 @@ discard block |
||
136 | 136 | } |
137 | 137 | */ |
138 | 138 | } |
139 | - } |
|
139 | + } |
|
140 | 140 | |
141 | - public function checkAll() { |
|
141 | + public function checkAll() { |
|
142 | 142 | global $globalDebug, $globalNoImport; |
143 | 143 | if ($globalDebug) echo "Update last seen flights data...\n"; |
144 | 144 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
145 | - foreach ($this->all_flights as $key => $flight) { |
|
145 | + foreach ($this->all_flights as $key => $flight) { |
|
146 | 146 | if (isset($this->all_flights[$key]['id'])) { |
147 | - //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
|
148 | - $Spotter = new Spotter($this->db); |
|
149 | - $real_arrival = $this->arrival($key); |
|
150 | - if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
151 | - } |
|
152 | - } |
|
147 | + //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
|
148 | + $Spotter = new Spotter($this->db); |
|
149 | + $real_arrival = $this->arrival($key); |
|
150 | + if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
151 | + } |
|
152 | + } |
|
153 | + } |
|
153 | 154 | } |
154 | - } |
|
155 | 155 | |
156 | - public function arrival($key) { |
|
156 | + public function arrival($key) { |
|
157 | 157 | global $globalClosestMinDist, $globalDebug; |
158 | 158 | if ($globalDebug) echo 'Update arrival...'."\n"; |
159 | 159 | $Spotter = new Spotter($this->db); |
160 | - $airport_icao = ''; |
|
161 | - $airport_time = ''; |
|
162 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
160 | + $airport_icao = ''; |
|
161 | + $airport_time = ''; |
|
162 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
163 | 163 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
164 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
165 | - if (isset($closestAirports[0])) { |
|
166 | - if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
167 | - $airport_icao = $closestAirports[0]['icao']; |
|
168 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
169 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
170 | - } elseif (count($closestAirports) > 1 && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
171 | - foreach ($closestAirports as $airport) { |
|
172 | - if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
173 | - $airport_icao = $airport['icao']; |
|
174 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
175 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
176 | - break; |
|
177 | - } |
|
178 | - } |
|
179 | - } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
180 | - $airport_icao = $closestAirports[0]['icao']; |
|
181 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
182 | - } else { |
|
183 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
184 | - } |
|
185 | - } else { |
|
186 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
187 | - } |
|
164 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
165 | + if (isset($closestAirports[0])) { |
|
166 | + if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
167 | + $airport_icao = $closestAirports[0]['icao']; |
|
168 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
169 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
170 | + } elseif (count($closestAirports) > 1 && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
171 | + foreach ($closestAirports as $airport) { |
|
172 | + if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
173 | + $airport_icao = $airport['icao']; |
|
174 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
175 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
176 | + break; |
|
177 | + } |
|
178 | + } |
|
179 | + } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
180 | + $airport_icao = $closestAirports[0]['icao']; |
|
181 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
182 | + } else { |
|
183 | + if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
184 | + } |
|
185 | + } else { |
|
186 | + if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
187 | + } |
|
188 | 188 | |
189 | - } else { |
|
190 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
191 | - } |
|
192 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
193 | - } |
|
189 | + } else { |
|
190 | + if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
191 | + } |
|
192 | + return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
193 | + } |
|
194 | 194 | |
195 | 195 | |
196 | 196 | |
197 | - public function del() { |
|
197 | + public function del() { |
|
198 | 198 | global $globalDebug, $globalNoImport, $globalNoDB; |
199 | 199 | // Delete old infos |
200 | 200 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
@@ -206,9 +206,9 @@ discard block |
||
206 | 206 | } |
207 | 207 | } |
208 | 208 | } |
209 | - } |
|
209 | + } |
|
210 | 210 | |
211 | - public function delKey($key) { |
|
211 | + public function delKey($key) { |
|
212 | 212 | global $globalDebug, $globalNoImport, $globalNoDB; |
213 | 213 | // Delete old infos |
214 | 214 | if (isset($this->all_flights[$key]['id'])) { |
@@ -230,9 +230,9 @@ discard block |
||
230 | 230 | if ($globalDebug) echo "\n"; |
231 | 231 | } |
232 | 232 | unset($this->all_flights[$key]); |
233 | - } |
|
233 | + } |
|
234 | 234 | |
235 | - public function add($line) { |
|
235 | + public function add($line) { |
|
236 | 236 | 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, $globalAPRSdelete; |
237 | 237 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
238 | 238 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.01'; |
@@ -258,20 +258,20 @@ discard block |
||
258 | 258 | |
259 | 259 | // SBS format is CSV format |
260 | 260 | if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
261 | - //print_r($line); |
|
262 | - if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
263 | - if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
261 | + //print_r($line); |
|
262 | + if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
263 | + if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
264 | 264 | |
265 | 265 | // Increment message number |
266 | 266 | if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
267 | - $current_date = date('Y-m-d'); |
|
268 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
269 | - else $source = ''; |
|
270 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
271 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
272 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
273 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
274 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
267 | + $current_date = date('Y-m-d'); |
|
268 | + if (isset($line['source_name'])) $source = $line['source_name']; |
|
269 | + else $source = ''; |
|
270 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
271 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
272 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
273 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
274 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | /* |
@@ -287,54 +287,54 @@ discard block |
||
287 | 287 | //$this->db = $dbc; |
288 | 288 | |
289 | 289 | //$hex = trim($line['hex']); |
290 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
291 | - else $id = trim($line['id']); |
|
290 | + if (!isset($line['id'])) $id = trim($line['hex']); |
|
291 | + else $id = trim($line['id']); |
|
292 | 292 | |
293 | 293 | if (!isset($this->all_flights[$id])) { |
294 | - if ($globalDebug) echo 'New flight...'."\n"; |
|
295 | - $this->all_flights[$id] = array(); |
|
296 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
297 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '','coordinates' => 0)); |
|
298 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
299 | - if (!isset($line['id'])) { |
|
294 | + if ($globalDebug) echo 'New flight...'."\n"; |
|
295 | + $this->all_flights[$id] = array(); |
|
296 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
297 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '','coordinates' => 0)); |
|
298 | + if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
299 | + if (!isset($line['id'])) { |
|
300 | 300 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
301 | 301 | // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
302 | 302 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
303 | 303 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
304 | - //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
305 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
306 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
304 | + //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
305 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
306 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
307 | 307 | } |
308 | 308 | if (isset($line['source_type']) && $line['source_type'] != '') { |
309 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
309 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | //print_r($this->all_flights); |
313 | 313 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
314 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
315 | - //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
314 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
315 | + //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
316 | 316 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
317 | - //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
318 | - 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') { |
|
317 | + //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
318 | + 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') { |
|
319 | 319 | $timeelapsed = microtime(true); |
320 | 320 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
321 | - $Spotter = new Spotter($this->db); |
|
322 | - if (isset($this->all_flights[$id]['source_type'])) { |
|
321 | + $Spotter = new Spotter($this->db); |
|
322 | + if (isset($this->all_flights[$id]['source_type'])) { |
|
323 | 323 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
324 | - } else { |
|
324 | + } else { |
|
325 | 325 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
326 | - } |
|
327 | - $Spotter->db = null; |
|
328 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
329 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
326 | + } |
|
327 | + $Spotter->db = null; |
|
328 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
329 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
330 | 330 | } |
331 | - } |
|
332 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
333 | - if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
331 | + } |
|
332 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
333 | + if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
334 | 334 | } |
335 | - if (isset($line['id']) && !isset($line['hex'])) { |
|
336 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
337 | - } |
|
335 | + if (isset($line['id']) && !isset($line['hex'])) { |
|
336 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
337 | + } |
|
338 | 338 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
339 | 339 | $icao = $line['aircraft_icao']; |
340 | 340 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -364,9 +364,9 @@ discard block |
||
364 | 364 | } |
365 | 365 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
366 | 366 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
367 | - if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
367 | + if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
368 | 368 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
369 | - } else { |
|
369 | + } else { |
|
370 | 370 | if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
371 | 371 | elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
372 | 372 | /* |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | print_r($line); |
376 | 376 | */ |
377 | 377 | return ''; |
378 | - } |
|
378 | + } |
|
379 | 379 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
380 | 380 | if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
381 | 381 | return ''; |
@@ -391,21 +391,21 @@ discard block |
||
391 | 391 | } |
392 | 392 | |
393 | 393 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG' && $line['registration'] != 'NA') { |
394 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
394 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
395 | 395 | } |
396 | 396 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
397 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
397 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
398 | 398 | } |
399 | 399 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
400 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
400 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
401 | 401 | } |
402 | 402 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
403 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
403 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | if (isset($line['ident']) && trim($line['ident']) != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
407 | 407 | |
408 | - if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
408 | + if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
409 | 409 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
410 | 410 | if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
411 | 411 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
@@ -414,23 +414,23 @@ discard block |
||
414 | 414 | elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
415 | 415 | elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
416 | 416 | } else { |
417 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
418 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
417 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
418 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
419 | 419 | $timeelapsed = microtime(true); |
420 | - $Spotter = new Spotter($this->db); |
|
421 | - $fromsource = NULL; |
|
422 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
423 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
420 | + $Spotter = new Spotter($this->db); |
|
421 | + $fromsource = NULL; |
|
422 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
423 | + elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
424 | 424 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
425 | 425 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
426 | 426 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
427 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource,$this->all_flights[$id]['source_type']); |
|
427 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource,$this->all_flights[$id]['source_type']); |
|
428 | 428 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
429 | 429 | $Spotter->db = null; |
430 | 430 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
431 | - } |
|
431 | + } |
|
432 | 432 | } |
433 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
433 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
434 | 434 | |
435 | 435 | /* |
436 | 436 | if (!isset($line['id'])) { |
@@ -440,63 +440,63 @@ discard block |
||
440 | 440 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
441 | 441 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
442 | 442 | */ |
443 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
443 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
444 | 444 | |
445 | - //$putinarchive = true; |
|
446 | - if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
445 | + //$putinarchive = true; |
|
446 | + if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
447 | 447 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
448 | - } |
|
449 | - if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
448 | + } |
|
449 | + if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
450 | 450 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
451 | - } |
|
452 | - if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
453 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
454 | - } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
451 | + } |
|
452 | + if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
453 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
454 | + } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
455 | 455 | $timeelapsed = microtime(true); |
456 | 456 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
457 | 457 | $Spotter = new Spotter($this->db); |
458 | 458 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
459 | 459 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
460 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
460 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
461 | 461 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
462 | - } |
|
463 | - } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
462 | + } |
|
463 | + } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
464 | 464 | $timeelapsed = microtime(true); |
465 | 465 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
466 | - $Spotter = new Spotter($this->db); |
|
467 | - $route = $Spotter->getRouteInfo(trim($line['ident'])); |
|
468 | - if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) { |
|
466 | + $Spotter = new Spotter($this->db); |
|
467 | + $route = $Spotter->getRouteInfo(trim($line['ident'])); |
|
468 | + if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) { |
|
469 | 469 | $Translation = new Translation($this->db); |
470 | 470 | $ident = $Translation->checkTranslation(trim($line['ident'])); |
471 | 471 | $route = $Spotter->getRouteInfo($ident); |
472 | 472 | $Translation->db = null; |
473 | - } |
|
474 | - $Spotter->db = null; |
|
475 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
476 | - } |
|
473 | + } |
|
474 | + $Spotter->db = null; |
|
475 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
476 | + } |
|
477 | 477 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
478 | - //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
479 | - if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
478 | + //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
479 | + if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
480 | 480 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop'])); |
481 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
482 | - } |
|
481 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
482 | + } |
|
483 | 483 | } |
484 | 484 | if (!isset($globalFork)) $globalFork = TRUE; |
485 | 485 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
486 | 486 | if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
487 | 487 | } |
488 | - } |
|
488 | + } |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) { |
492 | 492 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
493 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
494 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
495 | - //$dataFound = true; |
|
493 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
494 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
495 | + //$dataFound = true; |
|
496 | 496 | } else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
497 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
498 | - if ($distance > 1000 && $distance < 10000) { |
|
499 | - // use datetime |
|
497 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
498 | + if ($distance > 1000 && $distance < 10000) { |
|
499 | + // use datetime |
|
500 | 500 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
501 | 501 | $speed = $speed*3.6; |
502 | 502 | if ($speed < 1000) { |
@@ -505,49 +505,49 @@ discard block |
||
505 | 505 | } else { |
506 | 506 | if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
507 | 507 | } |
508 | - } |
|
508 | + } |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | |
512 | 512 | |
513 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
514 | - if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
|
515 | - if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
516 | - return false; |
|
517 | - } |
|
518 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
519 | - else unset($timediff); |
|
520 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
521 | - else unset($timediff_archive); |
|
522 | - if ($this->tmd > 5 |
|
523 | - || (isset($line['format_source']) |
|
524 | - && $line['format_source'] == 'airwhere' |
|
525 | - && ((!isset($this->all_flights[$id]['latitude']) |
|
526 | - || !isset($this->all_flights[$id]['longitude'])) |
|
527 | - || (isset($this->all_flights[$id]['latitude']) |
|
528 | - && isset($this->all_flights[$id]['longitude']) |
|
529 | - && $this->all_flights[$id]['latitude'] != $line['latitude'] |
|
530 | - && $this->all_flights[$id]['longitude'] != $line['longitude'] |
|
531 | - ) |
|
532 | - ) |
|
533 | - ) |
|
534 | - || (isset($globalVA) && $globalVA) |
|
535 | - || (isset($globalIVAO) && $globalIVAO) |
|
536 | - || (isset($globalVATSIM) && $globalVATSIM) |
|
537 | - || (isset($globalphpVMS) && $globalphpVMS) |
|
538 | - || (isset($globalVAM) && $globalVAM) |
|
539 | - || !isset($timediff) |
|
540 | - || (isset($timediff) && $timediff > $globalLiveInterval) |
|
541 | - || $globalArchive |
|
542 | - || (isset($timediff) && $timediff > 30 |
|
543 | - && isset($this->all_flights[$id]['latitude']) |
|
544 | - && isset($this->all_flights[$id]['longitude']) |
|
545 | - && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
546 | - ) |
|
547 | - ) { |
|
513 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
514 | + if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
|
515 | + if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
516 | + return false; |
|
517 | + } |
|
518 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
519 | + else unset($timediff); |
|
520 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
521 | + else unset($timediff_archive); |
|
522 | + if ($this->tmd > 5 |
|
523 | + || (isset($line['format_source']) |
|
524 | + && $line['format_source'] == 'airwhere' |
|
525 | + && ((!isset($this->all_flights[$id]['latitude']) |
|
526 | + || !isset($this->all_flights[$id]['longitude'])) |
|
527 | + || (isset($this->all_flights[$id]['latitude']) |
|
528 | + && isset($this->all_flights[$id]['longitude']) |
|
529 | + && $this->all_flights[$id]['latitude'] != $line['latitude'] |
|
530 | + && $this->all_flights[$id]['longitude'] != $line['longitude'] |
|
531 | + ) |
|
532 | + ) |
|
533 | + ) |
|
534 | + || (isset($globalVA) && $globalVA) |
|
535 | + || (isset($globalIVAO) && $globalIVAO) |
|
536 | + || (isset($globalVATSIM) && $globalVATSIM) |
|
537 | + || (isset($globalphpVMS) && $globalphpVMS) |
|
538 | + || (isset($globalVAM) && $globalVAM) |
|
539 | + || !isset($timediff) |
|
540 | + || (isset($timediff) && $timediff > $globalLiveInterval) |
|
541 | + || $globalArchive |
|
542 | + || (isset($timediff) && $timediff > 30 |
|
543 | + && isset($this->all_flights[$id]['latitude']) |
|
544 | + && isset($this->all_flights[$id]['longitude']) |
|
545 | + && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
546 | + ) |
|
547 | + ) { |
|
548 | 548 | |
549 | 549 | if ((isset($timediff) && !isset($timediff_archive)) || (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude']))) { |
550 | - if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
|
550 | + if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
|
551 | 551 | || (isset($line['format_source']) && $line['format_source'] == 'airwhere') |
552 | 552 | || ((isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])&& !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude']))) { |
553 | 553 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -559,9 +559,9 @@ discard block |
||
559 | 559 | } |
560 | 560 | $this->tmd = 0; |
561 | 561 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
562 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
563 | - $timeelapsed = microtime(true); |
|
564 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
562 | + if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
563 | + $timeelapsed = microtime(true); |
|
564 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
565 | 565 | $Spotter = new Spotter($this->db); |
566 | 566 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
567 | 567 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
@@ -569,11 +569,11 @@ discard block |
||
569 | 569 | $Spotter->db = null; |
570 | 570 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
571 | 571 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
572 | - } |
|
572 | + } |
|
573 | 573 | } |
574 | 574 | $this->all_flights[$id]['time_last_archive_coord'] = time(); |
575 | - } |
|
576 | - /* |
|
575 | + } |
|
576 | + /* |
|
577 | 577 | else { |
578 | 578 | if (!isset($timediff)) echo 'NO TIMEDIFF'; |
579 | 579 | else { |
@@ -587,16 +587,16 @@ discard block |
||
587 | 587 | } |
588 | 588 | |
589 | 589 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
590 | - //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) { |
|
590 | + //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) { |
|
591 | 591 | if (!isset($this->all_flights[$id]['archive_latitude'])) { |
592 | 592 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
593 | 593 | $this->all_flights[$id]['time_last_coord'] = time(); |
594 | 594 | } |
595 | 595 | //if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
596 | 596 | if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
597 | - $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
598 | - $dataFound = true; |
|
599 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
597 | + $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
598 | + $dataFound = true; |
|
599 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
600 | 600 | } |
601 | 601 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
602 | 602 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
@@ -607,25 +607,25 @@ discard block |
||
607 | 607 | //$putinarchive = true; |
608 | 608 | } |
609 | 609 | */ |
610 | - /* |
|
610 | + /* |
|
611 | 611 | } elseif (isset($this->all_flights[$id]['latitude'])) { |
612 | 612 | 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"; |
613 | 613 | } |
614 | 614 | */ |
615 | 615 | } |
616 | 616 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
617 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
618 | - //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) { |
|
617 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
618 | + //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) { |
|
619 | 619 | if (!isset($this->all_flights[$id]['archive_longitude'])) { |
620 | 620 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
621 | 621 | $this->all_flights[$id]['time_last_coord'] = time(); |
622 | 622 | } |
623 | 623 | //if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
624 | 624 | if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
625 | - $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
626 | - $dataFound = true; |
|
627 | - $this->all_flights[$id]['coordinates'] += 1; |
|
628 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
625 | + $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
626 | + $dataFound = true; |
|
627 | + $this->all_flights[$id]['coordinates'] += 1; |
|
628 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
629 | 629 | } |
630 | 630 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
631 | 631 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
@@ -643,76 +643,76 @@ discard block |
||
643 | 643 | */ |
644 | 644 | } |
645 | 645 | if ($globalDaemon === TRUE && isset($updateinitial) && $updateinitial && $this->all_flights[$id]['addedSpotter'] == 1) { |
646 | - if ($globalDebug) echo "\n".'>>> Update initial data !'."\n"; |
|
647 | - unset($updateinitial); |
|
648 | - $SpotterArchive = new SpotterArchive(); |
|
649 | - $SpotterArchive->deleteSpotterArchiveTrackDataByID($this->all_flights[$id]['id']); |
|
650 | - $SpotterArchive->db = null; |
|
651 | - $Spotter = new Spotter(); |
|
652 | - $Spotter->updateInitialSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime']); |
|
653 | - $Spotter->db = null; |
|
646 | + if ($globalDebug) echo "\n".'>>> Update initial data !'."\n"; |
|
647 | + unset($updateinitial); |
|
648 | + $SpotterArchive = new SpotterArchive(); |
|
649 | + $SpotterArchive->deleteSpotterArchiveTrackDataByID($this->all_flights[$id]['id']); |
|
650 | + $SpotterArchive->db = null; |
|
651 | + $Spotter = new Spotter(); |
|
652 | + $Spotter->updateInitialSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime']); |
|
653 | + $Spotter->db = null; |
|
654 | 654 | } |
655 | - } else if ($globalDebug && $timediff > 30) { |
|
655 | + } else if ($globalDebug && $timediff > 30) { |
|
656 | 656 | $this->tmd = $this->tmd + 1; |
657 | 657 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
658 | 658 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
659 | 659 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
660 | 660 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
661 | - } |
|
661 | + } |
|
662 | 662 | } |
663 | 663 | if (isset($line['last_update']) && $line['last_update'] != '') { |
664 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
665 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
664 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
665 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
666 | 666 | } |
667 | 667 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
668 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
669 | - //$dataFound = true; |
|
668 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
669 | + //$dataFound = true; |
|
670 | 670 | } |
671 | 671 | if (isset($line['format_source']) && $line['format_source'] != '') { |
672 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
672 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
673 | 673 | } |
674 | 674 | if (isset($line['source_name']) && $line['source_name'] != '') { |
675 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
675 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
676 | 676 | } |
677 | 677 | if (isset($line['emergency']) && $line['emergency'] != '') { |
678 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
679 | - //$dataFound = true; |
|
678 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
679 | + //$dataFound = true; |
|
680 | 680 | } |
681 | 681 | if (isset($line['ground']) && $line['ground'] != '') { |
682 | - if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
682 | + if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
683 | 683 | // Here we force archive of flight because after ground it's a new one (or should be) |
684 | 684 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
685 | 685 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
686 | 686 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
687 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
687 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
688 | 688 | elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
689 | - } |
|
690 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
691 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
692 | - //$dataFound = true; |
|
689 | + } |
|
690 | + if ($line['ground'] != 1) $line['ground'] = 0; |
|
691 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
692 | + //$dataFound = true; |
|
693 | 693 | } |
694 | 694 | if (isset($line['squawk']) && $line['squawk'] != '') { |
695 | - if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
|
696 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
697 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
698 | - $highlight = ''; |
|
699 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
700 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
701 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
702 | - if ($highlight != '') { |
|
695 | + if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
|
696 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
697 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
698 | + $highlight = ''; |
|
699 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
700 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
701 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
702 | + if ($highlight != '') { |
|
703 | 703 | $timeelapsed = microtime(true); |
704 | 704 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
705 | - $Spotter = new Spotter($this->db); |
|
706 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
707 | - $Spotter->db = null; |
|
708 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
705 | + $Spotter = new Spotter($this->db); |
|
706 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
707 | + $Spotter->db = null; |
|
708 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
709 | 709 | } |
710 | 710 | //$putinarchive = true; |
711 | 711 | //$highlight = ''; |
712 | - } |
|
712 | + } |
|
713 | 713 | |
714 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
715 | - //$dataFound = true; |
|
714 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
715 | + //$dataFound = true; |
|
716 | 716 | } |
717 | 717 | |
718 | 718 | if (isset($line['altitude']) && $line['altitude'] != '') { |
@@ -723,13 +723,13 @@ discard block |
||
723 | 723 | $line['altitude'] = $line['altitude'] - $geoid; |
724 | 724 | } |
725 | 725 | } |
726 | - //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
726 | + //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
727 | 727 | if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
728 | 728 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
729 | 729 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
730 | 730 | //$dataFound = true; |
731 | - //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
732 | - if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
|
731 | + //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
732 | + if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
|
733 | 733 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
734 | 734 | if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
735 | 735 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
@@ -738,27 +738,27 @@ discard block |
||
738 | 738 | elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
739 | 739 | elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
740 | 740 | } |
741 | - } |
|
742 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
741 | + } |
|
742 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
743 | 743 | } |
744 | 744 | |
745 | 745 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
746 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
746 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
747 | 747 | } |
748 | 748 | |
749 | 749 | if (isset($line['heading']) && $line['heading'] != '') { |
750 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
751 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
752 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
753 | - //$dataFound = true; |
|
750 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
751 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
752 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
753 | + //$dataFound = true; |
|
754 | 754 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
755 | - $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
756 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
757 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
758 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
755 | + $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
756 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
757 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
758 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
759 | 759 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
760 | - // If not enough messages and ACARS set heading to 0 |
|
761 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
760 | + // If not enough messages and ACARS set heading to 0 |
|
761 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
762 | 762 | } |
763 | 763 | if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
764 | 764 | elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
@@ -771,133 +771,133 @@ discard block |
||
771 | 771 | //if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
772 | 772 | //if ($dataFound === true && isset($this->all_flights[$id]['hex'])) { |
773 | 773 | if ($dataFound === true && isset($this->all_flights[$id]['id'])) { |
774 | - $this->all_flights[$id]['lastupdate'] = time(); |
|
775 | - if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
776 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
777 | - //print_r($this->all_flights); |
|
778 | - //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
779 | - //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
780 | - if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
774 | + $this->all_flights[$id]['lastupdate'] = time(); |
|
775 | + if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
776 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
777 | + //print_r($this->all_flights); |
|
778 | + //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
779 | + //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
780 | + if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
781 | 781 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
782 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
783 | - $timeelapsed = microtime(true); |
|
784 | - $SpotterLive = new SpotterLive($this->db); |
|
785 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
782 | + if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
783 | + $timeelapsed = microtime(true); |
|
784 | + $SpotterLive = new SpotterLive($this->db); |
|
785 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
786 | 786 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
787 | 787 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
788 | - } elseif (isset($line['id'])) { |
|
788 | + } elseif (isset($line['id'])) { |
|
789 | 789 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
790 | 790 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
791 | - } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
791 | + } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
792 | 792 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
793 | 793 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
794 | - } else $recent_ident = ''; |
|
795 | - $SpotterLive->db=null; |
|
796 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
797 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
794 | + } else $recent_ident = ''; |
|
795 | + $SpotterLive->db=null; |
|
796 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
797 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
798 | 798 | } else $recent_ident = ''; |
799 | - } else { |
|
799 | + } else { |
|
800 | 800 | $recent_ident = ''; |
801 | 801 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
802 | - } |
|
803 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
804 | - if($recent_ident == "") |
|
805 | - { |
|
802 | + } |
|
803 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
804 | + if($recent_ident == "") |
|
805 | + { |
|
806 | 806 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
807 | 807 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
808 | 808 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
809 | 809 | //adds the spotter data for the archive |
810 | 810 | $ignoreImport = false; |
811 | 811 | foreach($globalAirportIgnore as $airportIgnore) { |
812 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
812 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
813 | 813 | $ignoreImport = true; |
814 | - } |
|
814 | + } |
|
815 | 815 | } |
816 | 816 | if (count($globalAirportAccept) > 0) { |
817 | - $ignoreImport = true; |
|
818 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
817 | + $ignoreImport = true; |
|
818 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
819 | 819 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
820 | - $ignoreImport = false; |
|
820 | + $ignoreImport = false; |
|
821 | + } |
|
821 | 822 | } |
822 | - } |
|
823 | 823 | } |
824 | 824 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
825 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
825 | + foreach($globalAirlineIgnore as $airlineIgnore) { |
|
826 | 826 | if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
827 | - $ignoreImport = true; |
|
827 | + $ignoreImport = true; |
|
828 | + } |
|
828 | 829 | } |
829 | - } |
|
830 | 830 | } |
831 | 831 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
832 | - $ignoreImport = true; |
|
833 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
832 | + $ignoreImport = true; |
|
833 | + foreach($globalAirlineAccept as $airlineAccept) { |
|
834 | 834 | if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
835 | - $ignoreImport = false; |
|
835 | + $ignoreImport = false; |
|
836 | + } |
|
836 | 837 | } |
837 | - } |
|
838 | 838 | } |
839 | 839 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
840 | - $ignoreImport = true; |
|
841 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
840 | + $ignoreImport = true; |
|
841 | + foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
842 | 842 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
843 | - $ignoreImport = false; |
|
843 | + $ignoreImport = false; |
|
844 | + } |
|
844 | 845 | } |
845 | - } |
|
846 | 846 | } |
847 | 847 | |
848 | 848 | if (!$ignoreImport) { |
849 | - $highlight = ''; |
|
850 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
851 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
852 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
853 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
854 | - $timeelapsed = microtime(true); |
|
855 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
849 | + $highlight = ''; |
|
850 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
851 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
852 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
853 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
854 | + $timeelapsed = microtime(true); |
|
855 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
856 | 856 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
857 | - $Spotter = new Spotter($this->db); |
|
858 | - $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
859 | - $Spotter->db = null; |
|
860 | - if ($globalDebug) { |
|
857 | + $Spotter = new Spotter($this->db); |
|
858 | + $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
859 | + $Spotter->db = null; |
|
860 | + if ($globalDebug) { |
|
861 | 861 | if (isset($result['error'])) echo 'Error: '.$result['error']."\n"; |
862 | 862 | else echo 'Success'; |
863 | - } |
|
864 | - if (count($result) > 1) { |
|
865 | - // ':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type, |
|
863 | + } |
|
864 | + if (count($result) > 1) { |
|
865 | + // ':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type, |
|
866 | 866 | if ($this->all_flights[$id]['aircraft_icao'] == '') $this->all_flights[$id]['aircraft_icao'] = $result[':aircraft_icao']; |
867 | 867 | if ($this->all_flights[$id]['registration'] == '') $this->all_flights[$id]['registration'] = $result[':registration']; |
868 | - } |
|
868 | + } |
|
869 | + } |
|
869 | 870 | } |
870 | - } |
|
871 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
872 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
871 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
872 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
873 | 873 | |
874 | - // Add source stat in DB |
|
875 | - $Stats = new Stats($this->db); |
|
876 | - if (!empty($this->stats)) { |
|
874 | + // Add source stat in DB |
|
875 | + $Stats = new Stats($this->db); |
|
876 | + if (!empty($this->stats)) { |
|
877 | 877 | if ($globalDebug) echo 'Add source stats : '; |
878 | - foreach($this->stats as $date => $data) { |
|
879 | - foreach($data as $source => $sourced) { |
|
880 | - //print_r($sourced); |
|
881 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
882 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
883 | - if (isset($sourced['msg'])) { |
|
884 | - if (time() - $sourced['msg']['date'] > 10) { |
|
885 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
886 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
887 | - unset($this->stats[$date][$source]['msg']); |
|
888 | - } |
|
889 | - } |
|
890 | - } |
|
891 | - if ($date != date('Y-m-d')) { |
|
892 | - unset($this->stats[$date]); |
|
893 | - } |
|
894 | - } |
|
895 | - if ($globalDebug) echo 'Done'."\n"; |
|
878 | + foreach($this->stats as $date => $data) { |
|
879 | + foreach($data as $source => $sourced) { |
|
880 | + //print_r($sourced); |
|
881 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
882 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
883 | + if (isset($sourced['msg'])) { |
|
884 | + if (time() - $sourced['msg']['date'] > 10) { |
|
885 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
886 | + echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
887 | + unset($this->stats[$date][$source]['msg']); |
|
888 | + } |
|
889 | + } |
|
890 | + } |
|
891 | + if ($date != date('Y-m-d')) { |
|
892 | + unset($this->stats[$date]); |
|
893 | + } |
|
894 | + } |
|
895 | + if ($globalDebug) echo 'Done'."\n"; |
|
896 | 896 | |
897 | - } |
|
898 | - $Stats->db = null; |
|
899 | - } |
|
900 | - $this->del(); |
|
897 | + } |
|
898 | + $Stats->db = null; |
|
899 | + } |
|
900 | + $this->del(); |
|
901 | 901 | } elseif ($globalDebug) echo 'Ignore data'."\n"; |
902 | 902 | //$ignoreImport = false; |
903 | 903 | $this->all_flights[$id]['addedSpotter'] = 1; |
@@ -915,41 +915,41 @@ discard block |
||
915 | 915 | */ |
916 | 916 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
917 | 917 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
918 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
919 | - //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
920 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
918 | + if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
919 | + //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
920 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
921 | 921 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
922 | - $SpotterLive = new SpotterLive($this->db); |
|
923 | - $SpotterLive->deleteLiveSpotterData(); |
|
924 | - $SpotterLive->db=null; |
|
922 | + $SpotterLive = new SpotterLive($this->db); |
|
923 | + $SpotterLive->deleteLiveSpotterData(); |
|
924 | + $SpotterLive->db=null; |
|
925 | + } |
|
925 | 926 | } |
926 | - } |
|
927 | - if ($globalDebug) echo " Done\n"; |
|
928 | - $this->last_delete = time(); |
|
927 | + if ($globalDebug) echo " Done\n"; |
|
928 | + $this->last_delete = time(); |
|
929 | 929 | } |
930 | - } else { |
|
930 | + } else { |
|
931 | 931 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
932 | - $this->all_flights[$id]['id'] = $recent_ident; |
|
933 | - $this->all_flights[$id]['addedSpotter'] = 1; |
|
932 | + $this->all_flights[$id]['id'] = $recent_ident; |
|
933 | + $this->all_flights[$id]['addedSpotter'] = 1; |
|
934 | 934 | } |
935 | 935 | if (isset($globalDaemon) && !$globalDaemon) { |
936 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
936 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
937 | 937 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
938 | - $Spotter = new Spotter($this->db); |
|
939 | - $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
940 | - $Spotter->db = null; |
|
938 | + $Spotter = new Spotter($this->db); |
|
939 | + $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
940 | + $Spotter->db = null; |
|
941 | + } |
|
941 | 942 | } |
942 | - } |
|
943 | 943 | } |
944 | 944 | |
945 | - } |
|
945 | + } |
|
946 | 946 | } |
947 | - } |
|
948 | - //adds the spotter LIVE data |
|
949 | - //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
950 | - //echo "\nAdd in Live !! \n"; |
|
951 | - //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"; |
|
952 | - if ($globalDebug) { |
|
947 | + } |
|
948 | + //adds the spotter LIVE data |
|
949 | + //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
950 | + //echo "\nAdd in Live !! \n"; |
|
951 | + //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"; |
|
952 | + if ($globalDebug) { |
|
953 | 953 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
954 | 954 | 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"; |
955 | 955 | 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"; |
@@ -957,61 +957,61 @@ discard block |
||
957 | 957 | 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"; |
958 | 958 | 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"; |
959 | 959 | } |
960 | - } |
|
961 | - $ignoreImport = false; |
|
962 | - if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
963 | - if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
960 | + } |
|
961 | + $ignoreImport = false; |
|
962 | + if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
963 | + if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
964 | 964 | |
965 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
966 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
967 | - $ignoreImport = true; |
|
965 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
966 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
967 | + $ignoreImport = true; |
|
968 | + } |
|
968 | 969 | } |
969 | - } |
|
970 | - if (count($globalAirportAccept) > 0) { |
|
971 | - $ignoreImport = true; |
|
972 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
973 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
970 | + if (count($globalAirportAccept) > 0) { |
|
971 | + $ignoreImport = true; |
|
972 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
973 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
974 | 974 | $ignoreImport = false; |
975 | - } |
|
975 | + } |
|
976 | 976 | } |
977 | - } |
|
978 | - if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
977 | + } |
|
978 | + if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
979 | 979 | foreach($globalAirlineIgnore as $airlineIgnore) { |
980 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
980 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
981 | 981 | $ignoreImport = true; |
982 | - } |
|
982 | + } |
|
983 | 983 | } |
984 | - } |
|
985 | - if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
984 | + } |
|
985 | + if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
986 | 986 | $ignoreImport = true; |
987 | 987 | foreach($globalAirlineAccept as $airlineAccept) { |
988 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
988 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
989 | 989 | $ignoreImport = false; |
990 | - } |
|
990 | + } |
|
991 | + } |
|
991 | 992 | } |
992 | - } |
|
993 | - if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
993 | + if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
994 | 994 | $ignoreImport = true; |
995 | 995 | foreach($globalPilotIdAccept as $pilotIdAccept) { |
996 | - if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
997 | - $ignoreImport = false; |
|
998 | - } |
|
996 | + if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
997 | + $ignoreImport = false; |
|
998 | + } |
|
999 | + } |
|
999 | 1000 | } |
1000 | - } |
|
1001 | 1001 | |
1002 | - if (!$ignoreImport) { |
|
1002 | + if (!$ignoreImport) { |
|
1003 | 1003 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
1004 | 1004 | if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
1005 | 1005 | $timeelapsed = microtime(true); |
1006 | 1006 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
1007 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
1007 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
1008 | 1008 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
1009 | 1009 | $SpotterLive = new SpotterLive($this->db); |
1010 | 1010 | //var_dump($this->all_flights[$id]); |
1011 | 1011 | $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
1012 | 1012 | $SpotterLive->db = null; |
1013 | 1013 | if ($globalDebug) echo $result."\n"; |
1014 | - } |
|
1014 | + } |
|
1015 | 1015 | } |
1016 | 1016 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
1017 | 1017 | $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
@@ -1023,7 +1023,7 @@ discard block |
||
1023 | 1023 | //if ($line['format_source'] != 'aprs') { |
1024 | 1024 | //if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) { |
1025 | 1025 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
1026 | - if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
|
1026 | + if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
|
1027 | 1027 | $source = $this->all_flights[$id]['source_name']; |
1028 | 1028 | if ($source == '') $source = $this->all_flights[$id]['format_source']; |
1029 | 1029 | if (!isset($this->source_location[$source])) { |
@@ -1049,7 +1049,7 @@ discard block |
||
1049 | 1049 | if ($stats_heading == 16) $stats_heading = 0; |
1050 | 1050 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
1051 | 1051 | for ($i=0;$i<=15;$i++) { |
1052 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
1052 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
1053 | 1053 | } |
1054 | 1054 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
1055 | 1055 | } else { |
@@ -1062,17 +1062,17 @@ discard block |
||
1062 | 1062 | //var_dump($this->stats); |
1063 | 1063 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
1064 | 1064 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
1065 | - end($this->stats[$current_date][$source]['hist']); |
|
1066 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
1065 | + end($this->stats[$current_date][$source]['hist']); |
|
1066 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
1067 | 1067 | } else $mini = 0; |
1068 | 1068 | for ($i=$mini;$i<=$distance;$i+=10) { |
1069 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
1069 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
1070 | 1070 | } |
1071 | 1071 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
1072 | 1072 | } else { |
1073 | 1073 | $this->stats[$current_date][$source]['hist'][$distance] += 1; |
1074 | 1074 | } |
1075 | - } |
|
1075 | + } |
|
1076 | 1076 | } |
1077 | 1077 | |
1078 | 1078 | $this->all_flights[$id]['lastupdate'] = time(); |
@@ -1082,7 +1082,7 @@ discard block |
||
1082 | 1082 | //$this->del(); |
1083 | 1083 | |
1084 | 1084 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
1085 | - if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
1085 | + if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
1086 | 1086 | if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
1087 | 1087 | $SpotterLive = new SpotterLive($this->db); |
1088 | 1088 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
@@ -1097,19 +1097,19 @@ discard block |
||
1097 | 1097 | if ($globalDebug) echo " Done\n"; |
1098 | 1098 | } |
1099 | 1099 | $this->last_delete_hourly = time(); |
1100 | - } else { |
|
1100 | + } else { |
|
1101 | 1101 | $this->del(); |
1102 | 1102 | $this->last_delete_hourly = time(); |
1103 | - } |
|
1103 | + } |
|
1104 | 1104 | } |
1105 | 1105 | |
1106 | - } |
|
1107 | - //$ignoreImport = false; |
|
1106 | + } |
|
1107 | + //$ignoreImport = false; |
|
1108 | 1108 | } |
1109 | 1109 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
1110 | 1110 | if ($send) return $this->all_flights[$id]; |
1111 | - } |
|
1111 | + } |
|
1112 | + } |
|
1112 | 1113 | } |
1113 | - } |
|
1114 | 1114 | } |
1115 | 1115 | ?> |
@@ -41,12 +41,12 @@ discard block |
||
41 | 41 | $currentdate = date('Y-m-d'); |
42 | 42 | $sourcestat = $Stats->getStatsSource($currentdate); |
43 | 43 | if (!empty($sourcestat)) { |
44 | - foreach($sourcestat as $srcst) { |
|
44 | + foreach ($sourcestat as $srcst) { |
|
45 | 45 | $type = $srcst['stats_type']; |
46 | 46 | if ($type == 'polar' || $type == 'hist') { |
47 | 47 | $source = $srcst['source_name']; |
48 | 48 | $data = $srcst['source_data']; |
49 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
49 | + $this->stats[$currentdate][$source][$type] = json_decode($data, true); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | } |
@@ -58,14 +58,14 @@ discard block |
||
58 | 58 | if (isset($globalGeoid) && $globalGeoid) { |
59 | 59 | try { |
60 | 60 | $GeoidClass = new GeoidHeight(); |
61 | - } catch(Exception $e) { |
|
61 | + } catch (Exception $e) { |
|
62 | 62 | if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n"; |
63 | 63 | $GeoidClass = FALSE; |
64 | 64 | } |
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
68 | - public function get_Schedule($id,$ident) { |
|
68 | + public function get_Schedule($id, $ident) { |
|
69 | 69 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
70 | 70 | // Get schedule here, so it's done only one time |
71 | 71 | |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | $schedule = $Schedule->fetchSchedule($operator); |
91 | 91 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
92 | 92 | if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
93 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
94 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
93 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime'])); |
|
94 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
95 | 95 | // Should also check if route schedule = route from DB |
96 | 96 | if ($schedule['DepartureAirportIATA'] != '') { |
97 | 97 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | } |
112 | 112 | } |
113 | 113 | } |
114 | - $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
114 | + $Schedule->addSchedule($operator, $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time'], $schedule['Source']); |
|
115 | 115 | } |
116 | 116 | } else $scheduleexist = true; |
117 | 117 | } else $scheduleexist = true; |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | if ($scheduleexist) { |
120 | 120 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
121 | 121 | $sch = $Schedule->getSchedule($operator); |
122 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
123 | - if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']); |
|
122 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport' => $sch['arrival_airport_icao'], 'departure_airport' => $sch['departure_airport_icao'], 'departure_airport_time' => $sch['departure_airport_time'], 'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
123 | + if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'], $sch['departure_airport_icao'], $sch['departure_airport_time'], $sch['arrival_airport_icao'], $sch['arrival_airport_time']); |
|
124 | 124 | } |
125 | 125 | $Spotter->db = null; |
126 | 126 | $Schedule->db = null; |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
148 | 148 | $Spotter = new Spotter($this->db); |
149 | 149 | $real_arrival = $this->arrival($key); |
150 | - if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
150 | + if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | $airport_time = ''; |
162 | 162 | if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
163 | 163 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
164 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
164 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist); |
|
165 | 165 | if (isset($closestAirports[0])) { |
166 | 166 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
167 | 167 | $airport_icao = $closestAirports[0]['icao']; |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | break; |
177 | 177 | } |
178 | 178 | } |
179 | - } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
179 | + } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) { |
|
180 | 180 | $airport_icao = $closestAirports[0]['icao']; |
181 | 181 | $airport_time = $this->all_flights[$key]['datetime']; |
182 | 182 | } else { |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | } else { |
190 | 190 | if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
191 | 191 | } |
192 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
192 | + return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | |
202 | 202 | foreach ($this->all_flights as $key => $flight) { |
203 | 203 | if (isset($flight['lastupdate'])) { |
204 | - if ($flight['lastupdate'] < (time()-1800)) { |
|
204 | + if ($flight['lastupdate'] < (time() - 1800)) { |
|
205 | 205 | $this->delKey($key); |
206 | 206 | } |
207 | 207 | } |
@@ -218,10 +218,10 @@ discard block |
||
218 | 218 | $Spotter = new Spotter($this->db); |
219 | 219 | $SpotterLive = new SpotterLive($this->db); |
220 | 220 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
221 | - $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
221 | + $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
222 | 222 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
223 | 223 | $this->all_flights[$key]['putinarchive'] = true; |
224 | - $result = $SpotterLive->addLiveSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['aircraft_icao'], $this->all_flights[$key]['departure_airport'], $this->all_flights[$key]['arrival_airport'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['waypoints'], $this->all_flights[$key]['altitude'],$this->all_flights[$key]['altitude_real'], $this->all_flights[$key]['heading'], $this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'], $this->all_flights[$key]['departure_airport_time'], $this->all_flights[$key]['arrival_airport_time'], $this->all_flights[$key]['squawk'],$this->all_flights[$key]['route_stop'],$this->all_flights[$key]['hex'],$this->all_flights[$key]['putinarchive'],$this->all_flights[$key]['registration'],$this->all_flights[$key]['pilot_id'],$this->all_flights[$key]['pilot_name'], $this->all_flights[$key]['verticalrate'], $this->all_flights[$key]['noarchive'], $this->all_flights[$key]['ground'],$this->all_flights[$key]['format_source'],$this->all_flights[$key]['source_name'],$this->all_flights[$key]['over_country']); |
|
224 | + $result = $SpotterLive->addLiveSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['aircraft_icao'], $this->all_flights[$key]['departure_airport'], $this->all_flights[$key]['arrival_airport'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['waypoints'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['altitude_real'], $this->all_flights[$key]['heading'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $this->all_flights[$key]['departure_airport_time'], $this->all_flights[$key]['arrival_airport_time'], $this->all_flights[$key]['squawk'], $this->all_flights[$key]['route_stop'], $this->all_flights[$key]['hex'], $this->all_flights[$key]['putinarchive'], $this->all_flights[$key]['registration'], $this->all_flights[$key]['pilot_id'], $this->all_flights[$key]['pilot_name'], $this->all_flights[$key]['verticalrate'], $this->all_flights[$key]['noarchive'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['format_source'], $this->all_flights[$key]['source_name'], $this->all_flights[$key]['over_country']); |
|
225 | 225 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
226 | 226 | } |
227 | 227 | $Spotter->db = null; |
@@ -257,10 +257,10 @@ discard block |
||
257 | 257 | $send = false; |
258 | 258 | |
259 | 259 | // SBS format is CSV format |
260 | - if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
260 | + if (is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
261 | 261 | //print_r($line); |
262 | 262 | if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
263 | - if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
263 | + if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'], 0, 1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
264 | 264 | |
265 | 265 | // Increment message number |
266 | 266 | if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
@@ -293,25 +293,25 @@ discard block |
||
293 | 293 | if (!isset($this->all_flights[$id])) { |
294 | 294 | if ($globalDebug) echo 'New flight...'."\n"; |
295 | 295 | $this->all_flights[$id] = array(); |
296 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
297 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '','coordinates' => 0)); |
|
298 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
296 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
297 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'altitude_previous' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => true, 'source_type' => '', 'coordinates' => 0)); |
|
298 | + if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time())); |
|
299 | 299 | if (!isset($line['id'])) { |
300 | 300 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
301 | 301 | // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
302 | 302 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
303 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
303 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
304 | 304 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
305 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
305 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
306 | 306 | if ($globalAllFlights !== FALSE) $dataFound = true; |
307 | 307 | } |
308 | 308 | if (isset($line['source_type']) && $line['source_type'] != '') { |
309 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
309 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type'])); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | //print_r($this->all_flights); |
313 | 313 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
314 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
314 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex']))); |
|
315 | 315 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
316 | 316 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
317 | 317 | //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
@@ -320,20 +320,20 @@ discard block |
||
320 | 320 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
321 | 321 | $Spotter = new Spotter($this->db); |
322 | 322 | if (isset($this->all_flights[$id]['source_type'])) { |
323 | - $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
|
323 | + $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']); |
|
324 | 324 | } else { |
325 | 325 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
326 | 326 | } |
327 | 327 | $Spotter->db = null; |
328 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
329 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
328 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
329 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
330 | 330 | } |
331 | 331 | } |
332 | 332 | if ($globalAllFlights !== FALSE) $dataFound = true; |
333 | 333 | if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
334 | 334 | } |
335 | 335 | if (isset($line['id']) && !isset($line['hex'])) { |
336 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
336 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => '')); |
|
337 | 337 | } |
338 | 338 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
339 | 339 | $icao = $line['aircraft_icao']; |
@@ -342,14 +342,14 @@ discard block |
||
342 | 342 | if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
343 | 343 | $Spotter->db = null; |
344 | 344 | } |
345 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao)); |
|
345 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $icao)); |
|
346 | 346 | } elseif (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) { |
347 | 347 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
348 | 348 | // Get aircraft ICAO from aircraft name |
349 | 349 | $Spotter = new Spotter($this->db); |
350 | 350 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
351 | 351 | $Spotter->db = null; |
352 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
352 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
353 | 353 | } |
354 | 354 | } |
355 | 355 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
@@ -357,15 +357,15 @@ discard block |
||
357 | 357 | elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
358 | 358 | elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
359 | 359 | elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
360 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
360 | + if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
361 | 361 | } |
362 | 362 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
363 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
363 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA')); |
|
364 | 364 | } |
365 | 365 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
366 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
|
366 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
367 | 367 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
368 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
|
368 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime'])); |
|
369 | 369 | } else { |
370 | 370 | if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
371 | 371 | elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
@@ -376,31 +376,31 @@ discard block |
||
376 | 376 | */ |
377 | 377 | return ''; |
378 | 378 | } |
379 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
|
379 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) { |
|
380 | 380 | if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
381 | 381 | return ''; |
382 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
|
382 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) { |
|
383 | 383 | if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
384 | 384 | return ''; |
385 | 385 | } elseif (!isset($line['datetime'])) { |
386 | 386 | date_default_timezone_set('UTC'); |
387 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
387 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
388 | 388 | } else { |
389 | 389 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
390 | 390 | return ''; |
391 | 391 | } |
392 | 392 | |
393 | 393 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG' && $line['registration'] != 'NA') { |
394 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
394 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration'])); |
|
395 | 395 | } |
396 | 396 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
397 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
397 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints'])); |
|
398 | 398 | } |
399 | 399 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
400 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
400 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => trim($line['pilot_id']))); |
|
401 | 401 | } |
402 | 402 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
403 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
403 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => trim($line['pilot_name']))); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | if (isset($line['ident']) && trim($line['ident']) != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
@@ -408,13 +408,13 @@ discard block |
||
408 | 408 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
409 | 409 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
410 | 410 | if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
411 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
412 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
413 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
414 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
415 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
411 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
412 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
413 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
414 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
415 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
416 | 416 | } else { |
417 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
417 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
418 | 418 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
419 | 419 | $timeelapsed = microtime(true); |
420 | 420 | $Spotter = new Spotter($this->db); |
@@ -424,13 +424,13 @@ discard block |
||
424 | 424 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
425 | 425 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
426 | 426 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
427 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource,$this->all_flights[$id]['source_type']); |
|
427 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource, $this->all_flights[$id]['source_type']); |
|
428 | 428 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
429 | 429 | $Spotter->db = null; |
430 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
430 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
431 | 431 | } |
432 | 432 | } |
433 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
433 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
434 | 434 | |
435 | 435 | /* |
436 | 436 | if (!isset($line['id'])) { |
@@ -440,25 +440,25 @@ discard block |
||
440 | 440 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
441 | 441 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
442 | 442 | */ |
443 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
443 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
444 | 444 | |
445 | 445 | //$putinarchive = true; |
446 | 446 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
447 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
|
447 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time'])); |
|
448 | 448 | } |
449 | 449 | if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
450 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
450 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
451 | 451 | } |
452 | 452 | if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
453 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
453 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => '')); |
|
454 | 454 | } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
455 | 455 | $timeelapsed = microtime(true); |
456 | 456 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
457 | 457 | $Spotter = new Spotter($this->db); |
458 | 458 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
459 | 459 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
460 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
461 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
460 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => '')); |
|
461 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
462 | 462 | } |
463 | 463 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
464 | 464 | $timeelapsed = microtime(true); |
@@ -472,35 +472,35 @@ discard block |
||
472 | 472 | $Translation->db = null; |
473 | 473 | } |
474 | 474 | $Spotter->db = null; |
475 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
475 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
476 | 476 | } |
477 | 477 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
478 | 478 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
479 | 479 | if ($route['fromairport_icao'] != $route['toairport_icao']) { |
480 | 480 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop'])); |
481 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
481 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $route['fromairport_icao'], 'arrival_airport' => $route['toairport_icao'], 'route_stop' => $route['routestop'])); |
|
482 | 482 | } |
483 | 483 | } |
484 | 484 | if (!isset($globalFork)) $globalFork = TRUE; |
485 | 485 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
486 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
486 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident'])); |
|
487 | 487 | } |
488 | 488 | } |
489 | 489 | } |
490 | 490 | |
491 | 491 | if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) { |
492 | 492 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
493 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
494 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
493 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed']))); |
|
494 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true)); |
|
495 | 495 | //$dataFound = true; |
496 | 496 | } else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
497 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
497 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'); |
|
498 | 498 | if ($distance > 1000 && $distance < 10000) { |
499 | 499 | // use datetime |
500 | 500 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
501 | 501 | $speed = $speed*3.6; |
502 | 502 | if ($speed < 1000) { |
503 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
503 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed))); |
|
504 | 504 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
505 | 505 | } else { |
506 | 506 | if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
@@ -515,9 +515,9 @@ discard block |
||
515 | 515 | if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
516 | 516 | return false; |
517 | 517 | } |
518 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
518 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']); |
|
519 | 519 | else unset($timediff); |
520 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
520 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time() - $this->all_flights[$id]['time_last_archive_coord']); |
|
521 | 521 | else unset($timediff_archive); |
522 | 522 | if ($this->tmd > 5 |
523 | 523 | || (isset($line['format_source']) |
@@ -542,14 +542,14 @@ discard block |
||
542 | 542 | || (isset($timediff) && $timediff > 30 |
543 | 543 | && isset($this->all_flights[$id]['latitude']) |
544 | 544 | && isset($this->all_flights[$id]['longitude']) |
545 | - && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
545 | + && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')) |
|
546 | 546 | ) |
547 | 547 | ) { |
548 | 548 | |
549 | 549 | if ((isset($timediff) && !isset($timediff_archive)) || (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude']))) { |
550 | 550 | if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
551 | 551 | || (isset($line['format_source']) && $line['format_source'] == 'airwhere') |
552 | - || ((isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])&& !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude']))) { |
|
552 | + || ((isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude']) && !$Common->checkLine($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'], $line['latitude'], $line['longitude']))) { |
|
553 | 553 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
554 | 554 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
555 | 555 | $this->all_flights[$id]['putinarchive'] = true; |
@@ -563,11 +563,11 @@ discard block |
||
563 | 563 | $timeelapsed = microtime(true); |
564 | 564 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
565 | 565 | $Spotter = new Spotter($this->db); |
566 | - $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
566 | + $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
567 | 567 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
568 | 568 | else $this->all_flights[$id]['over_country'] = ''; |
569 | 569 | $Spotter->db = null; |
570 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
570 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
571 | 571 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
572 | 572 | } |
573 | 573 | } |
@@ -593,13 +593,13 @@ discard block |
||
593 | 593 | $this->all_flights[$id]['time_last_coord'] = time(); |
594 | 594 | } |
595 | 595 | //if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
596 | - if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
|
596 | + if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > 0.0001)) { |
|
597 | 597 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
598 | 598 | $dataFound = true; |
599 | 599 | $this->all_flights[$id]['time_last_coord'] = time(); |
600 | 600 | } |
601 | 601 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
602 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
|
602 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude'])); |
|
603 | 603 | /* |
604 | 604 | if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) { |
605 | 605 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -621,14 +621,14 @@ discard block |
||
621 | 621 | $this->all_flights[$id]['time_last_coord'] = time(); |
622 | 622 | } |
623 | 623 | //if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
624 | - if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
|
624 | + if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > 0.0001)) { |
|
625 | 625 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
626 | 626 | $dataFound = true; |
627 | 627 | $this->all_flights[$id]['coordinates'] += 1; |
628 | 628 | $this->all_flights[$id]['time_last_coord'] = time(); |
629 | 629 | } |
630 | 630 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
631 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
|
631 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude'])); |
|
632 | 632 | /* |
633 | 633 | if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) { |
634 | 634 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -649,52 +649,52 @@ discard block |
||
649 | 649 | $SpotterArchive->deleteSpotterArchiveTrackDataByID($this->all_flights[$id]['id']); |
650 | 650 | $SpotterArchive->db = null; |
651 | 651 | $Spotter = new Spotter(); |
652 | - $Spotter->updateInitialSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime']); |
|
652 | + $Spotter->updateInitialSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime']); |
|
653 | 653 | $Spotter->db = null; |
654 | 654 | } |
655 | 655 | } else if ($globalDebug && $timediff > 30) { |
656 | 656 | $this->tmd = $this->tmd + 1; |
657 | 657 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
658 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
|
659 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
658 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -"; |
|
659 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
660 | 660 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
661 | 661 | } |
662 | 662 | } |
663 | 663 | if (isset($line['last_update']) && $line['last_update'] != '') { |
664 | 664 | if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
665 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
665 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update'])); |
|
666 | 666 | } |
667 | 667 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
668 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
668 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate'])); |
|
669 | 669 | //$dataFound = true; |
670 | 670 | } |
671 | 671 | if (isset($line['format_source']) && $line['format_source'] != '') { |
672 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
672 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source'])); |
|
673 | 673 | } |
674 | 674 | if (isset($line['source_name']) && $line['source_name'] != '') { |
675 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
675 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name'])); |
|
676 | 676 | } |
677 | 677 | if (isset($line['emergency']) && $line['emergency'] != '') { |
678 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
678 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency'])); |
|
679 | 679 | //$dataFound = true; |
680 | 680 | } |
681 | 681 | if (isset($line['ground']) && $line['ground'] != '') { |
682 | 682 | if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
683 | 683 | // Here we force archive of flight because after ground it's a new one (or should be) |
684 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
685 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
686 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
687 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
688 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
684 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
685 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
686 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
687 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
688 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
689 | 689 | } |
690 | 690 | if ($line['ground'] != 1) $line['ground'] = 0; |
691 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
691 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground'])); |
|
692 | 692 | //$dataFound = true; |
693 | 693 | } |
694 | 694 | if (isset($line['squawk']) && $line['squawk'] != '') { |
695 | 695 | if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
696 | 696 | if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
697 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
697 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
698 | 698 | $highlight = ''; |
699 | 699 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
700 | 700 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
@@ -703,66 +703,66 @@ discard block |
||
703 | 703 | $timeelapsed = microtime(true); |
704 | 704 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
705 | 705 | $Spotter = new Spotter($this->db); |
706 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
706 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight); |
|
707 | 707 | $Spotter->db = null; |
708 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
708 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
709 | 709 | } |
710 | 710 | //$putinarchive = true; |
711 | 711 | //$highlight = ''; |
712 | 712 | } |
713 | 713 | |
714 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
714 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
715 | 715 | //$dataFound = true; |
716 | 716 | } |
717 | 717 | |
718 | 718 | if (isset($line['altitude']) && $line['altitude'] != '') { |
719 | 719 | if (isset($line['altitude_relative']) && isset($GeoidClass) && is_object($GeoidClass)) { |
720 | 720 | if ($line['altitude_relative'] == 'AMSL' || $line['altitude_relative'] == 'MSL') { |
721 | - $geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'])*3.28084,2); |
|
721 | + $geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'])*3.28084, 2); |
|
722 | 722 | //if ($globalDebug) echo '=> Set altitude to WGS84 Ellipsoid, add '.$geoid.' to '.$line['altitude']."\n"; |
723 | 723 | $line['altitude'] = $line['altitude'] - $geoid; |
724 | 724 | } |
725 | 725 | } |
726 | 726 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
727 | - if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
728 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
|
729 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
|
727 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
728 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100))); |
|
729 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude'])); |
|
730 | 730 | //$dataFound = true; |
731 | 731 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
732 | 732 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
733 | 733 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
734 | 734 | if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
735 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
736 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
737 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
738 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
739 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
735 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
736 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
737 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
738 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
739 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
740 | 740 | } |
741 | 741 | } |
742 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
742 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_previous' => $line['altitude'])); |
|
743 | 743 | } |
744 | 744 | |
745 | 745 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
746 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
746 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true)); |
|
747 | 747 | } |
748 | 748 | |
749 | 749 | if (isset($line['heading']) && $line['heading'] != '') { |
750 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
751 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
752 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
750 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
751 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading']))); |
|
752 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true)); |
|
753 | 753 | //$dataFound = true; |
754 | 754 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
755 | - $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
756 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
757 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
755 | + $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
756 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading))); |
|
757 | + if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
758 | 758 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
759 | 759 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
760 | 760 | // If not enough messages and ACARS set heading to 0 |
761 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
761 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0)); |
|
762 | 762 | } |
763 | - if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
764 | - elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
765 | - elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinUpdate) $dataFound = false; |
|
763 | + if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
764 | + elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
765 | + elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalAircraftMinUpdate) $dataFound = false; |
|
766 | 766 | |
767 | 767 | // print_r($this->all_flights[$id]); |
768 | 768 | //gets the callsign from the last hour |
@@ -773,7 +773,7 @@ discard block |
||
773 | 773 | if ($dataFound === true && isset($this->all_flights[$id]['id'])) { |
774 | 774 | $this->all_flights[$id]['lastupdate'] = time(); |
775 | 775 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
776 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
776 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
777 | 777 | //print_r($this->all_flights); |
778 | 778 | //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
779 | 779 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
@@ -784,61 +784,61 @@ discard block |
||
784 | 784 | $SpotterLive = new SpotterLive($this->db); |
785 | 785 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
786 | 786 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
787 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
787 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
788 | 788 | } elseif (isset($line['id'])) { |
789 | 789 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
790 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
790 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
791 | 791 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
792 | 792 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
793 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
793 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
794 | 794 | } else $recent_ident = ''; |
795 | - $SpotterLive->db=null; |
|
795 | + $SpotterLive->db = null; |
|
796 | 796 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
797 | 797 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
798 | 798 | } else $recent_ident = ''; |
799 | 799 | } else { |
800 | 800 | $recent_ident = ''; |
801 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
|
801 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0)); |
|
802 | 802 | } |
803 | 803 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
804 | - if($recent_ident == "") |
|
804 | + if ($recent_ident == "") |
|
805 | 805 | { |
806 | 806 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
807 | 807 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
808 | 808 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
809 | 809 | //adds the spotter data for the archive |
810 | 810 | $ignoreImport = false; |
811 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
811 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
812 | 812 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
813 | 813 | $ignoreImport = true; |
814 | 814 | } |
815 | 815 | } |
816 | 816 | if (count($globalAirportAccept) > 0) { |
817 | 817 | $ignoreImport = true; |
818 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
818 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
819 | 819 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
820 | 820 | $ignoreImport = false; |
821 | 821 | } |
822 | 822 | } |
823 | 823 | } |
824 | 824 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
825 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
826 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
825 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
826 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
827 | 827 | $ignoreImport = true; |
828 | 828 | } |
829 | 829 | } |
830 | 830 | } |
831 | 831 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
832 | 832 | $ignoreImport = true; |
833 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
834 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
833 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
834 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
835 | 835 | $ignoreImport = false; |
836 | 836 | } |
837 | 837 | } |
838 | 838 | } |
839 | 839 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
840 | 840 | $ignoreImport = true; |
841 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
841 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
842 | 842 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
843 | 843 | $ignoreImport = false; |
844 | 844 | } |
@@ -850,12 +850,12 @@ discard block |
||
850 | 850 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
851 | 851 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
852 | 852 | if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
853 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
853 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
854 | 854 | $timeelapsed = microtime(true); |
855 | 855 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
856 | 856 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
857 | 857 | $Spotter = new Spotter($this->db); |
858 | - $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
858 | + $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $highlight, $this->all_flights[$id]['hex'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['source_type']); |
|
859 | 859 | $Spotter->db = null; |
860 | 860 | if ($globalDebug) { |
861 | 861 | if (isset($result['error'])) echo 'Error: '.$result['error']."\n"; |
@@ -868,22 +868,22 @@ discard block |
||
868 | 868 | } |
869 | 869 | } |
870 | 870 | } |
871 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
871 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
872 | 872 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
873 | 873 | |
874 | 874 | // Add source stat in DB |
875 | 875 | $Stats = new Stats($this->db); |
876 | 876 | if (!empty($this->stats)) { |
877 | 877 | if ($globalDebug) echo 'Add source stats : '; |
878 | - foreach($this->stats as $date => $data) { |
|
879 | - foreach($data as $source => $sourced) { |
|
878 | + foreach ($this->stats as $date => $data) { |
|
879 | + foreach ($data as $source => $sourced) { |
|
880 | 880 | //print_r($sourced); |
881 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
882 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
881 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date); |
|
882 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date); |
|
883 | 883 | if (isset($sourced['msg'])) { |
884 | 884 | if (time() - $sourced['msg']['date'] > 10) { |
885 | 885 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
886 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
886 | + echo $Stats->addStatSource($nbmsg, $source, 'msg', $date); |
|
887 | 887 | unset($this->stats[$date][$source]['msg']); |
888 | 888 | } |
889 | 889 | } |
@@ -921,14 +921,14 @@ discard block |
||
921 | 921 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
922 | 922 | $SpotterLive = new SpotterLive($this->db); |
923 | 923 | $SpotterLive->deleteLiveSpotterData(); |
924 | - $SpotterLive->db=null; |
|
924 | + $SpotterLive->db = null; |
|
925 | 925 | } |
926 | 926 | } |
927 | 927 | if ($globalDebug) echo " Done\n"; |
928 | 928 | $this->last_delete = time(); |
929 | 929 | } |
930 | 930 | } else { |
931 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
|
931 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
|
932 | 932 | $this->all_flights[$id]['id'] = $recent_ident; |
933 | 933 | $this->all_flights[$id]['addedSpotter'] = 1; |
934 | 934 | } |
@@ -936,7 +936,7 @@ discard block |
||
936 | 936 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
937 | 937 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
938 | 938 | $Spotter = new Spotter($this->db); |
939 | - $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
939 | + $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']); |
|
940 | 940 | $Spotter->db = null; |
941 | 941 | } |
942 | 942 | } |
@@ -962,37 +962,37 @@ discard block |
||
962 | 962 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
963 | 963 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
964 | 964 | |
965 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
965 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
966 | 966 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
967 | 967 | $ignoreImport = true; |
968 | 968 | } |
969 | 969 | } |
970 | 970 | if (count($globalAirportAccept) > 0) { |
971 | 971 | $ignoreImport = true; |
972 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
972 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
973 | 973 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
974 | 974 | $ignoreImport = false; |
975 | 975 | } |
976 | 976 | } |
977 | 977 | } |
978 | 978 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
979 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
980 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
979 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
980 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
981 | 981 | $ignoreImport = true; |
982 | 982 | } |
983 | 983 | } |
984 | 984 | } |
985 | 985 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
986 | 986 | $ignoreImport = true; |
987 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
988 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
987 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
988 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
989 | 989 | $ignoreImport = false; |
990 | 990 | } |
991 | 991 | } |
992 | 992 | } |
993 | 993 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
994 | 994 | $ignoreImport = true; |
995 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
995 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
996 | 996 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
997 | 997 | $ignoreImport = false; |
998 | 998 | } |
@@ -1000,24 +1000,24 @@ discard block |
||
1000 | 1000 | } |
1001 | 1001 | |
1002 | 1002 | if (!$ignoreImport) { |
1003 | - if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
1004 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
1003 | + if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
1004 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
1005 | 1005 | $timeelapsed = microtime(true); |
1006 | 1006 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
1007 | 1007 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
1008 | 1008 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
1009 | 1009 | $SpotterLive = new SpotterLive($this->db); |
1010 | 1010 | //var_dump($this->all_flights[$id]); |
1011 | - $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
|
1011 | + $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']); |
|
1012 | 1012 | $SpotterLive->db = null; |
1013 | 1013 | if ($globalDebug) echo $result."\n"; |
1014 | 1014 | } |
1015 | 1015 | } |
1016 | 1016 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
1017 | - $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
|
1017 | + $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']); |
|
1018 | 1018 | } |
1019 | 1019 | $this->all_flights[$id]['putinarchive'] = false; |
1020 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1020 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
1021 | 1021 | |
1022 | 1022 | // Put statistics in $this->stats variable |
1023 | 1023 | //if ($line['format_source'] != 'aprs') { |
@@ -1036,19 +1036,19 @@ discard block |
||
1036 | 1036 | $latitude = $globalCenterLatitude; |
1037 | 1037 | $longitude = $globalCenterLongitude; |
1038 | 1038 | } |
1039 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
1039 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
1040 | 1040 | } else { |
1041 | 1041 | $latitude = $this->source_location[$source]['latitude']; |
1042 | 1042 | $longitude = $this->source_location[$source]['longitude']; |
1043 | 1043 | } |
1044 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
1044 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
1045 | 1045 | //$stats_heading = $stats_heading%22.5; |
1046 | 1046 | $stats_heading = round($stats_heading/22.5); |
1047 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
1047 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
1048 | 1048 | $current_date = date('Y-m-d'); |
1049 | 1049 | if ($stats_heading == 16) $stats_heading = 0; |
1050 | 1050 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
1051 | - for ($i=0;$i<=15;$i++) { |
|
1051 | + for ($i = 0; $i <= 15; $i++) { |
|
1052 | 1052 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
1053 | 1053 | } |
1054 | 1054 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -1063,9 +1063,9 @@ discard block |
||
1063 | 1063 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
1064 | 1064 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
1065 | 1065 | end($this->stats[$current_date][$source]['hist']); |
1066 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
1066 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
1067 | 1067 | } else $mini = 0; |
1068 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
1068 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
1069 | 1069 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
1070 | 1070 | } |
1071 | 1071 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -1078,7 +1078,7 @@ discard block |
||
1078 | 1078 | $this->all_flights[$id]['lastupdate'] = time(); |
1079 | 1079 | if ($this->all_flights[$id]['putinarchive']) $send = true; |
1080 | 1080 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
1081 | - } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1081 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
1082 | 1082 | //$this->del(); |
1083 | 1083 | |
1084 | 1084 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
@@ -22,7 +22,9 @@ discard block |
||
22 | 22 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
23 | 23 | } |
24 | 24 | |
25 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
25 | +if (!isset($globalDebug)) { |
|
26 | + $globalDebug = FALSE; |
|
27 | +} |
|
26 | 28 | |
27 | 29 | if ($globalInstalled === FALSE) { |
28 | 30 | echo "This script MUST be run after install script. Use your web browser to run install/index.php"; |
@@ -68,66 +70,107 @@ discard block |
||
68 | 70 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
69 | 71 | if (isset($options['s'])) { |
70 | 72 | $globalSources = array(); |
71 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
72 | - else $globalSources[] = array('host' => $options['s']); |
|
73 | -} elseif (isset($options['source'])) { |
|
73 | + if (isset($options['format'])) { |
|
74 | + $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
75 | + } else { |
|
76 | + $globalSources[] = array('host' => $options['s']); |
|
77 | + } |
|
78 | + } elseif (isset($options['source'])) { |
|
74 | 79 | $globalSources = array(); |
75 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
76 | - else $globalSources[] = array('host' => $options['source']); |
|
77 | -} |
|
80 | + if (isset($options['format'])) { |
|
81 | + $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
82 | + } else { |
|
83 | + $globalSources[] = array('host' => $options['source']); |
|
84 | + } |
|
85 | + } |
|
78 | 86 | if (isset($options['aprsserverhost'])) { |
79 | 87 | $globalServerAPRS = TRUE; |
80 | 88 | $globalServerAPRShost = $options['aprsserverhost']; |
81 | 89 | } |
82 | -if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport']; |
|
83 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
|
84 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
|
85 | -if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; |
|
90 | +if (isset($options['aprsserverport'])) { |
|
91 | + $globalServerAPRSport = $options['aprsserverport']; |
|
92 | +} |
|
93 | +if (isset($options['aprsserverssid'])) { |
|
94 | + $globalServerAPRSssid = $options['aprsserverssid']; |
|
95 | +} |
|
96 | +if (isset($options['aprsserverpass'])) { |
|
97 | + $globalServerAPRSpass = $options['aprsserverpass']; |
|
98 | +} |
|
99 | +if (isset($options['noaprsserver'])) { |
|
100 | + $globalServerAPRS = FALSE; |
|
101 | +} |
|
86 | 102 | if (isset($options['enable-aircraft'])) { |
87 | - if ($globalDebug) echo 'Enable Aircraft mode'."\n"; |
|
103 | + if ($globalDebug) { |
|
104 | + echo 'Enable Aircraft mode'."\n"; |
|
105 | + } |
|
88 | 106 | $globalAircraft = TRUE; |
89 | 107 | } |
90 | 108 | if (isset($options['disable-aircraft'])) { |
91 | - if ($globalDebug) echo 'Disable Aircraft mode'."\n"; |
|
109 | + if ($globalDebug) { |
|
110 | + echo 'Disable Aircraft mode'."\n"; |
|
111 | + } |
|
92 | 112 | $globalAircraft = FALSE; |
93 | 113 | } |
94 | 114 | if (isset($options['enable-tracker'])) { |
95 | - if ($globalDebug) echo 'Enable Tracker mode'."\n"; |
|
115 | + if ($globalDebug) { |
|
116 | + echo 'Enable Tracker mode'."\n"; |
|
117 | + } |
|
96 | 118 | $globalTracker = TRUE; |
97 | 119 | } |
98 | 120 | if (isset($options['disable-tracker'])) { |
99 | - if ($globalDebug) echo 'Disable Tracker mode'."\n"; |
|
121 | + if ($globalDebug) { |
|
122 | + echo 'Disable Tracker mode'."\n"; |
|
123 | + } |
|
100 | 124 | $globalTracker = FALSE; |
101 | 125 | } |
102 | 126 | if (isset($options['enable-marine'])) { |
103 | - if ($globalDebug) echo 'Enable Marine mode'."\n"; |
|
127 | + if ($globalDebug) { |
|
128 | + echo 'Enable Marine mode'."\n"; |
|
129 | + } |
|
104 | 130 | $globalMarine = TRUE; |
105 | 131 | } |
106 | 132 | if (isset($options['disable-marine'])) { |
107 | - if ($globalDebug) echo 'Disable Marine mode'."\n"; |
|
133 | + if ($globalDebug) { |
|
134 | + echo 'Disable Marine mode'."\n"; |
|
135 | + } |
|
108 | 136 | $globalMarine = FALSE; |
109 | 137 | } |
110 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; |
|
111 | -if (isset($options['server'])) $globalServer = TRUE; |
|
112 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
113 | -else $id_source = 1; |
|
138 | +if (isset($options['nodaemon'])) { |
|
139 | + $globalDaemon = FALSE; |
|
140 | +} |
|
141 | +if (isset($options['server'])) { |
|
142 | + $globalServer = TRUE; |
|
143 | +} |
|
144 | +if (isset($options['idsource'])) { |
|
145 | + $id_source = $options['idsource']; |
|
146 | +} else { |
|
147 | + $id_source = 1; |
|
148 | +} |
|
114 | 149 | if (isset($globalServer) && $globalServer) { |
115 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
150 | + if ($globalDebug) { |
|
151 | + echo "Using Server Mode\n"; |
|
152 | + } |
|
116 | 153 | $SI=new SpotterServer(); |
117 | 154 | /* |
118 | 155 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
119 | 156 | $SI = new adsb2aprs(); |
120 | 157 | $SI->connect(); |
121 | 158 | */ |
122 | -} else $SI=new SpotterImport($Connection->db); |
|
159 | +} else { |
|
160 | + $SI=new SpotterImport($Connection->db); |
|
161 | +} |
|
123 | 162 | |
124 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
163 | +if (isset($globalTracker) && $globalTracker) { |
|
164 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
165 | +} |
|
125 | 166 | if (isset($globalMarine) && $globalMarine) { |
126 | 167 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
127 | 168 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
128 | 169 | } |
129 | 170 | |
130 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
171 | +if (isset($globalTracker) && $globalTracker) { |
|
172 | + $TI = new TrackerImport($Connection->db); |
|
173 | +} |
|
131 | 174 | if (isset($globalMarine) && $globalMarine) { |
132 | 175 | $AIS = new AIS(); |
133 | 176 | $MI = new MarineImport($Connection->db); |
@@ -152,7 +195,9 @@ discard block |
||
152 | 195 | } |
153 | 196 | |
154 | 197 | // let's try and connect |
155 | -if ($globalDebug) echo "Connecting...\n"; |
|
198 | +if ($globalDebug) { |
|
199 | + echo "Connecting...\n"; |
|
200 | +} |
|
156 | 201 | $use_aprs = false; |
157 | 202 | $aprs_full = false; |
158 | 203 | $reset = 0; |
@@ -161,7 +206,9 @@ discard block |
||
161 | 206 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
162 | 207 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
163 | 208 | $reset++; |
164 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
209 | + if ($globalDebug) { |
|
210 | + echo 'Connect to all...'."\n"; |
|
211 | + } |
|
165 | 212 | foreach ($hosts as $id => $value) { |
166 | 213 | $host = $value['host']; |
167 | 214 | $udp = false; |
@@ -172,32 +219,44 @@ discard block |
||
172 | 219 | //$formats[$id] = 'deltadbtxt'; |
173 | 220 | $globalSources[$id]['format'] = 'deltadbtxt'; |
174 | 221 | //$last_exec['deltadbtxt'] = 0; |
175 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
222 | + if ($globalDebug) { |
|
223 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
224 | + } |
|
176 | 225 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
177 | 226 | //$formats[$id] = 'vatsimtxt'; |
178 | 227 | $globalSources[$id]['format'] = 'vatsimtxt'; |
179 | 228 | //$last_exec['vatsimtxt'] = 0; |
180 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
229 | + if ($globalDebug) { |
|
230 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
231 | + } |
|
181 | 232 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
182 | 233 | //$formats[$id] = 'aircraftlistjson'; |
183 | 234 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
184 | 235 | //$last_exec['aircraftlistjson'] = 0; |
185 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
236 | + if ($globalDebug) { |
|
237 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
238 | + } |
|
186 | 239 | } else if (preg_match('/aircraft.json$/i',$host)) { |
187 | 240 | //$formats[$id] = 'aircraftjson'; |
188 | 241 | $globalSources[$id]['format'] = 'aircraftjson'; |
189 | 242 | //$last_exec['aircraftlistjson'] = 0; |
190 | - if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; |
|
243 | + if ($globalDebug) { |
|
244 | + echo "Connect to aircraft.json source (".$host.")...\n"; |
|
245 | + } |
|
191 | 246 | } else if (preg_match('/aircraft$/i',$host)) { |
192 | 247 | //$formats[$id] = 'planefinderclient'; |
193 | 248 | $globalSources[$id]['format'] = 'planefinderclient'; |
194 | 249 | //$last_exec['aircraftlistjson'] = 0; |
195 | - if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; |
|
250 | + if ($globalDebug) { |
|
251 | + echo "Connect to planefinderclient source (".$host.")...\n"; |
|
252 | + } |
|
196 | 253 | } else if (preg_match('/opensky/i',$host)) { |
197 | 254 | //$formats[$id] = 'aircraftlistjson'; |
198 | 255 | $globalSources[$id]['format'] = 'opensky'; |
199 | 256 | //$last_exec['aircraftlistjson'] = 0; |
200 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
257 | + if ($globalDebug) { |
|
258 | + echo "Connect to opensky source (".$host.")...\n"; |
|
259 | + } |
|
201 | 260 | /* |
202 | 261 | // Disabled for now, site change source format |
203 | 262 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
@@ -214,7 +273,9 @@ discard block |
||
214 | 273 | //$formats[$id] = 'planeupdatefaa'; |
215 | 274 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
216 | 275 | //$last_exec['planeupdatefaa'] = 0; |
217 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
276 | + if ($globalDebug) { |
|
277 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
278 | + } |
|
218 | 279 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
219 | 280 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
220 | 281 | exit(0); |
@@ -223,37 +284,53 @@ discard block |
||
223 | 284 | //$formats[$id] = 'phpvmacars'; |
224 | 285 | $globalSources[$id]['format'] = 'phpvmacars'; |
225 | 286 | //$last_exec['phpvmacars'] = 0; |
226 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
287 | + if ($globalDebug) { |
|
288 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
289 | + } |
|
227 | 290 | } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
228 | 291 | //$formats[$id] = 'phpvmacars'; |
229 | 292 | $globalSources[$id]['format'] = 'vaos'; |
230 | 293 | //$last_exec['phpvmacars'] = 0; |
231 | - if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
294 | + if ($globalDebug) { |
|
295 | + echo "Connect to vaos source (".$host.")...\n"; |
|
296 | + } |
|
232 | 297 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
233 | 298 | //$formats[$id] = 'phpvmacars'; |
234 | 299 | $globalSources[$id]['format'] = 'vam'; |
235 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
300 | + if ($globalDebug) { |
|
301 | + echo "Connect to Vam source (".$host.")...\n"; |
|
302 | + } |
|
236 | 303 | } else if (preg_match('/whazzup/i',$host)) { |
237 | 304 | //$formats[$id] = 'whazzup'; |
238 | 305 | $globalSources[$id]['format'] = 'whazzup'; |
239 | 306 | //$last_exec['whazzup'] = 0; |
240 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
307 | + if ($globalDebug) { |
|
308 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
309 | + } |
|
241 | 310 | } else if (preg_match('/blitzortung/i',$host)) { |
242 | 311 | $globalSources[$id]['format'] = 'blitzortung'; |
243 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
312 | + if ($globalDebug) { |
|
313 | + echo "Connect to blitzortung source (".$host.")...\n"; |
|
314 | + } |
|
244 | 315 | } else if (preg_match('/airwhere/i',$host)) { |
245 | 316 | $globalSources[$id]['format'] = 'airwhere'; |
246 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
317 | + if ($globalDebug) { |
|
318 | + echo "Connect to airwhere source (".$host.")...\n"; |
|
319 | + } |
|
247 | 320 | } else if (preg_match('/recentpireps/i',$host)) { |
248 | 321 | //$formats[$id] = 'pirepsjson'; |
249 | 322 | $globalSources[$id]['format'] = 'pirepsjson'; |
250 | 323 | //$last_exec['pirepsjson'] = 0; |
251 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
324 | + if ($globalDebug) { |
|
325 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
326 | + } |
|
252 | 327 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
253 | 328 | //$formats[$id] = 'fr24json'; |
254 | 329 | $globalSources[$id]['format'] = 'fr24json'; |
255 | 330 | //$last_exec['fr24json'] = 0; |
256 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
331 | + if ($globalDebug) { |
|
332 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
333 | + } |
|
257 | 334 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
258 | 335 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
259 | 336 | exit(0); |
@@ -262,7 +339,9 @@ discard block |
||
262 | 339 | //$formats[$id] = 'fr24json'; |
263 | 340 | $globalSources[$id]['format'] = 'myshiptracking'; |
264 | 341 | //$last_exec['fr24json'] = 0; |
265 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
342 | + if ($globalDebug) { |
|
343 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
344 | + } |
|
266 | 345 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
267 | 346 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
268 | 347 | exit(0); |
@@ -271,18 +350,28 @@ discard block |
||
271 | 350 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
272 | 351 | //$formats[$id] = 'tsv'; |
273 | 352 | $globalSources[$id]['format'] = 'tsv'; |
274 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
353 | + if ($globalDebug) { |
|
354 | + echo "Connect to tsv source (".$host.")...\n"; |
|
355 | + } |
|
275 | 356 | } |
276 | 357 | } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) { |
277 | 358 | if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') { |
278 | 359 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
279 | 360 | if ($idf !== false) { |
280 | 361 | $httpfeeds[$id] = $idf; |
281 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
282 | - } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
283 | - } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
284 | - elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') echo "Connect to ".$globalSources[$id]['format']." source (sailawayfull)...\n"; |
|
285 | - elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
362 | + if ($globalDebug) { |
|
363 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
364 | + } |
|
365 | + } elseif ($globalDebug) { |
|
366 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
367 | + } |
|
368 | + } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') { |
|
369 | + echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
370 | + } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') { |
|
371 | + echo "Connect to ".$globalSources[$id]['format']." source (sailawayfull)...\n"; |
|
372 | + } elseif ($globalDebug) { |
|
373 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
374 | + } |
|
286 | 375 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
287 | 376 | $hostport = explode(':',$host); |
288 | 377 | if (isset($hostport[1])) { |
@@ -323,20 +412,29 @@ discard block |
||
323 | 412 | //$formats[$id] = 'beast'; |
324 | 413 | $globalSources[$id]['format'] = 'beast'; |
325 | 414 | //} else $formats[$id] = 'sbs'; |
326 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
415 | + } else { |
|
416 | + $globalSources[$id]['format'] = 'sbs'; |
|
417 | + } |
|
327 | 418 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
328 | 419 | } |
329 | - if ($globalDebug && $udp) echo 'Listening in UDP from '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
330 | - elseif ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
420 | + if ($globalDebug && $udp) { |
|
421 | + echo 'Listening in UDP from '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
422 | + } elseif ($globalDebug) { |
|
423 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
424 | + } |
|
331 | 425 | } else { |
332 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
426 | + if ($globalDebug) { |
|
427 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
428 | + } |
|
333 | 429 | sleep(10); |
334 | 430 | connect_all($hosts); |
335 | 431 | } |
336 | 432 | } |
337 | 433 | } |
338 | 434 | } |
339 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
435 | +if (!isset($globalMinFetch)) { |
|
436 | + $globalMinFetch = 15; |
|
437 | +} |
|
340 | 438 | |
341 | 439 | // Initialize all |
342 | 440 | $status = array(); |
@@ -345,13 +443,19 @@ discard block |
||
345 | 443 | $formats = array(); |
346 | 444 | $last_exec = array(); |
347 | 445 | $time = time(); |
348 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
349 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
350 | -else $timeout = 20; |
|
446 | +if (isset($globalSourcesTimeout)) { |
|
447 | + $timeout = $globalSourcesTimeOut; |
|
448 | +} else if (isset($globalSBS1TimeOut)) { |
|
449 | + $timeout = $globalSBS1TimeOut; |
|
450 | +} else { |
|
451 | + $timeout = 20; |
|
452 | +} |
|
351 | 453 | $errno = ''; |
352 | 454 | $errstr=''; |
353 | 455 | |
354 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
456 | +if (!isset($globalDaemon)) { |
|
457 | + $globalDaemon = TRUE; |
|
458 | +} |
|
355 | 459 | /* Initiate connections to all the hosts simultaneously */ |
356 | 460 | //connect_all($hosts); |
357 | 461 | //connect_all($globalSources); |
@@ -380,7 +484,9 @@ discard block |
||
380 | 484 | if (isset($source['format']) && $source['format'] == 'aprs') { |
381 | 485 | $aprs_connect = 0; |
382 | 486 | $use_aprs = true; |
383 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
487 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
488 | + $aprs_full = true; |
|
489 | + } |
|
384 | 490 | break; |
385 | 491 | } |
386 | 492 | } |
@@ -391,25 +497,46 @@ discard block |
||
391 | 497 | $aprs_connect = 0; |
392 | 498 | $aprs_keep = 120; |
393 | 499 | $aprs_last_tx = time(); |
394 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
395 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
396 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
397 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
398 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
399 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
400 | - if ($aprs_full) $aprs_filter = ''; |
|
401 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
402 | - else $aprs_pass = '-1'; |
|
500 | + if (isset($globalAPRSversion)) { |
|
501 | + $aprs_version = $globalAPRSversion; |
|
502 | + } else { |
|
503 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
504 | + } |
|
505 | + if (isset($globalAPRSssid)) { |
|
506 | + $aprs_ssid = $globalAPRSssid; |
|
507 | + } else { |
|
508 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
509 | + } |
|
510 | + if (isset($globalAPRSfilter)) { |
|
511 | + $aprs_filter = $globalAPRSfilter; |
|
512 | + } else { |
|
513 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
514 | + } |
|
515 | + if ($aprs_full) { |
|
516 | + $aprs_filter = ''; |
|
517 | + } |
|
518 | + if (isset($globalAPRSpass)) { |
|
519 | + $aprs_pass = $globalAPRSpass; |
|
520 | + } else { |
|
521 | + $aprs_pass = '-1'; |
|
522 | + } |
|
403 | 523 | |
404 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
405 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
406 | -} |
|
524 | + if ($aprs_filter != '') { |
|
525 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
526 | + } else { |
|
527 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
528 | + } |
|
529 | + } |
|
407 | 530 | |
408 | 531 | // connected - lets do some work |
409 | 532 | //if ($globalDebug) echo "Connected!\n"; |
410 | 533 | sleep(1); |
411 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
412 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
534 | +if ($globalDebug) { |
|
535 | + echo "SCAN MODE \n\n"; |
|
536 | +} |
|
537 | +if (!isset($globalCronEnd)) { |
|
538 | + $globalCronEnd = 60; |
|
539 | +} |
|
413 | 540 | $endtime = time()+$globalCronEnd; |
414 | 541 | $i = 1; |
415 | 542 | $tt = array(); |
@@ -423,22 +550,32 @@ discard block |
||
423 | 550 | |
424 | 551 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
425 | 552 | while ($i > 0) { |
426 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
553 | + if (function_exists('pcntl_fork')) { |
|
554 | + pcntl_signal_dispatch(); |
|
555 | + } |
|
427 | 556 | |
428 | - if (!$globalDaemon) $i = $endtime-time(); |
|
557 | + if (!$globalDaemon) { |
|
558 | + $i = $endtime-time(); |
|
559 | + } |
|
429 | 560 | // Delete old ATC |
430 | 561 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
431 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
562 | + if ($globalDebug) { |
|
563 | + echo 'Delete old ATC...'."\n"; |
|
564 | + } |
|
432 | 565 | $ATC->deleteOldATC(); |
433 | 566 | } |
434 | 567 | |
435 | 568 | if (count($last_exec) == count($globalSources)) { |
436 | 569 | $max = $globalMinFetch; |
437 | 570 | foreach ($last_exec as $last) { |
438 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
571 | + if ((time() - $last['last']) < $max) { |
|
572 | + $max = time() - $last['last']; |
|
573 | + } |
|
439 | 574 | } |
440 | 575 | if ($max < $globalMinFetch) { |
441 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
576 | + if ($globalDebug) { |
|
577 | + echo 'Sleeping...'."\n"; |
|
578 | + } |
|
442 | 579 | sleep($globalMinFetch-$max+2); |
443 | 580 | } |
444 | 581 | } |
@@ -448,7 +585,9 @@ discard block |
||
448 | 585 | foreach ($globalSources as $id => $value) { |
449 | 586 | date_default_timezone_set('UTC'); |
450 | 587 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
451 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
588 | + if (!isset($last_exec[$id]['last'])) { |
|
589 | + $last_exec[$id]['last'] = 0; |
|
590 | + } |
|
452 | 591 | if ($value['format'] === 'deltadbtxt' && |
453 | 592 | ( |
454 | 593 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
@@ -457,7 +596,9 @@ discard block |
||
457 | 596 | ) { |
458 | 597 | //$buffer = $Common->getData($hosts[$id]); |
459 | 598 | $buffer = $Common->getData($value['host']); |
460 | - if ($buffer != '') $reset = 0; |
|
599 | + if ($buffer != '') { |
|
600 | + $reset = 0; |
|
601 | + } |
|
461 | 602 | $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
462 | 603 | $buffer = explode('\n', $buffer); |
463 | 604 | foreach ($buffer as $line) { |
@@ -466,20 +607,41 @@ discard block |
||
466 | 607 | $data = array(); |
467 | 608 | $data['hex'] = $line[1]; // hex |
468 | 609 | $data['ident'] = $line[2]; // ident |
469 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
470 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
471 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
472 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
473 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
610 | + if (isset($line[3])) { |
|
611 | + $data['altitude'] = $line[3]; |
|
612 | + } |
|
613 | + // altitude |
|
614 | + if (isset($line[4])) { |
|
615 | + $data['speed'] = $line[4]; |
|
616 | + } |
|
617 | + // speed |
|
618 | + if (isset($line[5])) { |
|
619 | + $data['heading'] = $line[5]; |
|
620 | + } |
|
621 | + // heading |
|
622 | + if (isset($line[6])) { |
|
623 | + $data['latitude'] = $line[6]; |
|
624 | + } |
|
625 | + // lat |
|
626 | + if (isset($line[7])) { |
|
627 | + $data['longitude'] = $line[7]; |
|
628 | + } |
|
629 | + // long |
|
474 | 630 | $data['verticalrate'] = ''; // vertical rate |
475 | 631 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
476 | 632 | $data['emergency'] = ''; // emergency |
477 | 633 | $data['datetime'] = date('Y-m-d H:i:s'); |
478 | 634 | $data['format_source'] = 'deltadbtxt'; |
479 | 635 | $data['id_source'] = $id_source; |
480 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
481 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
482 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
636 | + if (isset($value['name']) && $value['name'] != '') { |
|
637 | + $data['source_name'] = $value['name']; |
|
638 | + } |
|
639 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
640 | + $data['noarchive'] = true; |
|
641 | + } |
|
642 | + if (isset($value['sourcestats'])) { |
|
643 | + $data['sourcestats'] = $value['sourcestats']; |
|
644 | + } |
|
483 | 645 | $SI->add($data); |
484 | 646 | unset($data); |
485 | 647 | } |
@@ -514,11 +676,20 @@ discard block |
||
514 | 676 | $data['format_source'] = 'radarcapejson'; |
515 | 677 | $data['id_source'] = $id_source; |
516 | 678 | if (isset($value['name']) && $value['name'] != '') { |
517 | - if (isset($line['src']) && !$line['src'] == 'M') $data['source_name'] = $value['name'].'_MLAT'; |
|
518 | - else $data['source_name'] = $value['name']; |
|
519 | - } elseif (isset($line['src']) && $line['src'] == 'M') $data['source_name'] = 'MLAT'; |
|
520 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
521 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
679 | + if (isset($line['src']) && !$line['src'] == 'M') { |
|
680 | + $data['source_name'] = $value['name'].'_MLAT'; |
|
681 | + } else { |
|
682 | + $data['source_name'] = $value['name']; |
|
683 | + } |
|
684 | + } elseif (isset($line['src']) && $line['src'] == 'M') { |
|
685 | + $data['source_name'] = 'MLAT'; |
|
686 | + } |
|
687 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
688 | + $data['noarchive'] = true; |
|
689 | + } |
|
690 | + if (isset($value['sourcestats'])) { |
|
691 | + $data['sourcestats'] = $value['sourcestats']; |
|
692 | + } |
|
522 | 693 | |
523 | 694 | $SI->add($data); |
524 | 695 | unset($data); |
@@ -534,7 +705,9 @@ discard block |
||
534 | 705 | date_default_timezone_set('CET'); |
535 | 706 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
536 | 707 | date_default_timezone_set('UTC'); |
537 | - if ($buffer != '') $reset = 0; |
|
708 | + if ($buffer != '') { |
|
709 | + $reset = 0; |
|
710 | + } |
|
538 | 711 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
539 | 712 | $buffer = explode('\n',$buffer); |
540 | 713 | foreach ($buffer as $line) { |
@@ -543,18 +716,42 @@ discard block |
||
543 | 716 | $add = false; |
544 | 717 | $ais_data = $AIS->parse_line(trim($line)); |
545 | 718 | $data = array(); |
546 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
547 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
548 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
549 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
550 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
551 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
552 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
553 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
554 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
555 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
556 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
557 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
719 | + if (isset($ais_data['ident'])) { |
|
720 | + $data['ident'] = $ais_data['ident']; |
|
721 | + } |
|
722 | + if (isset($ais_data['mmsi'])) { |
|
723 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
724 | + } |
|
725 | + if (isset($ais_data['speed'])) { |
|
726 | + $data['speed'] = $ais_data['speed']; |
|
727 | + } |
|
728 | + if (isset($ais_data['heading'])) { |
|
729 | + $data['heading'] = $ais_data['heading']; |
|
730 | + } |
|
731 | + if (isset($ais_data['latitude'])) { |
|
732 | + $data['latitude'] = $ais_data['latitude']; |
|
733 | + } |
|
734 | + if (isset($ais_data['longitude'])) { |
|
735 | + $data['longitude'] = $ais_data['longitude']; |
|
736 | + } |
|
737 | + if (isset($ais_data['status'])) { |
|
738 | + $data['status'] = $ais_data['status']; |
|
739 | + } |
|
740 | + if (isset($ais_data['statusid'])) { |
|
741 | + $data['status_id'] = $ais_data['statusid']; |
|
742 | + } |
|
743 | + if (isset($ais_data['type'])) { |
|
744 | + $data['type'] = $ais_data['type']; |
|
745 | + } |
|
746 | + if (isset($ais_data['typeid'])) { |
|
747 | + $data['type_id'] = $ais_data['typeid']; |
|
748 | + } |
|
749 | + if (isset($ais_data['imo'])) { |
|
750 | + $data['imo'] = $ais_data['imo']; |
|
751 | + } |
|
752 | + if (isset($ais_data['callsign'])) { |
|
753 | + $data['callsign'] = $ais_data['callsign']; |
|
754 | + } |
|
558 | 755 | if (isset($ais_data['timestamp'])) { |
559 | 756 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
560 | 757 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -568,8 +765,12 @@ discard block |
||
568 | 765 | $data['format_source'] = 'aisnmeatxt'; |
569 | 766 | $data['id_source'] = $id_source; |
570 | 767 | //print_r($data); |
571 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
572 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
768 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
769 | + $data['noarchive'] = true; |
|
770 | + } |
|
771 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
772 | + $MI->add($data); |
|
773 | + } |
|
573 | 774 | unset($data); |
574 | 775 | } |
575 | 776 | } |
@@ -592,20 +793,48 @@ discard block |
||
592 | 793 | if ($line != '') { |
593 | 794 | $ais_data = $AIS->parse_line(trim($line)); |
594 | 795 | $data = array(); |
595 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
596 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
597 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
598 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
599 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
600 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
601 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
602 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
603 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
604 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
605 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
606 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
607 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
608 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
796 | + if (isset($ais_data['ident'])) { |
|
797 | + $data['ident'] = $ais_data['ident']; |
|
798 | + } |
|
799 | + if (isset($ais_data['mmsi'])) { |
|
800 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
801 | + } |
|
802 | + if (isset($ais_data['speed'])) { |
|
803 | + $data['speed'] = $ais_data['speed']; |
|
804 | + } |
|
805 | + if (isset($ais_data['heading'])) { |
|
806 | + $data['heading'] = $ais_data['heading']; |
|
807 | + } |
|
808 | + if (isset($ais_data['latitude'])) { |
|
809 | + $data['latitude'] = $ais_data['latitude']; |
|
810 | + } |
|
811 | + if (isset($ais_data['longitude'])) { |
|
812 | + $data['longitude'] = $ais_data['longitude']; |
|
813 | + } |
|
814 | + if (isset($ais_data['status'])) { |
|
815 | + $data['status'] = $ais_data['status']; |
|
816 | + } |
|
817 | + if (isset($ais_data['statusid'])) { |
|
818 | + $data['status_id'] = $ais_data['statusid']; |
|
819 | + } |
|
820 | + if (isset($ais_data['type'])) { |
|
821 | + $data['type'] = $ais_data['type']; |
|
822 | + } |
|
823 | + if (isset($ais_data['typeid'])) { |
|
824 | + $data['type_id'] = $ais_data['typeid']; |
|
825 | + } |
|
826 | + if (isset($ais_data['imo'])) { |
|
827 | + $data['imo'] = $ais_data['imo']; |
|
828 | + } |
|
829 | + if (isset($ais_data['callsign'])) { |
|
830 | + $data['callsign'] = $ais_data['callsign']; |
|
831 | + } |
|
832 | + if (isset($ais_data['destination'])) { |
|
833 | + $data['arrival_code'] = $ais_data['destination']; |
|
834 | + } |
|
835 | + if (isset($ais_data['eta_ts'])) { |
|
836 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
837 | + } |
|
609 | 838 | if (isset($ais_data['timestamp'])) { |
610 | 839 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
611 | 840 | } else { |
@@ -613,18 +842,27 @@ discard block |
||
613 | 842 | } |
614 | 843 | $data['format_source'] = 'aisnmeahttp'; |
615 | 844 | $data['id_source'] = $id_source; |
616 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
617 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
845 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
846 | + $data['noarchive'] = true; |
|
847 | + } |
|
848 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
849 | + $MI->add($data); |
|
850 | + } |
|
618 | 851 | unset($data); |
619 | 852 | } |
620 | 853 | } |
621 | 854 | } |
622 | 855 | } else { |
623 | 856 | $format = $value['format']; |
624 | - if (isset($tt[$format])) $tt[$format]++; |
|
625 | - else $tt[$format] = 0; |
|
857 | + if (isset($tt[$format])) { |
|
858 | + $tt[$format]++; |
|
859 | + } else { |
|
860 | + $tt[$format] = 0; |
|
861 | + } |
|
626 | 862 | if ($tt[$format] > 30) { |
627 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
863 | + if ($globalDebug) { |
|
864 | + echo 'Reconnect...'."\n"; |
|
865 | + } |
|
628 | 866 | sleep(2); |
629 | 867 | //$sourceeen[] = $value; |
630 | 868 | //connect_all($sourceeen); |
@@ -660,12 +898,18 @@ discard block |
||
660 | 898 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
661 | 899 | //$data['type_id'] = $line['TYPE']; |
662 | 900 | $data['imo'] = $line['IMO']; |
663 | - if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
664 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
901 | + if ($line['DEST'] != '') { |
|
902 | + $data['arrival_code'] = $line['DEST']; |
|
903 | + } |
|
904 | + if ($line['ARV'] != '') { |
|
905 | + $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
906 | + } |
|
665 | 907 | $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
666 | 908 | $data['format_source'] = 'myshiptracking'; |
667 | 909 | $data['id_source'] = $id_source; |
668 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
910 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
911 | + $data['noarchive'] = true; |
|
912 | + } |
|
669 | 913 | $MI->add($data); |
670 | 914 | unset($data); |
671 | 915 | } |
@@ -690,7 +934,9 @@ discard block |
||
690 | 934 | $data['callsign'] = $line['callsign']; |
691 | 935 | $data['mmsi'] = substr($line['mmsi'],-9); |
692 | 936 | $data['speed'] = $line['sog']; |
693 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
937 | + if ($line['heading'] != '511') { |
|
938 | + $data['heading'] = $line['heading']; |
|
939 | + } |
|
694 | 940 | $data['latitude'] = $line['latitude']; |
695 | 941 | $data['longitude'] = $line['longitude']; |
696 | 942 | $data['type_id'] = $line['shiptype']; |
@@ -698,7 +944,9 @@ discard block |
||
698 | 944 | $data['datetime'] = $line['time']; |
699 | 945 | $data['format_source'] = 'boatbeaconapp'; |
700 | 946 | $data['id_source'] = $id_source; |
701 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
947 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
948 | + $data['noarchive'] = true; |
|
949 | + } |
|
702 | 950 | $MI->add($data); |
703 | 951 | unset($data); |
704 | 952 | } |
@@ -720,22 +968,44 @@ discard block |
||
720 | 968 | foreach ($all_data['features'] as $line) { |
721 | 969 | print_r($line); |
722 | 970 | $data = array(); |
723 | - if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
|
724 | - if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
|
725 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
726 | - if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo']; |
|
727 | - if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
|
728 | - if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading']; |
|
971 | + if (isset($line['properties']['name'])) { |
|
972 | + $data['ident'] = $line['properties']['name']; |
|
973 | + } |
|
974 | + if (isset($line['properties']['callsign'])) { |
|
975 | + $data['callsign'] = $line['properties']['callsign']; |
|
976 | + } |
|
977 | + if (isset($line['properties']['mmsi'])) { |
|
978 | + $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
979 | + } |
|
980 | + if (isset($line['properties']['imo'])) { |
|
981 | + $data['imo'] = $line['properties']['imo']; |
|
982 | + } |
|
983 | + if (isset($line['properties']['speed'])) { |
|
984 | + $data['speed'] = $line['properties']['speed']; |
|
985 | + } |
|
986 | + if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) { |
|
987 | + $data['heading'] = $line['properties']['heading']; |
|
988 | + } |
|
729 | 989 | $data['latitude'] = $line['geometry']['coordinates'][1]; |
730 | 990 | $data['longitude'] = $line['geometry']['coordinates'][0]; |
731 | - if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType']; |
|
732 | - if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination']; |
|
733 | - if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta']; |
|
991 | + if (isset($line['properties']['vesselType'])) { |
|
992 | + $data['type'] = $line['properties']['vesselType']; |
|
993 | + } |
|
994 | + if (isset($line['properties']['destination'])) { |
|
995 | + $data['arrival_code'] = $line['properties']['destination']; |
|
996 | + } |
|
997 | + if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') { |
|
998 | + $data['arrival_date'] = $line['properties']['eta']; |
|
999 | + } |
|
734 | 1000 | $data['format_source'] = 'boatnerd'; |
735 | 1001 | $data['id_source'] = $id_source; |
736 | 1002 | $data['datetime'] = date('Y-m-d H:i:s'); |
737 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
738 | - if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
|
1003 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1004 | + $data['noarchive'] = true; |
|
1005 | + } |
|
1006 | + if ($line['properties']['vesselType'] != 'Navigation Aid') { |
|
1007 | + $MI->add($data); |
|
1008 | + } |
|
739 | 1009 | unset($data); |
740 | 1010 | } |
741 | 1011 | } |
@@ -748,11 +1018,17 @@ discard block |
||
748 | 1018 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
749 | 1019 | ) |
750 | 1020 | ) { |
751 | - if ($globalDebug) echo 'download...'; |
|
1021 | + if ($globalDebug) { |
|
1022 | + echo 'download...'; |
|
1023 | + } |
|
752 | 1024 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
753 | - if ($globalDebug) echo 'done !'."\n"; |
|
1025 | + if ($globalDebug) { |
|
1026 | + echo 'done !'."\n"; |
|
1027 | + } |
|
754 | 1028 | // FIXME: Need more work |
755 | - if ($buffer != '') $reset = 0; |
|
1029 | + if ($buffer != '') { |
|
1030 | + $reset = 0; |
|
1031 | + } |
|
756 | 1032 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
757 | 1033 | $buffer = explode('\n',$buffer); |
758 | 1034 | foreach ($buffer as $line) { |
@@ -778,7 +1054,9 @@ discard block |
||
778 | 1054 | //$data['etaTime'] = substr($line,135,5); |
779 | 1055 | $data['format_source'] = 'shipplotter'; |
780 | 1056 | $data['id_source'] = $id_source; |
781 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1057 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1058 | + $data['noarchive'] = true; |
|
1059 | + } |
|
782 | 1060 | //print_r($data); |
783 | 1061 | //echo 'Add...'."\n"; |
784 | 1062 | $MI->add($data); |
@@ -796,13 +1074,21 @@ discard block |
||
796 | 1074 | exit(0); |
797 | 1075 | } |
798 | 1076 | $sailawayoption = array('key' => $globalSailaway['key']); |
799 | - if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr'])); |
|
800 | - if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr'])); |
|
1077 | + if (isset($globalSailaway['usrnr'])) { |
|
1078 | + $sailawayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr'])); |
|
1079 | + } |
|
1080 | + if (isset($globalSailaway['ubtnr'])) { |
|
1081 | + $sailawayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr'])); |
|
1082 | + } |
|
801 | 1083 | |
802 | 1084 | for ($i = 0; $i <= 1; $i++) { |
803 | - if ($globalDebug) echo '! Download... '; |
|
1085 | + if ($globalDebug) { |
|
1086 | + echo '! Download... '; |
|
1087 | + } |
|
804 | 1088 | $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?'.http_build_query($sailawayoption).'&race='.$i.'&tutorial=0&hist=1&racetype=2&challengetype=2','get','','','','',30); |
805 | - if ($globalDebug) echo 'done'."\n"; |
|
1089 | + if ($globalDebug) { |
|
1090 | + echo 'done'."\n"; |
|
1091 | + } |
|
806 | 1092 | if ($buffer != '') { |
807 | 1093 | $all_data = json_decode($buffer,true); |
808 | 1094 | if (isset($all_data['missions'])) { |
@@ -817,8 +1103,11 @@ discard block |
||
817 | 1103 | //$datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['usrname']))); |
818 | 1104 | $datar['creator'] = ''; |
819 | 1105 | $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle']))); |
820 | - if (isset($mission['misstart'])) $datar['startdate'] = date('Y-m-d H:i:s',strtotime($mission['misstart'])); |
|
821 | - else $datar['startdate'] = '1970-01-01 00:00:00'; |
|
1106 | + if (isset($mission['misstart'])) { |
|
1107 | + $datar['startdate'] = date('Y-m-d H:i:s',strtotime($mission['misstart'])); |
|
1108 | + } else { |
|
1109 | + $datar['startdate'] = '1970-01-01 00:00:00'; |
|
1110 | + } |
|
822 | 1111 | /* |
823 | 1112 | $markers = array(); |
824 | 1113 | foreach ($race_data['mission']['course'] as $course) { |
@@ -834,7 +1123,9 @@ discard block |
||
834 | 1123 | } |
835 | 1124 | } |
836 | 1125 | } |
837 | - if ($globalDebug) echo '=== Wait... ==='; |
|
1126 | + if ($globalDebug) { |
|
1127 | + echo '=== Wait... ==='; |
|
1128 | + } |
|
838 | 1129 | sleep(10*60); |
839 | 1130 | } |
840 | 1131 | $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption),'get','','','','',30); |
@@ -846,7 +1137,9 @@ discard block |
||
846 | 1137 | $data = array(); |
847 | 1138 | $data['id'] = $sail['ubtnr']; |
848 | 1139 | $data['datetime'] = date('Y-m-d H:i:s'); |
849 | - if ($sail['online'] == '1') $data['last_update'] = date('Y-m-d H:i:s'); |
|
1140 | + if ($sail['online'] == '1') { |
|
1141 | + $data['last_update'] = date('Y-m-d H:i:s'); |
|
1142 | + } |
|
850 | 1143 | $data['latitude'] = $sail['ubtlat']; |
851 | 1144 | $data['longitude'] = $sail['ubtlon']; |
852 | 1145 | $data['type_id'] = 36; |
@@ -855,16 +1148,24 @@ discard block |
||
855 | 1148 | $data['captain_name'] = $sail['usrname']; |
856 | 1149 | $allboats = array('Sailaway Cruiser 38','Mini Transat','Caribbean Rose','52' Cruising Cat','50' Performance Cruiser','Nordic Folkboat','32' Offshore Racer'); |
857 | 1150 | $boattype = $sail['ubtbtpnr']; |
858 | - if (isset($allboats[$boattype-1])) $data['type'] = $allboats[$boattype-1]; |
|
1151 | + if (isset($allboats[$boattype-1])) { |
|
1152 | + $data['type'] = $allboats[$boattype-1]; |
|
1153 | + } |
|
859 | 1154 | $data['speed'] = round($sail['ubtspeed']*3.6,2); |
860 | 1155 | $data['format_source'] = 'sailaway'; |
861 | 1156 | $data['id_source'] = $id_source; |
862 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1157 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1158 | + $data['noarchive'] = true; |
|
1159 | + } |
|
863 | 1160 | $MI->add($data); |
864 | 1161 | unset($data); |
865 | 1162 | } |
866 | - } elseif ($globalDebug) echo 'Error in JSON parsing'; |
|
867 | - } elseif ($globalDebug) echo 'Empty result !'."\n"; |
|
1163 | + } elseif ($globalDebug) { |
|
1164 | + echo 'Error in JSON parsing'; |
|
1165 | + } |
|
1166 | + } elseif ($globalDebug) { |
|
1167 | + echo 'Empty result !'."\n"; |
|
1168 | + } |
|
868 | 1169 | |
869 | 1170 | $last_exec[$id]['last'] = time(); |
870 | 1171 | } elseif ($value['format'] === 'sailaway' && |
@@ -887,10 +1188,16 @@ discard block |
||
887 | 1188 | echo 'Sailaway API key MUST be defined'; |
888 | 1189 | exit(0); |
889 | 1190 | } |
890 | - if ($globalDebug) echo '! Download... '; |
|
1191 | + if ($globalDebug) { |
|
1192 | + echo '! Download... '; |
|
1193 | + } |
|
891 | 1194 | $sailawayoption = array('key' => $globalSailaway['key']); |
892 | - if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr'])); |
|
893 | - if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr'])); |
|
1195 | + if (isset($globalSailaway['usrnr'])) { |
|
1196 | + $sailawayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr'])); |
|
1197 | + } |
|
1198 | + if (isset($globalSailaway['ubtnr'])) { |
|
1199 | + $sailawayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr'])); |
|
1200 | + } |
|
894 | 1201 | $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption),'get','','','','',30); |
895 | 1202 | if ($buffer != '') { |
896 | 1203 | $data = json_decode($buffer,true); |
@@ -900,7 +1207,9 @@ discard block |
||
900 | 1207 | $data = array(); |
901 | 1208 | $data['id'] = $sail['ubtnr']; |
902 | 1209 | $data['datetime'] = date('Y-m-d H:i:s'); |
903 | - if ($sail['online'] == '1') $data['last_update'] = date('Y-m-d H:i:s'); |
|
1210 | + if ($sail['online'] == '1') { |
|
1211 | + $data['last_update'] = date('Y-m-d H:i:s'); |
|
1212 | + } |
|
904 | 1213 | $data['latitude'] = $sail['ubtlat']; |
905 | 1214 | $data['longitude'] = $sail['ubtlon']; |
906 | 1215 | $data['type_id'] = 36; |
@@ -909,16 +1218,24 @@ discard block |
||
909 | 1218 | $data['captain_name'] = $sail['usrname']; |
910 | 1219 | $allboats = array('Sailaway Cruiser 38','Mini Transat','Caribbean Rose','52' Cruising Cat','50' Performance Cruiser','Nordic Folkboat','32' Offshore Racer'); |
911 | 1220 | $boattype = $sail['ubtbtpnr']; |
912 | - if (isset($allboats[$boattype-1])) $data['type'] = $allboats[$boattype-1]; |
|
1221 | + if (isset($allboats[$boattype-1])) { |
|
1222 | + $data['type'] = $allboats[$boattype-1]; |
|
1223 | + } |
|
913 | 1224 | $data['speed'] = round($sail['ubtspeed']*3.6,2); |
914 | 1225 | $data['format_source'] = 'sailaway'; |
915 | 1226 | $data['id_source'] = $id_source; |
916 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1227 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1228 | + $data['noarchive'] = true; |
|
1229 | + } |
|
917 | 1230 | $MI->add($data); |
918 | 1231 | unset($data); |
919 | 1232 | } |
920 | - } elseif ($globalDebug) echo 'Error in JSON parsing'; |
|
921 | - } elseif ($globalDebug) echo 'Empty result !'."\n"; |
|
1233 | + } elseif ($globalDebug) { |
|
1234 | + echo 'Error in JSON parsing'; |
|
1235 | + } |
|
1236 | + } elseif ($globalDebug) { |
|
1237 | + echo 'Empty result !'."\n"; |
|
1238 | + } |
|
922 | 1239 | $last_exec[$id]['last'] = time(); |
923 | 1240 | //} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
924 | 1241 | } elseif ( |
@@ -946,16 +1263,28 @@ discard block |
||
946 | 1263 | $line = explode(':', $line); |
947 | 1264 | if (count($line) > 30 && $line[0] != 'callsign') { |
948 | 1265 | $data = array(); |
949 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
950 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
1266 | + if (isset($line[37]) && $line[37] != '') { |
|
1267 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
1268 | + } else { |
|
1269 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
1270 | + } |
|
951 | 1271 | $data['pilot_id'] = $line[1]; |
952 | 1272 | $data['pilot_name'] = $line[2]; |
953 | 1273 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
954 | 1274 | $data['ident'] = $line[0]; // ident |
955 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
1275 | + if ($line[7] != '' && $line[7] != 0) { |
|
1276 | + $data['altitude'] = $line[7]; |
|
1277 | + } |
|
1278 | + // altitude |
|
956 | 1279 | $data['speed'] = $line[8]; // speed |
957 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
958 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
1280 | + if (isset($line[45])) { |
|
1281 | + $data['heading'] = $line[45]; |
|
1282 | + } |
|
1283 | + // heading |
|
1284 | + elseif (isset($line[38])) { |
|
1285 | + $data['heading'] = $line[38]; |
|
1286 | + } |
|
1287 | + // heading |
|
959 | 1288 | $data['latitude'] = $line[5]; // lat |
960 | 1289 | $data['longitude'] = $line[6]; // long |
961 | 1290 | $data['verticalrate'] = ''; // vertical rate |
@@ -971,7 +1300,9 @@ discard block |
||
971 | 1300 | $data['frequency'] = $line[4]; |
972 | 1301 | $data['type'] = $line[18]; |
973 | 1302 | $data['range'] = $line[19]; |
974 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
1303 | + if (isset($line[35])) { |
|
1304 | + $data['info'] = $line[35]; |
|
1305 | + } |
|
975 | 1306 | $data['id_source'] = $id_source; |
976 | 1307 | //$data['arrival_airport_time'] = ; |
977 | 1308 | if ($line[9] != '') { |
@@ -985,27 +1316,47 @@ discard block |
||
985 | 1316 | elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
986 | 1317 | */ |
987 | 1318 | $data['format_source'] = $value['format']; |
988 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
989 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
990 | - if ($line[3] === 'PILOT') $SI->add($data); |
|
991 | - elseif ($line[3] === 'ATC') { |
|
1319 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1320 | + $data['noarchive'] = true; |
|
1321 | + } |
|
1322 | + if (isset($value['name']) && $value['name'] != '') { |
|
1323 | + $data['source_name'] = $value['name']; |
|
1324 | + } |
|
1325 | + if ($line[3] === 'PILOT') { |
|
1326 | + $SI->add($data); |
|
1327 | + } elseif ($line[3] === 'ATC') { |
|
992 | 1328 | //print_r($data); |
993 | 1329 | $data['info'] = str_replace('^§','<br />',$data['info']); |
994 | 1330 | $data['info'] = str_replace('&sect;','',$data['info']); |
995 | 1331 | $typec = substr($data['ident'],-3); |
996 | - if ($typec === 'APP') $data['type'] = 'Approach'; |
|
997 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
998 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
|
999 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; |
|
1000 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; |
|
1001 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; |
|
1002 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
|
1003 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
1004 | - elseif ($data['type'] === '') $data['type'] = 'Observer'; |
|
1005 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
1332 | + if ($typec === 'APP') { |
|
1333 | + $data['type'] = 'Approach'; |
|
1334 | + } elseif ($typec === 'TWR') { |
|
1335 | + $data['type'] = 'Tower'; |
|
1336 | + } elseif ($typec === 'OBS') { |
|
1337 | + $data['type'] = 'Observer'; |
|
1338 | + } elseif ($typec === 'GND') { |
|
1339 | + $data['type'] = 'Ground'; |
|
1340 | + } elseif ($typec === 'DEL') { |
|
1341 | + $data['type'] = 'Delivery'; |
|
1342 | + } elseif ($typec === 'DEP') { |
|
1343 | + $data['type'] = 'Departure'; |
|
1344 | + } elseif ($typec === 'FSS') { |
|
1345 | + $data['type'] = 'Flight Service Station'; |
|
1346 | + } elseif ($typec === 'CTR') { |
|
1347 | + $data['type'] = 'Control Radar or Centre'; |
|
1348 | + } elseif ($data['type'] === '') { |
|
1349 | + $data['type'] = 'Observer'; |
|
1350 | + } |
|
1351 | + if (!isset($data['source_name'])) { |
|
1352 | + $data['source_name'] = ''; |
|
1353 | + } |
|
1006 | 1354 | if (isset($ATC)) { |
1007 | - 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']); |
|
1008 | - 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']); |
|
1355 | + if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) { |
|
1356 | + 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']); |
|
1357 | + } else { |
|
1358 | + 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']); |
|
1359 | + } |
|
1009 | 1360 | } |
1010 | 1361 | } |
1011 | 1362 | unset($data); |
@@ -1032,14 +1383,20 @@ discard block |
||
1032 | 1383 | $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
1033 | 1384 | $data['latitude'] = (float)$line['pktLatitude']; |
1034 | 1385 | $data['longitude'] = (float)$line['pktLongitude']; |
1035 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
1036 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
1386 | + if ((float)$line['pktTrack'] != 0) { |
|
1387 | + $data['heading'] = (float)$line['pktTrack']; |
|
1388 | + } |
|
1389 | + if ((int)$line['pktSpeed'] != 0) { |
|
1390 | + $data['speed'] = (int)$line['pktSpeed']; |
|
1391 | + } |
|
1037 | 1392 | $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
1038 | 1393 | $data['altitude_relative'] = 'AMSL'; |
1039 | 1394 | $data['pilot_id'] = (int)$line['pktPilotID']; |
1040 | 1395 | $data['aircraft_icao'] = 'PARAGLIDER'; |
1041 | 1396 | $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
1042 | - if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
|
1397 | + if (isset($pilot_data[4])) { |
|
1398 | + $data['pilot_name'] = $pilot_data[4]; |
|
1399 | + } |
|
1043 | 1400 | $data['format_source'] = $value['format']; |
1044 | 1401 | $SI->add($data); |
1045 | 1402 | unset($data); |
@@ -1087,25 +1444,59 @@ discard block |
||
1087 | 1444 | foreach ($all_data['acList'] as $line) { |
1088 | 1445 | $data = array(); |
1089 | 1446 | $data['hex'] = $line['Icao']; // hex |
1090 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
1091 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
1092 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
1093 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
1094 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
1095 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
1447 | + if (isset($line['Call'])) { |
|
1448 | + $data['ident'] = $line['Call']; |
|
1449 | + } |
|
1450 | + // ident |
|
1451 | + if (isset($line['Alt'])) { |
|
1452 | + $data['altitude'] = $line['Alt']; |
|
1453 | + } |
|
1454 | + // altitude |
|
1455 | + if (isset($line['Spd'])) { |
|
1456 | + $data['speed'] = $line['Spd']; |
|
1457 | + } |
|
1458 | + // speed |
|
1459 | + if (isset($line['Trak'])) { |
|
1460 | + $data['heading'] = $line['Trak']; |
|
1461 | + } |
|
1462 | + // heading |
|
1463 | + if (isset($line['Lat'])) { |
|
1464 | + $data['latitude'] = $line['Lat']; |
|
1465 | + } |
|
1466 | + // lat |
|
1467 | + if (isset($line['Long'])) { |
|
1468 | + $data['longitude'] = $line['Long']; |
|
1469 | + } |
|
1470 | + // long |
|
1096 | 1471 | //$data['verticalrate'] = $line['']; // verticale rate |
1097 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
1472 | + if (isset($line['Sqk'])) { |
|
1473 | + $data['squawk'] = $line['Sqk']; |
|
1474 | + } |
|
1475 | + // squawk |
|
1098 | 1476 | $data['emergency'] = ''; // emergency |
1099 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
1100 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1101 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1477 | + if (isset($line['Reg'])) { |
|
1478 | + $data['registration'] = $line['Reg']; |
|
1479 | + } |
|
1480 | + if (isset($line['PosTime'])) { |
|
1481 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1482 | + } else { |
|
1483 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1484 | + } |
|
1102 | 1485 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1103 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
1486 | + if (isset($line['Type'])) { |
|
1487 | + $data['aircraft_icao'] = $line['Type']; |
|
1488 | + } |
|
1104 | 1489 | $data['format_source'] = 'aircraftlistjson'; |
1105 | 1490 | $data['id_source'] = $id_source; |
1106 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1107 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1108 | - if (isset($data['latitude'])) $SI->add($data); |
|
1491 | + if (isset($value['name']) && $value['name'] != '') { |
|
1492 | + $data['source_name'] = $value['name']; |
|
1493 | + } |
|
1494 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1495 | + $data['noarchive'] = true; |
|
1496 | + } |
|
1497 | + if (isset($data['latitude'])) { |
|
1498 | + $SI->add($data); |
|
1499 | + } |
|
1109 | 1500 | unset($data); |
1110 | 1501 | } |
1111 | 1502 | } elseif (is_array($all_data)) { |
@@ -1122,17 +1513,26 @@ discard block |
||
1122 | 1513 | $data['verticalrate'] = $line['vrt']; // verticale rate |
1123 | 1514 | $data['squawk'] = $line['squawk']; // squawk |
1124 | 1515 | $data['emergency'] = ''; // emergency |
1125 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1126 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1516 | + if (isset($line['PosTime'])) { |
|
1517 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1518 | + } else { |
|
1519 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1520 | + } |
|
1127 | 1521 | $data['format_source'] = 'aircraftlistjson'; |
1128 | 1522 | $data['id_source'] = $id_source; |
1129 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1130 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1523 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1524 | + $data['noarchive'] = true; |
|
1525 | + } |
|
1526 | + if (isset($value['name']) && $value['name'] != '') { |
|
1527 | + $data['source_name'] = $value['name']; |
|
1528 | + } |
|
1131 | 1529 | $SI->add($data); |
1132 | 1530 | unset($data); |
1133 | 1531 | } |
1134 | 1532 | } |
1135 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
1533 | + } elseif ($globalDebug) { |
|
1534 | + echo 'No data'."\n"; |
|
1535 | + } |
|
1136 | 1536 | //$last_exec['aircraftlistjson'] = time(); |
1137 | 1537 | $last_exec[$id]['last'] = time(); |
1138 | 1538 | //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
@@ -1168,8 +1568,12 @@ discard block |
||
1168 | 1568 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
1169 | 1569 | $data['format_source'] = 'planeupdatefaa'; |
1170 | 1570 | $data['id_source'] = $id_source; |
1171 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1172 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1571 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1572 | + $data['noarchive'] = true; |
|
1573 | + } |
|
1574 | + if (isset($value['name']) && $value['name'] != '') { |
|
1575 | + $data['source_name'] = $value['name']; |
|
1576 | + } |
|
1173 | 1577 | $SI->add($data); |
1174 | 1578 | unset($data); |
1175 | 1579 | } |
@@ -1203,7 +1607,9 @@ discard block |
||
1203 | 1607 | $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
1204 | 1608 | $data['format_source'] = 'opensky'; |
1205 | 1609 | $data['id_source'] = $id_source; |
1206 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1610 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1611 | + $data['noarchive'] = true; |
|
1612 | + } |
|
1207 | 1613 | $SI->add($data); |
1208 | 1614 | unset($data); |
1209 | 1615 | } |
@@ -1223,15 +1629,42 @@ discard block |
||
1223 | 1629 | foreach ($all_data['aircraft'] as $key => $line) { |
1224 | 1630 | $data = array(); |
1225 | 1631 | // add support for ground vehicule with ~ in front of hex |
1226 | - if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
1227 | - if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
1228 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1229 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1230 | - if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
1231 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1232 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1233 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1234 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1632 | + if (isset($line['hex'])) { |
|
1633 | + $data['hex'] = $line['hex']; |
|
1634 | + } |
|
1635 | + // hex |
|
1636 | + if (isset($line['flight'])) { |
|
1637 | + $data['ident'] = trim($line['flight']); |
|
1638 | + } |
|
1639 | + // ident |
|
1640 | + if (isset($line['altitude'])) { |
|
1641 | + $data['altitude'] = $line['altitude']; |
|
1642 | + } |
|
1643 | + // altitude |
|
1644 | + if (isset($line['speed'])) { |
|
1645 | + $data['speed'] = $line['speed']; |
|
1646 | + } |
|
1647 | + // speed |
|
1648 | + if (isset($line['track'])) { |
|
1649 | + $data['heading'] = $line['track']; |
|
1650 | + } |
|
1651 | + // heading |
|
1652 | + if (isset($line['lat'])) { |
|
1653 | + $data['latitude'] = $line['lat']; |
|
1654 | + } |
|
1655 | + // lat |
|
1656 | + if (isset($line['lon'])) { |
|
1657 | + $data['longitude'] = $line['lon']; |
|
1658 | + } |
|
1659 | + // long |
|
1660 | + if (isset($line['vert_rate'])) { |
|
1661 | + $data['verticalrate'] = $line['vert_rate']; |
|
1662 | + } |
|
1663 | + // verticale rate |
|
1664 | + if (isset($line['squawk'])) { |
|
1665 | + $data['squawk'] = $line['squawk']; |
|
1666 | + } |
|
1667 | + // squawk |
|
1235 | 1668 | //$data['emergency'] = ''; // emergency |
1236 | 1669 | //$data['registration'] = $line[2]; |
1237 | 1670 | //$data['aircraft_icao'] = $line[0]; |
@@ -1239,10 +1672,17 @@ discard block |
||
1239 | 1672 | $data['format_source'] = 'aircraftjson'; |
1240 | 1673 | $data['id_source'] = $id_source; |
1241 | 1674 | if (isset($value['name']) && $value['name'] != '') { |
1242 | - if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
1243 | - else $data['source_name'] = $value['name']; |
|
1244 | - } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
1245 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1675 | + if (isset($line['mlat']) && !empty($line['mlat'])) { |
|
1676 | + $data['source_name'] = $value['name'].'_MLAT'; |
|
1677 | + } else { |
|
1678 | + $data['source_name'] = $value['name']; |
|
1679 | + } |
|
1680 | + } elseif (isset($line['mlat']) && !empty($line['mlat'])) { |
|
1681 | + $data['source_name'] = 'MLAT'; |
|
1682 | + } |
|
1683 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1684 | + $data['noarchive'] = true; |
|
1685 | + } |
|
1246 | 1686 | $SI->add($data); |
1247 | 1687 | unset($data); |
1248 | 1688 | } |
@@ -1262,22 +1702,54 @@ discard block |
||
1262 | 1702 | foreach ($all_data['aircraft'] as $key => $line) { |
1263 | 1703 | $data = array(); |
1264 | 1704 | $data['hex'] = $key; // hex |
1265 | - if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident |
|
1266 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1267 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1268 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1269 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1270 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1271 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1272 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1705 | + if (isset($line['callsign'])) { |
|
1706 | + $data['ident'] = trim($line['callsign']); |
|
1707 | + } |
|
1708 | + // ident |
|
1709 | + if (isset($line['altitude'])) { |
|
1710 | + $data['altitude'] = $line['altitude']; |
|
1711 | + } |
|
1712 | + // altitude |
|
1713 | + if (isset($line['speed'])) { |
|
1714 | + $data['speed'] = $line['speed']; |
|
1715 | + } |
|
1716 | + // speed |
|
1717 | + if (isset($line['heading'])) { |
|
1718 | + $data['heading'] = $line['heading']; |
|
1719 | + } |
|
1720 | + // heading |
|
1721 | + if (isset($line['lat'])) { |
|
1722 | + $data['latitude'] = $line['lat']; |
|
1723 | + } |
|
1724 | + // lat |
|
1725 | + if (isset($line['lon'])) { |
|
1726 | + $data['longitude'] = $line['lon']; |
|
1727 | + } |
|
1728 | + // long |
|
1729 | + if (isset($line['vert_rate'])) { |
|
1730 | + $data['verticalrate'] = $line['vert_rate']; |
|
1731 | + } |
|
1732 | + // verticale rate |
|
1733 | + if (isset($line['squawk'])) { |
|
1734 | + $data['squawk'] = $line['squawk']; |
|
1735 | + } |
|
1736 | + // squawk |
|
1273 | 1737 | //$data['emergency'] = ''; // emergency |
1274 | - if (isset($line['reg'])) $data['registration'] = $line['reg']; |
|
1275 | - if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
|
1738 | + if (isset($line['reg'])) { |
|
1739 | + $data['registration'] = $line['reg']; |
|
1740 | + } |
|
1741 | + if (isset($line['type'])) { |
|
1742 | + $data['aircraft_icao'] = $line['type']; |
|
1743 | + } |
|
1276 | 1744 | $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
1277 | 1745 | $data['format_source'] = 'planefinderclient'; |
1278 | 1746 | $data['id_source'] = $id_source; |
1279 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1280 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1747 | + if (isset($value['name']) && $value['name'] != '') { |
|
1748 | + $data['source_name'] = $value['name']; |
|
1749 | + } |
|
1750 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1751 | + $data['noarchive'] = true; |
|
1752 | + } |
|
1281 | 1753 | $SI->add($data); |
1282 | 1754 | unset($data); |
1283 | 1755 | } |
@@ -1293,7 +1765,9 @@ discard block |
||
1293 | 1765 | //$buffer = $Common->getData($hosts[$id]); |
1294 | 1766 | $buffer = $Common->getData($value['host']); |
1295 | 1767 | $all_data = json_decode($buffer,true); |
1296 | - if (!empty($all_data)) $reset = 0; |
|
1768 | + if (!empty($all_data)) { |
|
1769 | + $reset = 0; |
|
1770 | + } |
|
1297 | 1771 | foreach ($all_data as $key => $line) { |
1298 | 1772 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
1299 | 1773 | $data = array(); |
@@ -1314,8 +1788,12 @@ discard block |
||
1314 | 1788 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
1315 | 1789 | $data['format_source'] = 'fr24json'; |
1316 | 1790 | $data['id_source'] = $id_source; |
1317 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1318 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1791 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1792 | + $data['noarchive'] = true; |
|
1793 | + } |
|
1794 | + if (isset($value['name']) && $value['name'] != '') { |
|
1795 | + $data['source_name'] = $value['name']; |
|
1796 | + } |
|
1319 | 1797 | $SI->add($data); |
1320 | 1798 | unset($data); |
1321 | 1799 | } |
@@ -1344,24 +1822,42 @@ discard block |
||
1344 | 1822 | if (isset($line['inf'])) { |
1345 | 1823 | $data = array(); |
1346 | 1824 | $data['hex'] = $line['inf']['ia']; |
1347 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
1825 | + if (isset($line['inf']['cs'])) { |
|
1826 | + $data['ident'] = $line['inf']['cs']; |
|
1827 | + } |
|
1828 | + //$line[13] |
|
1348 | 1829 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
1349 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1350 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1830 | + if (isset($line['inf']['gs'])) { |
|
1831 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
1832 | + } |
|
1833 | + // speed |
|
1834 | + if (isset($line['inf']['tr'])) { |
|
1835 | + $data['heading'] = $line['inf']['tr']; |
|
1836 | + } |
|
1837 | + // heading |
|
1351 | 1838 | $data['latitude'] = $line['pt'][0]; // lat |
1352 | 1839 | $data['longitude'] = $line['pt'][1]; // long |
1353 | 1840 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
1354 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1841 | + if (isset($line['inf']['sq'])) { |
|
1842 | + $data['squawk'] = $line['inf']['sq']; |
|
1843 | + } |
|
1844 | + // squawk |
|
1355 | 1845 | //$data['aircraft_icao'] = $line[8]; |
1356 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1846 | + if (isset($line['inf']['rc'])) { |
|
1847 | + $data['registration'] = $line['inf']['rc']; |
|
1848 | + } |
|
1357 | 1849 | //$data['departure_airport_iata'] = $line[11]; |
1358 | 1850 | //$data['arrival_airport_iata'] = $line[12]; |
1359 | 1851 | //$data['emergency'] = ''; // emergency |
1360 | 1852 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
1361 | 1853 | $data['format_source'] = 'radarvirtueljson'; |
1362 | 1854 | $data['id_source'] = $id_source; |
1363 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1364 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1855 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1856 | + $data['noarchive'] = true; |
|
1857 | + } |
|
1858 | + if (isset($value['name']) && $value['name'] != '') { |
|
1859 | + $data['source_name'] = $value['name']; |
|
1860 | + } |
|
1365 | 1861 | $SI->add($data); |
1366 | 1862 | unset($data); |
1367 | 1863 | } |
@@ -1387,30 +1883,65 @@ discard block |
||
1387 | 1883 | $data['id'] = $line['id']; |
1388 | 1884 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
1389 | 1885 | $data['ident'] = $line['callsign']; // ident |
1390 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1391 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1392 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1393 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1394 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1395 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1886 | + if (isset($line['pilotid'])) { |
|
1887 | + $data['pilot_id'] = $line['pilotid']; |
|
1888 | + } |
|
1889 | + // pilot id |
|
1890 | + if (isset($line['name'])) { |
|
1891 | + $data['pilot_name'] = $line['name']; |
|
1892 | + } |
|
1893 | + // pilot name |
|
1894 | + if (isset($line['alt'])) { |
|
1895 | + $data['altitude'] = $line['alt']; |
|
1896 | + } |
|
1897 | + // altitude |
|
1898 | + if (isset($line['gs'])) { |
|
1899 | + $data['speed'] = $line['gs']; |
|
1900 | + } |
|
1901 | + // speed |
|
1902 | + if (isset($line['heading'])) { |
|
1903 | + $data['heading'] = $line['heading']; |
|
1904 | + } |
|
1905 | + // heading |
|
1906 | + if (isset($line['route'])) { |
|
1907 | + $data['waypoints'] = $line['route']; |
|
1908 | + } |
|
1909 | + // route |
|
1396 | 1910 | $data['latitude'] = $line['lat']; // lat |
1397 | 1911 | $data['longitude'] = $line['lon']; // long |
1398 | 1912 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
1399 | 1913 | //$data['squawk'] = $line['squawk']; // squawk |
1400 | 1914 | //$data['emergency'] = ''; // emergency |
1401 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1402 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1403 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1915 | + if (isset($line['depicao'])) { |
|
1916 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1917 | + } |
|
1918 | + if (isset($line['deptime'])) { |
|
1919 | + $data['departure_airport_time'] = $line['deptime']; |
|
1920 | + } |
|
1921 | + if (isset($line['arricao'])) { |
|
1922 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1923 | + } |
|
1404 | 1924 | //$data['arrival_airport_time'] = $line['arrtime']; |
1405 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1406 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1407 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1408 | - else $data['info'] = ''; |
|
1925 | + if (isset($line['aircraft'])) { |
|
1926 | + $data['aircraft_icao'] = $line['aircraft']; |
|
1927 | + } |
|
1928 | + if (isset($line['transponder'])) { |
|
1929 | + $data['squawk'] = $line['transponder']; |
|
1930 | + } |
|
1931 | + if (isset($line['atis'])) { |
|
1932 | + $data['info'] = $line['atis']; |
|
1933 | + } else { |
|
1934 | + $data['info'] = ''; |
|
1935 | + } |
|
1409 | 1936 | $data['format_source'] = 'pireps'; |
1410 | 1937 | $data['id_source'] = $id_source; |
1411 | 1938 | $data['datetime'] = date('Y-m-d H:i:s'); |
1412 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1413 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1939 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1940 | + $data['noarchive'] = true; |
|
1941 | + } |
|
1942 | + if (isset($value['name']) && $value['name'] != '') { |
|
1943 | + $data['source_name'] = $value['name']; |
|
1944 | + } |
|
1414 | 1945 | if ($line['icon'] === 'plane') { |
1415 | 1946 | $SI->add($data); |
1416 | 1947 | // print_r($data); |
@@ -1419,16 +1950,28 @@ discard block |
||
1419 | 1950 | $data['info'] = str_replace('&sect;','',$data['info']); |
1420 | 1951 | $typec = substr($data['ident'],-3); |
1421 | 1952 | $data['type'] = ''; |
1422 | - if ($typec === 'APP') $data['type'] = 'Approach'; |
|
1423 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
1424 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
|
1425 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; |
|
1426 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; |
|
1427 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; |
|
1428 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
|
1429 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
1430 | - else $data['type'] = 'Observer'; |
|
1431 | - 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']); |
|
1953 | + if ($typec === 'APP') { |
|
1954 | + $data['type'] = 'Approach'; |
|
1955 | + } elseif ($typec === 'TWR') { |
|
1956 | + $data['type'] = 'Tower'; |
|
1957 | + } elseif ($typec === 'OBS') { |
|
1958 | + $data['type'] = 'Observer'; |
|
1959 | + } elseif ($typec === 'GND') { |
|
1960 | + $data['type'] = 'Ground'; |
|
1961 | + } elseif ($typec === 'DEL') { |
|
1962 | + $data['type'] = 'Delivery'; |
|
1963 | + } elseif ($typec === 'DEP') { |
|
1964 | + $data['type'] = 'Departure'; |
|
1965 | + } elseif ($typec === 'FSS') { |
|
1966 | + $data['type'] = 'Flight Service Station'; |
|
1967 | + } elseif ($typec === 'CTR') { |
|
1968 | + $data['type'] = 'Control Radar or Centre'; |
|
1969 | + } else { |
|
1970 | + $data['type'] = 'Observer'; |
|
1971 | + } |
|
1972 | + if (isset($ATC)) { |
|
1973 | + 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']); |
|
1974 | + } |
|
1432 | 1975 | } |
1433 | 1976 | unset($data); |
1434 | 1977 | } |
@@ -1443,7 +1986,9 @@ discard block |
||
1443 | 1986 | ) |
1444 | 1987 | ) { |
1445 | 1988 | //$buffer = $Common->getData($hosts[$id]); |
1446 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1989 | + if ($globalDebug) { |
|
1990 | + echo 'Get Data...'."\n"; |
|
1991 | + } |
|
1447 | 1992 | $buffer = $Common->getData($value['host']); |
1448 | 1993 | $all_data = json_decode($buffer,true); |
1449 | 1994 | if ($buffer != '' && is_array($all_data)) { |
@@ -1451,11 +1996,18 @@ discard block |
||
1451 | 1996 | foreach ($all_data as $line) { |
1452 | 1997 | $data = array(); |
1453 | 1998 | //$data['id'] = $line['id']; // id not usable |
1454 | - if (isset($line['pilotid']) && isset($line['registration'])) $data['id'] = $line['pilotid'].$line['flightnum'].trim($line['registration']); |
|
1455 | - elseif (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1999 | + if (isset($line['pilotid']) && isset($line['registration'])) { |
|
2000 | + $data['id'] = $line['pilotid'].$line['flightnum'].trim($line['registration']); |
|
2001 | + } elseif (isset($line['pilotid'])) { |
|
2002 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
2003 | + } |
|
1456 | 2004 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
1457 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1458 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
2005 | + if (isset($line['pilotname'])) { |
|
2006 | + $data['pilot_name'] = $line['pilotname']; |
|
2007 | + } |
|
2008 | + if (isset($line['pilotid'])) { |
|
2009 | + $data['pilot_id'] = $line['pilotid']; |
|
2010 | + } |
|
1459 | 2011 | $data['ident'] = $line['flightnum']; // ident |
1460 | 2012 | $data['altitude'] = $line['alt']; // altitude |
1461 | 2013 | $data['speed'] = $line['gs']; // speed |
@@ -1471,7 +2023,9 @@ discard block |
||
1471 | 2023 | $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
1472 | 2024 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1473 | 2025 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1474 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
2026 | + } else { |
|
2027 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
2028 | + } |
|
1475 | 2029 | $data['departure_airport_icao'] = $line['depicao']; |
1476 | 2030 | $data['departure_airport_time'] = $line['deptime']; |
1477 | 2031 | $data['arrival_airport_icao'] = $line['arricao']; |
@@ -1479,29 +2033,47 @@ discard block |
||
1479 | 2033 | if (isset($line['registration'])) { |
1480 | 2034 | $data['registration'] = trim($line['registration']); |
1481 | 2035 | //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
1482 | - } else $data['registration'] = $line['aircraft']; |
|
1483 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1484 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
2036 | + } else { |
|
2037 | + $data['registration'] = $line['aircraft']; |
|
2038 | + } |
|
2039 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
2040 | + $data['noarchive'] = true; |
|
2041 | + } |
|
2042 | + if (isset($line['route'])) { |
|
2043 | + $data['waypoints'] = $line['route']; |
|
2044 | + } |
|
2045 | + // route |
|
1485 | 2046 | if (isset($line['aircraftname'])) { |
1486 | 2047 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1487 | 2048 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1488 | 2049 | $aircraft_data = explode('-',$line['aircraftname']); |
1489 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1490 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1491 | - else { |
|
2050 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { |
|
2051 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
2052 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { |
|
2053 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
2054 | + } else { |
|
1492 | 2055 | $aircraft_data = explode(' ',$line['aircraftname']); |
1493 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1494 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
2056 | + if (isset($aircraft_data[1])) { |
|
2057 | + $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
2058 | + } else { |
|
2059 | + $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
2060 | + } |
|
1495 | 2061 | } |
1496 | 2062 | } |
1497 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
2063 | + if (isset($line['route'])) { |
|
2064 | + $data['waypoints'] = $line['route']; |
|
2065 | + } |
|
1498 | 2066 | $data['id_source'] = $id_source; |
1499 | 2067 | $data['format_source'] = 'phpvmacars'; |
1500 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
2068 | + if (isset($value['name']) && $value['name'] != '') { |
|
2069 | + $data['source_name'] = $value['name']; |
|
2070 | + } |
|
1501 | 2071 | $SI->add($data); |
1502 | 2072 | unset($data); |
1503 | 2073 | } |
1504 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
2074 | + if ($globalDebug) { |
|
2075 | + echo 'No more data...'."\n"; |
|
2076 | + } |
|
1505 | 2077 | unset($buffer); |
1506 | 2078 | unset($all_data); |
1507 | 2079 | } |
@@ -1514,7 +2086,9 @@ discard block |
||
1514 | 2086 | ) |
1515 | 2087 | ) { |
1516 | 2088 | //$buffer = $Common->getData($hosts[$id]); |
1517 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
2089 | + if ($globalDebug) { |
|
2090 | + echo 'Get Data...'."\n"; |
|
2091 | + } |
|
1518 | 2092 | $buffer = $Common->getData($value['host']); |
1519 | 2093 | $all_data = json_decode($buffer,true); |
1520 | 2094 | if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
@@ -1525,10 +2099,16 @@ discard block |
||
1525 | 2099 | //$data['id'] = $line['id']; // id not usable |
1526 | 2100 | $data['id'] = $line['id']; |
1527 | 2101 | //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
1528 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
1529 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
2102 | + if (isset($line['user']['username'])) { |
|
2103 | + $data['pilot_name'] = $line['user']['username']; |
|
2104 | + } |
|
2105 | + if (isset($line['user_id'])) { |
|
2106 | + $data['pilot_id'] = $line['user_id']; |
|
2107 | + } |
|
1530 | 2108 | $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
1531 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
2109 | + if (is_numeric($data['ident'])) { |
|
2110 | + $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
2111 | + } |
|
1532 | 2112 | $data['altitude'] = $line['altitude']; // altitude |
1533 | 2113 | $data['speed'] = $line['groundspeed']; // speed |
1534 | 2114 | $data['heading'] = $line['heading']; // heading |
@@ -1541,7 +2121,9 @@ discard block |
||
1541 | 2121 | $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
1542 | 2122 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1543 | 2123 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1544 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
2124 | + } else { |
|
2125 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
2126 | + } |
|
1545 | 2127 | |
1546 | 2128 | $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
1547 | 2129 | $data['departure_airport_time'] = $line['bid']['deptime']; |
@@ -1549,17 +2131,26 @@ discard block |
||
1549 | 2131 | $data['arrival_airport_time'] = $line['bid']['arrtime']; |
1550 | 2132 | $data['registration'] = $line['bid']['aircraft']['registration']; |
1551 | 2133 | |
1552 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1553 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
2134 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
2135 | + $data['noarchive'] = true; |
|
2136 | + } |
|
2137 | + if (isset($line['bid']['route']) && $line['bid']['route'] != '') { |
|
2138 | + $data['waypoints'] = $line['bid']['route']; |
|
2139 | + } |
|
2140 | + // route |
|
1554 | 2141 | $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
1555 | 2142 | |
1556 | 2143 | $data['id_source'] = $id_source; |
1557 | 2144 | $data['format_source'] = 'vaos'; |
1558 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
2145 | + if (isset($value['name']) && $value['name'] != '') { |
|
2146 | + $data['source_name'] = $value['name']; |
|
2147 | + } |
|
1559 | 2148 | $SI->add($data); |
1560 | 2149 | unset($data); |
1561 | 2150 | } |
1562 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
2151 | + if ($globalDebug) { |
|
2152 | + echo 'No more data...'."\n"; |
|
2153 | + } |
|
1563 | 2154 | unset($buffer); |
1564 | 2155 | unset($all_data); |
1565 | 2156 | } |
@@ -1572,7 +2163,9 @@ discard block |
||
1572 | 2163 | ) |
1573 | 2164 | ) { |
1574 | 2165 | //$buffer = $Common->getData($hosts[$id]); |
1575 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
2166 | + if ($globalDebug) { |
|
2167 | + echo 'Get Data...'."\n"; |
|
2168 | + } |
|
1576 | 2169 | $buffer = $Common->getData($value['host']); |
1577 | 2170 | $all_data = json_decode($buffer,true); |
1578 | 2171 | if ($buffer != '' && is_array($all_data)) { |
@@ -1601,16 +2194,25 @@ discard block |
||
1601 | 2194 | $data['arrival_airport_icao'] = $line['arrival']; |
1602 | 2195 | //$data['arrival_airport_time'] = $line['arrival_time']; |
1603 | 2196 | //$data['registration'] = $line['aircraft']; |
1604 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
2197 | + if (isset($line['route'])) { |
|
2198 | + $data['waypoints'] = $line['route']; |
|
2199 | + } |
|
2200 | + // route |
|
1605 | 2201 | $data['aircraft_icao'] = $line['plane_type']; |
1606 | 2202 | $data['id_source'] = $id_source; |
1607 | 2203 | $data['format_source'] = 'vam'; |
1608 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1609 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
2204 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
2205 | + $data['noarchive'] = true; |
|
2206 | + } |
|
2207 | + if (isset($value['name']) && $value['name'] != '') { |
|
2208 | + $data['source_name'] = $value['name']; |
|
2209 | + } |
|
1610 | 2210 | $SI->add($data); |
1611 | 2211 | unset($data); |
1612 | 2212 | } |
1613 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
2213 | + if ($globalDebug) { |
|
2214 | + echo 'No more data...'."\n"; |
|
2215 | + } |
|
1614 | 2216 | unset($buffer); |
1615 | 2217 | unset($all_data); |
1616 | 2218 | } |
@@ -1623,7 +2225,9 @@ discard block |
||
1623 | 2225 | ) |
1624 | 2226 | ) { |
1625 | 2227 | //$buffer = $Common->getData($hosts[$id]); |
1626 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
2228 | + if ($globalDebug) { |
|
2229 | + echo 'Get Data...'."\n"; |
|
2230 | + } |
|
1627 | 2231 | $buffer = $Common->getData($value['host']); |
1628 | 2232 | $all_data = json_decode($buffer,true); |
1629 | 2233 | if ($buffer != '') { |
@@ -1641,12 +2245,16 @@ discard block |
||
1641 | 2245 | $data['id_source'] = $id_source; |
1642 | 2246 | $data['format_source'] = 'blitzortung'; |
1643 | 2247 | $SI->add($data); |
1644 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
2248 | + if ($globalDebug) { |
|
2249 | + echo '☈ Lightning added'."\n"; |
|
2250 | + } |
|
1645 | 2251 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
1646 | 2252 | unset($data); |
1647 | 2253 | } |
1648 | 2254 | } |
1649 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
2255 | + if ($globalDebug) { |
|
2256 | + echo 'No more data...'."\n"; |
|
2257 | + } |
|
1650 | 2258 | unset($buffer); |
1651 | 2259 | } |
1652 | 2260 | $last_exec[$id]['last'] = time(); |
@@ -1675,10 +2283,15 @@ discard block |
||
1675 | 2283 | } |
1676 | 2284 | } else { |
1677 | 2285 | $format = $value['format']; |
1678 | - if (isset($tt[$format])) $tt[$format]++; |
|
1679 | - else $tt[$format] = 0; |
|
2286 | + if (isset($tt[$format])) { |
|
2287 | + $tt[$format]++; |
|
2288 | + } else { |
|
2289 | + $tt[$format] = 0; |
|
2290 | + } |
|
1680 | 2291 | if ($tt[$format] > 30) { |
1681 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
2292 | + if ($globalDebug) { |
|
2293 | + echo 'Reconnect...'."\n"; |
|
2294 | + } |
|
1682 | 2295 | sleep(2); |
1683 | 2296 | //$sourceeen[] = $value; |
1684 | 2297 | //connect_all($sourceeen); |
@@ -1695,7 +2308,9 @@ discard block |
||
1695 | 2308 | $write = NULL; |
1696 | 2309 | $e = NULL; |
1697 | 2310 | $n = socket_select($read, $write, $e, $timeout); |
1698 | - if ($e != NULL) var_dump($e); |
|
2311 | + if ($e != NULL) { |
|
2312 | + var_dump($e); |
|
2313 | + } |
|
1699 | 2314 | if ($n > 0) { |
1700 | 2315 | $reset = 0; |
1701 | 2316 | foreach ($read as $nb => $r) { |
@@ -1717,13 +2332,17 @@ discard block |
||
1717 | 2332 | if ($buffer !== FALSE) { |
1718 | 2333 | if ($format === 'vrstcp') { |
1719 | 2334 | $buffer = explode('},{',$buffer); |
1720 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
2335 | + } else { |
|
2336 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
2337 | + } |
|
1721 | 2338 | } |
1722 | 2339 | // SBS format is CSV format |
1723 | 2340 | if ($buffer !== FALSE && $buffer !== '') { |
1724 | 2341 | $tt[$format] = 0; |
1725 | 2342 | if ($format === 'acarssbs3') { |
1726 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
2343 | + if ($globalDebug) { |
|
2344 | + echo 'ACARS : '.$buffer."\n"; |
|
2345 | + } |
|
1727 | 2346 | $ACARS->add(trim($buffer)); |
1728 | 2347 | $ACARS->deleteLiveAcarsData(); |
1729 | 2348 | } elseif ($format === 'raw') { |
@@ -1733,9 +2352,15 @@ discard block |
||
1733 | 2352 | //if (!empty($data)) print_r($data); |
1734 | 2353 | $data['datetime'] = date('Y-m-d H:i:s'); |
1735 | 2354 | $data['format_source'] = 'raw'; |
1736 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1737 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1738 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
2355 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2356 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2357 | + } |
|
2358 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2359 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2360 | + } |
|
2361 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2362 | + $data['noarchive'] = true; |
|
2363 | + } |
|
1739 | 2364 | //if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1740 | 2365 | $SI->add($data); |
1741 | 2366 | unset($data); |
@@ -1743,22 +2368,54 @@ discard block |
||
1743 | 2368 | } elseif ($format === 'ais') { |
1744 | 2369 | $ais_data = $AIS->parse_line(trim($buffer)); |
1745 | 2370 | $data = array(); |
1746 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1747 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1748 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1749 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1750 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1751 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1752 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1753 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1754 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1755 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1756 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1757 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1758 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1759 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1760 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1761 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2371 | + if (isset($ais_data['ident'])) { |
|
2372 | + $data['ident'] = $ais_data['ident']; |
|
2373 | + } |
|
2374 | + if (isset($ais_data['mmsi'])) { |
|
2375 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
2376 | + } |
|
2377 | + if (isset($ais_data['speed'])) { |
|
2378 | + $data['speed'] = $ais_data['speed']; |
|
2379 | + } |
|
2380 | + if (isset($ais_data['heading'])) { |
|
2381 | + $data['heading'] = $ais_data['heading']; |
|
2382 | + } |
|
2383 | + if (isset($ais_data['latitude'])) { |
|
2384 | + $data['latitude'] = $ais_data['latitude']; |
|
2385 | + } |
|
2386 | + if (isset($ais_data['longitude'])) { |
|
2387 | + $data['longitude'] = $ais_data['longitude']; |
|
2388 | + } |
|
2389 | + if (isset($ais_data['status'])) { |
|
2390 | + $data['status'] = $ais_data['status']; |
|
2391 | + } |
|
2392 | + if (isset($ais_data['statusid'])) { |
|
2393 | + $data['status_id'] = $ais_data['statusid']; |
|
2394 | + } |
|
2395 | + if (isset($ais_data['type'])) { |
|
2396 | + $data['type'] = $ais_data['type']; |
|
2397 | + } |
|
2398 | + if (isset($ais_data['imo'])) { |
|
2399 | + $data['imo'] = $ais_data['imo']; |
|
2400 | + } |
|
2401 | + if (isset($ais_data['callsign'])) { |
|
2402 | + $data['callsign'] = $ais_data['callsign']; |
|
2403 | + } |
|
2404 | + if (isset($ais_data['destination'])) { |
|
2405 | + $data['arrival_code'] = $ais_data['destination']; |
|
2406 | + } |
|
2407 | + if (isset($ais_data['eta_ts'])) { |
|
2408 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
2409 | + } |
|
2410 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2411 | + $data['noarchive'] = true; |
|
2412 | + } |
|
2413 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2414 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2415 | + } |
|
2416 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2417 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2418 | + } |
|
1762 | 2419 | |
1763 | 2420 | if (isset($ais_data['timestamp'])) { |
1764 | 2421 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1767,7 +2424,9 @@ discard block |
||
1767 | 2424 | } |
1768 | 2425 | $data['format_source'] = 'aisnmea'; |
1769 | 2426 | $data['id_source'] = $id_source; |
1770 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
2427 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
2428 | + $MI->add($data); |
|
2429 | + } |
|
1771 | 2430 | unset($data); |
1772 | 2431 | } elseif ($format === 'flightgearsp') { |
1773 | 2432 | //echo $buffer."\n"; |
@@ -1785,17 +2444,25 @@ discard block |
||
1785 | 2444 | $data['speed'] = round($line[5]*1.94384); |
1786 | 2445 | $data['datetime'] = date('Y-m-d H:i:s'); |
1787 | 2446 | $data['format_source'] = 'flightgearsp'; |
1788 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1789 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
2447 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2448 | + $data['noarchive'] = true; |
|
2449 | + } |
|
2450 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2451 | + $SI->add($data); |
|
2452 | + } |
|
1790 | 2453 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1791 | 2454 | } |
1792 | 2455 | } elseif ($format === 'acars') { |
1793 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
2456 | + if ($globalDebug) { |
|
2457 | + echo 'ACARS : '.$buffer."\n"; |
|
2458 | + } |
|
1794 | 2459 | $ACARS->add(trim($buffer)); |
1795 | 2460 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
1796 | 2461 | $ACARS->deleteLiveAcarsData(); |
1797 | 2462 | } elseif ($format === 'acarsjsonudp') { |
1798 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
2463 | + if ($globalDebug) { |
|
2464 | + echo 'ACARS : '.$buffer."\n"; |
|
2465 | + } |
|
1799 | 2466 | $line = json_decode(trim($buffer), true); |
1800 | 2467 | if (!empty($line)) { |
1801 | 2468 | $line = array_merge(array('text' => '','tail' => '','label' => '','block_id' => '','flight' => '','msgno' => ''),$line); |
@@ -1820,8 +2487,12 @@ discard block |
||
1820 | 2487 | $aircraft_type = $line[10]; |
1821 | 2488 | $aircraft_type = preg_split(':/:',$aircraft_type); |
1822 | 2489 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
1823 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1824 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
2490 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2491 | + $data['noarchive'] = true; |
|
2492 | + } |
|
2493 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2494 | + $SI->add($data); |
|
2495 | + } |
|
1825 | 2496 | } |
1826 | 2497 | } |
1827 | 2498 | } elseif ($format === 'beast') { |
@@ -1831,28 +2502,62 @@ discard block |
||
1831 | 2502 | foreach($buffer as $all_data) { |
1832 | 2503 | $line = json_decode('{'.$all_data.'}',true); |
1833 | 2504 | $data = array(); |
1834 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
1835 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
1836 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
1837 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
1838 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
1839 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
1840 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
2505 | + if (isset($line['Icao'])) { |
|
2506 | + $data['hex'] = $line['Icao']; |
|
2507 | + } |
|
2508 | + // hex |
|
2509 | + if (isset($line['Call'])) { |
|
2510 | + $data['ident'] = $line['Call']; |
|
2511 | + } |
|
2512 | + // ident |
|
2513 | + if (isset($line['Alt'])) { |
|
2514 | + $data['altitude'] = $line['Alt']; |
|
2515 | + } |
|
2516 | + // altitude |
|
2517 | + if (isset($line['Spd'])) { |
|
2518 | + $data['speed'] = $line['Spd']; |
|
2519 | + } |
|
2520 | + // speed |
|
2521 | + if (isset($line['Trak'])) { |
|
2522 | + $data['heading'] = $line['Trak']; |
|
2523 | + } |
|
2524 | + // heading |
|
2525 | + if (isset($line['Lat'])) { |
|
2526 | + $data['latitude'] = $line['Lat']; |
|
2527 | + } |
|
2528 | + // lat |
|
2529 | + if (isset($line['Long'])) { |
|
2530 | + $data['longitude'] = $line['Long']; |
|
2531 | + } |
|
2532 | + // long |
|
1841 | 2533 | //$data['verticalrate'] = $line['']; // verticale rate |
1842 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
2534 | + if (isset($line['Sqk'])) { |
|
2535 | + $data['squawk'] = $line['Sqk']; |
|
2536 | + } |
|
2537 | + // squawk |
|
1843 | 2538 | $data['emergency'] = ''; // emergency |
1844 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
2539 | + if (isset($line['Reg'])) { |
|
2540 | + $data['registration'] = $line['Reg']; |
|
2541 | + } |
|
1845 | 2542 | /* |
1846 | 2543 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
1847 | 2544 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1848 | 2545 | */ |
1849 | 2546 | $data['datetime'] = date('Y-m-d H:i:s'); |
1850 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
2547 | + if (isset($line['Type'])) { |
|
2548 | + $data['aircraft_icao'] = $line['Type']; |
|
2549 | + } |
|
1851 | 2550 | $data['format_source'] = 'vrstcp'; |
1852 | 2551 | $data['id_source'] = $id_source; |
1853 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1854 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1855 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
2552 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2553 | + $data['noarchive'] = true; |
|
2554 | + } |
|
2555 | + if (isset($value['name']) && $value['name'] != '') { |
|
2556 | + $data['source_name'] = $value['name']; |
|
2557 | + } |
|
2558 | + if (isset($data['latitude']) && isset($data['hex'])) { |
|
2559 | + $SI->add($data); |
|
2560 | + } |
|
1856 | 2561 | unset($data); |
1857 | 2562 | } |
1858 | 2563 | } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
@@ -1865,22 +2570,46 @@ discard block |
||
1865 | 2570 | $data['hex'] = $lined['hexid']; |
1866 | 2571 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1867 | 2572 | $data['datetime'] = date('Y-m-d H:i:s');; |
1868 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1869 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1870 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1871 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1872 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1873 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1874 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
2573 | + if (isset($lined['ident'])) { |
|
2574 | + $data['ident'] = $lined['ident']; |
|
2575 | + } |
|
2576 | + if (isset($lined['lat'])) { |
|
2577 | + $data['latitude'] = $lined['lat']; |
|
2578 | + } |
|
2579 | + if (isset($lined['lon'])) { |
|
2580 | + $data['longitude'] = $lined['lon']; |
|
2581 | + } |
|
2582 | + if (isset($lined['speed'])) { |
|
2583 | + $data['speed'] = $lined['speed']; |
|
2584 | + } |
|
2585 | + if (isset($lined['squawk'])) { |
|
2586 | + $data['squawk'] = $lined['squawk']; |
|
2587 | + } |
|
2588 | + if (isset($lined['alt'])) { |
|
2589 | + $data['altitude'] = $lined['alt']; |
|
2590 | + } |
|
2591 | + if (isset($lined['heading'])) { |
|
2592 | + $data['heading'] = $lined['heading']; |
|
2593 | + } |
|
1875 | 2594 | $data['id_source'] = $id_source; |
1876 | 2595 | $data['format_source'] = 'tsv'; |
1877 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1878 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1879 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1880 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
2596 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2597 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2598 | + } |
|
2599 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2600 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2601 | + } |
|
2602 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2603 | + $data['noarchive'] = true; |
|
2604 | + } |
|
2605 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2606 | + $SI->add($data); |
|
2607 | + } |
|
1881 | 2608 | unset($lined); |
1882 | 2609 | unset($data); |
1883 | - } else $error = true; |
|
2610 | + } else { |
|
2611 | + $error = true; |
|
2612 | + } |
|
1884 | 2613 | } elseif ($format === 'aprs' && $use_aprs) { |
1885 | 2614 | if ($aprs_connect === 0) { |
1886 | 2615 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1906,47 +2635,96 @@ discard block |
||
1906 | 2635 | $aprs_last_tx = time(); |
1907 | 2636 | $data = array(); |
1908 | 2637 | //print_r($line); |
1909 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1910 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1911 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1912 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1913 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
1914 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
1915 | - if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
1916 | - if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
1917 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1918 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
2638 | + if (isset($line['address'])) { |
|
2639 | + $data['hex'] = $line['address']; |
|
2640 | + } |
|
2641 | + if (isset($line['mmsi'])) { |
|
2642 | + $data['mmsi'] = $line['mmsi']; |
|
2643 | + } |
|
2644 | + if (isset($line['imo'])) { |
|
2645 | + $data['imo'] = $line['imo']; |
|
2646 | + } |
|
2647 | + if (isset($line['squawk'])) { |
|
2648 | + $data['squawk'] = $line['squawk']; |
|
2649 | + } |
|
2650 | + if (isset($line['arrival_code'])) { |
|
2651 | + $data['arrival_code'] = $line['arrival_code']; |
|
2652 | + } |
|
2653 | + if (isset($line['arrival_date'])) { |
|
2654 | + $data['arrival_date'] = $line['arrival_date']; |
|
2655 | + } |
|
2656 | + if (isset($line['typeid'])) { |
|
2657 | + $data['type_id'] = $line['typeid']; |
|
2658 | + } |
|
2659 | + if (isset($line['statusid'])) { |
|
2660 | + $data['status_id'] = $line['statusid']; |
|
2661 | + } |
|
2662 | + if (isset($line['timestamp'])) { |
|
2663 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
2664 | + } else { |
|
2665 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
2666 | + } |
|
1919 | 2667 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1920 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
2668 | + if (isset($line['ident'])) { |
|
2669 | + $data['ident'] = $line['ident']; |
|
2670 | + } |
|
1921 | 2671 | $data['latitude'] = $line['latitude']; |
1922 | 2672 | $data['longitude'] = $line['longitude']; |
1923 | 2673 | //$data['verticalrate'] = $line[16]; |
1924 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
2674 | + if (isset($line['speed'])) { |
|
2675 | + $data['speed'] = $line['speed']; |
|
2676 | + } |
|
1925 | 2677 | //else $data['speed'] = 0; |
1926 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1927 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1928 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
2678 | + if (isset($line['altitude'])) { |
|
2679 | + $data['altitude'] = $line['altitude']; |
|
2680 | + } |
|
2681 | + if (isset($line['comment'])) { |
|
2682 | + $data['comment'] = $line['comment']; |
|
2683 | + } |
|
2684 | + if (isset($line['symbol'])) { |
|
2685 | + $data['type'] = $line['symbol']; |
|
2686 | + } |
|
1929 | 2687 | //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
1930 | 2688 | |
1931 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
2689 | + if (isset($line['heading']) && isset($line['format_source'])) { |
|
2690 | + $data['heading'] = $line['heading']; |
|
2691 | + } |
|
1932 | 2692 | //else echo 'No heading...'."\n"; |
1933 | 2693 | //else $data['heading'] = 0; |
1934 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
2694 | + if (isset($line['stealth'])) { |
|
2695 | + $data['aircraft_type'] = $line['stealth']; |
|
2696 | + } |
|
1935 | 2697 | //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
1936 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1937 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1938 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1939 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
2698 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) { |
|
2699 | + $data['noarchive'] = true; |
|
2700 | + } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) { |
|
2701 | + $data['noarchive'] = false; |
|
2702 | + } |
|
2703 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2704 | + $data['noarchive'] = true; |
|
2705 | + } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) { |
|
2706 | + $data['noarchive'] = false; |
|
2707 | + } |
|
1940 | 2708 | $data['id_source'] = $id_source; |
1941 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1942 | - else $data['format_source'] = 'aprs'; |
|
2709 | + if (isset($line['format_source'])) { |
|
2710 | + $data['format_source'] = $line['format_source']; |
|
2711 | + } else { |
|
2712 | + $data['format_source'] = 'aprs'; |
|
2713 | + } |
|
1943 | 2714 | $data['source_name'] = $line['source']; |
1944 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1945 | - else $data['source_type'] = 'flarm'; |
|
1946 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2715 | + if (isset($line['source_type'])) { |
|
2716 | + $data['source_type'] = $line['source_type']; |
|
2717 | + } else { |
|
2718 | + $data['source_type'] = 'flarm'; |
|
2719 | + } |
|
2720 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2721 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2722 | + } |
|
1947 | 2723 | $currentdate = date('Y-m-d H:i:s'); |
1948 | 2724 | $aprsdate = strtotime($data['datetime']); |
1949 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
2725 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') { |
|
2726 | + $data['altitude_relative'] = 'AMSL'; |
|
2727 | + } |
|
1950 | 2728 | // Accept data if time <= system time + 20s |
1951 | 2729 | //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'])))) { |
1952 | 2730 | if ( |
@@ -1958,7 +2736,9 @@ discard block |
||
1958 | 2736 | $send = $SI->add($data); |
1959 | 2737 | } elseif ($data['source_type'] === 'ais') { |
1960 | 2738 | $data['type'] = ''; |
1961 | - if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
|
2739 | + if (isset($globalMarine) && $globalMarine) { |
|
2740 | + $send = $MI->add($data); |
|
2741 | + } |
|
1962 | 2742 | } elseif (isset($line['stealth']) && $line['stealth'] != 0) { |
1963 | 2743 | echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
1964 | 2744 | } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
@@ -1966,8 +2746,12 @@ discard block |
||
1966 | 2746 | $line['symbol'] === 'Glider' || |
1967 | 2747 | $line['symbol'] === 'No. Plane' || |
1968 | 2748 | $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
1969 | - if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1970 | - if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
2749 | + if ($line['symbol'] === 'Ballon') { |
|
2750 | + $data['aircraft_icao'] = 'BALL'; |
|
2751 | + } |
|
2752 | + if ($line['symbol'] === 'Glider') { |
|
2753 | + $data['aircraft_icao'] = 'PARAGLIDER'; |
|
2754 | + } |
|
1971 | 2755 | $send = $SI->add($data); |
1972 | 2756 | } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
1973 | 2757 | $line['symbol'] === 'Yacht (Sail)' || |
@@ -1998,9 +2782,13 @@ discard block |
||
1998 | 2782 | //} 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') { |
1999 | 2783 | // } 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') { |
2000 | 2784 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
2001 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
2785 | + if (isset($globalTracker) && $globalTracker) { |
|
2786 | + $send = $TI->add($data); |
|
2787 | + } |
|
2002 | 2788 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
2003 | - if (!isset($data['altitude'])) $data['altitude'] = 0; |
|
2789 | + if (!isset($data['altitude'])) { |
|
2790 | + $data['altitude'] = 0; |
|
2791 | + } |
|
2004 | 2792 | $Source->deleteOldLocationByType('gs'); |
2005 | 2793 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
2006 | 2794 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
@@ -2009,7 +2797,9 @@ discard block |
||
2009 | 2797 | } |
2010 | 2798 | } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
2011 | 2799 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
2012 | - if ($globalDebug) echo '# Weather Station added'."\n"; |
|
2800 | + if ($globalDebug) { |
|
2801 | + echo '# Weather Station added'."\n"; |
|
2802 | + } |
|
2013 | 2803 | $Source->deleteOldLocationByType('wx'); |
2014 | 2804 | $weather_data = json_encode($line); |
2015 | 2805 | if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
@@ -2019,7 +2809,9 @@ discard block |
||
2019 | 2809 | } |
2020 | 2810 | } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
2021 | 2811 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
2022 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
2812 | + if ($globalDebug) { |
|
2813 | + echo '☈ Lightning added'."\n"; |
|
2814 | + } |
|
2023 | 2815 | $Source->deleteOldLocationByType('lightning'); |
2024 | 2816 | if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
2025 | 2817 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
@@ -2031,8 +2823,7 @@ discard block |
||
2031 | 2823 | print_r($line); |
2032 | 2824 | } |
2033 | 2825 | unset($data); |
2034 | - } |
|
2035 | - elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
2826 | + } elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
2036 | 2827 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
2037 | 2828 | } |
2038 | 2829 | /* |
@@ -2041,7 +2832,9 @@ discard block |
||
2041 | 2832 | } |
2042 | 2833 | */ |
2043 | 2834 | //elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
2044 | - elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
|
2835 | + elseif ($line === true && $globalDebug) { |
|
2836 | + echo '!! Failed : '.$buffer."!!\n"; |
|
2837 | + } |
|
2045 | 2838 | if (isset($Source) && isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
2046 | 2839 | $Source->deleteOldLocationByType('lightning'); |
2047 | 2840 | $Source->deleteOldLocationByType('wx'); |
@@ -2078,27 +2871,47 @@ discard block |
||
2078 | 2871 | $data['ground'] = $line[21]; |
2079 | 2872 | $data['emergency'] = $line[19]; |
2080 | 2873 | $data['format_source'] = 'sbs'; |
2081 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
2082 | - elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT'; |
|
2083 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2084 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
2874 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2875 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2876 | + } elseif ($line[0] == 'MLAT') { |
|
2877 | + $data['source_name'] = 'MLAT'; |
|
2878 | + } |
|
2879 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2880 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2881 | + } |
|
2882 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2883 | + $data['noarchive'] = true; |
|
2884 | + } |
|
2085 | 2885 | $data['id_source'] = $id_source; |
2086 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
2087 | - else $error = true; |
|
2886 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2887 | + $send = $SI->add($data); |
|
2888 | + } else { |
|
2889 | + $error = true; |
|
2890 | + } |
|
2088 | 2891 | unset($data); |
2089 | - } else $error = true; |
|
2892 | + } else { |
|
2893 | + $error = true; |
|
2894 | + } |
|
2090 | 2895 | if ($error) { |
2091 | 2896 | if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { |
2092 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
2897 | + if ($globalDebug) { |
|
2898 | + echo "Not a message. Ignoring... \n"; |
|
2899 | + } |
|
2093 | 2900 | } else { |
2094 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
2901 | + if ($globalDebug) { |
|
2902 | + echo "Wrong line format. Ignoring... \n"; |
|
2903 | + } |
|
2095 | 2904 | if ($globalDebug) { |
2096 | 2905 | echo $buffer; |
2097 | 2906 | //print_r($line); |
2098 | 2907 | } |
2099 | 2908 | //socket_close($r); |
2100 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
2101 | - if ($format === 'aprs') $aprs_connect = 0; |
|
2909 | + if ($globalDebug) { |
|
2910 | + echo "Reconnect after an error...\n"; |
|
2911 | + } |
|
2912 | + if ($format === 'aprs') { |
|
2913 | + $aprs_connect = 0; |
|
2914 | + } |
|
2102 | 2915 | $sourceer[$nb] = $globalSources[$nb]; |
2103 | 2916 | connect_all($sourceer); |
2104 | 2917 | $sourceer = array(); |
@@ -2106,10 +2919,14 @@ discard block |
||
2106 | 2919 | } |
2107 | 2920 | } |
2108 | 2921 | // Sleep for xxx microseconds |
2109 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
2922 | + if (isset($globalSBSSleep)) { |
|
2923 | + usleep($globalSBSSleep); |
|
2924 | + } |
|
2110 | 2925 | } else { |
2111 | 2926 | if ($format === 'flightgearmp') { |
2112 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
2927 | + if ($globalDebug) { |
|
2928 | + echo "Reconnect FlightGear MP..."; |
|
2929 | + } |
|
2113 | 2930 | //@socket_close($r); |
2114 | 2931 | sleep($globalMinFetch); |
2115 | 2932 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -2118,10 +2935,15 @@ discard block |
||
2118 | 2935 | break; |
2119 | 2936 | |
2120 | 2937 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
2121 | - if (isset($tt[$format])) $tt[$format]++; |
|
2122 | - else $tt[$format] = 0; |
|
2938 | + if (isset($tt[$format])) { |
|
2939 | + $tt[$format]++; |
|
2940 | + } else { |
|
2941 | + $tt[$format] = 0; |
|
2942 | + } |
|
2123 | 2943 | if ($tt[$format] > 30 || $buffer === FALSE) { |
2124 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
2944 | + if ($globalDebug) { |
|
2945 | + echo "ERROR : Reconnect ".$format."..."; |
|
2946 | + } |
|
2125 | 2947 | //@socket_close($r); |
2126 | 2948 | sleep(2); |
2127 | 2949 | $aprs_connect = 0; |
@@ -2139,11 +2961,17 @@ discard block |
||
2139 | 2961 | } else { |
2140 | 2962 | $error = socket_strerror(socket_last_error()); |
2141 | 2963 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
2142 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
2143 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
2964 | + if ($globalDebug) { |
|
2965 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
2966 | + } |
|
2967 | + if (isset($globalDebug)) { |
|
2968 | + echo "Restarting...\n"; |
|
2969 | + } |
|
2144 | 2970 | // Restart the script if possible |
2145 | 2971 | if (is_array($sockets)) { |
2146 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
2972 | + if ($globalDebug) { |
|
2973 | + echo "Shutdown all sockets..."; |
|
2974 | + } |
|
2147 | 2975 | |
2148 | 2976 | foreach ($sockets as $sock) { |
2149 | 2977 | @socket_shutdown($sock,2); |
@@ -2151,23 +2979,39 @@ discard block |
||
2151 | 2979 | } |
2152 | 2980 | |
2153 | 2981 | } |
2154 | - if ($globalDebug) echo "Waiting..."; |
|
2982 | + if ($globalDebug) { |
|
2983 | + echo "Waiting..."; |
|
2984 | + } |
|
2155 | 2985 | sleep(2); |
2156 | 2986 | $time = time(); |
2157 | 2987 | //connect_all($hosts); |
2158 | 2988 | $aprs_connect = 0; |
2159 | - if ($reset%5 === 0) sleep(20); |
|
2160 | - if ($reset > 100) exit('Too many attempts...'); |
|
2161 | - if ($globalDebug) echo "Restart all connections..."; |
|
2989 | + if ($reset%5 === 0) { |
|
2990 | + sleep(20); |
|
2991 | + } |
|
2992 | + if ($reset > 100) { |
|
2993 | + exit('Too many attempts...'); |
|
2994 | + } |
|
2995 | + if ($globalDebug) { |
|
2996 | + echo "Restart all connections..."; |
|
2997 | + } |
|
2162 | 2998 | connect_all($globalSources); |
2163 | 2999 | } |
2164 | 3000 | } |
2165 | 3001 | } |
2166 | 3002 | if ($globalDaemon === false) { |
2167 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
2168 | - if (isset($SI)) $SI->checkAll(); |
|
2169 | - if (isset($TI)) $TI->checkAll(); |
|
2170 | - if (isset($MI)) $MI->checkAll(); |
|
3003 | + if ($globalDebug) { |
|
3004 | + echo 'Check all...'."\n"; |
|
3005 | + } |
|
3006 | + if (isset($SI)) { |
|
3007 | + $SI->checkAll(); |
|
3008 | + } |
|
3009 | + if (isset($TI)) { |
|
3010 | + $TI->checkAll(); |
|
3011 | + } |
|
3012 | + if (isset($MI)) { |
|
3013 | + $MI->checkAll(); |
|
3014 | + } |
|
2171 | 3015 | } |
2172 | 3016 | } |
2173 | 3017 | } |