@@ -2,10 +2,10 @@ discard block |
||
2 | 2 | require_once(dirname(__FILE__).'/settings.php'); |
3 | 3 | require_once(dirname(__FILE__).'/class.Common.php'); |
4 | 4 | class aprs { |
5 | - private $socket; |
|
6 | - private $connected = false; |
|
5 | + private $socket; |
|
6 | + private $connected = false; |
|
7 | 7 | |
8 | - protected $symbols = array('!' => 'Police', |
|
8 | + protected $symbols = array('!' => 'Police', |
|
9 | 9 | '#' => 'DIGI', |
10 | 10 | '$' => 'Phone', |
11 | 11 | '%' => 'DX Cluster', |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | 'y' => 'Yagi At QTH'); |
90 | 90 | |
91 | 91 | |
92 | - private function urshift($n, $s) { |
|
92 | + private function urshift($n, $s) { |
|
93 | 93 | return ($n >= 0) ? ($n >> $s) : |
94 | - (($n & 0x7fffffff) >> $s) | |
|
94 | + (($n & 0x7fffffff) >> $s) | |
|
95 | 95 | (0x40000000 >> ($s - 1)); |
96 | - } |
|
96 | + } |
|
97 | 97 | |
98 | - public function parse($input) { |
|
98 | + public function parse($input) { |
|
99 | 99 | global $globalDebug; |
100 | 100 | $debug = false; |
101 | 101 | $result = array(); |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | |
108 | 108 | /* Check that end was found and body has at least one byte. */ |
109 | 109 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
110 | - if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; |
|
111 | - return false; |
|
110 | + if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; |
|
111 | + return false; |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | if ($debug) echo 'input : '.$input."\n"; |
@@ -122,31 +122,31 @@ discard block |
||
122 | 122 | /* Parse source, target and path. */ |
123 | 123 | //FLRDF0A52>APRS,qAS,LSTB |
124 | 124 | if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) { |
125 | - $ident = $matches[1]; |
|
126 | - $all_elements = $matches[2]; |
|
127 | - if ($ident == 'AIRCRAFT') { |
|
125 | + $ident = $matches[1]; |
|
126 | + $all_elements = $matches[2]; |
|
127 | + if ($ident == 'AIRCRAFT') { |
|
128 | 128 | $result['format_source'] = 'famaprs'; |
129 | 129 | $result['source_type'] = 'modes'; |
130 | - } elseif ($ident == 'MARINE') { |
|
130 | + } elseif ($ident == 'MARINE') { |
|
131 | 131 | $result['format_source'] = 'famaprs'; |
132 | 132 | $result['source_type'] = 'ais'; |
133 | - } else { |
|
133 | + } else { |
|
134 | 134 | if ($debug) echo 'ident : '.$ident."\n"; |
135 | 135 | $result['ident'] = $ident; |
136 | - } |
|
136 | + } |
|
137 | 137 | } else return false; |
138 | 138 | $elements = explode(',',$all_elements); |
139 | 139 | $source = end($elements); |
140 | 140 | $result['source'] = $source; |
141 | 141 | foreach ($elements as $element) { |
142 | - if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
143 | - //echo "ok"; |
|
144 | - //if ($element == 'TCPIP*') return false; |
|
145 | - } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
142 | + if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
143 | + //echo "ok"; |
|
144 | + //if ($element == 'TCPIP*') return false; |
|
145 | + } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
146 | 146 | if ($debug) echo 'element : '.$element."\n"; |
147 | 147 | return false; |
148 | - } |
|
149 | - /* |
|
148 | + } |
|
149 | + /* |
|
150 | 150 | } elseif (preg_match('/^([0-9A-F]{32})$/',$element)) { |
151 | 151 | //echo "ok"; |
152 | 152 | } else { |
@@ -171,49 +171,49 @@ discard block |
||
171 | 171 | $body_parse = substr($body,1); |
172 | 172 | //echo 'Body : '.$body."\n"; |
173 | 173 | if (preg_match('/^;(.){9}\*/',$body,$matches)) { |
174 | - $body_parse = substr($body_parse,10); |
|
175 | - $find = true; |
|
176 | - //echo $body_parse."\n"; |
|
174 | + $body_parse = substr($body_parse,10); |
|
175 | + $find = true; |
|
176 | + //echo $body_parse."\n"; |
|
177 | 177 | } |
178 | 178 | if (preg_match('/^`(.*)\//',$body,$matches)) { |
179 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
180 | - $find = true; |
|
181 | - //echo $body_parse."\n"; |
|
179 | + $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
180 | + $find = true; |
|
181 | + //echo $body_parse."\n"; |
|
182 | 182 | } |
183 | 183 | if (preg_match("/^'(.*)\//",$body,$matches)) { |
184 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
185 | - $find = true; |
|
186 | - //echo $body_parse."\n"; |
|
184 | + $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
185 | + $find = true; |
|
186 | + //echo $body_parse."\n"; |
|
187 | 187 | } |
188 | 188 | if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) { |
189 | - $find = true; |
|
190 | - //print_r($matches); |
|
191 | - $timestamp = $matches[0]; |
|
192 | - if ($matches[4] == 'h') { |
|
189 | + $find = true; |
|
190 | + //print_r($matches); |
|
191 | + $timestamp = $matches[0]; |
|
192 | + if ($matches[4] == 'h') { |
|
193 | 193 | $timestamp = strtotime($matches[1].':'.$matches[2].':'.$matches[3]); |
194 | 194 | //echo 'timestamp : '.$timestamp.' - now : '.time()."\n"; |
195 | 195 | /* |
196 | 196 | if (time() + 3900 < $timestamp) $timestamp -= 86400; |
197 | 197 | elseif (time() - 82500 > $timestamp) $timestamp += 86400; |
198 | 198 | */ |
199 | - } elseif ($matches[4] == 'z' || $matches[4] == '/') { |
|
199 | + } elseif ($matches[4] == 'z' || $matches[4] == '/') { |
|
200 | 200 | // This work or not ? |
201 | 201 | $timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]); |
202 | - } |
|
203 | - $body_parse = substr($body_parse,7); |
|
204 | - $result['timestamp'] = $timestamp; |
|
205 | - //echo date('Ymd H:i:s',$timestamp); |
|
202 | + } |
|
203 | + $body_parse = substr($body_parse,7); |
|
204 | + $result['timestamp'] = $timestamp; |
|
205 | + //echo date('Ymd H:i:s',$timestamp); |
|
206 | 206 | } |
207 | 207 | if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) { |
208 | - $find = true; |
|
209 | - $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); |
|
210 | - $body_parse = substr($body_parse,8); |
|
211 | - $result['timestamp'] = $timestamp; |
|
212 | - //echo date('Ymd H:i:s',$timestamp); |
|
208 | + $find = true; |
|
209 | + $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); |
|
210 | + $body_parse = substr($body_parse,8); |
|
211 | + $result['timestamp'] = $timestamp; |
|
212 | + //echo date('Ymd H:i:s',$timestamp); |
|
213 | 213 | } |
214 | 214 | //if (strlen($body_parse) > 19) { |
215 | - if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) { |
|
216 | - $find = true; |
|
215 | + if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) { |
|
216 | + $find = true; |
|
217 | 217 | // 4658.70N/00707.78Ez |
218 | 218 | //print_r(str_split($body_parse)); |
219 | 219 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $lon = intval($lon_deg); |
231 | 231 | if ($lat > 89 || $lon > 179) return false; |
232 | 232 | |
233 | - /* |
|
233 | + /* |
|
234 | 234 | $tmp_5b = str_replace('.','',$lat_min); |
235 | 235 | if (preg_match('/^([0-9]{0,4})( {0,4})$/',$tmp_5b,$matches)) { |
236 | 236 | print_r($matches); |
@@ -244,9 +244,9 @@ discard block |
||
244 | 244 | $result['longitude'] = $longitude; |
245 | 245 | $body_parse = substr($body_parse,18); |
246 | 246 | $body_parse_len = strlen($body_parse); |
247 | - } |
|
248 | - $body_parse_len = strlen($body_parse); |
|
249 | - if ($body_parse_len > 0) { |
|
247 | + } |
|
248 | + $body_parse_len = strlen($body_parse); |
|
249 | + if ($body_parse_len > 0) { |
|
250 | 250 | /* |
251 | 251 | if (!isset($result['timestamp']) && !isset($result['latitude'])) { |
252 | 252 | $body_split = str_split($body); |
@@ -276,89 +276,89 @@ discard block |
||
276 | 276 | if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; |
277 | 277 | if ($symbol_code != '_') { |
278 | 278 | } |
279 | - //$body_parse = substr($body_parse,1); |
|
280 | - //$body_parse = trim($body_parse); |
|
281 | - //$body_parse_len = strlen($body_parse); |
|
282 | - if ($body_parse_len >= 7) { |
|
279 | + //$body_parse = substr($body_parse,1); |
|
280 | + //$body_parse = trim($body_parse); |
|
281 | + //$body_parse_len = strlen($body_parse); |
|
282 | + if ($body_parse_len >= 7) { |
|
283 | 283 | |
284 | - if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
285 | - $course = substr($body_parse,0,3); |
|
286 | - $tmp_s = intval($course); |
|
287 | - if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
|
288 | - $speed = substr($body_parse,4,3); |
|
289 | - if ($speed != '...') { |
|
290 | - //$result['speed'] = round($speed*1.852); |
|
291 | - $result['speed'] = intval($speed); |
|
292 | - } |
|
293 | - $body_parse = substr($body_parse,7); |
|
294 | - } |
|
295 | - // Check PHGR, PHG, RNG |
|
296 | - } |
|
297 | - /* |
|
284 | + if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
285 | + $course = substr($body_parse,0,3); |
|
286 | + $tmp_s = intval($course); |
|
287 | + if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
|
288 | + $speed = substr($body_parse,4,3); |
|
289 | + if ($speed != '...') { |
|
290 | + //$result['speed'] = round($speed*1.852); |
|
291 | + $result['speed'] = intval($speed); |
|
292 | + } |
|
293 | + $body_parse = substr($body_parse,7); |
|
294 | + } |
|
295 | + // Check PHGR, PHG, RNG |
|
296 | + } |
|
297 | + /* |
|
298 | 298 | else if ($body_parse_len > 0) { |
299 | 299 | $rest = $body_parse; |
300 | 300 | } |
301 | 301 | */ |
302 | - if (strlen($body_parse) > 0) { |
|
303 | - if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
304 | - $altitude = intval($matches[1]); |
|
305 | - //$result['altitude'] = round($altitude*0.3048); |
|
306 | - $result['altitude'] = $altitude; |
|
307 | - //$body_parse = trim(substr($body_parse,strlen($matches[0]))); |
|
308 | - $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); |
|
309 | - } |
|
310 | - } |
|
302 | + if (strlen($body_parse) > 0) { |
|
303 | + if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
304 | + $altitude = intval($matches[1]); |
|
305 | + //$result['altitude'] = round($altitude*0.3048); |
|
306 | + $result['altitude'] = $altitude; |
|
307 | + //$body_parse = trim(substr($body_parse,strlen($matches[0]))); |
|
308 | + $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); |
|
309 | + } |
|
310 | + } |
|
311 | 311 | |
312 | - // Telemetry |
|
313 | - /* |
|
312 | + // Telemetry |
|
313 | + /* |
|
314 | 314 | if (preg_match('/^([0-9]+),(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,([01]{0,8})/',$body_parse,$matches)) { |
315 | 315 | // Nothing yet... |
316 | 316 | } |
317 | 317 | */ |
318 | - // DAO |
|
318 | + // DAO |
|
319 | 319 | |
320 | - if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
320 | + if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
321 | 321 | |
322 | - $dao = $matches[1]; |
|
323 | - if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
322 | + $dao = $matches[1]; |
|
323 | + if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
324 | 324 | $dao_split = str_split($dao); |
325 | - $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
|
326 | - $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
|
325 | + $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
|
326 | + $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
|
327 | 327 | |
328 | 328 | if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
329 | 329 | else $result['latitude'] += $lat_off; |
330 | 330 | if ($result['longitude'] < 0) $result['longitude'] -= $lon_off; |
331 | 331 | else $result['longitude'] += $lon_off; |
332 | - } |
|
332 | + } |
|
333 | 333 | |
334 | - $body_parse = substr($body_parse,6); |
|
335 | - } |
|
334 | + $body_parse = substr($body_parse,6); |
|
335 | + } |
|
336 | 336 | |
337 | - if (preg_match('/CS=([0-9A-Z]*)/',$body_parse,$matches)) { |
|
337 | + if (preg_match('/CS=([0-9A-Z]*)/',$body_parse,$matches)) { |
|
338 | 338 | $result['ident'] = $matches[1]; |
339 | - } |
|
340 | - if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { |
|
339 | + } |
|
340 | + if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { |
|
341 | 341 | $result['squawk'] = $matches[1]; |
342 | - } |
|
343 | - if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { |
|
342 | + } |
|
343 | + if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { |
|
344 | 344 | $result['aircraft_icao'] = $matches[1]; |
345 | - } |
|
346 | - if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { |
|
345 | + } |
|
346 | + if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { |
|
347 | 347 | $result['typeid'] = $matches[1]; |
348 | - } |
|
349 | - if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { |
|
348 | + } |
|
349 | + if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { |
|
350 | 350 | $result['imo'] = $matches[1]; |
351 | - } |
|
352 | - if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { |
|
351 | + } |
|
352 | + if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { |
|
353 | 353 | $result['arrival_date'] = $matches[1]; |
354 | - } |
|
355 | - if (preg_match('/AC=([0-9A-Z]*)/',$body_parse,$matches)) { |
|
354 | + } |
|
355 | + if (preg_match('/AC=([0-9A-Z]*)/',$body_parse,$matches)) { |
|
356 | 356 | $result['arrival_code'] = $matches[1]; |
357 | - } |
|
358 | - // OGN comment |
|
357 | + } |
|
358 | + // OGN comment |
|
359 | 359 | // echo "Before OGN : ".$body_parse."\n"; |
360 | - //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
|
361 | - if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { |
|
360 | + //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
|
361 | + if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { |
|
362 | 362 | $id = $matches[1]; |
363 | 363 | //$mode = substr($id,0,2); |
364 | 364 | $address = substr($id,2); |
@@ -388,53 +388,53 @@ discard block |
||
388 | 388 | $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
389 | 389 | $result['stealth'] = $stealth; |
390 | 390 | $result['address'] = $address; |
391 | - } |
|
391 | + } |
|
392 | 392 | |
393 | - //Comment |
|
394 | - $result['comment'] = trim($body_parse); |
|
393 | + //Comment |
|
394 | + $result['comment'] = trim($body_parse); |
|
395 | 395 | } else { |
396 | - // parse weather |
|
397 | - //$body_parse = substr($body_parse,1); |
|
398 | - //$body_parse_len = strlen($body_parse); |
|
396 | + // parse weather |
|
397 | + //$body_parse = substr($body_parse,1); |
|
398 | + //$body_parse_len = strlen($body_parse); |
|
399 | 399 | |
400 | - if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
401 | - $result['wind_dir'] = intval($matches[1]); |
|
402 | - $result['wind_speed'] = round(intval($matches[2])*1.60934,1); |
|
403 | - $result['wind_gust'] = round(intval($matches[3])*1.60934,1); |
|
404 | - $result['temp'] = round(5/9*((intval($matches[4]))-32),1); |
|
405 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
406 | - } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
400 | + if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
401 | + $result['wind_dir'] = intval($matches[1]); |
|
402 | + $result['wind_speed'] = round(intval($matches[2])*1.60934,1); |
|
403 | + $result['wind_gust'] = round(intval($matches[3])*1.60934,1); |
|
404 | + $result['temp'] = round(5/9*((intval($matches[4]))-32),1); |
|
405 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
406 | + } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
407 | 407 | $result['wind_dir'] = intval($matches[1]); |
408 | 408 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
409 | 409 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
410 | 410 | $result['temp'] = round(5/9*(($matches[4])-32),1); |
411 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
412 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
411 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
412 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
413 | 413 | $result['wind_dir'] = intval($matches[1]); |
414 | 414 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
415 | 415 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
416 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
417 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { |
|
416 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
417 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { |
|
418 | 418 | $result['wind_dir'] = intval($matches[1]); |
419 | 419 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
420 | 420 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
421 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
422 | - } |
|
423 | - if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
|
421 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
422 | + } |
|
423 | + if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
|
424 | 424 | $result['temp'] = round(5/9*(($matches[1])-32),1); |
425 | - } |
|
425 | + } |
|
426 | 426 | } |
427 | 427 | } else $result['comment'] = trim($body_parse); |
428 | 428 | |
429 | - } |
|
429 | + } |
|
430 | 430 | //} |
431 | 431 | if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
432 | 432 | if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
433 | 433 | if ($debug) print_r($result); |
434 | 434 | return $result; |
435 | - } |
|
435 | + } |
|
436 | 436 | |
437 | - public function connect() { |
|
437 | + public function connect() { |
|
438 | 438 | global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport; |
439 | 439 | $aprs_connect = 0; |
440 | 440 | $aprs_keep = 120; |
@@ -457,32 +457,32 @@ discard block |
||
457 | 457 | $send = socket_send( $this->socket , $aprs_login , strlen($aprs_login) , 0 ); |
458 | 458 | while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) { |
459 | 459 | if (strpos($msgin, "$aprs_ssid verified") !== FALSE) { |
460 | - echo 'APRS user verified !'."\n"; |
|
461 | - $this->connected = true; |
|
462 | - return true; |
|
463 | - break; |
|
460 | + echo 'APRS user verified !'."\n"; |
|
461 | + $this->connected = true; |
|
462 | + return true; |
|
463 | + break; |
|
464 | 464 | } |
465 | 465 | if (time()-$authstart > 5) { |
466 | - echo 'APRS timeout'."\n"; |
|
467 | - break; |
|
466 | + echo 'APRS timeout'."\n"; |
|
467 | + break; |
|
468 | 468 | } |
469 | 469 | } |
470 | 470 | socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE); |
471 | 471 | } |
472 | - } |
|
472 | + } |
|
473 | 473 | |
474 | - public function disconnect() { |
|
474 | + public function disconnect() { |
|
475 | 475 | socket_close($this->socket); |
476 | - } |
|
476 | + } |
|
477 | 477 | |
478 | - public function send($data) { |
|
478 | + public function send($data) { |
|
479 | 479 | if ($this->connected === false) $this->connect(); |
480 | 480 | $send = socket_send( $this->socket , $data , strlen($data),0); |
481 | 481 | if ($send === FALSE) { |
482 | 482 | socket_close($this->socket); |
483 | 483 | $this->connect(); |
484 | 484 | } |
485 | - } |
|
485 | + } |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | class APRSSpotter extends APRS { |
@@ -3,8 +3,8 @@ |
||
3 | 3 | require_once('require/class.Spotter.php'); |
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | if (!isset($_GET['country'])) { |
6 | - header('Location: '.$globalURL.'/country'); |
|
7 | - die(); |
|
6 | + header('Location: '.$globalURL.'/country'); |
|
7 | + die(); |
|
8 | 8 | } |
9 | 9 | $Spotter = new Spotter(); |
10 | 10 | $country = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'country',FILTER_SANITIZE_STRING))); |
@@ -3,8 +3,8 @@ discard block |
||
3 | 3 | require_once('require/class.Spotter.php'); |
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | if (!isset($_GET['country'])) { |
6 | - header('Location: '.$globalURL.'/country'); |
|
7 | - die(); |
|
6 | + header('Location: '.$globalURL.'/country'); |
|
7 | + die(); |
|
8 | 8 | } |
9 | 9 | $Spotter = new Spotter(); |
10 | 10 | $country = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'country',FILTER_SANITIZE_STRING))); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | include('country-sub-menu.php'); |
52 | 52 | print '<div class="column">'; |
53 | 53 | print '<h2>'._("Most Common Arrival Airports by Country").'</h2>'; |
54 | - print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights of airports & airlines from <strong>%s</strong>."),$country).'</p>'; |
|
54 | + print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights of airports & airlines from <strong>%s</strong>."),$country).'</p>'; |
|
55 | 55 | |
56 | 56 | $airport_country_array = $Spotter->countAllArrivalAirportCountriesByCountry($country); |
57 | 57 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
@@ -12,11 +12,11 @@ discard block |
||
12 | 12 | } |
13 | 13 | |
14 | 14 | /** |
15 | - * Gets the images based on the aircraft registration |
|
16 | - * |
|
17 | - * @return Array the images list |
|
18 | - * |
|
19 | - */ |
|
15 | + * Gets the images based on the aircraft registration |
|
16 | + * |
|
17 | + * @return Array the images list |
|
18 | + * |
|
19 | + */ |
|
20 | 20 | public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
21 | 21 | { |
22 | 22 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
@@ -36,11 +36,11 @@ discard block |
||
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
39 | - * Gets the image copyright based on the Exif data |
|
40 | - * |
|
41 | - * @return String image copyright |
|
42 | - * |
|
43 | - */ |
|
39 | + * Gets the image copyright based on the Exif data |
|
40 | + * |
|
41 | + * @return String image copyright |
|
42 | + * |
|
43 | + */ |
|
44 | 44 | public function getExifCopyright($url) { |
45 | 45 | $exif = exif_read_data($url); |
46 | 46 | $copyright = ''; |
@@ -55,11 +55,11 @@ discard block |
||
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
58 | - * Adds the images based on the aircraft registration |
|
59 | - * |
|
60 | - * @return String either success or error |
|
61 | - * |
|
62 | - */ |
|
58 | + * Adds the images based on the aircraft registration |
|
59 | + * |
|
60 | + * @return String either success or error |
|
61 | + * |
|
62 | + */ |
|
63 | 63 | public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
64 | 64 | { |
65 | 65 | global $globalDebug,$globalAircraftImageFetch; |
@@ -88,12 +88,12 @@ discard block |
||
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
91 | - * Gets the aircraft image |
|
92 | - * |
|
93 | - * @param String $aircraft_registration the registration of the aircraft |
|
94 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
95 | - * |
|
96 | - */ |
|
91 | + * Gets the aircraft image |
|
92 | + * |
|
93 | + * @param String $aircraft_registration the registration of the aircraft |
|
94 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
95 | + * |
|
96 | + */ |
|
97 | 97 | public function findAircraftImage($aircraft_registration, $aircraft_icao = '', $airline_icao = '') |
98 | 98 | { |
99 | 99 | global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO; |
@@ -136,13 +136,13 @@ discard block |
||
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
139 | - * Gets the aircraft image from Planespotters |
|
140 | - * |
|
141 | - * @param String $aircraft_registration the registration of the aircraft |
|
142 | - * @param String $aircraft_name type of the aircraft |
|
143 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
144 | - * |
|
145 | - */ |
|
139 | + * Gets the aircraft image from Planespotters |
|
140 | + * |
|
141 | + * @param String $aircraft_registration the registration of the aircraft |
|
142 | + * @param String $aircraft_name type of the aircraft |
|
143 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
144 | + * |
|
145 | + */ |
|
146 | 146 | public function fromPlanespotters($aircraft_registration, $aircraft_name='') { |
147 | 147 | $Common = new Common(); |
148 | 148 | // If aircraft registration is only number, also check with aircraft model |
@@ -169,13 +169,13 @@ discard block |
||
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
172 | - * Gets the aircraft image from Deviantart |
|
173 | - * |
|
174 | - * @param String $aircraft_registration the registration of the aircraft |
|
175 | - * @param String $aircraft_name type of the aircraft |
|
176 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
177 | - * |
|
178 | - */ |
|
172 | + * Gets the aircraft image from Deviantart |
|
173 | + * |
|
174 | + * @param String $aircraft_registration the registration of the aircraft |
|
175 | + * @param String $aircraft_name type of the aircraft |
|
176 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
177 | + * |
|
178 | + */ |
|
179 | 179 | public function fromDeviantart($aircraft_registration, $aircraft_name='') { |
180 | 180 | $Common = new Common(); |
181 | 181 | // If aircraft registration is only number, also check with aircraft model |
@@ -203,13 +203,13 @@ discard block |
||
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
206 | - * Gets the aircraft image from JetPhotos |
|
207 | - * |
|
208 | - * @param String $aircraft_registration the registration of the aircraft |
|
209 | - * @param String $aircraft_name type of the aircraft |
|
210 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
211 | - * |
|
212 | - */ |
|
206 | + * Gets the aircraft image from JetPhotos |
|
207 | + * |
|
208 | + * @param String $aircraft_registration the registration of the aircraft |
|
209 | + * @param String $aircraft_name type of the aircraft |
|
210 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
211 | + * |
|
212 | + */ |
|
213 | 213 | public function fromJetPhotos($aircraft_registration, $aircraft_name='') { |
214 | 214 | $Common = new Common(); |
215 | 215 | $url= 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
@@ -245,13 +245,13 @@ discard block |
||
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
248 | - * Gets the aircraft image from PlanePictures |
|
249 | - * |
|
250 | - * @param String $aircraft_registration the registration of the aircraft |
|
251 | - * @param String $aircraft_name type of the aircraft |
|
252 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
253 | - * |
|
254 | - */ |
|
248 | + * Gets the aircraft image from PlanePictures |
|
249 | + * |
|
250 | + * @param String $aircraft_registration the registration of the aircraft |
|
251 | + * @param String $aircraft_name type of the aircraft |
|
252 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
253 | + * |
|
254 | + */ |
|
255 | 255 | public function fromPlanePictures($aircraft_registration, $aircraft_name='') { |
256 | 256 | $Common = new Common(); |
257 | 257 | $url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
@@ -279,13 +279,13 @@ discard block |
||
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
282 | - * Gets the aircraft image from Flickr |
|
283 | - * |
|
284 | - * @param String $aircraft_registration the registration of the aircraft |
|
285 | - * @param String $aircraft_name type of the aircraft |
|
286 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
287 | - * |
|
288 | - */ |
|
282 | + * Gets the aircraft image from Flickr |
|
283 | + * |
|
284 | + * @param String $aircraft_registration the registration of the aircraft |
|
285 | + * @param String $aircraft_name type of the aircraft |
|
286 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
287 | + * |
|
288 | + */ |
|
289 | 289 | public function fromFlickr($aircraft_registration,$aircraft_name='') { |
290 | 290 | $Common = new Common(); |
291 | 291 | if ($aircraft_name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.','.urlencode($aircraft_name); |
@@ -323,13 +323,13 @@ discard block |
||
323 | 323 | } |
324 | 324 | |
325 | 325 | /** |
326 | - * Gets the aircraft image from Bing |
|
327 | - * |
|
328 | - * @param String $aircraft_registration the registration of the aircraft |
|
329 | - * @param String $aircraft_name type of the aircraft |
|
330 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
331 | - * |
|
332 | - */ |
|
326 | + * Gets the aircraft image from Bing |
|
327 | + * |
|
328 | + * @param String $aircraft_registration the registration of the aircraft |
|
329 | + * @param String $aircraft_name type of the aircraft |
|
330 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
331 | + * |
|
332 | + */ |
|
333 | 333 | public function fromBing($aircraft_registration,$aircraft_name='') { |
334 | 334 | global $globalImageBingKey; |
335 | 335 | $Common = new Common(); |
@@ -355,13 +355,13 @@ discard block |
||
355 | 355 | } |
356 | 356 | |
357 | 357 | /** |
358 | - * Gets the aircraft image from airport-data |
|
359 | - * |
|
360 | - * @param String $aircraft_registration the registration of the aircraft |
|
361 | - * @param String $aircraft_name type of the aircraft |
|
362 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
363 | - * |
|
364 | - */ |
|
358 | + * Gets the aircraft image from airport-data |
|
359 | + * |
|
360 | + * @param String $aircraft_registration the registration of the aircraft |
|
361 | + * @param String $aircraft_name type of the aircraft |
|
362 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
363 | + * |
|
364 | + */ |
|
365 | 365 | public function fromAirportData($aircraft_registration,$aircraft_name='') { |
366 | 366 | $Common = new Common(); |
367 | 367 | $url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration; |
@@ -380,13 +380,13 @@ discard block |
||
380 | 380 | } |
381 | 381 | |
382 | 382 | /** |
383 | - * Gets the aircraft image from WikiMedia |
|
384 | - * |
|
385 | - * @param String $aircraft_registration the registration of the aircraft |
|
386 | - * @param String $aircraft_name type of the aircraft |
|
387 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
388 | - * |
|
389 | - */ |
|
383 | + * Gets the aircraft image from WikiMedia |
|
384 | + * |
|
385 | + * @param String $aircraft_registration the registration of the aircraft |
|
386 | + * @param String $aircraft_name type of the aircraft |
|
387 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
388 | + * |
|
389 | + */ |
|
390 | 390 | public function fromWikimedia($aircraft_registration,$aircraft_name='') { |
391 | 391 | $Common = new Common(); |
392 | 392 | if ($aircraft_name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20'.urlencode($aircraft_name); |
@@ -436,13 +436,13 @@ discard block |
||
436 | 436 | } |
437 | 437 | |
438 | 438 | /** |
439 | - * Gets the aircraft image from custom url |
|
440 | - * |
|
441 | - * @param String $aircraft_registration the registration of the aircraft |
|
442 | - * @param String $aircraft_name type of the aircraft |
|
443 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
444 | - * |
|
445 | - */ |
|
439 | + * Gets the aircraft image from custom url |
|
440 | + * |
|
441 | + * @param String $aircraft_registration the registration of the aircraft |
|
442 | + * @param String $aircraft_name type of the aircraft |
|
443 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
444 | + * |
|
445 | + */ |
|
446 | 446 | public function fromCustomSource($aircraft_registration,$aircraft_name='') { |
447 | 447 | global $globalAircraftImageCustomSources, $globalDebug; |
448 | 448 | //$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true); |
@@ -7,13 +7,13 @@ discard block |
||
7 | 7 | //protected $cookies = array(); |
8 | 8 | |
9 | 9 | /** |
10 | - * Get data from form result |
|
11 | - * @param String $url form URL |
|
12 | - * @param String $type type of submit form method (get or post) |
|
13 | - * @param String|Array $data values form post method |
|
14 | - * @param Array $headers header to submit with the form |
|
15 | - * @return String the result |
|
16 | - */ |
|
10 | + * Get data from form result |
|
11 | + * @param String $url form URL |
|
12 | + * @param String $type type of submit form method (get or post) |
|
13 | + * @param String|Array $data values form post method |
|
14 | + * @param Array $headers header to submit with the form |
|
15 | + * @return String the result |
|
16 | + */ |
|
17 | 17 | public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '') { |
18 | 18 | global $globalProxy, $globalForceIPv4; |
19 | 19 | $ch = curl_init(); |
@@ -107,10 +107,10 @@ discard block |
||
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
110 | - * Convert a HTML table to an array |
|
111 | - * @param String $data HTML page |
|
112 | - * @return Array array of the tables in HTML page |
|
113 | - */ |
|
110 | + * Convert a HTML table to an array |
|
111 | + * @param String $data HTML page |
|
112 | + * @return Array array of the tables in HTML page |
|
113 | + */ |
|
114 | 114 | public function table2array($data) { |
115 | 115 | if (!is_string($data)) return array(); |
116 | 116 | if ($data == '') return array(); |
@@ -144,10 +144,10 @@ discard block |
||
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
147 | - * Convert <p> part of a HTML page to an array |
|
148 | - * @param String $data HTML page |
|
149 | - * @return Array array of the <p> in HTML page |
|
150 | - */ |
|
147 | + * Convert <p> part of a HTML page to an array |
|
148 | + * @param String $data HTML page |
|
149 | + * @return Array array of the <p> in HTML page |
|
150 | + */ |
|
151 | 151 | public function text2array($data) { |
152 | 152 | $html = str_get_html($data); |
153 | 153 | if ($html === false) return array(); |
@@ -162,14 +162,14 @@ discard block |
||
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
165 | - * Give distance between 2 coordonnates |
|
166 | - * @param Float $lat latitude of first point |
|
167 | - * @param Float $lon longitude of first point |
|
168 | - * @param Float $latc latitude of second point |
|
169 | - * @param Float $lonc longitude of second point |
|
170 | - * @param String $unit km else no unit used |
|
171 | - * @return Float Distance in $unit |
|
172 | - */ |
|
165 | + * Give distance between 2 coordonnates |
|
166 | + * @param Float $lat latitude of first point |
|
167 | + * @param Float $lon longitude of first point |
|
168 | + * @param Float $latc latitude of second point |
|
169 | + * @param Float $lonc longitude of second point |
|
170 | + * @param String $unit km else no unit used |
|
171 | + * @return Float Distance in $unit |
|
172 | + */ |
|
173 | 173 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
174 | 174 | if ($lat == $latc && $lon == $lonc) return 0; |
175 | 175 | $dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515; |
@@ -187,11 +187,11 @@ discard block |
||
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
190 | - * Check is distance realistic |
|
191 | - * @param int $timeDifference the time between the reception of both messages |
|
192 | - * @param float $distance distance covered |
|
193 | - * @return whether distance is realistic |
|
194 | - */ |
|
190 | + * Check is distance realistic |
|
191 | + * @param int $timeDifference the time between the reception of both messages |
|
192 | + * @param float $distance distance covered |
|
193 | + * @return whether distance is realistic |
|
194 | + */ |
|
195 | 195 | public function withinThreshold ($timeDifference, $distance) { |
196 | 196 | $x = abs($timeDifference); |
197 | 197 | $d = abs($distance); |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | } |
210 | 210 | |
211 | 211 | public function isInteger($input){ |
212 | - return(ctype_digit(strval($input))); |
|
212 | + return(ctype_digit(strval($input))); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | |
@@ -240,11 +240,11 @@ discard block |
||
240 | 240 | } |
241 | 241 | |
242 | 242 | /** |
243 | - * Copy folder contents |
|
244 | - * @param string $source Source path |
|
245 | - * @param string $dest Destination path |
|
246 | - * @return bool Returns true on success, false on failure |
|
247 | - */ |
|
243 | + * Copy folder contents |
|
244 | + * @param string $source Source path |
|
245 | + * @param string $dest Destination path |
|
246 | + * @return bool Returns true on success, false on failure |
|
247 | + */ |
|
248 | 248 | public function xcopy($source, $dest) |
249 | 249 | { |
250 | 250 | $files = glob($source.'*.*'); |
@@ -256,20 +256,20 @@ discard block |
||
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
259 | - * Check if an url exist |
|
260 | - * @param String $url url to check |
|
261 | - * @return bool Return true on succes false on failure |
|
262 | - */ |
|
259 | + * Check if an url exist |
|
260 | + * @param String $url url to check |
|
261 | + * @return bool Return true on succes false on failure |
|
262 | + */ |
|
263 | 263 | public function urlexist($url){ |
264 | 264 | $headers=get_headers($url); |
265 | 265 | return stripos($headers[0],"200 OK")?true:false; |
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
269 | - * Convert hexa to string |
|
270 | - * @param String $hex data in hexa |
|
271 | - * @return String Return result |
|
272 | - */ |
|
269 | + * Convert hexa to string |
|
270 | + * @param String $hex data in hexa |
|
271 | + * @return String Return result |
|
272 | + */ |
|
273 | 273 | public function hex2str($hex) { |
274 | 274 | $str = ''; |
275 | 275 | $hexln = strlen($hex); |
@@ -278,10 +278,10 @@ discard block |
||
278 | 278 | } |
279 | 279 | |
280 | 280 | /** |
281 | - * Convert hexa color to rgb |
|
282 | - * @param String $hex data in hexa |
|
283 | - * @return String Return result |
|
284 | - */ |
|
281 | + * Convert hexa color to rgb |
|
282 | + * @param String $hex data in hexa |
|
283 | + * @return String Return result |
|
284 | + */ |
|
285 | 285 | public function hex2rgb($hex) { |
286 | 286 | $hex = str_replace('#','',$hex); |
287 | 287 | return sscanf($hex, "%02x%02x%02x"); |
@@ -359,9 +359,9 @@ discard block |
||
359 | 359 | } |
360 | 360 | |
361 | 361 | /** |
362 | - * Returns list of available locales |
|
363 | - * |
|
364 | - * @return array |
|
362 | + * Returns list of available locales |
|
363 | + * |
|
364 | + * @return array |
|
365 | 365 | */ |
366 | 366 | public function listLocaleDir() |
367 | 367 | { |
@@ -456,100 +456,100 @@ discard block |
||
456 | 456 | public function remove_accents($string) { |
457 | 457 | if ( !preg_match('/[\x80-\xff]/', $string) ) return $string; |
458 | 458 | $chars = array( |
459 | - // Decompositions for Latin-1 Supplement |
|
460 | - chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', |
|
461 | - chr(195).chr(130) => 'A', chr(195).chr(131) => 'A', |
|
462 | - chr(195).chr(132) => 'A', chr(195).chr(133) => 'A', |
|
463 | - chr(195).chr(135) => 'C', chr(195).chr(136) => 'E', |
|
464 | - chr(195).chr(137) => 'E', chr(195).chr(138) => 'E', |
|
465 | - chr(195).chr(139) => 'E', chr(195).chr(140) => 'I', |
|
466 | - chr(195).chr(141) => 'I', chr(195).chr(142) => 'I', |
|
467 | - chr(195).chr(143) => 'I', chr(195).chr(145) => 'N', |
|
468 | - chr(195).chr(146) => 'O', chr(195).chr(147) => 'O', |
|
469 | - chr(195).chr(148) => 'O', chr(195).chr(149) => 'O', |
|
470 | - chr(195).chr(150) => 'O', chr(195).chr(153) => 'U', |
|
471 | - chr(195).chr(154) => 'U', chr(195).chr(155) => 'U', |
|
472 | - chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y', |
|
473 | - chr(195).chr(159) => 's', chr(195).chr(160) => 'a', |
|
474 | - chr(195).chr(161) => 'a', chr(195).chr(162) => 'a', |
|
475 | - chr(195).chr(163) => 'a', chr(195).chr(164) => 'a', |
|
476 | - chr(195).chr(165) => 'a', chr(195).chr(167) => 'c', |
|
477 | - chr(195).chr(168) => 'e', chr(195).chr(169) => 'e', |
|
478 | - chr(195).chr(170) => 'e', chr(195).chr(171) => 'e', |
|
479 | - chr(195).chr(172) => 'i', chr(195).chr(173) => 'i', |
|
480 | - chr(195).chr(174) => 'i', chr(195).chr(175) => 'i', |
|
481 | - chr(195).chr(177) => 'n', chr(195).chr(178) => 'o', |
|
482 | - chr(195).chr(179) => 'o', chr(195).chr(180) => 'o', |
|
483 | - chr(195).chr(181) => 'o', chr(195).chr(182) => 'o', |
|
484 | - chr(195).chr(182) => 'o', chr(195).chr(185) => 'u', |
|
485 | - chr(195).chr(186) => 'u', chr(195).chr(187) => 'u', |
|
486 | - chr(195).chr(188) => 'u', chr(195).chr(189) => 'y', |
|
487 | - chr(195).chr(191) => 'y', |
|
488 | - // Decompositions for Latin Extended-A |
|
489 | - chr(196).chr(128) => 'A', chr(196).chr(129) => 'a', |
|
490 | - chr(196).chr(130) => 'A', chr(196).chr(131) => 'a', |
|
491 | - chr(196).chr(132) => 'A', chr(196).chr(133) => 'a', |
|
492 | - chr(196).chr(134) => 'C', chr(196).chr(135) => 'c', |
|
493 | - chr(196).chr(136) => 'C', chr(196).chr(137) => 'c', |
|
494 | - chr(196).chr(138) => 'C', chr(196).chr(139) => 'c', |
|
495 | - chr(196).chr(140) => 'C', chr(196).chr(141) => 'c', |
|
496 | - chr(196).chr(142) => 'D', chr(196).chr(143) => 'd', |
|
497 | - chr(196).chr(144) => 'D', chr(196).chr(145) => 'd', |
|
498 | - chr(196).chr(146) => 'E', chr(196).chr(147) => 'e', |
|
499 | - chr(196).chr(148) => 'E', chr(196).chr(149) => 'e', |
|
500 | - chr(196).chr(150) => 'E', chr(196).chr(151) => 'e', |
|
501 | - chr(196).chr(152) => 'E', chr(196).chr(153) => 'e', |
|
502 | - chr(196).chr(154) => 'E', chr(196).chr(155) => 'e', |
|
503 | - chr(196).chr(156) => 'G', chr(196).chr(157) => 'g', |
|
504 | - chr(196).chr(158) => 'G', chr(196).chr(159) => 'g', |
|
505 | - chr(196).chr(160) => 'G', chr(196).chr(161) => 'g', |
|
506 | - chr(196).chr(162) => 'G', chr(196).chr(163) => 'g', |
|
507 | - chr(196).chr(164) => 'H', chr(196).chr(165) => 'h', |
|
508 | - chr(196).chr(166) => 'H', chr(196).chr(167) => 'h', |
|
509 | - chr(196).chr(168) => 'I', chr(196).chr(169) => 'i', |
|
510 | - chr(196).chr(170) => 'I', chr(196).chr(171) => 'i', |
|
511 | - chr(196).chr(172) => 'I', chr(196).chr(173) => 'i', |
|
512 | - chr(196).chr(174) => 'I', chr(196).chr(175) => 'i', |
|
513 | - chr(196).chr(176) => 'I', chr(196).chr(177) => 'i', |
|
514 | - chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij', |
|
515 | - chr(196).chr(180) => 'J', chr(196).chr(181) => 'j', |
|
516 | - chr(196).chr(182) => 'K', chr(196).chr(183) => 'k', |
|
517 | - chr(196).chr(184) => 'k', chr(196).chr(185) => 'L', |
|
518 | - chr(196).chr(186) => 'l', chr(196).chr(187) => 'L', |
|
519 | - chr(196).chr(188) => 'l', chr(196).chr(189) => 'L', |
|
520 | - chr(196).chr(190) => 'l', chr(196).chr(191) => 'L', |
|
521 | - chr(197).chr(128) => 'l', chr(197).chr(129) => 'L', |
|
522 | - chr(197).chr(130) => 'l', chr(197).chr(131) => 'N', |
|
523 | - chr(197).chr(132) => 'n', chr(197).chr(133) => 'N', |
|
524 | - chr(197).chr(134) => 'n', chr(197).chr(135) => 'N', |
|
525 | - chr(197).chr(136) => 'n', chr(197).chr(137) => 'N', |
|
526 | - chr(197).chr(138) => 'n', chr(197).chr(139) => 'N', |
|
527 | - chr(197).chr(140) => 'O', chr(197).chr(141) => 'o', |
|
528 | - chr(197).chr(142) => 'O', chr(197).chr(143) => 'o', |
|
529 | - chr(197).chr(144) => 'O', chr(197).chr(145) => 'o', |
|
530 | - chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe', |
|
531 | - chr(197).chr(148) => 'R',chr(197).chr(149) => 'r', |
|
532 | - chr(197).chr(150) => 'R',chr(197).chr(151) => 'r', |
|
533 | - chr(197).chr(152) => 'R',chr(197).chr(153) => 'r', |
|
534 | - chr(197).chr(154) => 'S',chr(197).chr(155) => 's', |
|
535 | - chr(197).chr(156) => 'S',chr(197).chr(157) => 's', |
|
536 | - chr(197).chr(158) => 'S',chr(197).chr(159) => 's', |
|
537 | - chr(197).chr(160) => 'S', chr(197).chr(161) => 's', |
|
538 | - chr(197).chr(162) => 'T', chr(197).chr(163) => 't', |
|
539 | - chr(197).chr(164) => 'T', chr(197).chr(165) => 't', |
|
540 | - chr(197).chr(166) => 'T', chr(197).chr(167) => 't', |
|
541 | - chr(197).chr(168) => 'U', chr(197).chr(169) => 'u', |
|
542 | - chr(197).chr(170) => 'U', chr(197).chr(171) => 'u', |
|
543 | - chr(197).chr(172) => 'U', chr(197).chr(173) => 'u', |
|
544 | - chr(197).chr(174) => 'U', chr(197).chr(175) => 'u', |
|
545 | - chr(197).chr(176) => 'U', chr(197).chr(177) => 'u', |
|
546 | - chr(197).chr(178) => 'U', chr(197).chr(179) => 'u', |
|
547 | - chr(197).chr(180) => 'W', chr(197).chr(181) => 'w', |
|
548 | - chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y', |
|
549 | - chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z', |
|
550 | - chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z', |
|
551 | - chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z', |
|
552 | - chr(197).chr(190) => 'z', chr(197).chr(191) => 's' |
|
459 | + // Decompositions for Latin-1 Supplement |
|
460 | + chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', |
|
461 | + chr(195).chr(130) => 'A', chr(195).chr(131) => 'A', |
|
462 | + chr(195).chr(132) => 'A', chr(195).chr(133) => 'A', |
|
463 | + chr(195).chr(135) => 'C', chr(195).chr(136) => 'E', |
|
464 | + chr(195).chr(137) => 'E', chr(195).chr(138) => 'E', |
|
465 | + chr(195).chr(139) => 'E', chr(195).chr(140) => 'I', |
|
466 | + chr(195).chr(141) => 'I', chr(195).chr(142) => 'I', |
|
467 | + chr(195).chr(143) => 'I', chr(195).chr(145) => 'N', |
|
468 | + chr(195).chr(146) => 'O', chr(195).chr(147) => 'O', |
|
469 | + chr(195).chr(148) => 'O', chr(195).chr(149) => 'O', |
|
470 | + chr(195).chr(150) => 'O', chr(195).chr(153) => 'U', |
|
471 | + chr(195).chr(154) => 'U', chr(195).chr(155) => 'U', |
|
472 | + chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y', |
|
473 | + chr(195).chr(159) => 's', chr(195).chr(160) => 'a', |
|
474 | + chr(195).chr(161) => 'a', chr(195).chr(162) => 'a', |
|
475 | + chr(195).chr(163) => 'a', chr(195).chr(164) => 'a', |
|
476 | + chr(195).chr(165) => 'a', chr(195).chr(167) => 'c', |
|
477 | + chr(195).chr(168) => 'e', chr(195).chr(169) => 'e', |
|
478 | + chr(195).chr(170) => 'e', chr(195).chr(171) => 'e', |
|
479 | + chr(195).chr(172) => 'i', chr(195).chr(173) => 'i', |
|
480 | + chr(195).chr(174) => 'i', chr(195).chr(175) => 'i', |
|
481 | + chr(195).chr(177) => 'n', chr(195).chr(178) => 'o', |
|
482 | + chr(195).chr(179) => 'o', chr(195).chr(180) => 'o', |
|
483 | + chr(195).chr(181) => 'o', chr(195).chr(182) => 'o', |
|
484 | + chr(195).chr(182) => 'o', chr(195).chr(185) => 'u', |
|
485 | + chr(195).chr(186) => 'u', chr(195).chr(187) => 'u', |
|
486 | + chr(195).chr(188) => 'u', chr(195).chr(189) => 'y', |
|
487 | + chr(195).chr(191) => 'y', |
|
488 | + // Decompositions for Latin Extended-A |
|
489 | + chr(196).chr(128) => 'A', chr(196).chr(129) => 'a', |
|
490 | + chr(196).chr(130) => 'A', chr(196).chr(131) => 'a', |
|
491 | + chr(196).chr(132) => 'A', chr(196).chr(133) => 'a', |
|
492 | + chr(196).chr(134) => 'C', chr(196).chr(135) => 'c', |
|
493 | + chr(196).chr(136) => 'C', chr(196).chr(137) => 'c', |
|
494 | + chr(196).chr(138) => 'C', chr(196).chr(139) => 'c', |
|
495 | + chr(196).chr(140) => 'C', chr(196).chr(141) => 'c', |
|
496 | + chr(196).chr(142) => 'D', chr(196).chr(143) => 'd', |
|
497 | + chr(196).chr(144) => 'D', chr(196).chr(145) => 'd', |
|
498 | + chr(196).chr(146) => 'E', chr(196).chr(147) => 'e', |
|
499 | + chr(196).chr(148) => 'E', chr(196).chr(149) => 'e', |
|
500 | + chr(196).chr(150) => 'E', chr(196).chr(151) => 'e', |
|
501 | + chr(196).chr(152) => 'E', chr(196).chr(153) => 'e', |
|
502 | + chr(196).chr(154) => 'E', chr(196).chr(155) => 'e', |
|
503 | + chr(196).chr(156) => 'G', chr(196).chr(157) => 'g', |
|
504 | + chr(196).chr(158) => 'G', chr(196).chr(159) => 'g', |
|
505 | + chr(196).chr(160) => 'G', chr(196).chr(161) => 'g', |
|
506 | + chr(196).chr(162) => 'G', chr(196).chr(163) => 'g', |
|
507 | + chr(196).chr(164) => 'H', chr(196).chr(165) => 'h', |
|
508 | + chr(196).chr(166) => 'H', chr(196).chr(167) => 'h', |
|
509 | + chr(196).chr(168) => 'I', chr(196).chr(169) => 'i', |
|
510 | + chr(196).chr(170) => 'I', chr(196).chr(171) => 'i', |
|
511 | + chr(196).chr(172) => 'I', chr(196).chr(173) => 'i', |
|
512 | + chr(196).chr(174) => 'I', chr(196).chr(175) => 'i', |
|
513 | + chr(196).chr(176) => 'I', chr(196).chr(177) => 'i', |
|
514 | + chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij', |
|
515 | + chr(196).chr(180) => 'J', chr(196).chr(181) => 'j', |
|
516 | + chr(196).chr(182) => 'K', chr(196).chr(183) => 'k', |
|
517 | + chr(196).chr(184) => 'k', chr(196).chr(185) => 'L', |
|
518 | + chr(196).chr(186) => 'l', chr(196).chr(187) => 'L', |
|
519 | + chr(196).chr(188) => 'l', chr(196).chr(189) => 'L', |
|
520 | + chr(196).chr(190) => 'l', chr(196).chr(191) => 'L', |
|
521 | + chr(197).chr(128) => 'l', chr(197).chr(129) => 'L', |
|
522 | + chr(197).chr(130) => 'l', chr(197).chr(131) => 'N', |
|
523 | + chr(197).chr(132) => 'n', chr(197).chr(133) => 'N', |
|
524 | + chr(197).chr(134) => 'n', chr(197).chr(135) => 'N', |
|
525 | + chr(197).chr(136) => 'n', chr(197).chr(137) => 'N', |
|
526 | + chr(197).chr(138) => 'n', chr(197).chr(139) => 'N', |
|
527 | + chr(197).chr(140) => 'O', chr(197).chr(141) => 'o', |
|
528 | + chr(197).chr(142) => 'O', chr(197).chr(143) => 'o', |
|
529 | + chr(197).chr(144) => 'O', chr(197).chr(145) => 'o', |
|
530 | + chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe', |
|
531 | + chr(197).chr(148) => 'R',chr(197).chr(149) => 'r', |
|
532 | + chr(197).chr(150) => 'R',chr(197).chr(151) => 'r', |
|
533 | + chr(197).chr(152) => 'R',chr(197).chr(153) => 'r', |
|
534 | + chr(197).chr(154) => 'S',chr(197).chr(155) => 's', |
|
535 | + chr(197).chr(156) => 'S',chr(197).chr(157) => 's', |
|
536 | + chr(197).chr(158) => 'S',chr(197).chr(159) => 's', |
|
537 | + chr(197).chr(160) => 'S', chr(197).chr(161) => 's', |
|
538 | + chr(197).chr(162) => 'T', chr(197).chr(163) => 't', |
|
539 | + chr(197).chr(164) => 'T', chr(197).chr(165) => 't', |
|
540 | + chr(197).chr(166) => 'T', chr(197).chr(167) => 't', |
|
541 | + chr(197).chr(168) => 'U', chr(197).chr(169) => 'u', |
|
542 | + chr(197).chr(170) => 'U', chr(197).chr(171) => 'u', |
|
543 | + chr(197).chr(172) => 'U', chr(197).chr(173) => 'u', |
|
544 | + chr(197).chr(174) => 'U', chr(197).chr(175) => 'u', |
|
545 | + chr(197).chr(176) => 'U', chr(197).chr(177) => 'u', |
|
546 | + chr(197).chr(178) => 'U', chr(197).chr(179) => 'u', |
|
547 | + chr(197).chr(180) => 'W', chr(197).chr(181) => 'w', |
|
548 | + chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y', |
|
549 | + chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z', |
|
550 | + chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z', |
|
551 | + chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z', |
|
552 | + chr(197).chr(190) => 'z', chr(197).chr(191) => 's' |
|
553 | 553 | ); |
554 | 554 | $string = strtr($string, $chars); |
555 | 555 | return $string; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | <div id="showdetails" class="showdetails"></div> |
37 | 37 | <div id="infobox" class="infobox"><h4><?php echo _("Aircrafts detected"); ?></h4><br /><i class="fa fa-spinner fa-pulse fa-fw"></i></div> |
38 | 38 | <?php |
39 | - if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) { |
|
39 | + if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) { |
|
40 | 40 | |
41 | 41 | ?> |
42 | 42 | <script src="<?php echo $globalURL; ?>/js/map.3d.js.php"></script> |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | <script src="<?php echo $globalURL; ?>/js/map-marine.3d.js.php"></script> |
57 | 57 | <?php |
58 | 58 | } |
59 | - } |
|
59 | + } |
|
60 | 60 | ?> |
61 | 61 | <div id="dialog" title="<?php echo _("Session has timed-out"); ?>"> |
62 | 62 | <p><?php echo _("In order to save data consumption web page times out after 30 minutes. Close this dialog to continue."); ?></p> |
@@ -70,34 +70,34 @@ discard block |
||
70 | 70 | <li><a href="#" onclick="getUserLocation(); return false;" title="<?php echo _("Plot your Location"); ?>"><i class="fa fa-map-marker"></i></a></li> |
71 | 71 | <li><a href="#" onclick="getCompassDirection(); return false;" title="<?php echo _("Compass Mode"); ?>"><i class="fa fa-compass"></i></a></li> |
72 | 72 | <?php |
73 | - if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
73 | + if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
74 | 74 | if (isset($globalArchive) && $globalArchive == TRUE) { |
75 | 75 | ?> |
76 | 76 | <li><a href="#archive" role="tab" title="<?php echo _("Archive"); ?>"><i class="fa fa-archive"></i></a></li> |
77 | 77 | <?php |
78 | 78 | } |
79 | - } |
|
79 | + } |
|
80 | 80 | ?> |
81 | 81 | <li><a href="#home" role="tab" title="<?php echo _("Layers"); ?>"><i class="fa fa-map"></i></a></li> |
82 | 82 | <li><a href="#filters" role="tab" title="<?php echo _("Filters"); ?>"><i class="fa fa-filter"></i></a></li> |
83 | 83 | <li><a href="#settings" role="tab" title="<?php echo _("Settings"); ?>"><i class="fa fa-gears"></i></a></li> |
84 | 84 | <?php |
85 | - if (isset($globalMap3D) && $globalMap3D) { |
|
85 | + if (isset($globalMap3D) && $globalMap3D) { |
|
86 | 86 | if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
87 | 87 | ?> |
88 | 88 | <li><a href="#" onclick="show3D(); return false;" role="tab" title="3D"><b>3D</b></a></li> |
89 | 89 | <?php |
90 | - } else { |
|
91 | - if (isset($globalMapSatellites) && $globalMapSatellites) { |
|
90 | + } else { |
|
91 | + if (isset($globalMapSatellites) && $globalMapSatellites) { |
|
92 | 92 | ?> |
93 | 93 | <li><a href="#satellites" role="tab" title="<?php echo _("Satellites"); ?>"><i class="satellite"></i></a></li> |
94 | 94 | <?php |
95 | - } |
|
95 | + } |
|
96 | 96 | ?> |
97 | 97 | <li><a href="#" onclick="show2D(); return false;" role="tab" title="2D"><b>2D</b></a></li> |
98 | 98 | <?php |
99 | 99 | } |
100 | - } |
|
100 | + } |
|
101 | 101 | ?> |
102 | 102 | </ul> |
103 | 103 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | ?> |
172 | 172 | </div> |
173 | 173 | <?php |
174 | - if (isset($globalArchive) && $globalArchive == TRUE) { |
|
174 | + if (isset($globalArchive) && $globalArchive == TRUE) { |
|
175 | 175 | ?> |
176 | 176 | <div class="sidebar-pane" id="archive"> |
177 | 177 | <h1 class="sidebar-header"><?php echo _("Playback"); ?> <i>Bêta</i><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | </form> |
232 | 232 | </div> |
233 | 233 | <?php |
234 | - } |
|
234 | + } |
|
235 | 235 | ?> |
236 | 236 | <div class="sidebar-pane" id="settings"> |
237 | 237 | <h1 class="sidebar-header"><?php echo _("Settings"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
@@ -242,56 +242,56 @@ discard block |
||
242 | 242 | <?php |
243 | 243 | if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider; |
244 | 244 | else $MapType = $_COOKIE['MapType']; |
245 | - ?> |
|
245 | + ?> |
|
246 | 246 | <?php |
247 | 247 | if (isset($globalBingMapKey) && $globalBingMapKey != '') { |
248 | - ?> |
|
248 | + ?> |
|
249 | 249 | <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option> |
250 | 250 | <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option> |
251 | 251 | <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option> |
252 | 252 | <?php |
253 | 253 | } |
254 | - ?> |
|
254 | + ?> |
|
255 | 255 | <?php |
256 | - if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
257 | - ?> |
|
256 | + if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
257 | + ?> |
|
258 | 258 | <?php |
259 | - if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') { |
|
260 | - ?> |
|
259 | + if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') { |
|
260 | + ?> |
|
261 | 261 | <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option> |
262 | 262 | <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option> |
263 | 263 | <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option> |
264 | 264 | <?php |
265 | - } |
|
266 | - ?> |
|
265 | + } |
|
266 | + ?> |
|
267 | 267 | <?php |
268 | - if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') { |
|
269 | - ?> |
|
268 | + if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') { |
|
269 | + ?> |
|
270 | 270 | <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option> |
271 | 271 | <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option> |
272 | 272 | <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option> |
273 | 273 | <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option> |
274 | 274 | <?php |
275 | - } |
|
276 | - ?> |
|
275 | + } |
|
276 | + ?> |
|
277 | 277 | <?php |
278 | - if (isset($globalMapQuestKey) && $globalMapQuestKey != '') { |
|
279 | - ?> |
|
278 | + if (isset($globalMapQuestKey) && $globalMapQuestKey != '') { |
|
279 | + ?> |
|
280 | 280 | <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option> |
281 | 281 | <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option> |
282 | 282 | <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option> |
283 | 283 | <?php |
284 | - } |
|
285 | - ?> |
|
284 | + } |
|
285 | + ?> |
|
286 | 286 | <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option> |
287 | 287 | <?php |
288 | 288 | } |
289 | - ?> |
|
289 | + ?> |
|
290 | 290 | <?php |
291 | - if (isset($globalMapboxToken) && $globalMapboxToken != '') { |
|
291 | + if (isset($globalMapboxToken) && $globalMapboxToken != '') { |
|
292 | 292 | if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default'; |
293 | 293 | else $MapBoxId = $_COOKIE['MapTypeId']; |
294 | - ?> |
|
294 | + ?> |
|
295 | 295 | <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option> |
296 | 296 | <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option> |
297 | 297 | <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option> |
@@ -305,13 +305,13 @@ discard block |
||
305 | 305 | <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option> |
306 | 306 | <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option> |
307 | 307 | <?php |
308 | - } |
|
309 | - ?> |
|
308 | + } |
|
309 | + ?> |
|
310 | 310 | <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option> |
311 | 311 | </select> |
312 | 312 | </li> |
313 | 313 | <?php |
314 | - if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
314 | + if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
315 | 315 | ?> |
316 | 316 | <li><?php echo _("Type of Terrain:"); ?> |
317 | 317 | <select class="selectpicker" onchange="terrainType(this);"> |
@@ -321,10 +321,10 @@ discard block |
||
321 | 321 | </select> |
322 | 322 | </li> |
323 | 323 | <?php |
324 | - } |
|
324 | + } |
|
325 | 325 | ?> |
326 | 326 | <?php |
327 | - if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
327 | + if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
328 | 328 | ?> |
329 | 329 | |
330 | 330 | <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') print 'checked'; ?> ><?php echo _("Display flight info as popup"); ?></label></div></li> |
@@ -332,59 +332,59 @@ discard block |
||
332 | 332 | <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || !isset($_COOKIE['MapRoute'])) print 'checked'; ?> ><?php echo _("Display flight route on click"); ?></label></div></li> |
333 | 333 | <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Planes animate between updates"); ?></label></div></li> |
334 | 334 | <?php |
335 | - } |
|
335 | + } |
|
336 | 336 | ?> |
337 | 337 | <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true') print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li> |
338 | 338 | <?php |
339 | - if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
339 | + if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
340 | 340 | ?> |
341 | 341 | <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li> |
342 | 342 | <?php |
343 | - } |
|
344 | - if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) { |
|
343 | + } |
|
344 | + if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) { |
|
345 | 345 | ?> |
346 | 346 | <li><div class="checkbox"><label><input type="checkbox" name="displaysanta" value="1" onclick="clickSanta(this)"><i class="fa fa-snowflake-o" aria-hidden="true"></i> <?php echo _("Show Santa Claus now"); ?> <i class="fa fa-snowflake-o" aria-hidden="true"></i></label></div></li> |
347 | 347 | <?php |
348 | - } |
|
348 | + } |
|
349 | 349 | ?> |
350 | 350 | |
351 | 351 | <?php |
352 | 352 | if (function_exists('array_column')) { |
353 | - if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) { |
|
354 | - ?> |
|
353 | + if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) { |
|
354 | + ?> |
|
355 | 355 | <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li> |
356 | 356 | <?php |
357 | - } |
|
357 | + } |
|
358 | 358 | } elseif (isset($globalSources)) { |
359 | - $dispolar = false; |
|
360 | - foreach ($globalSources as $testsource) { |
|
361 | - if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true; |
|
362 | - } |
|
363 | - if ($dispolar) { |
|
364 | - ?> |
|
359 | + $dispolar = false; |
|
360 | + foreach ($globalSources as $testsource) { |
|
361 | + if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true; |
|
362 | + } |
|
363 | + if ($dispolar) { |
|
364 | + ?> |
|
365 | 365 | <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li> |
366 | 366 | <?php |
367 | - } |
|
368 | - } |
|
369 | - ?> |
|
367 | + } |
|
368 | + } |
|
369 | + ?> |
|
370 | 370 | <?php |
371 | - if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
371 | + if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
372 | 372 | ?> |
373 | 373 | |
374 | 374 | <?php |
375 | - if (extension_loaded('gd') && function_exists('gd_info')) { |
|
376 | - ?> |
|
375 | + if (extension_loaded('gd') && function_exists('gd_info')) { |
|
376 | + ?> |
|
377 | 377 | <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') print 'checked'; ?> ><?php echo _("Aircraft icon color based on altitude"); ?></li> |
378 | 378 | <?php |
379 | 379 | if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') { |
380 | - ?> |
|
380 | + ?> |
|
381 | 381 | <li><?php echo _("Aircraft icon color:"); ?> |
382 | 382 | <input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>"> |
383 | 383 | </li> |
384 | 384 | <?php |
385 | - } |
|
386 | - } |
|
387 | - ?> |
|
385 | + } |
|
386 | + } |
|
387 | + ?> |
|
388 | 388 | <li><?php echo _("Show airport icon at zoom level:"); ?> |
389 | 389 | <div class="range"> |
390 | 390 | <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?>"> |
@@ -392,14 +392,14 @@ discard block |
||
392 | 392 | </div> |
393 | 393 | </li> |
394 | 394 | <?php |
395 | - } elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') { |
|
395 | + } elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') { |
|
396 | 396 | ?> |
397 | 397 | <li><input type="checkbox" name="aircraftcolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] == 'true') print 'checked'; ?> ><?php echo _("Force Aircraft color"); ?></li> |
398 | 398 | <li><?php echo _("Aircraft icon color:"); ?> |
399 | 399 | <input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print 'ff0000'; ?>"> |
400 | 400 | </li> |
401 | 401 | <?php |
402 | - } |
|
402 | + } |
|
403 | 403 | ?> |
404 | 404 | <li><?php echo _("Distance unit:"); ?> |
405 | 405 | <select class="selectpicker" onchange="unitdistance(this);"> |
@@ -432,16 +432,16 @@ discard block |
||
432 | 432 | <ul> |
433 | 433 | <?php |
434 | 434 | if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) { |
435 | - ?> |
|
435 | + ?> |
|
436 | 436 | <?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?> |
437 | 437 | <?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?> |
438 | 438 | <?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?> |
439 | 439 | <?php |
440 | 440 | } |
441 | - ?> |
|
441 | + ?> |
|
442 | 442 | <?php |
443 | 443 | if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) { |
444 | - ?> |
|
444 | + ?> |
|
445 | 445 | <?php if (isset($globalSBS1) && $globalSBS1) { ?> |
446 | 446 | <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li> |
447 | 447 | <?php } ?> |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | <?php } ?> |
451 | 451 | <?php |
452 | 452 | } |
453 | - ?> |
|
453 | + ?> |
|
454 | 454 | <li><?php echo _("Display airlines:"); ?> |
455 | 455 | <br/> |
456 | 456 | <select class="selectpicker" multiple onchange="airlines(this);" id="display_airlines"> |
@@ -470,14 +470,14 @@ discard block |
||
470 | 470 | echo '<option value="'.$airline['airline_icao'].'">'.$airline_name.'</option>'; |
471 | 471 | } |
472 | 472 | } |
473 | - ?> |
|
473 | + ?> |
|
474 | 474 | </select> |
475 | 475 | </li> |
476 | 476 | <?php |
477 | 477 | $Spotter = new Spotter(); |
478 | 478 | $allalliancenames = $Spotter->getAllAllianceNames(); |
479 | 479 | if (!empty($allalliancenames)) { |
480 | - ?> |
|
480 | + ?> |
|
481 | 481 | <li><?php echo _("Display alliance:"); ?> |
482 | 482 | <br/> |
483 | 483 | <select class="selectpicker" onchange="alliance(this);" id="display_alliance"> |
@@ -491,15 +491,15 @@ discard block |
||
491 | 491 | echo '<option value="'.$alliance_name.'">'.$alliance_name.'</option>'; |
492 | 492 | } |
493 | 493 | } |
494 | - ?> |
|
494 | + ?> |
|
495 | 495 | </select> |
496 | 496 | </li> |
497 | 497 | <?php |
498 | 498 | } |
499 | - ?> |
|
499 | + ?> |
|
500 | 500 | <?php |
501 | 501 | if (isset($globalAPRS) && $globalAPRS) { |
502 | - ?> |
|
502 | + ?> |
|
503 | 503 | <li><?php echo _("Display APRS sources name:"); ?> |
504 | 504 | <select class="selectpicker" multiple onchange="sources(this);"> |
505 | 505 | <?php |
@@ -511,15 +511,15 @@ discard block |
||
511 | 511 | echo '<option value="'.$source['source_name'].'">'.$source['source_name'].'</option>'; |
512 | 512 | } |
513 | 513 | } |
514 | - ?> |
|
514 | + ?> |
|
515 | 515 | </select> |
516 | 516 | </li> |
517 | 517 | <?php |
518 | 518 | } |
519 | - ?> |
|
519 | + ?> |
|
520 | 520 | <?php |
521 | 521 | if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS)) { |
522 | - ?> |
|
522 | + ?> |
|
523 | 523 | <li><?php echo _("Display airlines of type:"); ?><br/> |
524 | 524 | <select class="selectpicker" onchange="airlinestype(this);"> |
525 | 525 | <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option> |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | </li> |
531 | 531 | <?php |
532 | 532 | } |
533 | - ?> |
|
533 | + ?> |
|
534 | 534 | <li> |
535 | 535 | <?php echo _("Display flight with ident:"); ?> |
536 | 536 | <input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" /> |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | </form> |
544 | 544 | </div> |
545 | 545 | <?php |
546 | - if (isset($globalMapSatellites) && $globalMapSatellites && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
546 | + if (isset($globalMapSatellites) && $globalMapSatellites && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
547 | 547 | ?> |
548 | 548 | <div class="sidebar-pane" id="satellites"> |
549 | 549 | <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
@@ -583,14 +583,14 @@ discard block |
||
583 | 583 | print '<option value="'.$type['tle_type'].'">'.$type_name.'</option>'; |
584 | 584 | } |
585 | 585 | } |
586 | - ?> |
|
586 | + ?> |
|
587 | 587 | </select> |
588 | 588 | </li> |
589 | 589 | </ul> |
590 | 590 | </form> |
591 | 591 | </div> |
592 | 592 | <?php |
593 | - } |
|
593 | + } |
|
594 | 594 | ?> |
595 | 595 | </div> |
596 | 596 | </div> |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
16 | 16 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
17 | 17 | if (isset($globalMarine) && $globalMarine) { |
18 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
19 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
18 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
19 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | if (!isset($globalDebug)) $globalDebug = FALSE; |
@@ -24,40 +24,40 @@ discard block |
||
24 | 24 | // Check if schema is at latest version |
25 | 25 | $Connection = new Connection(); |
26 | 26 | if ($Connection->latest() === false) { |
27 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
28 | - exit(); |
|
27 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
28 | + exit(); |
|
29 | 29 | } |
30 | 30 | if (PHP_SAPI != 'cli') { |
31 | - echo "This script MUST be called from console, not a web browser."; |
|
31 | + echo "This script MUST be called from console, not a web browser."; |
|
32 | 32 | // exit(); |
33 | 33 | } |
34 | 34 | |
35 | 35 | // This is to be compatible with old version of settings.php |
36 | 36 | if (!isset($globalSources)) { |
37 | - if (isset($globalSBS1Hosts)) { |
|
38 | - //$hosts = $globalSBS1Hosts; |
|
39 | - foreach ($globalSBS1Hosts as $host) { |
|
40 | - $globalSources[] = array('host' => $host); |
|
41 | - } |
|
42 | - } else { |
|
43 | - if (!isset($globalSBS1Host)) { |
|
44 | - echo '$globalSources MUST be defined !'; |
|
45 | - die; |
|
37 | + if (isset($globalSBS1Hosts)) { |
|
38 | + //$hosts = $globalSBS1Hosts; |
|
39 | + foreach ($globalSBS1Hosts as $host) { |
|
40 | + $globalSources[] = array('host' => $host); |
|
41 | + } |
|
42 | + } else { |
|
43 | + if (!isset($globalSBS1Host)) { |
|
44 | + echo '$globalSources MUST be defined !'; |
|
45 | + die; |
|
46 | 46 | } |
47 | 47 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
48 | 48 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
49 | - } |
|
49 | + } |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::')); |
53 | 53 | //if (isset($options['s'])) $hosts = array($options['s']); |
54 | 54 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
55 | 55 | if (isset($options['s'])) { |
56 | - $globalSources = array(); |
|
57 | - $globalSources[] = array('host' => $options['s']); |
|
56 | + $globalSources = array(); |
|
57 | + $globalSources[] = array('host' => $options['s']); |
|
58 | 58 | } elseif (isset($options['source'])) { |
59 | - $globalSources = array(); |
|
60 | - $globalSources[] = array('host' => $options['source']); |
|
59 | + $globalSources = array(); |
|
60 | + $globalSources[] = array('host' => $options['source']); |
|
61 | 61 | } |
62 | 62 | if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
63 | 63 | if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
67 | 67 | else $id_source = 1; |
68 | 68 | if (isset($globalServer) && $globalServer) { |
69 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
70 | - $SI=new SpotterServer(); |
|
69 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
70 | + $SI=new SpotterServer(); |
|
71 | 71 | /* |
72 | 72 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
73 | 73 | $SI = new adsb2aprs(); |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | } else $SI=new SpotterImport($Connection->db); |
77 | 77 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
78 | 78 | if (isset($globalMarine) && $globalMarine) { |
79 | - $AIS = new AIS(); |
|
80 | - $MI = new MarineImport($Connection->db); |
|
79 | + $AIS = new AIS(); |
|
80 | + $MI = new MarineImport($Connection->db); |
|
81 | 81 | } |
82 | 82 | //$APRS=new APRS($Connection->db); |
83 | 83 | $SBS=new SBS(); |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | //$servertz = system('date +%Z'); |
88 | 88 | // signal handler - playing nice with sockets and dump1090 |
89 | 89 | if (function_exists('pcntl_fork')) { |
90 | - pcntl_signal(SIGINT, function() { |
|
91 | - global $sockets; |
|
92 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
93 | - die("Bye!\n"); |
|
94 | - }); |
|
95 | - pcntl_signal_dispatch(); |
|
90 | + pcntl_signal(SIGINT, function() { |
|
91 | + global $sockets; |
|
92 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
93 | + die("Bye!\n"); |
|
94 | + }); |
|
95 | + pcntl_signal_dispatch(); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | // let's try and connect |
@@ -102,153 +102,153 @@ discard block |
||
102 | 102 | $reset = 0; |
103 | 103 | |
104 | 104 | function connect_all($hosts) { |
105 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
106 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
107 | - $reset++; |
|
108 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
109 | - foreach ($hosts as $id => $value) { |
|
105 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
106 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
107 | + $reset++; |
|
108 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
109 | + foreach ($hosts as $id => $value) { |
|
110 | 110 | $host = $value['host']; |
111 | 111 | $globalSources[$id]['last_exec'] = 0; |
112 | 112 | // Here we check type of source(s) |
113 | 113 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
114 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
115 | - //$formats[$id] = 'deltadbtxt'; |
|
116 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
117 | - //$last_exec['deltadbtxt'] = 0; |
|
118 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
119 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
120 | - //$formats[$id] = 'vatsimtxt'; |
|
121 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
122 | - //$last_exec['vatsimtxt'] = 0; |
|
123 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
124 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
125 | - //$formats[$id] = 'aircraftlistjson'; |
|
126 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
127 | - //$last_exec['aircraftlistjson'] = 0; |
|
128 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
129 | - } else if (preg_match('/opensky/i',$host)) { |
|
130 | - //$formats[$id] = 'aircraftlistjson'; |
|
131 | - $globalSources[$id]['format'] = 'opensky'; |
|
132 | - //$last_exec['aircraftlistjson'] = 0; |
|
133 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
134 | - } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
135 | - //$formats[$id] = 'radarvirtueljson'; |
|
136 | - $globalSources[$id]['format'] = 'radarvirtueljson'; |
|
137 | - //$last_exec['radarvirtueljson'] = 0; |
|
138 | - if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
139 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
140 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
141 | - exit(0); |
|
142 | - } |
|
143 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
144 | - //$formats[$id] = 'planeupdatefaa'; |
|
145 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
146 | - //$last_exec['planeupdatefaa'] = 0; |
|
147 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
148 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
149 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
150 | - exit(0); |
|
151 | - } |
|
152 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
153 | - //$formats[$id] = 'phpvmacars'; |
|
154 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
155 | - //$last_exec['phpvmacars'] = 0; |
|
156 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
157 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
158 | - //$formats[$id] = 'phpvmacars'; |
|
159 | - $globalSources[$id]['format'] = 'vam'; |
|
160 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
161 | - } else if (preg_match('/whazzup/i',$host)) { |
|
162 | - //$formats[$id] = 'whazzup'; |
|
163 | - $globalSources[$id]['format'] = 'whazzup'; |
|
164 | - //$last_exec['whazzup'] = 0; |
|
165 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
166 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
167 | - //$formats[$id] = 'pirepsjson'; |
|
168 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
169 | - //$last_exec['pirepsjson'] = 0; |
|
170 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
171 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
172 | - //$formats[$id] = 'fr24json'; |
|
173 | - $globalSources[$id]['format'] = 'fr24json'; |
|
174 | - //$last_exec['fr24json'] = 0; |
|
175 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
176 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
177 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
178 | - exit(0); |
|
179 | - } |
|
180 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
181 | - //$formats[$id] = 'fr24json'; |
|
182 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
183 | - //$last_exec['fr24json'] = 0; |
|
184 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
185 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
186 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
187 | - exit(0); |
|
188 | - } |
|
189 | - //} else if (preg_match('/10001/',$host)) { |
|
190 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
191 | - //$formats[$id] = 'tsv'; |
|
192 | - $globalSources[$id]['format'] = 'tsv'; |
|
193 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
194 | - } |
|
195 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
196 | - if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
197 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
198 | - if ($idf !== false) { |
|
199 | - $httpfeeds[$id] = $idf; |
|
200 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
201 | - } |
|
202 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
203 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
204 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
205 | - $hostport = explode(':',$host); |
|
206 | - if (isset($hostport[1])) { |
|
114 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
115 | + //$formats[$id] = 'deltadbtxt'; |
|
116 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
117 | + //$last_exec['deltadbtxt'] = 0; |
|
118 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
119 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
120 | + //$formats[$id] = 'vatsimtxt'; |
|
121 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
122 | + //$last_exec['vatsimtxt'] = 0; |
|
123 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
124 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
125 | + //$formats[$id] = 'aircraftlistjson'; |
|
126 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
127 | + //$last_exec['aircraftlistjson'] = 0; |
|
128 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
129 | + } else if (preg_match('/opensky/i',$host)) { |
|
130 | + //$formats[$id] = 'aircraftlistjson'; |
|
131 | + $globalSources[$id]['format'] = 'opensky'; |
|
132 | + //$last_exec['aircraftlistjson'] = 0; |
|
133 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
134 | + } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
135 | + //$formats[$id] = 'radarvirtueljson'; |
|
136 | + $globalSources[$id]['format'] = 'radarvirtueljson'; |
|
137 | + //$last_exec['radarvirtueljson'] = 0; |
|
138 | + if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
139 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
140 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
141 | + exit(0); |
|
142 | + } |
|
143 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
144 | + //$formats[$id] = 'planeupdatefaa'; |
|
145 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
146 | + //$last_exec['planeupdatefaa'] = 0; |
|
147 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
148 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
149 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
150 | + exit(0); |
|
151 | + } |
|
152 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
153 | + //$formats[$id] = 'phpvmacars'; |
|
154 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
155 | + //$last_exec['phpvmacars'] = 0; |
|
156 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
157 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
158 | + //$formats[$id] = 'phpvmacars'; |
|
159 | + $globalSources[$id]['format'] = 'vam'; |
|
160 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
161 | + } else if (preg_match('/whazzup/i',$host)) { |
|
162 | + //$formats[$id] = 'whazzup'; |
|
163 | + $globalSources[$id]['format'] = 'whazzup'; |
|
164 | + //$last_exec['whazzup'] = 0; |
|
165 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
166 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
167 | + //$formats[$id] = 'pirepsjson'; |
|
168 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
169 | + //$last_exec['pirepsjson'] = 0; |
|
170 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
171 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
172 | + //$formats[$id] = 'fr24json'; |
|
173 | + $globalSources[$id]['format'] = 'fr24json'; |
|
174 | + //$last_exec['fr24json'] = 0; |
|
175 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
176 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
177 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
178 | + exit(0); |
|
179 | + } |
|
180 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
181 | + //$formats[$id] = 'fr24json'; |
|
182 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
183 | + //$last_exec['fr24json'] = 0; |
|
184 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
185 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
186 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
187 | + exit(0); |
|
188 | + } |
|
189 | + //} else if (preg_match('/10001/',$host)) { |
|
190 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
191 | + //$formats[$id] = 'tsv'; |
|
192 | + $globalSources[$id]['format'] = 'tsv'; |
|
193 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
194 | + } |
|
195 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
196 | + if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
197 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
198 | + if ($idf !== false) { |
|
199 | + $httpfeeds[$id] = $idf; |
|
200 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
201 | + } |
|
202 | + elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
203 | + } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
204 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
205 | + $hostport = explode(':',$host); |
|
206 | + if (isset($hostport[1])) { |
|
207 | 207 | $port = $hostport[1]; |
208 | 208 | $hostn = $hostport[0]; |
209 | - } else { |
|
209 | + } else { |
|
210 | 210 | $port = $globalSources[$id]['port']; |
211 | 211 | $hostn = $globalSources[$id]['host']; |
212 | - } |
|
213 | - $Common = new Common(); |
|
214 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
215 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
216 | - } else { |
|
217 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
218 | - } |
|
219 | - if ($s) { |
|
220 | - $sockets[$id] = $s; |
|
221 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
222 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
212 | + } |
|
213 | + $Common = new Common(); |
|
214 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
215 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
216 | + } else { |
|
217 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
218 | + } |
|
219 | + if ($s) { |
|
220 | + $sockets[$id] = $s; |
|
221 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
222 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
223 | 223 | //$formats[$id] = 'aprs'; |
224 | 224 | $globalSources[$id]['format'] = 'aprs'; |
225 | 225 | //$aprs_connect = 0; |
226 | 226 | //$use_aprs = true; |
227 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
227 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
228 | 228 | $globalSources[$id]['format'] = 'vrstcp'; |
229 | - } elseif ($port == '10001') { |
|
230 | - //$formats[$id] = 'tsv'; |
|
231 | - $globalSources[$id]['format'] = 'tsv'; |
|
232 | - } elseif ($port == '30002') { |
|
233 | - //$formats[$id] = 'raw'; |
|
234 | - $globalSources[$id]['format'] = 'raw'; |
|
235 | - } elseif ($port == '5001') { |
|
236 | - //$formats[$id] = 'raw'; |
|
237 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
238 | - } elseif ($port == '30005') { |
|
229 | + } elseif ($port == '10001') { |
|
230 | + //$formats[$id] = 'tsv'; |
|
231 | + $globalSources[$id]['format'] = 'tsv'; |
|
232 | + } elseif ($port == '30002') { |
|
233 | + //$formats[$id] = 'raw'; |
|
234 | + $globalSources[$id]['format'] = 'raw'; |
|
235 | + } elseif ($port == '5001') { |
|
236 | + //$formats[$id] = 'raw'; |
|
237 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
238 | + } elseif ($port == '30005') { |
|
239 | 239 | // Not yet supported |
240 | - //$formats[$id] = 'beast'; |
|
241 | - $globalSources[$id]['format'] = 'beast'; |
|
242 | - //} else $formats[$id] = 'sbs'; |
|
243 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
244 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
240 | + //$formats[$id] = 'beast'; |
|
241 | + $globalSources[$id]['format'] = 'beast'; |
|
242 | + //} else $formats[$id] = 'sbs'; |
|
243 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
244 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
245 | 245 | } |
246 | 246 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
247 | - } else { |
|
247 | + } else { |
|
248 | 248 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
249 | - } |
|
250 | - } |
|
251 | - } |
|
249 | + } |
|
250 | + } |
|
251 | + } |
|
252 | 252 | } |
253 | 253 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
254 | 254 | |
@@ -271,9 +271,9 @@ discard block |
||
271 | 271 | //connect_all($globalSources); |
272 | 272 | |
273 | 273 | if (isset($globalProxy) && $globalProxy) { |
274 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
274 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
275 | 275 | } else { |
276 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
276 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | // APRS Configuration |
@@ -282,18 +282,18 @@ discard block |
||
282 | 282 | die; |
283 | 283 | } |
284 | 284 | foreach ($globalSources as $key => $source) { |
285 | - if (!isset($source['format'])) { |
|
286 | - $globalSources[$key]['format'] = 'auto'; |
|
287 | - } |
|
285 | + if (!isset($source['format'])) { |
|
286 | + $globalSources[$key]['format'] = 'auto'; |
|
287 | + } |
|
288 | 288 | } |
289 | 289 | connect_all($globalSources); |
290 | 290 | foreach ($globalSources as $key => $source) { |
291 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
291 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
292 | 292 | $aprs_connect = 0; |
293 | 293 | $use_aprs = true; |
294 | 294 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
295 | 295 | break; |
296 | - } |
|
296 | + } |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | if ($use_aprs) { |
@@ -334,152 +334,152 @@ discard block |
||
334 | 334 | |
335 | 335 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
336 | 336 | while ($i > 0) { |
337 | - if (!$globalDaemon) $i = $endtime-time(); |
|
338 | - // Delete old ATC |
|
339 | - if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
337 | + if (!$globalDaemon) $i = $endtime-time(); |
|
338 | + // Delete old ATC |
|
339 | + if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
340 | 340 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
341 | - $ATC->deleteOldATC(); |
|
342 | - } |
|
341 | + $ATC->deleteOldATC(); |
|
342 | + } |
|
343 | 343 | |
344 | - //if (count($last_exec) > 0) { |
|
345 | - if (count($last_exec) == count($globalSources)) { |
|
344 | + //if (count($last_exec) > 0) { |
|
345 | + if (count($last_exec) == count($globalSources)) { |
|
346 | 346 | $max = $globalMinFetch; |
347 | 347 | foreach ($last_exec as $last) { |
348 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
348 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
349 | 349 | } |
350 | 350 | if ($max != $globalMinFetch) { |
351 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
352 | - sleep($globalMinFetch-$max+2); |
|
351 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
352 | + sleep($globalMinFetch-$max+2); |
|
353 | + } |
|
353 | 354 | } |
354 | - } |
|
355 | 355 | |
356 | 356 | |
357 | - //foreach ($formats as $id => $value) { |
|
358 | - foreach ($globalSources as $id => $value) { |
|
357 | + //foreach ($formats as $id => $value) { |
|
358 | + foreach ($globalSources as $id => $value) { |
|
359 | 359 | date_default_timezone_set('UTC'); |
360 | 360 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
361 | 361 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
362 | - //$buffer = $Common->getData($hosts[$id]); |
|
363 | - $buffer = $Common->getData($value['host']); |
|
364 | - if ($buffer != '') $reset = 0; |
|
365 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
366 | - $buffer = explode('\n',$buffer); |
|
367 | - foreach ($buffer as $line) { |
|
368 | - if ($line != '' && count($line) > 7) { |
|
369 | - $line = explode(',', $line); |
|
370 | - $data = array(); |
|
371 | - $data['hex'] = $line[1]; // hex |
|
372 | - $data['ident'] = $line[2]; // ident |
|
373 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
374 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
375 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
376 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
377 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
378 | - $data['verticalrate'] = ''; // vertical rate |
|
379 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
380 | - $data['emergency'] = ''; // emergency |
|
381 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
382 | - $data['format_source'] = 'deltadbtxt'; |
|
383 | - $data['id_source'] = $id_source; |
|
384 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
385 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
386 | - $SI->add($data); |
|
387 | - unset($data); |
|
388 | - } |
|
389 | - } |
|
390 | - $last_exec[$id]['last'] = time(); |
|
362 | + //$buffer = $Common->getData($hosts[$id]); |
|
363 | + $buffer = $Common->getData($value['host']); |
|
364 | + if ($buffer != '') $reset = 0; |
|
365 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
366 | + $buffer = explode('\n',$buffer); |
|
367 | + foreach ($buffer as $line) { |
|
368 | + if ($line != '' && count($line) > 7) { |
|
369 | + $line = explode(',', $line); |
|
370 | + $data = array(); |
|
371 | + $data['hex'] = $line[1]; // hex |
|
372 | + $data['ident'] = $line[2]; // ident |
|
373 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
374 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
375 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
376 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
377 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
378 | + $data['verticalrate'] = ''; // vertical rate |
|
379 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
380 | + $data['emergency'] = ''; // emergency |
|
381 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
382 | + $data['format_source'] = 'deltadbtxt'; |
|
383 | + $data['id_source'] = $id_source; |
|
384 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
385 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
386 | + $SI->add($data); |
|
387 | + unset($data); |
|
388 | + } |
|
389 | + } |
|
390 | + $last_exec[$id]['last'] = time(); |
|
391 | 391 | } elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
392 | - date_default_timezone_set('CET'); |
|
393 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
394 | - date_default_timezone_set('UTC'); |
|
395 | - if ($buffer != '') $reset = 0; |
|
396 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
397 | - $buffer = explode('\n',$buffer); |
|
398 | - foreach ($buffer as $line) { |
|
392 | + date_default_timezone_set('CET'); |
|
393 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
394 | + date_default_timezone_set('UTC'); |
|
395 | + if ($buffer != '') $reset = 0; |
|
396 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
397 | + $buffer = explode('\n',$buffer); |
|
398 | + foreach ($buffer as $line) { |
|
399 | 399 | if ($line != '') { |
400 | - echo "'".$line."'\n"; |
|
401 | - $add = false; |
|
402 | - $ais_data = $AIS->parse_line(trim($line)); |
|
403 | - $data = array(); |
|
404 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
405 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
406 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
407 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
408 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
409 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
410 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
411 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
412 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
413 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
414 | - if (isset($ais_data['timestamp'])) { |
|
400 | + echo "'".$line."'\n"; |
|
401 | + $add = false; |
|
402 | + $ais_data = $AIS->parse_line(trim($line)); |
|
403 | + $data = array(); |
|
404 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
405 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
406 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
407 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
408 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
409 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
410 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
411 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
412 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
413 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
414 | + if (isset($ais_data['timestamp'])) { |
|
415 | 415 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
416 | 416 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
417 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
418 | - $add = true; |
|
417 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
418 | + $add = true; |
|
419 | 419 | } |
420 | - } else { |
|
420 | + } else { |
|
421 | 421 | $data['datetime'] = date('Y-m-d H:i:s'); |
422 | 422 | $add = true; |
423 | - } |
|
424 | - $data['format_source'] = 'aisnmeatxt'; |
|
425 | - $data['id_source'] = $id_source; |
|
426 | - print_r($data); |
|
427 | - echo 'Add...'."\n"; |
|
428 | - if ($add && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
429 | - unset($data); |
|
423 | + } |
|
424 | + $data['format_source'] = 'aisnmeatxt'; |
|
425 | + $data['id_source'] = $id_source; |
|
426 | + print_r($data); |
|
427 | + echo 'Add...'."\n"; |
|
428 | + if ($add && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
429 | + unset($data); |
|
430 | 430 | } |
431 | - } |
|
432 | - $last_exec[$id]['last'] = time(); |
|
431 | + } |
|
432 | + $last_exec[$id]['last'] = time(); |
|
433 | 433 | } elseif ($value['format'] == 'aisnmeahttp') { |
434 | - $arr = $httpfeeds; |
|
435 | - $w = $e = null; |
|
434 | + $arr = $httpfeeds; |
|
435 | + $w = $e = null; |
|
436 | 436 | |
437 | - if (isset($arr[$id])) { |
|
438 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
439 | - if ($nn > 0) { |
|
437 | + if (isset($arr[$id])) { |
|
438 | + $nn = stream_select($arr,$w,$e,$timeout); |
|
439 | + if ($nn > 0) { |
|
440 | 440 | foreach ($httpfeeds as $feed) { |
441 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
442 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
443 | - $buffer = explode('\n',$buffer); |
|
444 | - foreach ($buffer as $line) { |
|
441 | + $buffer = stream_get_line($feed,2000,"\n"); |
|
442 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
443 | + $buffer = explode('\n',$buffer); |
|
444 | + foreach ($buffer as $line) { |
|
445 | 445 | if ($line != '') { |
446 | - $ais_data = $AIS->parse_line(trim($line)); |
|
447 | - $data = array(); |
|
448 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
449 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
450 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
451 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
452 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
453 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
454 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
455 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
456 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
457 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
458 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
459 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
460 | - if (isset($ais_data['timestamp'])) { |
|
446 | + $ais_data = $AIS->parse_line(trim($line)); |
|
447 | + $data = array(); |
|
448 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
449 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
450 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
451 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
452 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
453 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
454 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
455 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
456 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
457 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
458 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
459 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
460 | + if (isset($ais_data['timestamp'])) { |
|
461 | 461 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
462 | - } else { |
|
462 | + } else { |
|
463 | 463 | $data['datetime'] = date('Y-m-d H:i:s'); |
464 | - } |
|
465 | - $data['format_source'] = 'aisnmeahttp'; |
|
466 | - $data['id_source'] = $id_source; |
|
467 | - if ($ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
468 | - unset($data); |
|
464 | + } |
|
465 | + $data['format_source'] = 'aisnmeahttp'; |
|
466 | + $data['id_source'] = $id_source; |
|
467 | + if ($ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
468 | + unset($data); |
|
469 | 469 | } |
470 | - } |
|
470 | + } |
|
471 | + } |
|
471 | 472 | } |
472 | 473 | } |
473 | - } |
|
474 | 474 | } elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
475 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
476 | - if ($buffer != '') { |
|
475 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
476 | + if ($buffer != '') { |
|
477 | 477 | //echo $buffer; |
478 | 478 | $all_data = json_decode($buffer,true); |
479 | 479 | //print_r($all_data); |
480 | 480 | if (isset($all_data[0]['DATA'])) { |
481 | 481 | foreach ($all_data[0]['DATA'] as $line) { |
482 | - if ($line != '') { |
|
482 | + if ($line != '') { |
|
483 | 483 | $data = array(); |
484 | 484 | $data['ident'] = $line['NAME']; |
485 | 485 | $data['mmsi'] = $line['MMSI']; |
@@ -495,87 +495,87 @@ discard block |
||
495 | 495 | $data['id_source'] = $id_source; |
496 | 496 | $MI->add($data); |
497 | 497 | unset($data); |
498 | - } |
|
498 | + } |
|
499 | 499 | } |
500 | 500 | } |
501 | 501 | |
502 | - } |
|
503 | - $last_exec[$id]['last'] = time(); |
|
502 | + } |
|
503 | + $last_exec[$id]['last'] = time(); |
|
504 | 504 | } elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
505 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
506 | - if ($buffer != '') { |
|
505 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
506 | + if ($buffer != '') { |
|
507 | 507 | $all_data = json_decode($buffer,true); |
508 | 508 | if (isset($all_data[0]['mmsi'])) { |
509 | - foreach ($all_data as $line) { |
|
509 | + foreach ($all_data as $line) { |
|
510 | 510 | if ($line != '') { |
511 | - $data = array(); |
|
512 | - $data['ident'] = $line['shipname']; |
|
513 | - $data['callsign'] = $line['callsign']; |
|
514 | - $data['mmsi'] = $line['mmsi']; |
|
515 | - $data['speed'] = $line['sog']; |
|
516 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
517 | - $data['latitude'] = $line['latitude']; |
|
518 | - $data['longitude'] = $line['longitude']; |
|
519 | - $data['type_id'] = $line['shiptype']; |
|
520 | - $data['arrival_code'] = $line['destination']; |
|
521 | - $data['datetime'] = $line['time']; |
|
522 | - $data['format_source'] = 'boatbeaconapp'; |
|
523 | - $data['id_source'] = $id_source; |
|
524 | - $MI->add($data); |
|
525 | - unset($data); |
|
511 | + $data = array(); |
|
512 | + $data['ident'] = $line['shipname']; |
|
513 | + $data['callsign'] = $line['callsign']; |
|
514 | + $data['mmsi'] = $line['mmsi']; |
|
515 | + $data['speed'] = $line['sog']; |
|
516 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
517 | + $data['latitude'] = $line['latitude']; |
|
518 | + $data['longitude'] = $line['longitude']; |
|
519 | + $data['type_id'] = $line['shiptype']; |
|
520 | + $data['arrival_code'] = $line['destination']; |
|
521 | + $data['datetime'] = $line['time']; |
|
522 | + $data['format_source'] = 'boatbeaconapp'; |
|
523 | + $data['id_source'] = $id_source; |
|
524 | + $MI->add($data); |
|
525 | + unset($data); |
|
526 | + } |
|
526 | 527 | } |
527 | - } |
|
528 | 528 | } |
529 | 529 | |
530 | - } |
|
531 | - $last_exec[$id]['last'] = time(); |
|
530 | + } |
|
531 | + $last_exec[$id]['last'] = time(); |
|
532 | 532 | } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
533 | - echo 'download...'; |
|
534 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
535 | - echo 'done !'."\n"; |
|
536 | - if ($buffer != '') $reset = 0; |
|
537 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
538 | - $buffer = explode('\n',$buffer); |
|
539 | - foreach ($buffer as $line) { |
|
533 | + echo 'download...'; |
|
534 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
535 | + echo 'done !'."\n"; |
|
536 | + if ($buffer != '') $reset = 0; |
|
537 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
538 | + $buffer = explode('\n',$buffer); |
|
539 | + foreach ($buffer as $line) { |
|
540 | 540 | if ($line != '') { |
541 | - $data = array(); |
|
542 | - $data['mmsi'] = (int)substr($line,0,9); |
|
543 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
544 | - //$data['status'] = substr($line,21,2); |
|
545 | - //$data['type'] = substr($line,24,3); |
|
546 | - $data['latitude'] = substr($line,29,9); |
|
547 | - $data['longitude'] = substr($line,41,9); |
|
548 | - $data['speed'] = round(substr($line,51,5)); |
|
549 | - //$data['course'] = substr($line,57,5); |
|
550 | - $data['heading'] = round(substr($line,63,3)); |
|
551 | - //$data['draft'] = substr($line,67,4); |
|
552 | - //$data['length'] = substr($line,72,3); |
|
553 | - //$data['beam'] = substr($line,76,2); |
|
554 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
555 | - //$data['callsign'] = trim(substr($line,100,7); |
|
556 | - //$data['dest'] = substr($line,108,20); |
|
557 | - //$data['etaDate'] = substr($line,129,5); |
|
558 | - //$data['etaTime'] = substr($line,135,5); |
|
559 | - $data['format_source'] = 'shipplotter'; |
|
560 | - $data['id_source'] = $id_source; |
|
561 | - print_r($data); |
|
562 | - echo 'Add...'."\n"; |
|
563 | - $MI->add($data); |
|
564 | - unset($data); |
|
541 | + $data = array(); |
|
542 | + $data['mmsi'] = (int)substr($line,0,9); |
|
543 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
544 | + //$data['status'] = substr($line,21,2); |
|
545 | + //$data['type'] = substr($line,24,3); |
|
546 | + $data['latitude'] = substr($line,29,9); |
|
547 | + $data['longitude'] = substr($line,41,9); |
|
548 | + $data['speed'] = round(substr($line,51,5)); |
|
549 | + //$data['course'] = substr($line,57,5); |
|
550 | + $data['heading'] = round(substr($line,63,3)); |
|
551 | + //$data['draft'] = substr($line,67,4); |
|
552 | + //$data['length'] = substr($line,72,3); |
|
553 | + //$data['beam'] = substr($line,76,2); |
|
554 | + $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
555 | + //$data['callsign'] = trim(substr($line,100,7); |
|
556 | + //$data['dest'] = substr($line,108,20); |
|
557 | + //$data['etaDate'] = substr($line,129,5); |
|
558 | + //$data['etaTime'] = substr($line,135,5); |
|
559 | + $data['format_source'] = 'shipplotter'; |
|
560 | + $data['id_source'] = $id_source; |
|
561 | + print_r($data); |
|
562 | + echo 'Add...'."\n"; |
|
563 | + $MI->add($data); |
|
564 | + unset($data); |
|
565 | 565 | } |
566 | - } |
|
567 | - $last_exec[$id]['last'] = time(); |
|
566 | + } |
|
567 | + $last_exec[$id]['last'] = time(); |
|
568 | 568 | //} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
569 | 569 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
570 | - //$buffer = $Common->getData($hosts[$id]); |
|
571 | - $buffer = $Common->getData($value['host']); |
|
572 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
573 | - $buffer = explode('\n',$buffer); |
|
574 | - $reset = 0; |
|
575 | - foreach ($buffer as $line) { |
|
576 | - if ($line != '') { |
|
577 | - $line = explode(':', $line); |
|
578 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
570 | + //$buffer = $Common->getData($hosts[$id]); |
|
571 | + $buffer = $Common->getData($value['host']); |
|
572 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
573 | + $buffer = explode('\n',$buffer); |
|
574 | + $reset = 0; |
|
575 | + foreach ($buffer as $line) { |
|
576 | + if ($line != '') { |
|
577 | + $line = explode(':', $line); |
|
578 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
579 | 579 | $data = array(); |
580 | 580 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
581 | 581 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -588,36 +588,36 @@ discard block |
||
588 | 588 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
589 | 589 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
590 | 590 | $data['latitude'] = $line[5]; // lat |
591 | - $data['longitude'] = $line[6]; // long |
|
592 | - $data['verticalrate'] = ''; // vertical rate |
|
593 | - $data['squawk'] = ''; // squawk |
|
594 | - $data['emergency'] = ''; // emergency |
|
595 | - $data['waypoints'] = $line[30]; |
|
591 | + $data['longitude'] = $line[6]; // long |
|
592 | + $data['verticalrate'] = ''; // vertical rate |
|
593 | + $data['squawk'] = ''; // squawk |
|
594 | + $data['emergency'] = ''; // emergency |
|
595 | + $data['waypoints'] = $line[30]; |
|
596 | 596 | $data['datetime'] = date('Y-m-d H:i:s'); |
597 | 597 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
598 | 598 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
599 | - $data['departure_airport_icao'] = $line[11]; |
|
600 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
601 | - $data['arrival_airport_icao'] = $line[13]; |
|
599 | + $data['departure_airport_icao'] = $line[11]; |
|
600 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
601 | + $data['arrival_airport_icao'] = $line[13]; |
|
602 | 602 | $data['frequency'] = $line[4]; |
603 | 603 | $data['type'] = $line[18]; |
604 | 604 | $data['range'] = $line[19]; |
605 | 605 | if (isset($line[35])) $data['info'] = $line[35]; |
606 | - $data['id_source'] = $id_source; |
|
607 | - //$data['arrival_airport_time'] = ; |
|
608 | - if ($line[9] != '') { |
|
609 | - $aircraft_data = explode('/',$line[9]); |
|
610 | - if (isset($aircraft_data[1])) { |
|
611 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
612 | - } |
|
613 | - } |
|
614 | - /* |
|
606 | + $data['id_source'] = $id_source; |
|
607 | + //$data['arrival_airport_time'] = ; |
|
608 | + if ($line[9] != '') { |
|
609 | + $aircraft_data = explode('/',$line[9]); |
|
610 | + if (isset($aircraft_data[1])) { |
|
611 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
612 | + } |
|
613 | + } |
|
614 | + /* |
|
615 | 615 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; |
616 | 616 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
617 | 617 | */ |
618 | - $data['format_source'] = $value['format']; |
|
618 | + $data['format_source'] = $value['format']; |
|
619 | 619 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
620 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
620 | + if ($line[3] == 'PILOT') $SI->add($data); |
|
621 | 621 | elseif ($line[3] == 'ATC') { |
622 | 622 | //print_r($data); |
623 | 623 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -635,247 +635,247 @@ discard block |
||
635 | 635 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
636 | 636 | if (isset($ATC)) 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']); |
637 | 637 | } |
638 | - unset($data); |
|
639 | - } |
|
640 | - } |
|
641 | - } |
|
642 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
643 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
644 | - $last_exec[$id]['last'] = time(); |
|
645 | - //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
646 | - } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
647 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
648 | - if ($buffer != '') { |
|
649 | - $all_data = json_decode($buffer,true); |
|
650 | - if (isset($all_data['acList'])) { |
|
638 | + unset($data); |
|
639 | + } |
|
640 | + } |
|
641 | + } |
|
642 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
643 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
644 | + $last_exec[$id]['last'] = time(); |
|
645 | + //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
646 | + } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
647 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
648 | + if ($buffer != '') { |
|
649 | + $all_data = json_decode($buffer,true); |
|
650 | + if (isset($all_data['acList'])) { |
|
651 | 651 | $reset = 0; |
652 | 652 | foreach ($all_data['acList'] as $line) { |
653 | - $data = array(); |
|
654 | - $data['hex'] = $line['Icao']; // hex |
|
655 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
656 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
657 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
658 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
659 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
660 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
661 | - //$data['verticalrate'] = $line['']; // verticale rate |
|
662 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
663 | - $data['emergency'] = ''; // emergency |
|
664 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
665 | - /* |
|
653 | + $data = array(); |
|
654 | + $data['hex'] = $line['Icao']; // hex |
|
655 | + if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
656 | + if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
657 | + if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
658 | + if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
659 | + if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
660 | + if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
661 | + //$data['verticalrate'] = $line['']; // verticale rate |
|
662 | + if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
663 | + $data['emergency'] = ''; // emergency |
|
664 | + if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
665 | + /* |
|
666 | 666 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
667 | 667 | else $data['datetime'] = date('Y-m-d H:i:s'); |
668 | 668 | */ |
669 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
670 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
671 | - $data['format_source'] = 'aircraftlistjson'; |
|
672 | - $data['id_source'] = $id_source; |
|
673 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
674 | - if (isset($data['latitude'])) $SI->add($data); |
|
675 | - unset($data); |
|
669 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
670 | + if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
671 | + $data['format_source'] = 'aircraftlistjson'; |
|
672 | + $data['id_source'] = $id_source; |
|
673 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
674 | + if (isset($data['latitude'])) $SI->add($data); |
|
675 | + unset($data); |
|
676 | 676 | } |
677 | - } elseif (is_array($all_data)) { |
|
677 | + } elseif (is_array($all_data)) { |
|
678 | 678 | $reset = 0; |
679 | 679 | foreach ($all_data as $line) { |
680 | - $data = array(); |
|
681 | - $data['hex'] = $line['hex']; // hex |
|
682 | - $data['ident'] = $line['flight']; // ident |
|
683 | - $data['altitude'] = $line['altitude']; // altitude |
|
684 | - $data['speed'] = $line['speed']; // speed |
|
685 | - $data['heading'] = $line['track']; // heading |
|
686 | - $data['latitude'] = $line['lat']; // lat |
|
687 | - $data['longitude'] = $line['lon']; // long |
|
688 | - $data['verticalrate'] = $line['vrt']; // verticale rate |
|
689 | - $data['squawk'] = $line['squawk']; // squawk |
|
690 | - $data['emergency'] = ''; // emergency |
|
691 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
692 | - $data['format_source'] = 'aircraftlistjson'; |
|
693 | - $data['id_source'] = $id_source; |
|
694 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
695 | - $SI->add($data); |
|
696 | - unset($data); |
|
680 | + $data = array(); |
|
681 | + $data['hex'] = $line['hex']; // hex |
|
682 | + $data['ident'] = $line['flight']; // ident |
|
683 | + $data['altitude'] = $line['altitude']; // altitude |
|
684 | + $data['speed'] = $line['speed']; // speed |
|
685 | + $data['heading'] = $line['track']; // heading |
|
686 | + $data['latitude'] = $line['lat']; // lat |
|
687 | + $data['longitude'] = $line['lon']; // long |
|
688 | + $data['verticalrate'] = $line['vrt']; // verticale rate |
|
689 | + $data['squawk'] = $line['squawk']; // squawk |
|
690 | + $data['emergency'] = ''; // emergency |
|
691 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
692 | + $data['format_source'] = 'aircraftlistjson'; |
|
693 | + $data['id_source'] = $id_source; |
|
694 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
695 | + $SI->add($data); |
|
696 | + unset($data); |
|
697 | + } |
|
698 | + } |
|
697 | 699 | } |
698 | - } |
|
699 | - } |
|
700 | - //$last_exec['aircraftlistjson'] = time(); |
|
701 | - $last_exec[$id]['last'] = time(); |
|
702 | - //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
703 | - } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
704 | - $buffer = $Common->getData($value['host']); |
|
705 | - $all_data = json_decode($buffer,true); |
|
706 | - if (isset($all_data['planes'])) { |
|
700 | + //$last_exec['aircraftlistjson'] = time(); |
|
701 | + $last_exec[$id]['last'] = time(); |
|
702 | + //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
703 | + } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
704 | + $buffer = $Common->getData($value['host']); |
|
705 | + $all_data = json_decode($buffer,true); |
|
706 | + if (isset($all_data['planes'])) { |
|
707 | 707 | $reset = 0; |
708 | 708 | foreach ($all_data['planes'] as $key => $line) { |
709 | - $data = array(); |
|
710 | - $data['hex'] = $key; // hex |
|
711 | - $data['ident'] = $line[3]; // ident |
|
712 | - $data['altitude'] = $line[6]; // altitude |
|
713 | - $data['speed'] = $line[8]; // speed |
|
714 | - $data['heading'] = $line[7]; // heading |
|
715 | - $data['latitude'] = $line[4]; // lat |
|
716 | - $data['longitude'] = $line[5]; // long |
|
717 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
718 | - $data['squawk'] = $line[10]; // squawk |
|
719 | - $data['emergency'] = ''; // emergency |
|
720 | - $data['registration'] = $line[2]; |
|
721 | - $data['aircraft_icao'] = $line[0]; |
|
722 | - $deparr = explode('-',$line[1]); |
|
723 | - if (count($deparr) == 2) { |
|
709 | + $data = array(); |
|
710 | + $data['hex'] = $key; // hex |
|
711 | + $data['ident'] = $line[3]; // ident |
|
712 | + $data['altitude'] = $line[6]; // altitude |
|
713 | + $data['speed'] = $line[8]; // speed |
|
714 | + $data['heading'] = $line[7]; // heading |
|
715 | + $data['latitude'] = $line[4]; // lat |
|
716 | + $data['longitude'] = $line[5]; // long |
|
717 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
718 | + $data['squawk'] = $line[10]; // squawk |
|
719 | + $data['emergency'] = ''; // emergency |
|
720 | + $data['registration'] = $line[2]; |
|
721 | + $data['aircraft_icao'] = $line[0]; |
|
722 | + $deparr = explode('-',$line[1]); |
|
723 | + if (count($deparr) == 2) { |
|
724 | 724 | $data['departure_airport_icao'] = $deparr[0]; |
725 | 725 | $data['arrival_airport_icao'] = $deparr[1]; |
726 | - } |
|
727 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
728 | - $data['format_source'] = 'planeupdatefaa'; |
|
729 | - $data['id_source'] = $id_source; |
|
730 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
731 | - $SI->add($data); |
|
732 | - unset($data); |
|
726 | + } |
|
727 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
728 | + $data['format_source'] = 'planeupdatefaa'; |
|
729 | + $data['id_source'] = $id_source; |
|
730 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
731 | + $SI->add($data); |
|
732 | + unset($data); |
|
733 | + } |
|
733 | 734 | } |
734 | - } |
|
735 | - //$last_exec['planeupdatefaa'] = time(); |
|
736 | - $last_exec[$id]['last'] = time(); |
|
737 | - } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
738 | - $buffer = $Common->getData($value['host']); |
|
739 | - $all_data = json_decode($buffer,true); |
|
740 | - if (isset($all_data['states'])) { |
|
735 | + //$last_exec['planeupdatefaa'] = time(); |
|
736 | + $last_exec[$id]['last'] = time(); |
|
737 | + } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
738 | + $buffer = $Common->getData($value['host']); |
|
739 | + $all_data = json_decode($buffer,true); |
|
740 | + if (isset($all_data['states'])) { |
|
741 | 741 | $reset = 0; |
742 | 742 | foreach ($all_data['states'] as $key => $line) { |
743 | - $data = array(); |
|
744 | - $data['hex'] = $line[0]; // hex |
|
745 | - $data['ident'] = trim($line[1]); // ident |
|
746 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
747 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
748 | - $data['heading'] = round($line[10]); // heading |
|
749 | - $data['latitude'] = $line[5]; // lat |
|
750 | - $data['longitude'] = $line[6]; // long |
|
751 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
752 | - //$data['squawk'] = $line[10]; // squawk |
|
753 | - //$data['emergency'] = ''; // emergency |
|
754 | - //$data['registration'] = $line[2]; |
|
755 | - //$data['aircraft_icao'] = $line[0]; |
|
756 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
757 | - $data['format_source'] = 'opensky'; |
|
758 | - $data['id_source'] = $id_source; |
|
759 | - $SI->add($data); |
|
760 | - unset($data); |
|
743 | + $data = array(); |
|
744 | + $data['hex'] = $line[0]; // hex |
|
745 | + $data['ident'] = trim($line[1]); // ident |
|
746 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
747 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
748 | + $data['heading'] = round($line[10]); // heading |
|
749 | + $data['latitude'] = $line[5]; // lat |
|
750 | + $data['longitude'] = $line[6]; // long |
|
751 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
752 | + //$data['squawk'] = $line[10]; // squawk |
|
753 | + //$data['emergency'] = ''; // emergency |
|
754 | + //$data['registration'] = $line[2]; |
|
755 | + //$data['aircraft_icao'] = $line[0]; |
|
756 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
757 | + $data['format_source'] = 'opensky'; |
|
758 | + $data['id_source'] = $id_source; |
|
759 | + $SI->add($data); |
|
760 | + unset($data); |
|
761 | 761 | } |
762 | - } |
|
763 | - //$last_exec['planeupdatefaa'] = time(); |
|
764 | - $last_exec[$id]['last'] = time(); |
|
765 | - //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
766 | - } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
767 | - //$buffer = $Common->getData($hosts[$id]); |
|
768 | - $buffer = $Common->getData($value['host']); |
|
769 | - $all_data = json_decode($buffer,true); |
|
770 | - if (!empty($all_data)) $reset = 0; |
|
771 | - foreach ($all_data as $key => $line) { |
|
762 | + } |
|
763 | + //$last_exec['planeupdatefaa'] = time(); |
|
764 | + $last_exec[$id]['last'] = time(); |
|
765 | + //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
766 | + } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
767 | + //$buffer = $Common->getData($hosts[$id]); |
|
768 | + $buffer = $Common->getData($value['host']); |
|
769 | + $all_data = json_decode($buffer,true); |
|
770 | + if (!empty($all_data)) $reset = 0; |
|
771 | + foreach ($all_data as $key => $line) { |
|
772 | 772 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
773 | - $data = array(); |
|
774 | - $data['hex'] = $line[0]; |
|
775 | - $data['ident'] = $line[16]; //$line[13] |
|
776 | - $data['altitude'] = $line[4]; // altitude |
|
777 | - $data['speed'] = $line[5]; // speed |
|
778 | - $data['heading'] = $line[3]; // heading |
|
779 | - $data['latitude'] = $line[1]; // lat |
|
780 | - $data['longitude'] = $line[2]; // long |
|
781 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
782 | - $data['squawk'] = $line[6]; // squawk |
|
783 | - $data['aircraft_icao'] = $line[8]; |
|
784 | - $data['registration'] = $line[9]; |
|
785 | - $data['departure_airport_iata'] = $line[11]; |
|
786 | - $data['arrival_airport_iata'] = $line[12]; |
|
787 | - $data['emergency'] = ''; // emergency |
|
788 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
789 | - $data['format_source'] = 'fr24json'; |
|
790 | - $data['id_source'] = $id_source; |
|
791 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
792 | - $SI->add($data); |
|
793 | - unset($data); |
|
773 | + $data = array(); |
|
774 | + $data['hex'] = $line[0]; |
|
775 | + $data['ident'] = $line[16]; //$line[13] |
|
776 | + $data['altitude'] = $line[4]; // altitude |
|
777 | + $data['speed'] = $line[5]; // speed |
|
778 | + $data['heading'] = $line[3]; // heading |
|
779 | + $data['latitude'] = $line[1]; // lat |
|
780 | + $data['longitude'] = $line[2]; // long |
|
781 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
782 | + $data['squawk'] = $line[6]; // squawk |
|
783 | + $data['aircraft_icao'] = $line[8]; |
|
784 | + $data['registration'] = $line[9]; |
|
785 | + $data['departure_airport_iata'] = $line[11]; |
|
786 | + $data['arrival_airport_iata'] = $line[12]; |
|
787 | + $data['emergency'] = ''; // emergency |
|
788 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
789 | + $data['format_source'] = 'fr24json'; |
|
790 | + $data['id_source'] = $id_source; |
|
791 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
792 | + $SI->add($data); |
|
793 | + unset($data); |
|
794 | + } |
|
794 | 795 | } |
795 | - } |
|
796 | - //$last_exec['fr24json'] = time(); |
|
797 | - $last_exec[$id]['last'] = time(); |
|
798 | - //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
799 | - } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
800 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
801 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
802 | - //echo $buffer; |
|
803 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
804 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
805 | - $all_data = json_decode($buffer,true); |
|
806 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
796 | + //$last_exec['fr24json'] = time(); |
|
797 | + $last_exec[$id]['last'] = time(); |
|
798 | + //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
799 | + } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
800 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
801 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
802 | + //echo $buffer; |
|
803 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
804 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
805 | + $all_data = json_decode($buffer,true); |
|
806 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
807 | 807 | die(json_last_error_msg()); |
808 | - } |
|
809 | - if (isset($all_data['mrkrs'])) { |
|
808 | + } |
|
809 | + if (isset($all_data['mrkrs'])) { |
|
810 | 810 | $reset = 0; |
811 | 811 | foreach ($all_data['mrkrs'] as $key => $line) { |
812 | - if (isset($line['inf'])) { |
|
812 | + if (isset($line['inf'])) { |
|
813 | 813 | $data = array(); |
814 | 814 | $data['hex'] = $line['inf']['ia']; |
815 | 815 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
816 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
817 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
818 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
819 | - $data['latitude'] = $line['pt'][0]; // lat |
|
820 | - $data['longitude'] = $line['pt'][1]; // long |
|
821 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
822 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
823 | - //$data['aircraft_icao'] = $line[8]; |
|
824 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
816 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
817 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
818 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
819 | + $data['latitude'] = $line['pt'][0]; // lat |
|
820 | + $data['longitude'] = $line['pt'][1]; // long |
|
821 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
822 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
823 | + //$data['aircraft_icao'] = $line[8]; |
|
824 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
825 | 825 | //$data['departure_airport_iata'] = $line[11]; |
826 | 826 | //$data['arrival_airport_iata'] = $line[12]; |
827 | - //$data['emergency'] = ''; // emergency |
|
827 | + //$data['emergency'] = ''; // emergency |
|
828 | 828 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
829 | - $data['format_source'] = 'radarvirtueljson'; |
|
830 | - $data['id_source'] = $id_source; |
|
829 | + $data['format_source'] = 'radarvirtueljson'; |
|
830 | + $data['id_source'] = $id_source; |
|
831 | 831 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
832 | 832 | $SI->add($data); |
833 | 833 | unset($data); |
834 | - } |
|
834 | + } |
|
835 | + } |
|
835 | 836 | } |
836 | - } |
|
837 | - //$last_exec['radarvirtueljson'] = time(); |
|
838 | - $last_exec[$id]['last'] = time(); |
|
839 | - //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
840 | - } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
841 | - //$buffer = $Common->getData($hosts[$id]); |
|
842 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
843 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
837 | + //$last_exec['radarvirtueljson'] = time(); |
|
838 | + $last_exec[$id]['last'] = time(); |
|
839 | + //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
840 | + } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
841 | + //$buffer = $Common->getData($hosts[$id]); |
|
842 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
843 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
844 | 844 | |
845 | - if (isset($all_data['pireps'])) { |
|
845 | + if (isset($all_data['pireps'])) { |
|
846 | 846 | $reset = 0; |
847 | - foreach ($all_data['pireps'] as $line) { |
|
848 | - $data = array(); |
|
849 | - $data['id'] = $line['id']; |
|
850 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
851 | - $data['ident'] = $line['callsign']; // ident |
|
852 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
853 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
854 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
855 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
856 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
857 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
858 | - $data['latitude'] = $line['lat']; // lat |
|
859 | - $data['longitude'] = $line['lon']; // long |
|
860 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
861 | - //$data['squawk'] = $line['squawk']; // squawk |
|
862 | - //$data['emergency'] = ''; // emergency |
|
863 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
864 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
865 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
866 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
867 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
868 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
869 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
870 | - else $data['info'] = ''; |
|
871 | - $data['format_source'] = 'pireps'; |
|
872 | - $data['id_source'] = $id_source; |
|
873 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
874 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
875 | - if ($line['icon'] == 'plane') { |
|
847 | + foreach ($all_data['pireps'] as $line) { |
|
848 | + $data = array(); |
|
849 | + $data['id'] = $line['id']; |
|
850 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
851 | + $data['ident'] = $line['callsign']; // ident |
|
852 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
853 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
854 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
855 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
856 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
857 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
858 | + $data['latitude'] = $line['lat']; // lat |
|
859 | + $data['longitude'] = $line['lon']; // long |
|
860 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
861 | + //$data['squawk'] = $line['squawk']; // squawk |
|
862 | + //$data['emergency'] = ''; // emergency |
|
863 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
864 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
865 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
866 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
867 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
868 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
869 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
870 | + else $data['info'] = ''; |
|
871 | + $data['format_source'] = 'pireps'; |
|
872 | + $data['id_source'] = $id_source; |
|
873 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
874 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
875 | + if ($line['icon'] == 'plane') { |
|
876 | 876 | $SI->add($data); |
877 | - // print_r($data); |
|
878 | - } elseif ($line['icon'] == 'ct') { |
|
877 | + // print_r($data); |
|
878 | + } elseif ($line['icon'] == 'ct') { |
|
879 | 879 | $data['info'] = str_replace('^§','<br />',$data['info']); |
880 | 880 | $data['info'] = str_replace('&sect;','',$data['info']); |
881 | 881 | $typec = substr($data['ident'],-3); |
@@ -890,192 +890,192 @@ discard block |
||
890 | 890 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
891 | 891 | else $data['type'] = 'Observer'; |
892 | 892 | 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']); |
893 | - } |
|
894 | - unset($data); |
|
893 | + } |
|
894 | + unset($data); |
|
895 | + } |
|
895 | 896 | } |
896 | - } |
|
897 | - //$last_exec['pirepsjson'] = time(); |
|
898 | - $last_exec[$id]['last'] = time(); |
|
899 | - //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
900 | - } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
901 | - //$buffer = $Common->getData($hosts[$id]); |
|
902 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
903 | - $buffer = $Common->getData($value['host']); |
|
904 | - $all_data = json_decode($buffer,true); |
|
905 | - if ($buffer != '' && is_array($all_data)) { |
|
897 | + //$last_exec['pirepsjson'] = time(); |
|
898 | + $last_exec[$id]['last'] = time(); |
|
899 | + //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
900 | + } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
901 | + //$buffer = $Common->getData($hosts[$id]); |
|
902 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
903 | + $buffer = $Common->getData($value['host']); |
|
904 | + $all_data = json_decode($buffer,true); |
|
905 | + if ($buffer != '' && is_array($all_data)) { |
|
906 | 906 | $reset = 0; |
907 | 907 | foreach ($all_data as $line) { |
908 | - $data = array(); |
|
909 | - //$data['id'] = $line['id']; // id not usable |
|
910 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
911 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
912 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
913 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
914 | - $data['ident'] = $line['flightnum']; // ident |
|
915 | - $data['altitude'] = $line['alt']; // altitude |
|
916 | - $data['speed'] = $line['gs']; // speed |
|
917 | - $data['heading'] = $line['heading']; // heading |
|
918 | - $data['latitude'] = $line['lat']; // lat |
|
919 | - $data['longitude'] = $line['lng']; // long |
|
920 | - $data['verticalrate'] = ''; // verticale rate |
|
921 | - $data['squawk'] = ''; // squawk |
|
922 | - $data['emergency'] = ''; // emergency |
|
923 | - //$data['datetime'] = $line['lastupdate']; |
|
924 | - $data['last_update'] = $line['lastupdate']; |
|
925 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
926 | - $data['departure_airport_icao'] = $line['depicao']; |
|
927 | - $data['departure_airport_time'] = $line['deptime']; |
|
928 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
929 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
930 | - $data['registration'] = $line['aircraft']; |
|
931 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
932 | - if (isset($line['aircraftname'])) { |
|
908 | + $data = array(); |
|
909 | + //$data['id'] = $line['id']; // id not usable |
|
910 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
911 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
912 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
913 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
914 | + $data['ident'] = $line['flightnum']; // ident |
|
915 | + $data['altitude'] = $line['alt']; // altitude |
|
916 | + $data['speed'] = $line['gs']; // speed |
|
917 | + $data['heading'] = $line['heading']; // heading |
|
918 | + $data['latitude'] = $line['lat']; // lat |
|
919 | + $data['longitude'] = $line['lng']; // long |
|
920 | + $data['verticalrate'] = ''; // verticale rate |
|
921 | + $data['squawk'] = ''; // squawk |
|
922 | + $data['emergency'] = ''; // emergency |
|
923 | + //$data['datetime'] = $line['lastupdate']; |
|
924 | + $data['last_update'] = $line['lastupdate']; |
|
925 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
926 | + $data['departure_airport_icao'] = $line['depicao']; |
|
927 | + $data['departure_airport_time'] = $line['deptime']; |
|
928 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
929 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
930 | + $data['registration'] = $line['aircraft']; |
|
931 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
932 | + if (isset($line['aircraftname'])) { |
|
933 | 933 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
934 | 934 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
935 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
936 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
937 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
938 | - else { |
|
939 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
940 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
941 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
942 | - } |
|
943 | - } |
|
944 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
945 | - $data['id_source'] = $id_source; |
|
946 | - $data['format_source'] = 'phpvmacars'; |
|
947 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
948 | - $SI->add($data); |
|
949 | - unset($data); |
|
935 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
936 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
937 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
938 | + else { |
|
939 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
940 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
941 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
942 | + } |
|
943 | + } |
|
944 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
945 | + $data['id_source'] = $id_source; |
|
946 | + $data['format_source'] = 'phpvmacars'; |
|
947 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
948 | + $SI->add($data); |
|
949 | + unset($data); |
|
950 | 950 | } |
951 | 951 | if ($globalDebug) echo 'No more data...'."\n"; |
952 | 952 | unset($buffer); |
953 | 953 | unset($all_data); |
954 | - } |
|
955 | - //$last_exec['phpvmacars'] = time(); |
|
956 | - $last_exec[$id]['last'] = time(); |
|
957 | - } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
958 | - //$buffer = $Common->getData($hosts[$id]); |
|
959 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
960 | - $buffer = $Common->getData($value['host']); |
|
961 | - $all_data = json_decode($buffer,true); |
|
962 | - if ($buffer != '' && is_array($all_data)) { |
|
954 | + } |
|
955 | + //$last_exec['phpvmacars'] = time(); |
|
956 | + $last_exec[$id]['last'] = time(); |
|
957 | + } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
958 | + //$buffer = $Common->getData($hosts[$id]); |
|
959 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
960 | + $buffer = $Common->getData($value['host']); |
|
961 | + $all_data = json_decode($buffer,true); |
|
962 | + if ($buffer != '' && is_array($all_data)) { |
|
963 | 963 | $reset = 0; |
964 | 964 | foreach ($all_data as $line) { |
965 | - $data = array(); |
|
966 | - //$data['id'] = $line['id']; // id not usable |
|
967 | - $data['id'] = trim($line['flight_id']); |
|
968 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
969 | - $data['pilot_name'] = $line['pilot_name']; |
|
970 | - $data['pilot_id'] = $line['pilot_id']; |
|
971 | - $data['ident'] = trim($line['callsign']); // ident |
|
972 | - $data['altitude'] = $line['altitude']; // altitude |
|
973 | - $data['speed'] = $line['gs']; // speed |
|
974 | - $data['heading'] = $line['heading']; // heading |
|
975 | - $data['latitude'] = $line['latitude']; // lat |
|
976 | - $data['longitude'] = $line['longitude']; // long |
|
977 | - $data['verticalrate'] = ''; // verticale rate |
|
978 | - $data['squawk'] = ''; // squawk |
|
979 | - $data['emergency'] = ''; // emergency |
|
980 | - //$data['datetime'] = $line['lastupdate']; |
|
981 | - $data['last_update'] = $line['last_update']; |
|
982 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
983 | - $data['departure_airport_icao'] = $line['departure']; |
|
984 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
985 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
986 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
987 | - //$data['registration'] = $line['aircraft']; |
|
988 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
989 | - $data['aircraft_icao'] = $line['plane_type']; |
|
990 | - $data['id_source'] = $id_source; |
|
991 | - $data['format_source'] = 'vam'; |
|
992 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
993 | - $SI->add($data); |
|
994 | - unset($data); |
|
965 | + $data = array(); |
|
966 | + //$data['id'] = $line['id']; // id not usable |
|
967 | + $data['id'] = trim($line['flight_id']); |
|
968 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
969 | + $data['pilot_name'] = $line['pilot_name']; |
|
970 | + $data['pilot_id'] = $line['pilot_id']; |
|
971 | + $data['ident'] = trim($line['callsign']); // ident |
|
972 | + $data['altitude'] = $line['altitude']; // altitude |
|
973 | + $data['speed'] = $line['gs']; // speed |
|
974 | + $data['heading'] = $line['heading']; // heading |
|
975 | + $data['latitude'] = $line['latitude']; // lat |
|
976 | + $data['longitude'] = $line['longitude']; // long |
|
977 | + $data['verticalrate'] = ''; // verticale rate |
|
978 | + $data['squawk'] = ''; // squawk |
|
979 | + $data['emergency'] = ''; // emergency |
|
980 | + //$data['datetime'] = $line['lastupdate']; |
|
981 | + $data['last_update'] = $line['last_update']; |
|
982 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
983 | + $data['departure_airport_icao'] = $line['departure']; |
|
984 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
985 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
986 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
987 | + //$data['registration'] = $line['aircraft']; |
|
988 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
989 | + $data['aircraft_icao'] = $line['plane_type']; |
|
990 | + $data['id_source'] = $id_source; |
|
991 | + $data['format_source'] = 'vam'; |
|
992 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
993 | + $SI->add($data); |
|
994 | + unset($data); |
|
995 | 995 | } |
996 | 996 | if ($globalDebug) echo 'No more data...'."\n"; |
997 | 997 | unset($buffer); |
998 | 998 | unset($all_data); |
999 | - } |
|
1000 | - //$last_exec['phpvmacars'] = time(); |
|
1001 | - $last_exec[$id]['last'] = time(); |
|
999 | + } |
|
1000 | + //$last_exec['phpvmacars'] = time(); |
|
1001 | + $last_exec[$id]['last'] = time(); |
|
1002 | 1002 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
1003 | 1003 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { |
1004 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1005 | - //$last_exec[$id]['last'] = time(); |
|
1004 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1005 | + //$last_exec[$id]['last'] = time(); |
|
1006 | 1006 | |
1007 | - //$read = array( $sockets[$id] ); |
|
1008 | - $read = $sockets; |
|
1009 | - $write = NULL; |
|
1010 | - $e = NULL; |
|
1011 | - $n = socket_select($read, $write, $e, $timeout); |
|
1012 | - if ($e != NULL) var_dump($e); |
|
1013 | - if ($n > 0) { |
|
1007 | + //$read = array( $sockets[$id] ); |
|
1008 | + $read = $sockets; |
|
1009 | + $write = NULL; |
|
1010 | + $e = NULL; |
|
1011 | + $n = socket_select($read, $write, $e, $timeout); |
|
1012 | + if ($e != NULL) var_dump($e); |
|
1013 | + if ($n > 0) { |
|
1014 | 1014 | $reset = 0; |
1015 | 1015 | foreach ($read as $nb => $r) { |
1016 | - //$value = $formats[$nb]; |
|
1017 | - $format = $globalSources[$nb]['format']; |
|
1018 | - if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1016 | + //$value = $formats[$nb]; |
|
1017 | + $format = $globalSources[$nb]['format']; |
|
1018 | + if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1019 | 1019 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
1020 | - } elseif ($format == 'vrstcp') { |
|
1020 | + } elseif ($format == 'vrstcp') { |
|
1021 | 1021 | $buffer = @socket_read($r, 6000); |
1022 | - } else { |
|
1022 | + } else { |
|
1023 | 1023 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
1024 | - } |
|
1025 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1026 | - //echo $buffer."\n"; |
|
1027 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
1028 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1029 | - $error = false; |
|
1030 | - //$SI::del(); |
|
1031 | - if ($format == 'vrstcp') { |
|
1024 | + } |
|
1025 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1026 | + //echo $buffer."\n"; |
|
1027 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
1028 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1029 | + $error = false; |
|
1030 | + //$SI::del(); |
|
1031 | + if ($format == 'vrstcp') { |
|
1032 | 1032 | $buffer = explode('},{',$buffer); |
1033 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1034 | - // SBS format is CSV format |
|
1035 | - if ($buffer !== FALSE && $buffer != '') { |
|
1033 | + } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1034 | + // SBS format is CSV format |
|
1035 | + if ($buffer !== FALSE && $buffer != '') { |
|
1036 | 1036 | $tt[$format] = 0; |
1037 | 1037 | if ($format == 'acarssbs3') { |
1038 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1039 | - $ACARS->add(trim($buffer)); |
|
1040 | - $ACARS->deleteLiveAcarsData(); |
|
1038 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1039 | + $ACARS->add(trim($buffer)); |
|
1040 | + $ACARS->deleteLiveAcarsData(); |
|
1041 | 1041 | } elseif ($format == 'raw') { |
1042 | - // AVR format |
|
1043 | - $data = $SBS->parse($buffer); |
|
1044 | - if (is_array($data)) { |
|
1042 | + // AVR format |
|
1043 | + $data = $SBS->parse($buffer); |
|
1044 | + if (is_array($data)) { |
|
1045 | 1045 | $data['datetime'] = date('Y-m-d H:i:s'); |
1046 | 1046 | $data['format_source'] = 'raw'; |
1047 | 1047 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1048 | 1048 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1049 | 1049 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1050 | - } |
|
1050 | + } |
|
1051 | 1051 | } elseif ($format == 'ais') { |
1052 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
1053 | - $data = array(); |
|
1054 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1055 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1056 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1057 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1058 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1059 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1060 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1061 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1062 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1063 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1064 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1065 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1052 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
1053 | + $data = array(); |
|
1054 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1055 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1056 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1057 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1058 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1059 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1060 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1061 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1062 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1063 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1064 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1065 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1066 | 1066 | |
1067 | - if (isset($ais_data['timestamp'])) { |
|
1067 | + if (isset($ais_data['timestamp'])) { |
|
1068 | 1068 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
1069 | - } else { |
|
1069 | + } else { |
|
1070 | 1070 | $data['datetime'] = date('Y-m-d H:i:s'); |
1071 | - } |
|
1072 | - $data['format_source'] = 'aisnmea'; |
|
1073 | - $data['id_source'] = $id_source; |
|
1074 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1075 | - unset($data); |
|
1076 | - } elseif ($format == 'flightgearsp') { |
|
1077 | - //echo $buffer."\n"; |
|
1078 | - if (strlen($buffer) > 5) { |
|
1071 | + } |
|
1072 | + $data['format_source'] = 'aisnmea'; |
|
1073 | + $data['id_source'] = $id_source; |
|
1074 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1075 | + unset($data); |
|
1076 | + } elseif ($format == 'flightgearsp') { |
|
1077 | + //echo $buffer."\n"; |
|
1078 | + if (strlen($buffer) > 5) { |
|
1079 | 1079 | $line = explode(',',$buffer); |
1080 | 1080 | $data = array(); |
1081 | 1081 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1091,37 +1091,37 @@ discard block |
||
1091 | 1091 | $data['format_source'] = 'flightgearsp'; |
1092 | 1092 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1093 | 1093 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1094 | - } |
|
1095 | - } elseif ($format == 'acars') { |
|
1096 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1097 | - $ACARS->add(trim($buffer)); |
|
1098 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1099 | - $ACARS->deleteLiveAcarsData(); |
|
1094 | + } |
|
1095 | + } elseif ($format == 'acars') { |
|
1096 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1097 | + $ACARS->add(trim($buffer)); |
|
1098 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1099 | + $ACARS->deleteLiveAcarsData(); |
|
1100 | 1100 | } elseif ($format == 'flightgearmp') { |
1101 | - if (substr($buffer,0,1) != '#') { |
|
1101 | + if (substr($buffer,0,1) != '#') { |
|
1102 | 1102 | $data = array(); |
1103 | 1103 | //echo $buffer."\n"; |
1104 | 1104 | $line = explode(' ',$buffer); |
1105 | 1105 | if (count($line) == 11) { |
1106 | - $userserver = explode('@',$line[0]); |
|
1107 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1108 | - $data['ident'] = $userserver[0]; |
|
1109 | - $data['registration'] = $userserver[0]; |
|
1110 | - $data['latitude'] = $line[4]; |
|
1111 | - $data['longitude'] = $line[5]; |
|
1112 | - $data['altitude'] = $line[6]; |
|
1113 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1114 | - $aircraft_type = $line[10]; |
|
1115 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1116 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1117 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1106 | + $userserver = explode('@',$line[0]); |
|
1107 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1108 | + $data['ident'] = $userserver[0]; |
|
1109 | + $data['registration'] = $userserver[0]; |
|
1110 | + $data['latitude'] = $line[4]; |
|
1111 | + $data['longitude'] = $line[5]; |
|
1112 | + $data['altitude'] = $line[6]; |
|
1113 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1114 | + $aircraft_type = $line[10]; |
|
1115 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1116 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1117 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1118 | + } |
|
1118 | 1119 | } |
1119 | - } |
|
1120 | 1120 | } elseif ($format == 'beast') { |
1121 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1122 | - die; |
|
1121 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1122 | + die; |
|
1123 | 1123 | } elseif ($format == 'vrstcp') { |
1124 | - foreach($buffer as $all_data) { |
|
1124 | + foreach($buffer as $all_data) { |
|
1125 | 1125 | $line = json_decode('{'.$all_data.'}',true); |
1126 | 1126 | $data = array(); |
1127 | 1127 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1141,100 +1141,100 @@ discard block |
||
1141 | 1141 | */ |
1142 | 1142 | $data['datetime'] = date('Y-m-d H:i:s'); |
1143 | 1143 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
1144 | - $data['format_source'] = 'vrstcp'; |
|
1144 | + $data['format_source'] = 'vrstcp'; |
|
1145 | 1145 | $data['id_source'] = $id_source; |
1146 | 1146 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1147 | 1147 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1148 | 1148 | unset($data); |
1149 | - } |
|
1149 | + } |
|
1150 | 1150 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
1151 | - $line = explode("\t", $buffer); |
|
1152 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1151 | + $line = explode("\t", $buffer); |
|
1152 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
1153 | 1153 | $key = $line[$k]; |
1154 | - $lined[$key] = $line[$k+1]; |
|
1155 | - } |
|
1156 | - if (count($lined) > 3) { |
|
1157 | - $data['hex'] = $lined['hexid']; |
|
1158 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1159 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1160 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1161 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1162 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1163 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1164 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1165 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1166 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1167 | - $data['id_source'] = $id_source; |
|
1168 | - $data['format_source'] = 'tsv'; |
|
1169 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1170 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1171 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1172 | - unset($lined); |
|
1173 | - unset($data); |
|
1174 | - } else $error = true; |
|
1154 | + $lined[$key] = $line[$k+1]; |
|
1155 | + } |
|
1156 | + if (count($lined) > 3) { |
|
1157 | + $data['hex'] = $lined['hexid']; |
|
1158 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1159 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
1160 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1161 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1162 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1163 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1164 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1165 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1166 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1167 | + $data['id_source'] = $id_source; |
|
1168 | + $data['format_source'] = 'tsv'; |
|
1169 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1170 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1171 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1172 | + unset($lined); |
|
1173 | + unset($data); |
|
1174 | + } else $error = true; |
|
1175 | 1175 | } elseif ($format == 'aprs' && $use_aprs) { |
1176 | - if ($aprs_connect == 0) { |
|
1176 | + if ($aprs_connect == 0) { |
|
1177 | 1177 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
1178 | 1178 | $aprs_connect = 1; |
1179 | - } |
|
1179 | + } |
|
1180 | 1180 | |
1181 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1181 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1182 | 1182 | $aprs_last_tx = time(); |
1183 | 1183 | $data_aprs = "# Keep alive"; |
1184 | 1184 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1185 | - } |
|
1185 | + } |
|
1186 | 1186 | |
1187 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1188 | - //echo 'APRS data : '.$buffer."\n"; |
|
1189 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1190 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1191 | - //echo $buffer."\n"; |
|
1192 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1187 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1188 | + //echo 'APRS data : '.$buffer."\n"; |
|
1189 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
1190 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
1191 | + //echo $buffer."\n"; |
|
1192 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1193 | 1193 | $line = $APRS->parse($buffer); |
1194 | 1194 | //print_r($line); |
1195 | 1195 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1196 | 1196 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']))) { |
1197 | - $aprs_last_tx = time(); |
|
1198 | - $data = array(); |
|
1199 | - //print_r($line); |
|
1200 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1201 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1202 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1203 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1204 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1205 | - $data['latitude'] = $line['latitude']; |
|
1206 | - $data['longitude'] = $line['longitude']; |
|
1207 | - //$data['verticalrate'] = $line[16]; |
|
1208 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1209 | - else $data['speed'] = 0; |
|
1210 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1211 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1212 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1213 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1214 | - //else $data['heading'] = 0; |
|
1215 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1216 | - if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
1217 | - $data['id_source'] = $id_source; |
|
1218 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1219 | - else $data['format_source'] = 'aprs'; |
|
1220 | - $data['source_name'] = $line['source']; |
|
1221 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1222 | - else $data['source_type'] = 'flarm'; |
|
1223 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1224 | - $currentdate = date('Y-m-d H:i:s'); |
|
1225 | - $aprsdate = strtotime($data['datetime']); |
|
1226 | - // Accept data if time <= system time + 20s |
|
1227 | - 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'])))) { |
|
1197 | + $aprs_last_tx = time(); |
|
1198 | + $data = array(); |
|
1199 | + //print_r($line); |
|
1200 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1201 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1202 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1203 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1204 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1205 | + $data['latitude'] = $line['latitude']; |
|
1206 | + $data['longitude'] = $line['longitude']; |
|
1207 | + //$data['verticalrate'] = $line[16]; |
|
1208 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1209 | + else $data['speed'] = 0; |
|
1210 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1211 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1212 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1213 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1214 | + //else $data['heading'] = 0; |
|
1215 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1216 | + if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
1217 | + $data['id_source'] = $id_source; |
|
1218 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1219 | + else $data['format_source'] = 'aprs'; |
|
1220 | + $data['source_name'] = $line['source']; |
|
1221 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1222 | + else $data['source_type'] = 'flarm'; |
|
1223 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1224 | + $currentdate = date('Y-m-d H:i:s'); |
|
1225 | + $aprsdate = strtotime($data['datetime']); |
|
1226 | + // Accept data if time <= system time + 20s |
|
1227 | + 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'])))) { |
|
1228 | 1228 | $send = $SI->add($data); |
1229 | - } elseif (isset($line['stealth'])) { |
|
1229 | + } elseif (isset($line['stealth'])) { |
|
1230 | 1230 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
1231 | 1231 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
1232 | - //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1233 | - } 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') { |
|
1232 | + //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1233 | + } 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') { |
|
1234 | 1234 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1235 | 1235 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
1236 | - } |
|
1237 | - unset($data); |
|
1236 | + } |
|
1237 | + unset($data); |
|
1238 | 1238 | } |
1239 | 1239 | elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
1240 | 1240 | echo '!! Weather Station not yet supported'."\n"; |
@@ -1244,12 +1244,12 @@ discard block |
||
1244 | 1244 | } |
1245 | 1245 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
1246 | 1246 | //elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
1247 | - } |
|
1247 | + } |
|
1248 | 1248 | } else { |
1249 | - $line = explode(',', $buffer); |
|
1250 | - if (count($line) > 20) { |
|
1251 | - $data['hex'] = $line[4]; |
|
1252 | - /* |
|
1249 | + $line = explode(',', $buffer); |
|
1250 | + if (count($line) > 20) { |
|
1251 | + $data['hex'] = $line[4]; |
|
1252 | + /* |
|
1253 | 1253 | $data['datetime'] = $line[6].' '.$line[7]; |
1254 | 1254 | date_default_timezone_set($globalTimezone); |
1255 | 1255 | $datetime = new DateTime($data['datetime']); |
@@ -1257,29 +1257,29 @@ discard block |
||
1257 | 1257 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1258 | 1258 | date_default_timezone_set('UTC'); |
1259 | 1259 | */ |
1260 | - // Force datetime to current UTC datetime |
|
1261 | - date_default_timezone_set('UTC'); |
|
1262 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1263 | - $data['ident'] = trim($line[10]); |
|
1264 | - $data['latitude'] = $line[14]; |
|
1265 | - $data['longitude'] = $line[15]; |
|
1266 | - $data['verticalrate'] = $line[16]; |
|
1267 | - $data['emergency'] = $line[20]; |
|
1268 | - $data['speed'] = $line[12]; |
|
1269 | - $data['squawk'] = $line[17]; |
|
1270 | - $data['altitude'] = $line[11]; |
|
1271 | - $data['heading'] = $line[13]; |
|
1272 | - $data['ground'] = $line[21]; |
|
1273 | - $data['emergency'] = $line[19]; |
|
1274 | - $data['format_source'] = 'sbs'; |
|
1260 | + // Force datetime to current UTC datetime |
|
1261 | + date_default_timezone_set('UTC'); |
|
1262 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1263 | + $data['ident'] = trim($line[10]); |
|
1264 | + $data['latitude'] = $line[14]; |
|
1265 | + $data['longitude'] = $line[15]; |
|
1266 | + $data['verticalrate'] = $line[16]; |
|
1267 | + $data['emergency'] = $line[20]; |
|
1268 | + $data['speed'] = $line[12]; |
|
1269 | + $data['squawk'] = $line[17]; |
|
1270 | + $data['altitude'] = $line[11]; |
|
1271 | + $data['heading'] = $line[13]; |
|
1272 | + $data['ground'] = $line[21]; |
|
1273 | + $data['emergency'] = $line[19]; |
|
1274 | + $data['format_source'] = 'sbs'; |
|
1275 | 1275 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1276 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1277 | - $data['id_source'] = $id_source; |
|
1278 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1279 | - else $error = true; |
|
1280 | - unset($data); |
|
1281 | - } else $error = true; |
|
1282 | - if ($error) { |
|
1276 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1277 | + $data['id_source'] = $id_source; |
|
1278 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1279 | + else $error = true; |
|
1280 | + unset($data); |
|
1281 | + } else $error = true; |
|
1282 | + if ($error) { |
|
1283 | 1283 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
1284 | 1284 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
1285 | 1285 | } else { |
@@ -1295,13 +1295,13 @@ discard block |
||
1295 | 1295 | connect_all($sourceer); |
1296 | 1296 | $sourceer = array(); |
1297 | 1297 | } |
1298 | - } |
|
1298 | + } |
|
1299 | 1299 | } |
1300 | 1300 | // Sleep for xxx microseconds |
1301 | 1301 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
1302 | - } else { |
|
1302 | + } else { |
|
1303 | 1303 | if ($format == 'flightgearmp') { |
1304 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1304 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1305 | 1305 | //@socket_close($r); |
1306 | 1306 | sleep($globalMinFetch); |
1307 | 1307 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1310,9 +1310,9 @@ discard block |
||
1310 | 1310 | break; |
1311 | 1311 | |
1312 | 1312 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1313 | - if (isset($tt[$format])) $tt[$format]++; |
|
1314 | - else $tt[$format] = 0; |
|
1315 | - if ($tt[$format] > 30) { |
|
1313 | + if (isset($tt[$format])) $tt[$format]++; |
|
1314 | + else $tt[$format] = 0; |
|
1315 | + if ($tt[$format] > 30) { |
|
1316 | 1316 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
1317 | 1317 | //@socket_close($r); |
1318 | 1318 | sleep(2); |
@@ -1323,23 +1323,23 @@ discard block |
||
1323 | 1323 | //connect_all($globalSources); |
1324 | 1324 | $tt[$format]=0; |
1325 | 1325 | break; |
1326 | - } |
|
1326 | + } |
|
1327 | + } |
|
1327 | 1328 | } |
1328 | - } |
|
1329 | 1329 | } |
1330 | - } else { |
|
1330 | + } else { |
|
1331 | 1331 | $error = socket_strerror(socket_last_error()); |
1332 | 1332 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1333 | 1333 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
1334 | 1334 | if (isset($globalDebug)) echo "Restarting...\n"; |
1335 | 1335 | // Restart the script if possible |
1336 | 1336 | if (is_array($sockets)) { |
1337 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
1337 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
1338 | 1338 | |
1339 | - foreach ($sockets as $sock) { |
|
1339 | + foreach ($sockets as $sock) { |
|
1340 | 1340 | @socket_shutdown($sock,2); |
1341 | 1341 | @socket_close($sock); |
1342 | - } |
|
1342 | + } |
|
1343 | 1343 | |
1344 | 1344 | } |
1345 | 1345 | if ($globalDebug) echo "Restart all connections..."; |
@@ -1350,13 +1350,13 @@ discard block |
||
1350 | 1350 | if ($reset > 40) exit('Too many attempts...'); |
1351 | 1351 | connect_all($globalSources); |
1352 | 1352 | } |
1353 | - } |
|
1353 | + } |
|
1354 | 1354 | } |
1355 | 1355 | if ($globalDaemon === false) { |
1356 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1357 | - $SI->checkAll(); |
|
1356 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
1357 | + $SI->checkAll(); |
|
1358 | + } |
|
1358 | 1359 | } |
1359 | - } |
|
1360 | 1360 | } |
1361 | 1361 | |
1362 | 1362 | ?> |
@@ -5,23 +5,23 @@ discard block |
||
5 | 5 | $marine = false; |
6 | 6 | $usecoord = false; |
7 | 7 | if (isset($_GET['tracker'])) { |
8 | - $tracker = true; |
|
8 | + $tracker = true; |
|
9 | 9 | } |
10 | 10 | if (isset($_GET['marine'])) { |
11 | - $marine = true; |
|
11 | + $marine = true; |
|
12 | 12 | } |
13 | 13 | if ($tracker) { |
14 | - require_once('require/class.Tracker.php'); |
|
15 | - require_once('require/class.TrackerLive.php'); |
|
16 | - //require_once('require/class.TrackerArchive.php'); |
|
14 | + require_once('require/class.Tracker.php'); |
|
15 | + require_once('require/class.TrackerLive.php'); |
|
16 | + //require_once('require/class.TrackerArchive.php'); |
|
17 | 17 | } elseif ($marine) { |
18 | - require_once('require/class.Marine.php'); |
|
19 | - require_once('require/class.MarineLive.php'); |
|
20 | - //require_once('require/class.MarineArchive.php'); |
|
18 | + require_once('require/class.Marine.php'); |
|
19 | + require_once('require/class.MarineLive.php'); |
|
20 | + //require_once('require/class.MarineArchive.php'); |
|
21 | 21 | } else { |
22 | - require_once('require/class.Spotter.php'); |
|
23 | - require_once('require/class.SpotterLive.php'); |
|
24 | - require_once('require/class.SpotterArchive.php'); |
|
22 | + require_once('require/class.Spotter.php'); |
|
23 | + require_once('require/class.SpotterLive.php'); |
|
24 | + require_once('require/class.SpotterArchive.php'); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | $begintime = microtime(true); |
@@ -41,10 +41,10 @@ discard block |
||
41 | 41 | $Common = new Common(); |
42 | 42 | |
43 | 43 | if (isset($_GET['download'])) { |
44 | - if ($_GET['download'] == "true") |
|
45 | - { |
|
44 | + if ($_GET['download'] == "true") |
|
45 | + { |
|
46 | 46 | header('Content-disposition: attachment; filename="flightairmap.json"'); |
47 | - } |
|
47 | + } |
|
48 | 48 | } |
49 | 49 | header('Content-Type: text/javascript'); |
50 | 50 | |
@@ -496,13 +496,13 @@ discard block |
||
496 | 496 | if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
497 | 497 | |
498 | 498 | if ( |
499 | - (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') |
|
500 | - || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory) |
|
499 | + (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') |
|
500 | + || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory) |
|
501 | 501 | // || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id'])) |
502 | 502 | // || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident']) |
503 | - || (isset($history) && $history != '' && $history != 'NA' && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
504 | - || (isset($history) && $history == '' && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']) |
|
505 | - ) { |
|
503 | + || (isset($history) && $history != '' && $history != 'NA' && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
504 | + || (isset($history) && $history == '' && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']) |
|
505 | + ) { |
|
506 | 506 | if ($tracker) { |
507 | 507 | $spotter_history_array = $TrackerLive->getAllLiveTrackerDataById($spotter_item['famtrackid']); |
508 | 508 | } elseif ($marine) { |
@@ -555,26 +555,26 @@ discard block |
||
555 | 555 | } |
556 | 556 | |
557 | 557 | if (isset($history) && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) { |
558 | - $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
559 | - if (isset($spotter_item['departure_airport_latitude'])) { |
|
558 | + $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
559 | + if (isset($spotter_item['departure_airport_latitude'])) { |
|
560 | 560 | $output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],'; |
561 | - } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') { |
|
561 | + } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') { |
|
562 | 562 | $dairport = $Spotter->getAllAirportInfo($spotter_item['departure_airport']); |
563 | 563 | if (isset($dairport[0]['latitude'])) { |
564 | - $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],'; |
|
564 | + $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],'; |
|
565 | 565 | } |
566 | - } |
|
567 | - if (isset($spotter_item['arrival_airport_latitude'])) { |
|
566 | + } |
|
567 | + if (isset($spotter_item['arrival_airport_latitude'])) { |
|
568 | 568 | $output_air .= '['.$spotter_item['arrival_airport_longitude'].','.$spotter_item['arrival_airport_latitude'].']'; |
569 | - } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
|
569 | + } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
|
570 | 570 | $aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']); |
571 | 571 | if (isset($aairport[0]['latitude'])) { |
572 | - $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']'; |
|
572 | + $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']'; |
|
573 | 573 | } |
574 | - } |
|
575 | - $output_air .= ']}},'; |
|
576 | - $output .= $output_air; |
|
577 | - unset($output_air); |
|
574 | + } |
|
575 | + $output_air .= ']}},'; |
|
576 | + $output .= $output_air; |
|
577 | + unset($output_air); |
|
578 | 578 | } |
579 | 579 | } |
580 | 580 | $output = substr($output, 0, -1); |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | |
13 | 13 | |
14 | 14 | /** |
15 | - * Get SQL query part for filter used |
|
16 | - * @param Array $filter the filter |
|
17 | - * @return Array the SQL part |
|
18 | - */ |
|
15 | + * Get SQL query part for filter used |
|
16 | + * @param Array $filter the filter |
|
17 | + * @return Array the SQL part |
|
18 | + */ |
|
19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
21 | 21 | $filters = array(); |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
131 | - * Gets all the spotter information based on the latest data entry |
|
132 | - * |
|
133 | - * @return Array the spotter information |
|
134 | - * |
|
135 | - */ |
|
131 | + * Gets all the spotter information based on the latest data entry |
|
132 | + * |
|
133 | + * @return Array the spotter information |
|
134 | + * |
|
135 | + */ |
|
136 | 136 | public function getLiveSpotterData($limit = '', $sort = '', $filter = array()) |
137 | 137 | { |
138 | 138 | global $globalDBdriver, $globalLiveInterval; |
@@ -174,11 +174,11 @@ discard block |
||
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
177 | - * Gets Minimal Live Spotter data |
|
178 | - * |
|
179 | - * @return Array the spotter information |
|
180 | - * |
|
181 | - */ |
|
177 | + * Gets Minimal Live Spotter data |
|
178 | + * |
|
179 | + * @return Array the spotter information |
|
180 | + * |
|
181 | + */ |
|
182 | 182 | public function getMinLiveSpotterData($filter = array()) |
183 | 183 | { |
184 | 184 | global $globalDBdriver, $globalLiveInterval; |
@@ -231,11 +231,11 @@ discard block |
||
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
234 | - * Gets Minimal Live Spotter data since xx seconds |
|
235 | - * |
|
236 | - * @return Array the spotter information |
|
237 | - * |
|
238 | - */ |
|
234 | + * Gets Minimal Live Spotter data since xx seconds |
|
235 | + * |
|
236 | + * @return Array the spotter information |
|
237 | + * |
|
238 | + */ |
|
239 | 239 | public function getMinLastLiveSpotterData($filter = array()) |
240 | 240 | { |
241 | 241 | global $globalDBdriver, $globalLiveInterval; |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
254 | 254 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
255 | 255 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
256 | - } else { |
|
256 | + } else { |
|
257 | 257 | /* |
258 | 258 | $query = "SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
259 | 259 | FROM spotter_live LEFT JOIN (SELECT aircraft_shadow,engine_type, engine_count, wake_category, icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | // echo $query; |
266 | 266 | } |
267 | 267 | |
268 | - try { |
|
268 | + try { |
|
269 | 269 | $sth = $this->db->prepare($query); |
270 | 270 | $sth->execute(); |
271 | 271 | } catch(PDOException $e) { |
@@ -277,11 +277,11 @@ discard block |
||
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
280 | - * Gets number of latest data entry |
|
281 | - * |
|
282 | - * @return String number of entry |
|
283 | - * |
|
284 | - */ |
|
280 | + * Gets number of latest data entry |
|
281 | + * |
|
282 | + * @return String number of entry |
|
283 | + * |
|
284 | + */ |
|
285 | 285 | public function getLiveSpotterCount($filter = array()) |
286 | 286 | { |
287 | 287 | global $globalDBdriver, $globalLiveInterval; |
@@ -308,11 +308,11 @@ discard block |
||
308 | 308 | } |
309 | 309 | |
310 | 310 | /** |
311 | - * Gets all the spotter information based on the latest data entry and coord |
|
312 | - * |
|
313 | - * @return Array the spotter information |
|
314 | - * |
|
315 | - */ |
|
311 | + * Gets all the spotter information based on the latest data entry and coord |
|
312 | + * |
|
313 | + * @return Array the spotter information |
|
314 | + * |
|
315 | + */ |
|
316 | 316 | public function getLiveSpotterDatabyCoord($coord, $filter = array()) |
317 | 317 | { |
318 | 318 | global $globalDBdriver, $globalLiveInterval; |
@@ -337,11 +337,11 @@ discard block |
||
337 | 337 | } |
338 | 338 | |
339 | 339 | /** |
340 | - * Gets all the spotter information based on the latest data entry and coord |
|
341 | - * |
|
342 | - * @return Array the spotter information |
|
343 | - * |
|
344 | - */ |
|
340 | + * Gets all the spotter information based on the latest data entry and coord |
|
341 | + * |
|
342 | + * @return Array the spotter information |
|
343 | + * |
|
344 | + */ |
|
345 | 345 | public function getMinLiveSpotterDatabyCoord($coord, $filter = array()) |
346 | 346 | { |
347 | 347 | global $globalDBdriver, $globalLiveInterval; |
@@ -382,11 +382,11 @@ discard block |
||
382 | 382 | } |
383 | 383 | |
384 | 384 | /** |
385 | - * Gets all the spotter information based on a user's latitude and longitude |
|
386 | - * |
|
387 | - * @return Array the spotter information |
|
388 | - * |
|
389 | - */ |
|
385 | + * Gets all the spotter information based on a user's latitude and longitude |
|
386 | + * |
|
387 | + * @return Array the spotter information |
|
388 | + * |
|
389 | + */ |
|
390 | 390 | public function getLatestSpotterForLayar($lat, $lng, $radius, $interval) |
391 | 391 | { |
392 | 392 | $Spotter = new Spotter($this->db); |
@@ -396,145 +396,145 @@ discard block |
||
396 | 396 | return false; |
397 | 397 | } |
398 | 398 | } |
399 | - if ($lng != '') |
|
400 | - { |
|
401 | - if (!is_numeric($lng)) |
|
402 | - { |
|
403 | - return false; |
|
404 | - } |
|
405 | - } |
|
406 | - |
|
407 | - if ($radius != '') |
|
408 | - { |
|
409 | - if (!is_numeric($radius)) |
|
410 | - { |
|
411 | - return false; |
|
412 | - } |
|
413 | - } |
|
399 | + if ($lng != '') |
|
400 | + { |
|
401 | + if (!is_numeric($lng)) |
|
402 | + { |
|
403 | + return false; |
|
404 | + } |
|
405 | + } |
|
406 | + |
|
407 | + if ($radius != '') |
|
408 | + { |
|
409 | + if (!is_numeric($radius)) |
|
410 | + { |
|
411 | + return false; |
|
412 | + } |
|
413 | + } |
|
414 | 414 | $additional_query = ''; |
415 | - if ($interval != '') |
|
416 | - { |
|
417 | - if (!is_string($interval)) |
|
418 | - { |
|
419 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
420 | - return false; |
|
421 | - } else { |
|
422 | - if ($interval == '1m') |
|
423 | - { |
|
424 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
425 | - } else if ($interval == '15m'){ |
|
426 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
427 | - } |
|
428 | - } |
|
429 | - } else { |
|
430 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
431 | - } |
|
432 | - |
|
433 | - $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
415 | + if ($interval != '') |
|
416 | + { |
|
417 | + if (!is_string($interval)) |
|
418 | + { |
|
419 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
420 | + return false; |
|
421 | + } else { |
|
422 | + if ($interval == '1m') |
|
423 | + { |
|
424 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
425 | + } else if ($interval == '15m'){ |
|
426 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
427 | + } |
|
428 | + } |
|
429 | + } else { |
|
430 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
431 | + } |
|
432 | + |
|
433 | + $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
434 | 434 | WHERE spotter_live.latitude <> '' |
435 | 435 | AND spotter_live.longitude <> '' |
436 | 436 | ".$additional_query." |
437 | 437 | HAVING distance < :radius |
438 | 438 | ORDER BY distance"; |
439 | 439 | |
440 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
440 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
441 | 441 | |
442 | - return $spotter_array; |
|
443 | - } |
|
442 | + return $spotter_array; |
|
443 | + } |
|
444 | 444 | |
445 | 445 | |
446 | - /** |
|
447 | - * Gets all the spotter information based on a particular callsign |
|
448 | - * |
|
449 | - * @return Array the spotter information |
|
450 | - * |
|
451 | - */ |
|
446 | + /** |
|
447 | + * Gets all the spotter information based on a particular callsign |
|
448 | + * |
|
449 | + * @return Array the spotter information |
|
450 | + * |
|
451 | + */ |
|
452 | 452 | public function getLastLiveSpotterDataByIdent($ident) |
453 | 453 | { |
454 | 454 | $Spotter = new Spotter($this->db); |
455 | 455 | date_default_timezone_set('UTC'); |
456 | 456 | |
457 | 457 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
458 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
458 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
459 | 459 | |
460 | 460 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
461 | 461 | |
462 | 462 | return $spotter_array; |
463 | 463 | } |
464 | 464 | |
465 | - /** |
|
466 | - * Gets all the spotter information based on a particular callsign |
|
467 | - * |
|
468 | - * @return Array the spotter information |
|
469 | - * |
|
470 | - */ |
|
465 | + /** |
|
466 | + * Gets all the spotter information based on a particular callsign |
|
467 | + * |
|
468 | + * @return Array the spotter information |
|
469 | + * |
|
470 | + */ |
|
471 | 471 | public function getDateLiveSpotterDataByIdent($ident,$date) |
472 | 472 | { |
473 | 473 | $Spotter = new Spotter($this->db); |
474 | 474 | date_default_timezone_set('UTC'); |
475 | 475 | |
476 | 476 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
477 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
477 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
478 | 478 | |
479 | - $date = date('c',$date); |
|
479 | + $date = date('c',$date); |
|
480 | 480 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
481 | 481 | |
482 | 482 | return $spotter_array; |
483 | 483 | } |
484 | 484 | |
485 | - /** |
|
486 | - * Gets last spotter information based on a particular callsign |
|
487 | - * |
|
488 | - * @return Array the spotter information |
|
489 | - * |
|
490 | - */ |
|
485 | + /** |
|
486 | + * Gets last spotter information based on a particular callsign |
|
487 | + * |
|
488 | + * @return Array the spotter information |
|
489 | + * |
|
490 | + */ |
|
491 | 491 | public function getLastLiveSpotterDataById($id) |
492 | 492 | { |
493 | 493 | $Spotter = new Spotter($this->db); |
494 | 494 | date_default_timezone_set('UTC'); |
495 | 495 | |
496 | 496 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
497 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
497 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
498 | 498 | |
499 | 499 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
500 | 500 | |
501 | 501 | return $spotter_array; |
502 | 502 | } |
503 | 503 | |
504 | - /** |
|
505 | - * Gets last spotter information based on a particular callsign |
|
506 | - * |
|
507 | - * @return Array the spotter information |
|
508 | - * |
|
509 | - */ |
|
504 | + /** |
|
505 | + * Gets last spotter information based on a particular callsign |
|
506 | + * |
|
507 | + * @return Array the spotter information |
|
508 | + * |
|
509 | + */ |
|
510 | 510 | public function getDateLiveSpotterDataById($id,$date) |
511 | 511 | { |
512 | 512 | $Spotter = new Spotter($this->db); |
513 | 513 | date_default_timezone_set('UTC'); |
514 | 514 | |
515 | 515 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
516 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
517 | - $date = date('c',$date); |
|
516 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
517 | + $date = date('c',$date); |
|
518 | 518 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
519 | 519 | |
520 | 520 | return $spotter_array; |
521 | 521 | } |
522 | 522 | |
523 | - /** |
|
524 | - * Gets altitude information based on a particular callsign |
|
525 | - * |
|
526 | - * @return Array the spotter information |
|
527 | - * |
|
528 | - */ |
|
523 | + /** |
|
524 | + * Gets altitude information based on a particular callsign |
|
525 | + * |
|
526 | + * @return Array the spotter information |
|
527 | + * |
|
528 | + */ |
|
529 | 529 | public function getAltitudeLiveSpotterDataByIdent($ident) |
530 | 530 | { |
531 | 531 | |
532 | 532 | date_default_timezone_set('UTC'); |
533 | 533 | |
534 | 534 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
535 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
535 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
536 | 536 | |
537 | - try { |
|
537 | + try { |
|
538 | 538 | |
539 | 539 | $sth = $this->db->prepare($query); |
540 | 540 | $sth->execute(array(':ident' => $ident)); |
@@ -547,12 +547,12 @@ discard block |
||
547 | 547 | return $spotter_array; |
548 | 548 | } |
549 | 549 | |
550 | - /** |
|
551 | - * Gets all the spotter information based on a particular id |
|
552 | - * |
|
553 | - * @return Array the spotter information |
|
554 | - * |
|
555 | - */ |
|
550 | + /** |
|
551 | + * Gets all the spotter information based on a particular id |
|
552 | + * |
|
553 | + * @return Array the spotter information |
|
554 | + * |
|
555 | + */ |
|
556 | 556 | public function getAllLiveSpotterDataById($id,$liveinterval = false) |
557 | 557 | { |
558 | 558 | global $globalDBdriver, $globalLiveInterval; |
@@ -580,18 +580,18 @@ discard block |
||
580 | 580 | return $spotter_array; |
581 | 581 | } |
582 | 582 | |
583 | - /** |
|
584 | - * Gets all the spotter information based on a particular ident |
|
585 | - * |
|
586 | - * @return Array the spotter information |
|
587 | - * |
|
588 | - */ |
|
583 | + /** |
|
584 | + * Gets all the spotter information based on a particular ident |
|
585 | + * |
|
586 | + * @return Array the spotter information |
|
587 | + * |
|
588 | + */ |
|
589 | 589 | public function getAllLiveSpotterDataByIdent($ident) |
590 | 590 | { |
591 | 591 | date_default_timezone_set('UTC'); |
592 | 592 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
593 | 593 | $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
594 | - try { |
|
594 | + try { |
|
595 | 595 | |
596 | 596 | $sth = $this->db->prepare($query); |
597 | 597 | $sth->execute(array(':ident' => $ident)); |
@@ -605,23 +605,23 @@ discard block |
||
605 | 605 | |
606 | 606 | |
607 | 607 | /** |
608 | - * Deletes all info in the table |
|
609 | - * |
|
610 | - * @return String success or false |
|
611 | - * |
|
612 | - */ |
|
608 | + * Deletes all info in the table |
|
609 | + * |
|
610 | + * @return String success or false |
|
611 | + * |
|
612 | + */ |
|
613 | 613 | public function deleteLiveSpotterData() |
614 | 614 | { |
615 | 615 | global $globalDBdriver; |
616 | 616 | if ($globalDBdriver == 'mysql') { |
617 | 617 | //$query = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date"; |
618 | 618 | $query = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date'; |
619 | - //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
619 | + //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
620 | 620 | } else { |
621 | 621 | $query = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date"; |
622 | 622 | } |
623 | 623 | |
624 | - try { |
|
624 | + try { |
|
625 | 625 | |
626 | 626 | $sth = $this->db->prepare($query); |
627 | 627 | $sth->execute(); |
@@ -633,18 +633,18 @@ discard block |
||
633 | 633 | } |
634 | 634 | |
635 | 635 | /** |
636 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
637 | - * |
|
638 | - * @return String success or false |
|
639 | - * |
|
640 | - */ |
|
636 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
637 | + * |
|
638 | + * @return String success or false |
|
639 | + * |
|
640 | + */ |
|
641 | 641 | public function deleteLiveSpotterDataNotUpdated() |
642 | 642 | { |
643 | 643 | global $globalDBdriver, $globalDebug; |
644 | 644 | if ($globalDBdriver == 'mysql') { |
645 | 645 | //$query = 'SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < spotter_live.date) LIMIT 800 OFFSET 0'; |
646 | - $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
647 | - try { |
|
646 | + $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
647 | + try { |
|
648 | 648 | |
649 | 649 | $sth = $this->db->prepare($query); |
650 | 650 | $sth->execute(); |
@@ -652,8 +652,8 @@ discard block |
||
652 | 652 | return "error"; |
653 | 653 | } |
654 | 654 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
655 | - $i = 0; |
|
656 | - $j =0; |
|
655 | + $i = 0; |
|
656 | + $j =0; |
|
657 | 657 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
658 | 658 | foreach($all as $row) |
659 | 659 | { |
@@ -661,20 +661,20 @@ discard block |
||
661 | 661 | $j++; |
662 | 662 | if ($j == 30) { |
663 | 663 | if ($globalDebug) echo "."; |
664 | - try { |
|
664 | + try { |
|
665 | 665 | |
666 | 666 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
667 | 667 | $sth->execute(); |
668 | 668 | } catch(PDOException $e) { |
669 | 669 | return "error"; |
670 | 670 | } |
671 | - $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
672 | - $j = 0; |
|
671 | + $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
672 | + $j = 0; |
|
673 | 673 | } |
674 | 674 | $query_delete .= "'".$row['flightaware_id']."',"; |
675 | 675 | } |
676 | 676 | if ($i > 0) { |
677 | - try { |
|
677 | + try { |
|
678 | 678 | |
679 | 679 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
680 | 680 | $sth->execute(); |
@@ -685,9 +685,9 @@ discard block |
||
685 | 685 | return "success"; |
686 | 686 | } elseif ($globalDBdriver == 'pgsql') { |
687 | 687 | //$query = "SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < spotter_live.date) LIMIT 800 OFFSET 0"; |
688 | - //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
689 | - $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
690 | - try { |
|
688 | + //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
689 | + $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
690 | + try { |
|
691 | 691 | |
692 | 692 | $sth = $this->db->prepare($query); |
693 | 693 | $sth->execute(); |
@@ -731,17 +731,17 @@ discard block |
||
731 | 731 | } |
732 | 732 | |
733 | 733 | /** |
734 | - * Deletes all info in the table for an ident |
|
735 | - * |
|
736 | - * @return String success or false |
|
737 | - * |
|
738 | - */ |
|
734 | + * Deletes all info in the table for an ident |
|
735 | + * |
|
736 | + * @return String success or false |
|
737 | + * |
|
738 | + */ |
|
739 | 739 | public function deleteLiveSpotterDataByIdent($ident) |
740 | 740 | { |
741 | 741 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
742 | 742 | $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
743 | 743 | |
744 | - try { |
|
744 | + try { |
|
745 | 745 | |
746 | 746 | $sth = $this->db->prepare($query); |
747 | 747 | $sth->execute(array(':ident' => $ident)); |
@@ -753,17 +753,17 @@ discard block |
||
753 | 753 | } |
754 | 754 | |
755 | 755 | /** |
756 | - * Deletes all info in the table for an id |
|
757 | - * |
|
758 | - * @return String success or false |
|
759 | - * |
|
760 | - */ |
|
756 | + * Deletes all info in the table for an id |
|
757 | + * |
|
758 | + * @return String success or false |
|
759 | + * |
|
760 | + */ |
|
761 | 761 | public function deleteLiveSpotterDataById($id) |
762 | 762 | { |
763 | 763 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
764 | 764 | $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
765 | 765 | |
766 | - try { |
|
766 | + try { |
|
767 | 767 | |
768 | 768 | $sth = $this->db->prepare($query); |
769 | 769 | $sth->execute(array(':id' => $id)); |
@@ -776,11 +776,11 @@ discard block |
||
776 | 776 | |
777 | 777 | |
778 | 778 | /** |
779 | - * Gets the aircraft ident within the last hour |
|
780 | - * |
|
781 | - * @return String the ident |
|
782 | - * |
|
783 | - */ |
|
779 | + * Gets the aircraft ident within the last hour |
|
780 | + * |
|
781 | + * @return String the ident |
|
782 | + * |
|
783 | + */ |
|
784 | 784 | public function getIdentFromLastHour($ident) |
785 | 785 | { |
786 | 786 | global $globalDBdriver, $globalTimezone; |
@@ -806,14 +806,14 @@ discard block |
||
806 | 806 | $ident_result = $row['ident']; |
807 | 807 | } |
808 | 808 | return $ident_result; |
809 | - } |
|
809 | + } |
|
810 | 810 | |
811 | 811 | /** |
812 | - * Check recent aircraft |
|
813 | - * |
|
814 | - * @return String the ident |
|
815 | - * |
|
816 | - */ |
|
812 | + * Check recent aircraft |
|
813 | + * |
|
814 | + * @return String the ident |
|
815 | + * |
|
816 | + */ |
|
817 | 817 | public function checkIdentRecent($ident) |
818 | 818 | { |
819 | 819 | global $globalDBdriver, $globalTimezone; |
@@ -839,14 +839,14 @@ discard block |
||
839 | 839 | $ident_result = $row['flightaware_id']; |
840 | 840 | } |
841 | 841 | return $ident_result; |
842 | - } |
|
842 | + } |
|
843 | 843 | |
844 | 844 | /** |
845 | - * Check recent aircraft by id |
|
846 | - * |
|
847 | - * @return String the ident |
|
848 | - * |
|
849 | - */ |
|
845 | + * Check recent aircraft by id |
|
846 | + * |
|
847 | + * @return String the ident |
|
848 | + * |
|
849 | + */ |
|
850 | 850 | public function checkIdRecent($id) |
851 | 851 | { |
852 | 852 | global $globalDBdriver, $globalTimezone; |
@@ -872,14 +872,14 @@ discard block |
||
872 | 872 | $ident_result = $row['flightaware_id']; |
873 | 873 | } |
874 | 874 | return $ident_result; |
875 | - } |
|
875 | + } |
|
876 | 876 | |
877 | 877 | /** |
878 | - * Check recent aircraft by ModeS |
|
879 | - * |
|
880 | - * @return String the ModeS |
|
881 | - * |
|
882 | - */ |
|
878 | + * Check recent aircraft by ModeS |
|
879 | + * |
|
880 | + * @return String the ModeS |
|
881 | + * |
|
882 | + */ |
|
883 | 883 | public function checkModeSRecent($modes) |
884 | 884 | { |
885 | 885 | global $globalDBdriver, $globalTimezone; |
@@ -906,19 +906,19 @@ discard block |
||
906 | 906 | $ident_result = $row['flightaware_id']; |
907 | 907 | } |
908 | 908 | return $ident_result; |
909 | - } |
|
909 | + } |
|
910 | 910 | |
911 | 911 | /** |
912 | - * Adds a new spotter data |
|
913 | - * |
|
914 | - * @param String $flightaware_id the ID from flightaware |
|
915 | - * @param String $ident the flight ident |
|
916 | - * @param String $aircraft_icao the aircraft type |
|
917 | - * @param String $departure_airport_icao the departure airport |
|
918 | - * @param String $arrival_airport_icao the arrival airport |
|
919 | - * @return String success or false |
|
920 | - * |
|
921 | - */ |
|
912 | + * Adds a new spotter data |
|
913 | + * |
|
914 | + * @param String $flightaware_id the ID from flightaware |
|
915 | + * @param String $ident the flight ident |
|
916 | + * @param String $aircraft_icao the aircraft type |
|
917 | + * @param String $departure_airport_icao the departure airport |
|
918 | + * @param String $arrival_airport_icao the arrival airport |
|
919 | + * @return String success or false |
|
920 | + * |
|
921 | + */ |
|
922 | 922 | public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
923 | 923 | { |
924 | 924 | global $globalURL, $globalArchive, $globalDebug; |
@@ -1053,10 +1053,10 @@ discard block |
||
1053 | 1053 | $arrival_airport_country = ''; |
1054 | 1054 | |
1055 | 1055 | |
1056 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1057 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1058 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1059 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1056 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1057 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1058 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1059 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1060 | 1060 | |
1061 | 1061 | $query = 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) |
1062 | 1062 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country)'; |
@@ -1066,14 +1066,14 @@ discard block |
||
1066 | 1066 | |
1067 | 1067 | $sth = $this->db->prepare($query); |
1068 | 1068 | $sth->execute($query_values); |
1069 | - } catch(PDOException $e) { |
|
1070 | - return "error : ".$e->getMessage(); |
|
1071 | - } |
|
1069 | + } catch(PDOException $e) { |
|
1070 | + return "error : ".$e->getMessage(); |
|
1071 | + } |
|
1072 | 1072 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1073 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
1074 | - $SpotterArchive = new SpotterArchive($this->db); |
|
1075 | - $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
1076 | - if ($globalDebug) echo $result.')'; |
|
1073 | + if ($globalDebug) echo '(Add to SBS archive : '; |
|
1074 | + $SpotterArchive = new SpotterArchive($this->db); |
|
1075 | + $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
1076 | + if ($globalDebug) echo $result.')'; |
|
1077 | 1077 | } |
1078 | 1078 | return "success"; |
1079 | 1079 |