@@ -5,8 +5,8 @@ |
||
5 | 5 | require_once('require/class.Language.php'); |
6 | 6 | |
7 | 7 | if (!isset($_GET['aircraft_type'])) { |
8 | - header('Location: '.$globalURL.'/aircraft'); |
|
9 | - die(); |
|
8 | + header('Location: '.$globalURL.'/aircraft'); |
|
9 | + die(); |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | $aircraft_type = filter_input(INPUT_GET,'aircraft_type',FILTER_SANITIZE_STRING); |
@@ -4,8 +4,8 @@ |
||
4 | 4 | require_once('require/class.Stats.php'); |
5 | 5 | require_once('require/class.Language.php'); |
6 | 6 | if (!isset($_GET['aircraft_manufacturer'])) { |
7 | - header('Location: '.$globalURL.'/manufacturer'); |
|
8 | - die(); |
|
7 | + header('Location: '.$globalURL.'/manufacturer'); |
|
8 | + die(); |
|
9 | 9 | } |
10 | 10 | $Spotter = new Spotter(); |
11 | 11 | $manufacturer = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'aircraft_manufacturer',FILTER_SANITIZE_STRING))); |
@@ -48,7 +48,7 @@ |
||
48 | 48 | $metar_info = $METAR->getMETAR($airport_icao); |
49 | 49 | //print_r($metar_info); |
50 | 50 | if (isset($metar_info[0]['metar'])) $metar_parse = $METAR->parse($metar_info[0]['metar']); |
51 | - //print_r($metar_parse); |
|
51 | + //print_r($metar_parse); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | $title = sprintf(_("Detailed View for %s, %s (%s)"),$airport_array[0]['city'],$airport_array[0]['name'],$airport_array[0]['icao']); |
@@ -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))); |
@@ -317,18 +317,18 @@ discard block |
||
317 | 317 | </tr> |
318 | 318 | <!-- |
319 | 319 | <?php |
320 | - require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
|
321 | - $Connection = new Connection(); |
|
320 | + require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
|
321 | + $Connection = new Connection(); |
|
322 | 322 | ?> |
323 | 323 | --> |
324 | 324 | <?php |
325 | - if ($Connection->db != NULL) { |
|
325 | + if ($Connection->db != NULL) { |
|
326 | 326 | if ($Connection->tableExists('source_location')) { |
327 | - require_once(dirname(__FILE__).'/../require/class.Source.php'); |
|
328 | - $Source = new Source(); |
|
329 | - //$alllocations = $Source->getAllLocationInfo(); |
|
330 | - $alllocations = $Source->getLocationInfobyType(''); |
|
331 | - foreach ($alllocations as $location) { |
|
327 | + require_once(dirname(__FILE__).'/../require/class.Source.php'); |
|
328 | + $Source = new Source(); |
|
329 | + //$alllocations = $Source->getAllLocationInfo(); |
|
330 | + $alllocations = $Source->getLocationInfobyType(''); |
|
331 | + foreach ($alllocations as $location) { |
|
332 | 332 | ?> |
333 | 333 | <tr> |
334 | 334 | <input type="hidden" name="source_id[]" value="<?php print $location['id']; ?>" /> |
@@ -342,9 +342,9 @@ discard block |
||
342 | 342 | </tr> |
343 | 343 | |
344 | 344 | <?php |
345 | - } |
|
345 | + } |
|
346 | + } |
|
346 | 347 | } |
347 | - } |
|
348 | 348 | ?> |
349 | 349 | |
350 | 350 | <tr> |
@@ -452,12 +452,12 @@ discard block |
||
452 | 452 | ?> |
453 | 453 | <tr> |
454 | 454 | <?php |
455 | - if (filter_var($source['host'],FILTER_VALIDATE_URL)) { |
|
455 | + if (filter_var($source['host'],FILTER_VALIDATE_URL)) { |
|
456 | 456 | ?> |
457 | 457 | <td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td> |
458 | 458 | <td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td> |
459 | 459 | <?php |
460 | - } else { |
|
460 | + } else { |
|
461 | 461 | $hostport = explode(':',$source['host']); |
462 | 462 | if (isset($hostport[1])) { |
463 | 463 | $host = $hostport[0]; |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | <td><input type="text" name="host[]" id="host" value="<?php print $host; ?>" /></td> |
471 | 471 | <td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php print $port; ?>" /></td> |
472 | 472 | <?php |
473 | - } |
|
473 | + } |
|
474 | 474 | ?> |
475 | 475 | <td> |
476 | 476 | <select name="format[]" id="format"> |
@@ -880,7 +880,7 @@ discard block |
||
880 | 880 | <br /> |
881 | 881 | <p> |
882 | 882 | <?php |
883 | - if (extension_loaded('gd') && function_exists('gd_info')) { |
|
883 | + if (extension_loaded('gd') && function_exists('gd_info')) { |
|
884 | 884 | ?> |
885 | 885 | <label for="aircrafticoncolor">Color of aircraft icon on map</label> |
886 | 886 | <input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" /> |
@@ -890,11 +890,11 @@ discard block |
||
890 | 890 | <b>The directory cache is not writable, aircraft icon will not be cached</b> |
891 | 891 | <?php |
892 | 892 | } |
893 | - } else { |
|
893 | + } else { |
|
894 | 894 | ?> |
895 | 895 | <b>PHP GD is not installed, you can't change color of aircraft icon on map</b> |
896 | 896 | <?php |
897 | - } |
|
897 | + } |
|
898 | 898 | ?> |
899 | 899 | </p> |
900 | 900 | <br /> |
@@ -918,7 +918,7 @@ discard block |
||
918 | 918 | </p> |
919 | 919 | <?php |
920 | 920 | require('../footer.php'); |
921 | - exit; |
|
921 | + exit; |
|
922 | 922 | } |
923 | 923 | // ' |
924 | 924 | $settings = array(); |
@@ -1009,8 +1009,8 @@ discard block |
||
1009 | 1009 | |
1010 | 1010 | $sources = array(); |
1011 | 1011 | foreach ($source_name as $keys => $name) { |
1012 | - if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
1013 | - else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
1012 | + if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
1013 | + else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
1014 | 1014 | } |
1015 | 1015 | if (count($sources) > 0) $_SESSION['sources'] = $sources; |
1016 | 1016 | |
@@ -1392,14 +1392,14 @@ discard block |
||
1392 | 1392 | |
1393 | 1393 | // Set some defaults values... |
1394 | 1394 | if (!isset($globalAircraftImageSources)) { |
1395 | - $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
1396 | - $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources)); |
|
1395 | + $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
1396 | + $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources)); |
|
1397 | 1397 | } |
1398 | 1398 | |
1399 | 1399 | if (!isset($globalSchedulesSources)) { |
1400 | - $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
1401 | - $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources)); |
|
1402 | - } |
|
1400 | + $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
1401 | + $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources)); |
|
1402 | + } |
|
1403 | 1403 | |
1404 | 1404 | $settings = array_merge($settings,array('globalInstalled' => 'TRUE')); |
1405 | 1405 | |
@@ -1446,21 +1446,21 @@ discard block |
||
1446 | 1446 | $popi = false; |
1447 | 1447 | $popw = false; |
1448 | 1448 | foreach ($_SESSION['done'] as $done) { |
1449 | - print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
1450 | - if ($done == 'Create database') $pop = true; |
|
1451 | - if ($_SESSION['install'] == 'database_create') $pop = true; |
|
1452 | - if ($_SESSION['install'] == 'database_import') $popi = true; |
|
1453 | - if ($_SESSION['install'] == 'waypoints') $popw = true; |
|
1449 | + print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
1450 | + if ($done == 'Create database') $pop = true; |
|
1451 | + if ($_SESSION['install'] == 'database_create') $pop = true; |
|
1452 | + if ($_SESSION['install'] == 'database_import') $popi = true; |
|
1453 | + if ($_SESSION['install'] == 'waypoints') $popw = true; |
|
1454 | 1454 | } |
1455 | 1455 | if ($pop) { |
1456 | - sleep(5); |
|
1457 | - print '<li>Create database....<img src="../images/loading.gif" /></li>'; |
|
1456 | + sleep(5); |
|
1457 | + print '<li>Create database....<img src="../images/loading.gif" /></li>'; |
|
1458 | 1458 | } else if ($popi) { |
1459 | - sleep(5); |
|
1460 | - print '<li>Create and import tables....<img src="../images/loading.gif" /></li>'; |
|
1459 | + sleep(5); |
|
1460 | + print '<li>Create and import tables....<img src="../images/loading.gif" /></li>'; |
|
1461 | 1461 | } else if ($popw) { |
1462 | - sleep(5); |
|
1463 | - print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>'; |
|
1462 | + sleep(5); |
|
1463 | + print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>'; |
|
1464 | 1464 | } else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>'; |
1465 | 1465 | print '</div></ul>'; |
1466 | 1466 | print '<div id="error"></div>'; |
@@ -1523,7 +1523,7 @@ discard block |
||
1523 | 1523 | unset($_COOKIE['install']); |
1524 | 1524 | print '<div class="info column"><ul>'; |
1525 | 1525 | foreach ($_SESSION['done'] as $done) { |
1526 | - print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
1526 | + print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
1527 | 1527 | } |
1528 | 1528 | print '<li>Reloading page to check all is now ok....<strong>SUCCESS</strong></li>'; |
1529 | 1529 | print '</ul></div>'; |
@@ -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', |
@@ -165,13 +165,13 @@ discard block |
||
165 | 165 | '\~' => 'TNC Stream SW'); |
166 | 166 | |
167 | 167 | |
168 | - private function urshift($n, $s) { |
|
168 | + private function urshift($n, $s) { |
|
169 | 169 | return ($n >= 0) ? ($n >> $s) : |
170 | - (($n & 0x7fffffff) >> $s) | |
|
170 | + (($n & 0x7fffffff) >> $s) | |
|
171 | 171 | (0x40000000 >> ($s - 1)); |
172 | - } |
|
172 | + } |
|
173 | 173 | |
174 | - public function parse($input) { |
|
174 | + public function parse($input) { |
|
175 | 175 | global $globalDebug; |
176 | 176 | $debug = false; |
177 | 177 | $result = array(); |
@@ -183,8 +183,8 @@ discard block |
||
183 | 183 | |
184 | 184 | /* Check that end was found and body has at least one byte. */ |
185 | 185 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
186 | - if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; |
|
187 | - return false; |
|
186 | + if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; |
|
187 | + return false; |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | if ($debug) echo 'input : '.$input."\n"; |
@@ -198,34 +198,34 @@ discard block |
||
198 | 198 | /* Parse source, target and path. */ |
199 | 199 | //FLRDF0A52>APRS,qAS,LSTB |
200 | 200 | if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) { |
201 | - $ident = $matches[1]; |
|
202 | - $all_elements = $matches[2]; |
|
203 | - if ($ident == 'AIRCRAFT') { |
|
201 | + $ident = $matches[1]; |
|
202 | + $all_elements = $matches[2]; |
|
203 | + if ($ident == 'AIRCRAFT') { |
|
204 | 204 | $result['format_source'] = 'famaprs'; |
205 | 205 | $result['source_type'] = 'modes'; |
206 | - } elseif ($ident == 'MARINE') { |
|
206 | + } elseif ($ident == 'MARINE') { |
|
207 | 207 | $result['format_source'] = 'famaprs'; |
208 | 208 | $result['source_type'] = 'ais'; |
209 | - } else { |
|
209 | + } else { |
|
210 | 210 | if ($debug) echo 'ident : '.$ident."\n"; |
211 | 211 | $result['ident'] = $ident; |
212 | - } |
|
212 | + } |
|
213 | 213 | } else { |
214 | - if ($debug) 'No ident'."\n"; |
|
215 | - return false; |
|
214 | + if ($debug) 'No ident'."\n"; |
|
215 | + return false; |
|
216 | 216 | } |
217 | 217 | $elements = explode(',',$all_elements); |
218 | 218 | $source = end($elements); |
219 | 219 | $result['source'] = $source; |
220 | 220 | foreach ($elements as $element) { |
221 | - if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
222 | - //echo "ok"; |
|
223 | - //if ($element == 'TCPIP*') return false; |
|
224 | - } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
221 | + if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
222 | + //echo "ok"; |
|
223 | + //if ($element == 'TCPIP*') return false; |
|
224 | + } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
225 | 225 | if ($debug) echo 'element : '.$element."\n"; |
226 | 226 | return false; |
227 | - } |
|
228 | - /* |
|
227 | + } |
|
228 | + /* |
|
229 | 229 | } elseif (preg_match('/^([0-9A-F]{32})$/',$element)) { |
230 | 230 | //echo "ok"; |
231 | 231 | } else { |
@@ -252,48 +252,48 @@ discard block |
||
252 | 252 | $body_parse = substr($body,1); |
253 | 253 | //echo 'Body : '.$body."\n"; |
254 | 254 | if (preg_match('/^;(.){9}\*/',$body,$matches)) { |
255 | - $body_parse = substr($body_parse,10); |
|
256 | - $find = true; |
|
257 | - //echo $body_parse."\n"; |
|
255 | + $body_parse = substr($body_parse,10); |
|
256 | + $find = true; |
|
257 | + //echo $body_parse."\n"; |
|
258 | 258 | } |
259 | 259 | if (preg_match('/^`(.*)\//',$body,$matches)) { |
260 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
261 | - $find = true; |
|
262 | - //echo $body_parse."\n"; |
|
260 | + $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
261 | + $find = true; |
|
262 | + //echo $body_parse."\n"; |
|
263 | 263 | } |
264 | 264 | if (preg_match("/^'(.*)\//",$body,$matches)) { |
265 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
266 | - $find = true; |
|
267 | - //echo $body_parse."\n"; |
|
265 | + $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
266 | + $find = true; |
|
267 | + //echo $body_parse."\n"; |
|
268 | 268 | } |
269 | 269 | if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) { |
270 | - $find = true; |
|
271 | - //print_r($matches); |
|
272 | - $timestamp = $matches[0]; |
|
273 | - if ($matches[4] == 'h') { |
|
270 | + $find = true; |
|
271 | + //print_r($matches); |
|
272 | + $timestamp = $matches[0]; |
|
273 | + if ($matches[4] == 'h') { |
|
274 | 274 | $timestamp = strtotime(date('Ymd').' '.$matches[1].':'.$matches[2].':'.$matches[3]); |
275 | 275 | //echo 'timestamp : '.$timestamp.' - now : '.time()."\n"; |
276 | 276 | /* |
277 | 277 | if (time() + 3900 < $timestamp) $timestamp -= 86400; |
278 | 278 | elseif (time() - 82500 > $timestamp) $timestamp += 86400; |
279 | 279 | */ |
280 | - } elseif ($matches[4] == 'z' || $matches[4] == '/') { |
|
280 | + } elseif ($matches[4] == 'z' || $matches[4] == '/') { |
|
281 | 281 | // This work or not ? |
282 | 282 | $timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]); |
283 | - } |
|
284 | - $body_parse = substr($body_parse,7); |
|
285 | - $result['timestamp'] = $timestamp; |
|
286 | - //echo date('Ymd H:i:s',$timestamp); |
|
283 | + } |
|
284 | + $body_parse = substr($body_parse,7); |
|
285 | + $result['timestamp'] = $timestamp; |
|
286 | + //echo date('Ymd H:i:s',$timestamp); |
|
287 | 287 | } |
288 | 288 | if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) { |
289 | - $find = true; |
|
290 | - $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); |
|
291 | - $body_parse = substr($body_parse,8); |
|
292 | - $result['timestamp'] = $timestamp; |
|
293 | - //echo date('Ymd H:i:s',$timestamp); |
|
289 | + $find = true; |
|
290 | + $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); |
|
291 | + $body_parse = substr($body_parse,8); |
|
292 | + $result['timestamp'] = $timestamp; |
|
293 | + //echo date('Ymd H:i:s',$timestamp); |
|
294 | 294 | } |
295 | 295 | //if (strlen($body_parse) > 19) { |
296 | - 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)) { |
|
296 | + 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)) { |
|
297 | 297 | $find = true; |
298 | 298 | // 4658.70N/00707.78Ez |
299 | 299 | //print_r(str_split($body_parse)); |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | $lon = intval($lon_deg); |
313 | 313 | if ($lat > 89 || $lon > 179) return false; |
314 | 314 | |
315 | - /* |
|
315 | + /* |
|
316 | 316 | $tmp_5b = str_replace('.','',$lat_min); |
317 | 317 | if (preg_match('/^([0-9]{0,4})( {0,4})$/',$tmp_5b,$matches)) { |
318 | 318 | print_r($matches); |
@@ -326,9 +326,9 @@ discard block |
||
326 | 326 | $result['longitude'] = $longitude; |
327 | 327 | $body_parse = substr($body_parse,18); |
328 | 328 | $body_parse_len = strlen($body_parse); |
329 | - } |
|
330 | - $body_parse_len = strlen($body_parse); |
|
331 | - if ($body_parse_len > 0) { |
|
329 | + } |
|
330 | + $body_parse_len = strlen($body_parse); |
|
331 | + if ($body_parse_len > 0) { |
|
332 | 332 | /* |
333 | 333 | if (!isset($result['timestamp']) && !isset($result['latitude'])) { |
334 | 334 | $body_split = str_split($body); |
@@ -362,95 +362,95 @@ discard block |
||
362 | 362 | if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; |
363 | 363 | if ($symbol_code != '_') { |
364 | 364 | } |
365 | - //$body_parse = substr($body_parse,1); |
|
366 | - //$body_parse = trim($body_parse); |
|
367 | - //$body_parse_len = strlen($body_parse); |
|
368 | - if ($body_parse_len >= 7) { |
|
365 | + //$body_parse = substr($body_parse,1); |
|
366 | + //$body_parse = trim($body_parse); |
|
367 | + //$body_parse_len = strlen($body_parse); |
|
368 | + if ($body_parse_len >= 7) { |
|
369 | 369 | |
370 | - if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
371 | - $course = substr($body_parse,0,3); |
|
372 | - $tmp_s = intval($course); |
|
373 | - if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
|
374 | - $speed = substr($body_parse,4,3); |
|
375 | - if ($speed != '...') { |
|
376 | - //$result['speed'] = round($speed*1.852); |
|
377 | - $result['speed'] = intval($speed); |
|
378 | - } |
|
379 | - $body_parse = substr($body_parse,7); |
|
380 | - } |
|
381 | - // Check PHGR, PHG, RNG |
|
382 | - } |
|
383 | - /* |
|
370 | + if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
371 | + $course = substr($body_parse,0,3); |
|
372 | + $tmp_s = intval($course); |
|
373 | + if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
|
374 | + $speed = substr($body_parse,4,3); |
|
375 | + if ($speed != '...') { |
|
376 | + //$result['speed'] = round($speed*1.852); |
|
377 | + $result['speed'] = intval($speed); |
|
378 | + } |
|
379 | + $body_parse = substr($body_parse,7); |
|
380 | + } |
|
381 | + // Check PHGR, PHG, RNG |
|
382 | + } |
|
383 | + /* |
|
384 | 384 | else if ($body_parse_len > 0) { |
385 | 385 | $rest = $body_parse; |
386 | 386 | } |
387 | 387 | */ |
388 | - if (strlen($body_parse) > 0) { |
|
389 | - if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
390 | - $altitude = intval($matches[1]); |
|
391 | - //$result['altitude'] = round($altitude*0.3048); |
|
392 | - $result['altitude'] = $altitude; |
|
393 | - //$body_parse = trim(substr($body_parse,strlen($matches[0]))); |
|
394 | - $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); |
|
395 | - } |
|
396 | - } |
|
388 | + if (strlen($body_parse) > 0) { |
|
389 | + if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
390 | + $altitude = intval($matches[1]); |
|
391 | + //$result['altitude'] = round($altitude*0.3048); |
|
392 | + $result['altitude'] = $altitude; |
|
393 | + //$body_parse = trim(substr($body_parse,strlen($matches[0]))); |
|
394 | + $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); |
|
395 | + } |
|
396 | + } |
|
397 | 397 | |
398 | - // Telemetry |
|
399 | - /* |
|
398 | + // Telemetry |
|
399 | + /* |
|
400 | 400 | 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)) { |
401 | 401 | // Nothing yet... |
402 | 402 | } |
403 | 403 | */ |
404 | - // DAO |
|
404 | + // DAO |
|
405 | 405 | |
406 | - if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
406 | + if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
407 | 407 | |
408 | - $dao = $matches[1]; |
|
409 | - if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
408 | + $dao = $matches[1]; |
|
409 | + if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
410 | 410 | $dao_split = str_split($dao); |
411 | - $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
|
412 | - $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
|
411 | + $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
|
412 | + $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
|
413 | 413 | |
414 | 414 | if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
415 | 415 | else $result['latitude'] += $lat_off; |
416 | 416 | if ($result['longitude'] < 0) $result['longitude'] -= $lon_off; |
417 | 417 | else $result['longitude'] += $lon_off; |
418 | - } |
|
418 | + } |
|
419 | 419 | |
420 | - $body_parse = substr($body_parse,6); |
|
421 | - } |
|
420 | + $body_parse = substr($body_parse,6); |
|
421 | + } |
|
422 | 422 | |
423 | - if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
423 | + if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
424 | 424 | $result['ident'] = str_replace('_',' ',$matches[1]); |
425 | - } |
|
426 | - if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { |
|
425 | + } |
|
426 | + if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { |
|
427 | 427 | $result['squawk'] = $matches[1]; |
428 | - } |
|
429 | - if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { |
|
428 | + } |
|
429 | + if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { |
|
430 | 430 | $result['aircraft_icao'] = $matches[1]; |
431 | - } |
|
432 | - if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) { |
|
431 | + } |
|
432 | + if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) { |
|
433 | 433 | $result['verticalrate'] = $matches[1]; |
434 | - } |
|
435 | - if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { |
|
434 | + } |
|
435 | + if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { |
|
436 | 436 | $result['typeid'] = $matches[1]; |
437 | - } |
|
438 | - if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) { |
|
437 | + } |
|
438 | + if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) { |
|
439 | 439 | $result['statusid'] = $matches[1]; |
440 | - } |
|
441 | - if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { |
|
440 | + } |
|
441 | + if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { |
|
442 | 442 | $result['imo'] = $matches[1]; |
443 | - } |
|
444 | - if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { |
|
443 | + } |
|
444 | + if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { |
|
445 | 445 | $result['arrival_date'] = $matches[1]; |
446 | - } |
|
447 | - if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
446 | + } |
|
447 | + if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
448 | 448 | $result['arrival_code'] = str_replace('_',' ',$matches[1]); |
449 | - } |
|
450 | - // OGN comment |
|
449 | + } |
|
450 | + // OGN comment |
|
451 | 451 | // echo "Before OGN : ".$body_parse."\n"; |
452 | - //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
|
453 | - if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { |
|
452 | + //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
|
453 | + if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { |
|
454 | 454 | $id = $matches[1]; |
455 | 455 | //$mode = substr($id,0,2); |
456 | 456 | $address = substr($id,2); |
@@ -480,42 +480,42 @@ discard block |
||
480 | 480 | $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
481 | 481 | $result['stealth'] = $stealth; |
482 | 482 | $result['address'] = $address; |
483 | - } |
|
483 | + } |
|
484 | 484 | |
485 | - //Comment |
|
486 | - $result['comment'] = trim($body_parse); |
|
485 | + //Comment |
|
486 | + $result['comment'] = trim($body_parse); |
|
487 | 487 | //} else { |
488 | - // parse weather |
|
489 | - //$body_parse = substr($body_parse,1); |
|
490 | - //$body_parse_len = strlen($body_parse); |
|
491 | - //echo 'weather'."\n"; |
|
492 | - if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
493 | - $result['wind_dir'] = intval($matches[1]); |
|
494 | - $result['wind_speed'] = round(intval($matches[2])*1.60934,1); |
|
495 | - $result['wind_gust'] = round(intval($matches[3])*1.60934,1); |
|
496 | - $result['temp'] = round(5/9*((intval($matches[4]))-32),1); |
|
497 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
498 | - } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
488 | + // parse weather |
|
489 | + //$body_parse = substr($body_parse,1); |
|
490 | + //$body_parse_len = strlen($body_parse); |
|
491 | + //echo 'weather'."\n"; |
|
492 | + if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
493 | + $result['wind_dir'] = intval($matches[1]); |
|
494 | + $result['wind_speed'] = round(intval($matches[2])*1.60934,1); |
|
495 | + $result['wind_gust'] = round(intval($matches[3])*1.60934,1); |
|
496 | + $result['temp'] = round(5/9*((intval($matches[4]))-32),1); |
|
497 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
498 | + } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
499 | 499 | $result['wind_dir'] = intval($matches[1]); |
500 | 500 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
501 | 501 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
502 | 502 | $result['temp'] = round(5/9*(($matches[4])-32),1); |
503 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
504 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
503 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
504 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
505 | 505 | $result['wind_dir'] = intval($matches[1]); |
506 | 506 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
507 | 507 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
508 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
509 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { |
|
508 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
509 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { |
|
510 | 510 | $result['wind_dir'] = intval($matches[1]); |
511 | 511 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
512 | 512 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
513 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
514 | - } |
|
515 | - //if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
|
516 | - //g012t088r000p000P000h38b10110 |
|
517 | - //g011t086r000p000P000h29b10198 |
|
518 | - if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
|
513 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
514 | + } |
|
515 | + //if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
|
516 | + //g012t088r000p000P000h38b10110 |
|
517 | + //g011t086r000p000P000h29b10198 |
|
518 | + if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
|
519 | 519 | if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
520 | 520 | if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
521 | 521 | if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
@@ -523,8 +523,8 @@ discard block |
||
523 | 523 | if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); |
524 | 524 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
525 | 525 | if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1); |
526 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
527 | - } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
|
526 | + $body_parse = substr($body_parse,strlen($matches[0])); |
|
527 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
|
528 | 528 | if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
529 | 529 | if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
530 | 530 | if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
@@ -532,8 +532,8 @@ discard block |
||
532 | 532 | if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); |
533 | 533 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
534 | 534 | if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1); |
535 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
536 | - } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { |
|
535 | + $body_parse = substr($body_parse,strlen($matches[0])); |
|
536 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { |
|
537 | 537 | if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
538 | 538 | if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
539 | 539 | if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
@@ -541,58 +541,58 @@ discard block |
||
541 | 541 | if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); |
542 | 542 | if ($matches[7] != '...') $result['humidity'] = intval($matches[7]); |
543 | 543 | if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1); |
544 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
545 | - } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { |
|
544 | + $body_parse = substr($body_parse,strlen($matches[0])); |
|
545 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { |
|
546 | 546 | if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
547 | 547 | if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
548 | 548 | if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
549 | 549 | if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); |
550 | 550 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
551 | 551 | if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); |
552 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
553 | - } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { |
|
552 | + $body_parse = substr($body_parse,strlen($matches[0])); |
|
553 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { |
|
554 | 554 | if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
555 | 555 | if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
556 | 556 | if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
557 | 557 | if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
558 | 558 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
559 | 559 | if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); |
560 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
561 | - } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
|
560 | + $body_parse = substr($body_parse,strlen($matches[0])); |
|
561 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
|
562 | 562 | if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
563 | 563 | if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
564 | 564 | if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
565 | 565 | if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
566 | 566 | if ($matches[5] != '...') $result['humidity'] = intval($matches[5]); |
567 | 567 | if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1); |
568 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
569 | - } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
|
568 | + $body_parse = substr($body_parse,strlen($matches[0])); |
|
569 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
|
570 | 570 | if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
571 | 571 | if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
572 | 572 | if ($matches[2] != '...') $result['humidity'] = intval($matches[3]); |
573 | 573 | if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10),1); |
574 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
575 | - } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
|
574 | + $body_parse = substr($body_parse,strlen($matches[0])); |
|
575 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
|
576 | 576 | if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
577 | 577 | if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
578 | 578 | if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
579 | 579 | if ($matches[4] != '...') $result['humidity'] = intval($matches[4]); |
580 | 580 | if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); |
581 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
582 | - } |
|
583 | - $result['comment'] = trim($body_parse); |
|
581 | + $body_parse = substr($body_parse,strlen($matches[0])); |
|
582 | + } |
|
583 | + $result['comment'] = trim($body_parse); |
|
584 | 584 | } |
585 | 585 | } else $result['comment'] = trim($body_parse); |
586 | 586 | |
587 | - } |
|
587 | + } |
|
588 | 588 | //} |
589 | 589 | if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
590 | 590 | if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
591 | 591 | if ($debug) print_r($result); |
592 | 592 | return $result; |
593 | - } |
|
593 | + } |
|
594 | 594 | |
595 | - public function connect() { |
|
595 | + public function connect() { |
|
596 | 596 | global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport; |
597 | 597 | $aprs_connect = 0; |
598 | 598 | $aprs_keep = 120; |
@@ -616,24 +616,24 @@ discard block |
||
616 | 616 | socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE,1); |
617 | 617 | while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) { |
618 | 618 | if (strpos($msgin, "$aprs_ssid verified") !== FALSE) { |
619 | - echo 'APRS user verified !'."\n"; |
|
620 | - $this->connected = true; |
|
621 | - return true; |
|
622 | - break; |
|
619 | + echo 'APRS user verified !'."\n"; |
|
620 | + $this->connected = true; |
|
621 | + return true; |
|
622 | + break; |
|
623 | 623 | } |
624 | 624 | if (time()-$authstart > 5) { |
625 | - echo 'APRS timeout'."\n"; |
|
626 | - break; |
|
625 | + echo 'APRS timeout'."\n"; |
|
626 | + break; |
|
627 | 627 | } |
628 | 628 | } |
629 | 629 | } |
630 | - } |
|
630 | + } |
|
631 | 631 | |
632 | - public function disconnect() { |
|
632 | + public function disconnect() { |
|
633 | 633 | socket_close($this->socket); |
634 | - } |
|
634 | + } |
|
635 | 635 | |
636 | - public function send($data) { |
|
636 | + public function send($data) { |
|
637 | 637 | global $globalDebug; |
638 | 638 | if ($this->connected === false) $this->connect(); |
639 | 639 | $send = socket_send( $this->socket , $data , strlen($data),0); |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | socket_close($this->socket); |
643 | 643 | $this->connect(); |
644 | 644 | } |
645 | - } |
|
645 | + } |
|
646 | 646 | } |
647 | 647 | |
648 | 648 | class APRSSpotter extends APRS { |
@@ -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(); |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
89 | - * Gets all the spotter information based on the latest data entry |
|
90 | - * |
|
91 | - * @return Array the spotter information |
|
92 | - * |
|
93 | - */ |
|
89 | + * Gets all the spotter information based on the latest data entry |
|
90 | + * |
|
91 | + * @return Array the spotter information |
|
92 | + * |
|
93 | + */ |
|
94 | 94 | public function getLiveTrackerData($limit = '', $sort = '', $filter = array()) |
95 | 95 | { |
96 | 96 | global $globalDBdriver, $globalLiveInterval; |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
135 | - * Gets Minimal Live Spotter data |
|
136 | - * |
|
137 | - * @return Array the spotter information |
|
138 | - * |
|
139 | - */ |
|
135 | + * Gets Minimal Live Spotter data |
|
136 | + * |
|
137 | + * @return Array the spotter information |
|
138 | + * |
|
139 | + */ |
|
140 | 140 | public function getMinLiveTrackerData($filter = array()) |
141 | 141 | { |
142 | 142 | global $globalDBdriver, $globalLiveInterval; |
@@ -170,11 +170,11 @@ discard block |
||
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
173 | - * Gets Minimal Live Spotter data since xx seconds |
|
174 | - * |
|
175 | - * @return Array the spotter information |
|
176 | - * |
|
177 | - */ |
|
173 | + * Gets Minimal Live Spotter data since xx seconds |
|
174 | + * |
|
175 | + * @return Array the spotter information |
|
176 | + * |
|
177 | + */ |
|
178 | 178 | public function getMinLastLiveTrackerData($filter = array()) |
179 | 179 | { |
180 | 180 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -230,11 +230,11 @@ discard block |
||
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
233 | - * Gets number of latest data entry |
|
234 | - * |
|
235 | - * @return String number of entry |
|
236 | - * |
|
237 | - */ |
|
233 | + * Gets number of latest data entry |
|
234 | + * |
|
235 | + * @return String number of entry |
|
236 | + * |
|
237 | + */ |
|
238 | 238 | public function getLiveTrackerCount($filter = array()) |
239 | 239 | { |
240 | 240 | global $globalDBdriver, $globalLiveInterval; |
@@ -259,11 +259,11 @@ discard block |
||
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
262 | - * Gets all the spotter information based on the latest data entry and coord |
|
263 | - * |
|
264 | - * @return Array the spotter information |
|
265 | - * |
|
266 | - */ |
|
262 | + * Gets all the spotter information based on the latest data entry and coord |
|
263 | + * |
|
264 | + * @return Array the spotter information |
|
265 | + * |
|
266 | + */ |
|
267 | 267 | public function getLiveTrackerDatabyCoord($coord, $filter = array()) |
268 | 268 | { |
269 | 269 | global $globalDBdriver, $globalLiveInterval; |
@@ -287,11 +287,11 @@ discard block |
||
287 | 287 | } |
288 | 288 | |
289 | 289 | /** |
290 | - * Gets all the spotter information based on the latest data entry and coord |
|
291 | - * |
|
292 | - * @return Array the spotter information |
|
293 | - * |
|
294 | - */ |
|
290 | + * Gets all the spotter information based on the latest data entry and coord |
|
291 | + * |
|
292 | + * @return Array the spotter information |
|
293 | + * |
|
294 | + */ |
|
295 | 295 | public function getMinLiveTrackerDatabyCoord($coord, $filter = array()) |
296 | 296 | { |
297 | 297 | global $globalDBdriver, $globalLiveInterval; |
@@ -318,11 +318,11 @@ discard block |
||
318 | 318 | } |
319 | 319 | |
320 | 320 | /** |
321 | - * Gets all the spotter information based on a user's latitude and longitude |
|
322 | - * |
|
323 | - * @return Array the spotter information |
|
324 | - * |
|
325 | - */ |
|
321 | + * Gets all the spotter information based on a user's latitude and longitude |
|
322 | + * |
|
323 | + * @return Array the spotter information |
|
324 | + * |
|
325 | + */ |
|
326 | 326 | public function getLatestTrackerForLayar($lat, $lng, $radius, $interval) |
327 | 327 | { |
328 | 328 | $Tracker = new Tracker($this->db); |
@@ -335,142 +335,142 @@ discard block |
||
335 | 335 | if ($lng != '') |
336 | 336 | { |
337 | 337 | if (!is_numeric($lng)) |
338 | - { |
|
339 | - return false; |
|
340 | - } |
|
341 | - } |
|
342 | - |
|
343 | - if ($radius != '') |
|
344 | - { |
|
345 | - if (!is_numeric($radius)) |
|
346 | - { |
|
347 | - return false; |
|
348 | - } |
|
349 | - } |
|
338 | + { |
|
339 | + return false; |
|
340 | + } |
|
341 | + } |
|
342 | + |
|
343 | + if ($radius != '') |
|
344 | + { |
|
345 | + if (!is_numeric($radius)) |
|
346 | + { |
|
347 | + return false; |
|
348 | + } |
|
349 | + } |
|
350 | 350 | $additional_query = ''; |
351 | 351 | if ($interval != '') |
352 | - { |
|
353 | - if (!is_string($interval)) |
|
354 | - { |
|
355 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
356 | - return false; |
|
357 | - } else { |
|
358 | - if ($interval == '1m') |
|
359 | - { |
|
360 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
361 | - } else if ($interval == '15m'){ |
|
362 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
|
363 | - } |
|
364 | - } |
|
365 | - } else { |
|
366 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
367 | - } |
|
368 | - |
|
369 | - $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
352 | + { |
|
353 | + if (!is_string($interval)) |
|
354 | + { |
|
355 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
356 | + return false; |
|
357 | + } else { |
|
358 | + if ($interval == '1m') |
|
359 | + { |
|
360 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
361 | + } else if ($interval == '15m'){ |
|
362 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
|
363 | + } |
|
364 | + } |
|
365 | + } else { |
|
366 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
367 | + } |
|
368 | + |
|
369 | + $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
370 | 370 | WHERE tracker_live.latitude <> '' |
371 | 371 | AND tracker_live.longitude <> '' |
372 | 372 | ".$additional_query." |
373 | 373 | HAVING distance < :radius |
374 | 374 | ORDER BY distance"; |
375 | 375 | |
376 | - $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
376 | + $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
377 | 377 | |
378 | - return $spotter_array; |
|
379 | - } |
|
378 | + return $spotter_array; |
|
379 | + } |
|
380 | 380 | |
381 | 381 | |
382 | - /** |
|
383 | - * Gets all the spotter information based on a particular callsign |
|
384 | - * |
|
385 | - * @return Array the spotter information |
|
386 | - * |
|
387 | - */ |
|
382 | + /** |
|
383 | + * Gets all the spotter information based on a particular callsign |
|
384 | + * |
|
385 | + * @return Array the spotter information |
|
386 | + * |
|
387 | + */ |
|
388 | 388 | public function getLastLiveTrackerDataByIdent($ident) |
389 | 389 | { |
390 | 390 | $Tracker = new Tracker($this->db); |
391 | 391 | date_default_timezone_set('UTC'); |
392 | 392 | |
393 | 393 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
394 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
394 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
395 | 395 | |
396 | 396 | $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true); |
397 | 397 | |
398 | 398 | return $spotter_array; |
399 | 399 | } |
400 | 400 | |
401 | - /** |
|
402 | - * Gets all the spotter information based on a particular callsign |
|
403 | - * |
|
404 | - * @return Array the spotter information |
|
405 | - * |
|
406 | - */ |
|
401 | + /** |
|
402 | + * Gets all the spotter information based on a particular callsign |
|
403 | + * |
|
404 | + * @return Array the spotter information |
|
405 | + * |
|
406 | + */ |
|
407 | 407 | public function getDateLiveTrackerDataByIdent($ident,$date) |
408 | 408 | { |
409 | 409 | $Tracker = new Tracker($this->db); |
410 | 410 | date_default_timezone_set('UTC'); |
411 | 411 | |
412 | 412 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
413 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
413 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
414 | 414 | |
415 | - $date = date('c',$date); |
|
415 | + $date = date('c',$date); |
|
416 | 416 | $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
417 | 417 | |
418 | 418 | return $spotter_array; |
419 | 419 | } |
420 | 420 | |
421 | - /** |
|
422 | - * Gets last spotter information based on a particular callsign |
|
423 | - * |
|
424 | - * @return Array the spotter information |
|
425 | - * |
|
426 | - */ |
|
421 | + /** |
|
422 | + * Gets last spotter information based on a particular callsign |
|
423 | + * |
|
424 | + * @return Array the spotter information |
|
425 | + * |
|
426 | + */ |
|
427 | 427 | public function getLastLiveTrackerDataById($id) |
428 | 428 | { |
429 | 429 | $Tracker = new Tracker($this->db); |
430 | 430 | date_default_timezone_set('UTC'); |
431 | 431 | |
432 | 432 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
433 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
433 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
434 | 434 | |
435 | 435 | $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true); |
436 | 436 | |
437 | 437 | return $spotter_array; |
438 | 438 | } |
439 | 439 | |
440 | - /** |
|
441 | - * Gets last spotter information based on a particular callsign |
|
442 | - * |
|
443 | - * @return Array the spotter information |
|
444 | - * |
|
445 | - */ |
|
440 | + /** |
|
441 | + * Gets last spotter information based on a particular callsign |
|
442 | + * |
|
443 | + * @return Array the spotter information |
|
444 | + * |
|
445 | + */ |
|
446 | 446 | public function getDateLiveTrackerDataById($id,$date) |
447 | 447 | { |
448 | 448 | $Tracker = new Tracker($this->db); |
449 | 449 | date_default_timezone_set('UTC'); |
450 | 450 | |
451 | 451 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
452 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
453 | - $date = date('c',$date); |
|
452 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
453 | + $date = date('c',$date); |
|
454 | 454 | $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
455 | 455 | |
456 | 456 | return $spotter_array; |
457 | 457 | } |
458 | 458 | |
459 | - /** |
|
460 | - * Gets altitude information based on a particular callsign |
|
461 | - * |
|
462 | - * @return Array the spotter information |
|
463 | - * |
|
464 | - */ |
|
459 | + /** |
|
460 | + * Gets altitude information based on a particular callsign |
|
461 | + * |
|
462 | + * @return Array the spotter information |
|
463 | + * |
|
464 | + */ |
|
465 | 465 | public function getAltitudeLiveTrackerDataByIdent($ident) |
466 | 466 | { |
467 | 467 | |
468 | 468 | date_default_timezone_set('UTC'); |
469 | 469 | |
470 | 470 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
471 | - $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
471 | + $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
472 | 472 | |
473 | - try { |
|
473 | + try { |
|
474 | 474 | |
475 | 475 | $sth = $this->db->prepare($query); |
476 | 476 | $sth->execute(array(':ident' => $ident)); |
@@ -483,12 +483,12 @@ discard block |
||
483 | 483 | return $spotter_array; |
484 | 484 | } |
485 | 485 | |
486 | - /** |
|
487 | - * Gets all the spotter information based on a particular id |
|
488 | - * |
|
489 | - * @return Array the spotter information |
|
490 | - * |
|
491 | - */ |
|
486 | + /** |
|
487 | + * Gets all the spotter information based on a particular id |
|
488 | + * |
|
489 | + * @return Array the spotter information |
|
490 | + * |
|
491 | + */ |
|
492 | 492 | public function getAllLiveTrackerDataById($id,$liveinterval = false) |
493 | 493 | { |
494 | 494 | global $globalDBdriver, $globalLiveInterval; |
@@ -516,18 +516,18 @@ discard block |
||
516 | 516 | return $spotter_array; |
517 | 517 | } |
518 | 518 | |
519 | - /** |
|
520 | - * Gets all the spotter information based on a particular ident |
|
521 | - * |
|
522 | - * @return Array the spotter information |
|
523 | - * |
|
524 | - */ |
|
519 | + /** |
|
520 | + * Gets all the spotter information based on a particular ident |
|
521 | + * |
|
522 | + * @return Array the spotter information |
|
523 | + * |
|
524 | + */ |
|
525 | 525 | public function getAllLiveTrackerDataByIdent($ident) |
526 | 526 | { |
527 | 527 | date_default_timezone_set('UTC'); |
528 | 528 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
529 | 529 | $query = self::$global_query.' WHERE tracker_live.ident = :ident'; |
530 | - try { |
|
530 | + try { |
|
531 | 531 | |
532 | 532 | $sth = $this->db->prepare($query); |
533 | 533 | $sth->execute(array(':ident' => $ident)); |
@@ -541,23 +541,23 @@ discard block |
||
541 | 541 | |
542 | 542 | |
543 | 543 | /** |
544 | - * Deletes all info in the table |
|
545 | - * |
|
546 | - * @return String success or false |
|
547 | - * |
|
548 | - */ |
|
544 | + * Deletes all info in the table |
|
545 | + * |
|
546 | + * @return String success or false |
|
547 | + * |
|
548 | + */ |
|
549 | 549 | public function deleteLiveTrackerData() |
550 | 550 | { |
551 | 551 | global $globalDBdriver; |
552 | 552 | if ($globalDBdriver == 'mysql') { |
553 | 553 | //$query = "DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= tracker_live.date"; |
554 | 554 | $query = 'DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= tracker_live.date'; |
555 | - //$query = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)"; |
|
555 | + //$query = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)"; |
|
556 | 556 | } else { |
557 | 557 | $query = "DELETE FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date"; |
558 | 558 | } |
559 | 559 | |
560 | - try { |
|
560 | + try { |
|
561 | 561 | |
562 | 562 | $sth = $this->db->prepare($query); |
563 | 563 | $sth->execute(); |
@@ -569,18 +569,18 @@ discard block |
||
569 | 569 | } |
570 | 570 | |
571 | 571 | /** |
572 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
573 | - * |
|
574 | - * @return String success or false |
|
575 | - * |
|
576 | - */ |
|
572 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
573 | + * |
|
574 | + * @return String success or false |
|
575 | + * |
|
576 | + */ |
|
577 | 577 | public function deleteLiveTrackerDataNotUpdated() |
578 | 578 | { |
579 | 579 | global $globalDBdriver, $globalDebug; |
580 | 580 | if ($globalDBdriver == 'mysql') { |
581 | 581 | //$query = 'SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < tracker_live.date) LIMIT 800 OFFSET 0'; |
582 | - $query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
583 | - try { |
|
582 | + $query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
583 | + try { |
|
584 | 584 | |
585 | 585 | $sth = $this->db->prepare($query); |
586 | 586 | $sth->execute(); |
@@ -588,8 +588,8 @@ discard block |
||
588 | 588 | return "error"; |
589 | 589 | } |
590 | 590 | $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
591 | - $i = 0; |
|
592 | - $j =0; |
|
591 | + $i = 0; |
|
592 | + $j =0; |
|
593 | 593 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
594 | 594 | foreach($all as $row) |
595 | 595 | { |
@@ -597,20 +597,20 @@ discard block |
||
597 | 597 | $j++; |
598 | 598 | if ($j == 30) { |
599 | 599 | if ($globalDebug) echo "."; |
600 | - try { |
|
600 | + try { |
|
601 | 601 | |
602 | 602 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
603 | 603 | $sth->execute(); |
604 | 604 | } catch(PDOException $e) { |
605 | 605 | return "error"; |
606 | 606 | } |
607 | - $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
|
608 | - $j = 0; |
|
607 | + $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
|
608 | + $j = 0; |
|
609 | 609 | } |
610 | 610 | $query_delete .= "'".$row['famtrackid']."',"; |
611 | 611 | } |
612 | 612 | if ($i > 0) { |
613 | - try { |
|
613 | + try { |
|
614 | 614 | |
615 | 615 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
616 | 616 | $sth->execute(); |
@@ -621,9 +621,9 @@ discard block |
||
621 | 621 | return "success"; |
622 | 622 | } elseif ($globalDBdriver == 'pgsql') { |
623 | 623 | //$query = "SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < tracker_live.date) LIMIT 800 OFFSET 0"; |
624 | - //$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
625 | - $query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
626 | - try { |
|
624 | + //$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
625 | + $query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
626 | + try { |
|
627 | 627 | |
628 | 628 | $sth = $this->db->prepare($query); |
629 | 629 | $sth->execute(); |
@@ -667,17 +667,17 @@ discard block |
||
667 | 667 | } |
668 | 668 | |
669 | 669 | /** |
670 | - * Deletes all info in the table for an ident |
|
671 | - * |
|
672 | - * @return String success or false |
|
673 | - * |
|
674 | - */ |
|
670 | + * Deletes all info in the table for an ident |
|
671 | + * |
|
672 | + * @return String success or false |
|
673 | + * |
|
674 | + */ |
|
675 | 675 | public function deleteLiveTrackerDataByIdent($ident) |
676 | 676 | { |
677 | 677 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
678 | 678 | $query = 'DELETE FROM tracker_live WHERE ident = :ident'; |
679 | 679 | |
680 | - try { |
|
680 | + try { |
|
681 | 681 | |
682 | 682 | $sth = $this->db->prepare($query); |
683 | 683 | $sth->execute(array(':ident' => $ident)); |
@@ -689,17 +689,17 @@ discard block |
||
689 | 689 | } |
690 | 690 | |
691 | 691 | /** |
692 | - * Deletes all info in the table for an id |
|
693 | - * |
|
694 | - * @return String success or false |
|
695 | - * |
|
696 | - */ |
|
692 | + * Deletes all info in the table for an id |
|
693 | + * |
|
694 | + * @return String success or false |
|
695 | + * |
|
696 | + */ |
|
697 | 697 | public function deleteLiveTrackerDataById($id) |
698 | 698 | { |
699 | 699 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
700 | 700 | $query = 'DELETE FROM tracker_live WHERE famtrackid = :id'; |
701 | 701 | |
702 | - try { |
|
702 | + try { |
|
703 | 703 | |
704 | 704 | $sth = $this->db->prepare($query); |
705 | 705 | $sth->execute(array(':id' => $id)); |
@@ -712,11 +712,11 @@ discard block |
||
712 | 712 | |
713 | 713 | |
714 | 714 | /** |
715 | - * Gets the aircraft ident within the last hour |
|
716 | - * |
|
717 | - * @return String the ident |
|
718 | - * |
|
719 | - */ |
|
715 | + * Gets the aircraft ident within the last hour |
|
716 | + * |
|
717 | + * @return String the ident |
|
718 | + * |
|
719 | + */ |
|
720 | 720 | public function getIdentFromLastHour($ident) |
721 | 721 | { |
722 | 722 | global $globalDBdriver, $globalTimezone; |
@@ -742,14 +742,14 @@ discard block |
||
742 | 742 | $ident_result = $row['ident']; |
743 | 743 | } |
744 | 744 | return $ident_result; |
745 | - } |
|
745 | + } |
|
746 | 746 | |
747 | 747 | /** |
748 | - * Check recent aircraft |
|
749 | - * |
|
750 | - * @return String the ident |
|
751 | - * |
|
752 | - */ |
|
748 | + * Check recent aircraft |
|
749 | + * |
|
750 | + * @return String the ident |
|
751 | + * |
|
752 | + */ |
|
753 | 753 | public function checkIdentRecent($ident) |
754 | 754 | { |
755 | 755 | global $globalDBdriver, $globalTimezone; |
@@ -775,14 +775,14 @@ discard block |
||
775 | 775 | $ident_result = $row['famtrackid']; |
776 | 776 | } |
777 | 777 | return $ident_result; |
778 | - } |
|
778 | + } |
|
779 | 779 | |
780 | 780 | /** |
781 | - * Check recent aircraft by id |
|
782 | - * |
|
783 | - * @return String the ident |
|
784 | - * |
|
785 | - */ |
|
781 | + * Check recent aircraft by id |
|
782 | + * |
|
783 | + * @return String the ident |
|
784 | + * |
|
785 | + */ |
|
786 | 786 | public function checkIdRecent($id) |
787 | 787 | { |
788 | 788 | global $globalDBdriver, $globalTimezone; |
@@ -808,19 +808,19 @@ discard block |
||
808 | 808 | $ident_result = $row['famtrackid']; |
809 | 809 | } |
810 | 810 | return $ident_result; |
811 | - } |
|
811 | + } |
|
812 | 812 | |
813 | 813 | /** |
814 | - * Adds a new spotter data |
|
815 | - * |
|
816 | - * @param String $famtrackid the ID from flightaware |
|
817 | - * @param String $ident the flight ident |
|
818 | - * @param String $aircraft_icao the aircraft type |
|
819 | - * @param String $departure_airport_icao the departure airport |
|
820 | - * @param String $arrival_airport_icao the arrival airport |
|
821 | - * @return String success or false |
|
822 | - * |
|
823 | - */ |
|
814 | + * Adds a new spotter data |
|
815 | + * |
|
816 | + * @param String $famtrackid the ID from flightaware |
|
817 | + * @param String $ident the flight ident |
|
818 | + * @param String $aircraft_icao the aircraft type |
|
819 | + * @param String $departure_airport_icao the departure airport |
|
820 | + * @param String $arrival_airport_icao the arrival airport |
|
821 | + * @return String success or false |
|
822 | + * |
|
823 | + */ |
|
824 | 824 | public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
825 | 825 | { |
826 | 826 | global $globalURL, $globalArchive, $globalDebug; |
@@ -893,8 +893,8 @@ discard block |
||
893 | 893 | $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
894 | 894 | $type = filter_var($type,FILTER_SANITIZE_STRING); |
895 | 895 | |
896 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
897 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
896 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
897 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
898 | 898 | |
899 | 899 | $query = ''; |
900 | 900 | if ($globalArchive) { |
@@ -909,18 +909,18 @@ discard block |
||
909 | 909 | |
910 | 910 | $sth = $this->db->prepare($query); |
911 | 911 | $sth->execute($query_values); |
912 | - } catch(PDOException $e) { |
|
913 | - return "error : ".$e->getMessage(); |
|
914 | - } |
|
915 | - /* |
|
912 | + } catch(PDOException $e) { |
|
913 | + return "error : ".$e->getMessage(); |
|
914 | + } |
|
915 | + /* |
|
916 | 916 | echo 'putinarchive : '.$putinarchive."\n"; |
917 | 917 | echo 'noarchive : '.$noarchive."\n"; |
918 | 918 | */ |
919 | 919 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
920 | - if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : '; |
|
921 | - $TrackerArchive = new TrackerArchive($this->db); |
|
922 | - $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country); |
|
923 | - if ($globalDebug) echo $result.')'; |
|
920 | + if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : '; |
|
921 | + $TrackerArchive = new TrackerArchive($this->db); |
|
922 | + $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country); |
|
923 | + if ($globalDebug) echo $result.')'; |
|
924 | 924 | } |
925 | 925 | |
926 | 926 | return "success"; |
@@ -4,31 +4,31 @@ discard block |
||
4 | 4 | $hex = str_replace("#", "", $hex); |
5 | 5 | $color = array(); |
6 | 6 | if (strlen($hex) == 3) { |
7 | - $color['r'] = hexdec(substr($hex, 0, 1) . substr($hex,0,1)); |
|
8 | - $color['g'] = hexdec(substr($hex, 1, 1) . substr($hex,1,1)); |
|
9 | - $color['b'] = hexdec(substr($hex, 2, 1) . substr($hex,2,1)); |
|
7 | + $color['r'] = hexdec(substr($hex, 0, 1) . substr($hex,0,1)); |
|
8 | + $color['g'] = hexdec(substr($hex, 1, 1) . substr($hex,1,1)); |
|
9 | + $color['b'] = hexdec(substr($hex, 2, 1) . substr($hex,2,1)); |
|
10 | 10 | } else if (strlen($hex) == 6) { |
11 | - $color['r'] = hexdec(substr($hex, 0, 2)); |
|
12 | - $color['g'] = hexdec(substr($hex, 2, 2)); |
|
13 | - $color['b'] = hexdec(substr($hex, 4, 2)); |
|
11 | + $color['r'] = hexdec(substr($hex, 0, 2)); |
|
12 | + $color['g'] = hexdec(substr($hex, 2, 2)); |
|
13 | + $color['b'] = hexdec(substr($hex, 4, 2)); |
|
14 | 14 | } |
15 | 15 | return $color; |
16 | 16 | } |
17 | 17 | |
18 | 18 | |
19 | 19 | if (!isset($_GET['color']) || $_GET['color'] == '' || !preg_match('/^([a-fA-F0-9]){3}(([a-fA-F0-9]){3})?\b/',$_GET['color'])) { |
20 | - exit(0); |
|
20 | + exit(0); |
|
21 | 21 | } |
22 | 22 | $color = $_GET['color']; |
23 | 23 | if (!isset($_GET['filename']) || !preg_match('/^[a-z0-9-_]+\.png$/', strtolower($_GET['filename']))) { |
24 | - echo "Incorrect filename"; |
|
25 | - exit(0); |
|
24 | + echo "Incorrect filename"; |
|
25 | + exit(0); |
|
26 | 26 | } |
27 | 27 | $filename = $_GET['filename']; |
28 | 28 | if (file_exists(dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.$color.'-'.$filename)) { |
29 | - header('Content-type: image/png'); |
|
30 | - readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.$color.'-'.$filename); |
|
31 | - exit(0); |
|
29 | + header('Content-type: image/png'); |
|
30 | + readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.$color.'-'.$filename); |
|
31 | + exit(0); |
|
32 | 32 | } |
33 | 33 | if (isset($_GET['tracker'])) { |
34 | 34 | $original = dirname(__FILE__).DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'vehicules'.DIRECTORY_SEPARATOR.'color'.DIRECTORY_SEPARATOR.$filename; |
@@ -42,66 +42,66 @@ discard block |
||
42 | 42 | $original = dirname(__FILE__).DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'aircrafts'.DIRECTORY_SEPARATOR.'new'.DIRECTORY_SEPARATOR.$filename; |
43 | 43 | } |
44 | 44 | if (!file_exists($original)) { |
45 | - echo "File not found"; |
|
45 | + echo "File not found"; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | if (extension_loaded('gd') && function_exists('gd_info')) { |
49 | - $image = imagecreatefrompng($original); |
|
50 | - $index = imagecolorexact($image,26,49,81); |
|
51 | - if ($index < 0) { |
|
49 | + $image = imagecreatefrompng($original); |
|
50 | + $index = imagecolorexact($image,26,49,81); |
|
51 | + if ($index < 0) { |
|
52 | 52 | $index = imagecolorexact($image,25,49,79); |
53 | - } |
|
54 | - if ($index < 0) { |
|
53 | + } |
|
54 | + if ($index < 0) { |
|
55 | 55 | $index = imagecolorexact($image,0,0,0); |
56 | - } |
|
57 | - $c = hexToRGB($color); |
|
58 | - imagecolorset($image,$index,$c['r'],$c['g'],$c['b']); |
|
56 | + } |
|
57 | + $c = hexToRGB($color); |
|
58 | + imagecolorset($image,$index,$c['r'],$c['g'],$c['b']); |
|
59 | 59 | /* |
60 | 60 | $ig = imagecolorat($image, 0, 0); |
61 | 61 | imagecolortransparent($image, $ig); |
62 | 62 | */ |
63 | 63 | |
64 | - header('Content-type: image/png'); |
|
65 | - if (isset($_GET['resize']) && function_exists('imagecopyresampled')) { |
|
64 | + header('Content-type: image/png'); |
|
65 | + if (isset($_GET['resize']) && function_exists('imagecopyresampled')) { |
|
66 | 66 | $resize = filter_input(INPUT_GET,'resize',FILTER_SANITIZE_NUMBER_INT); |
67 | 67 | $newimg = imagecreatetruecolor($resize,$resize); |
68 | - imagealphablending($newimg, false); |
|
68 | + imagealphablending($newimg, false); |
|
69 | 69 | imagesavealpha($newimg, true); |
70 | 70 | imagecopyresampled($newimg,$image,0,0,0,0,15,15,imagesx($image),imagesy($image)); |
71 | 71 | if (isset($_GET['heading'])) { |
72 | - $heading = filter_input(INPUT_GET,'heading',FILTER_SANITIZE_NUMBER_INT); |
|
73 | - $rotation = imagerotate($newimg,$heading,imageColorAllocateAlpha($newimg,0,0,0,127)); |
|
74 | - imagealphablending($rotation, false); |
|
75 | - imagesavealpha($rotation, true); |
|
76 | - imagepng($rotation); |
|
77 | - imagedestroy($newimg); |
|
78 | - imagedestroy($image); |
|
79 | - imagedestroy($rotation); |
|
72 | + $heading = filter_input(INPUT_GET,'heading',FILTER_SANITIZE_NUMBER_INT); |
|
73 | + $rotation = imagerotate($newimg,$heading,imageColorAllocateAlpha($newimg,0,0,0,127)); |
|
74 | + imagealphablending($rotation, false); |
|
75 | + imagesavealpha($rotation, true); |
|
76 | + imagepng($rotation); |
|
77 | + imagedestroy($newimg); |
|
78 | + imagedestroy($image); |
|
79 | + imagedestroy($rotation); |
|
80 | 80 | |
81 | 81 | } else { |
82 | - imagepng($newimg); |
|
83 | - imagedestroy($newimg); |
|
84 | - imagedestroy($image); |
|
85 | - } |
|
86 | - } else { |
|
82 | + imagepng($newimg); |
|
83 | + imagedestroy($newimg); |
|
84 | + imagedestroy($image); |
|
85 | + } |
|
86 | + } else { |
|
87 | 87 | imagealphablending($image, false); |
88 | - imagesavealpha($image, true); |
|
88 | + imagesavealpha($image, true); |
|
89 | 89 | imagepng($image); |
90 | 90 | imagepng($image); |
91 | 91 | if (is_writable('cache')) { |
92 | - imagepng($image,dirname(__FILE__).DIRECTORY_SEPARATOR.'cache/'.$color.'-'.$filename); |
|
92 | + imagepng($image,dirname(__FILE__).DIRECTORY_SEPARATOR.'cache/'.$color.'-'.$filename); |
|
93 | + } |
|
94 | + imagedestroy($image); |
|
93 | 95 | } |
94 | - imagedestroy($image); |
|
95 | - } |
|
96 | 96 | } else { |
97 | - header('Content-type: image/png'); |
|
98 | - if (isset($_GET['tracker'])) { |
|
99 | - readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/vehicules/'.$filename); |
|
100 | - } elseif (isset($_GET['marine'])) { |
|
101 | - readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/vehicules/'.$filename); |
|
102 | - } else { |
|
103 | - if ($color == 'FF0000') readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/aircrafts/selected/'.$filename); |
|
97 | + header('Content-type: image/png'); |
|
98 | + if (isset($_GET['tracker'])) { |
|
99 | + readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/vehicules/'.$filename); |
|
100 | + } elseif (isset($_GET['marine'])) { |
|
101 | + readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/vehicules/'.$filename); |
|
102 | + } else { |
|
103 | + if ($color == 'FF0000') readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/aircrafts/selected/'.$filename); |
|
104 | 104 | else readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/aircrafts/'.$filename); |
105 | - } |
|
105 | + } |
|
106 | 106 | } |
107 | 107 | ?> |
108 | 108 | \ No newline at end of file |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
17 | 17 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
18 | 18 | if (isset($globalMarine) && $globalMarine) { |
19 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
20 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
19 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
20 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | if (!isset($globalDebug)) $globalDebug = FALSE; |
@@ -25,42 +25,42 @@ discard block |
||
25 | 25 | // Check if schema is at latest version |
26 | 26 | $Connection = new Connection(); |
27 | 27 | if ($Connection->latest() === false) { |
28 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
29 | - exit(); |
|
28 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
29 | + exit(); |
|
30 | 30 | } |
31 | 31 | if (PHP_SAPI != 'cli') { |
32 | - echo "This script MUST be called from console, not a web browser."; |
|
32 | + echo "This script MUST be called from console, not a web browser."; |
|
33 | 33 | // exit(); |
34 | 34 | } |
35 | 35 | |
36 | 36 | // This is to be compatible with old version of settings.php |
37 | 37 | if (!isset($globalSources)) { |
38 | - if (isset($globalSBS1Hosts)) { |
|
39 | - //$hosts = $globalSBS1Hosts; |
|
40 | - foreach ($globalSBS1Hosts as $host) { |
|
41 | - $globalSources[] = array('host' => $host); |
|
42 | - } |
|
43 | - } else { |
|
44 | - if (!isset($globalSBS1Host)) { |
|
45 | - echo '$globalSources MUST be defined !'; |
|
46 | - die; |
|
38 | + if (isset($globalSBS1Hosts)) { |
|
39 | + //$hosts = $globalSBS1Hosts; |
|
40 | + foreach ($globalSBS1Hosts as $host) { |
|
41 | + $globalSources[] = array('host' => $host); |
|
42 | + } |
|
43 | + } else { |
|
44 | + if (!isset($globalSBS1Host)) { |
|
45 | + echo '$globalSources MUST be defined !'; |
|
46 | + die; |
|
47 | 47 | } |
48 | 48 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
49 | 49 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
50 | - } |
|
50 | + } |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver')); |
54 | 54 | //if (isset($options['s'])) $hosts = array($options['s']); |
55 | 55 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
56 | 56 | if (isset($options['s'])) { |
57 | - $globalSources = array(); |
|
58 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
59 | - else $globalSources[] = array('host' => $options['s']); |
|
57 | + $globalSources = array(); |
|
58 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
59 | + else $globalSources[] = array('host' => $options['s']); |
|
60 | 60 | } elseif (isset($options['source'])) { |
61 | - $globalSources = array(); |
|
62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
63 | - else $globalSources[] = array('host' => $options['source']); |
|
61 | + $globalSources = array(); |
|
62 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
63 | + else $globalSources[] = array('host' => $options['source']); |
|
64 | 64 | } |
65 | 65 | if (isset($options['aprsserverhost'])) { |
66 | 66 | $globalServerAPRS = TRUE; |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
76 | 76 | else $id_source = 1; |
77 | 77 | if (isset($globalServer) && $globalServer) { |
78 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
79 | - $SI=new SpotterServer(); |
|
78 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
79 | + $SI=new SpotterServer(); |
|
80 | 80 | /* |
81 | 81 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
82 | 82 | $SI = new adsb2aprs(); |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | } else $SI=new SpotterImport($Connection->db); |
86 | 86 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
87 | 87 | if (isset($globalMarine) && $globalMarine) { |
88 | - $AIS = new AIS(); |
|
89 | - $MI = new MarineImport($Connection->db); |
|
88 | + $AIS = new AIS(); |
|
89 | + $MI = new MarineImport($Connection->db); |
|
90 | 90 | } |
91 | 91 | //$APRS=new APRS($Connection->db); |
92 | 92 | $SBS=new SBS(); |
@@ -97,12 +97,12 @@ discard block |
||
97 | 97 | //$servertz = system('date +%Z'); |
98 | 98 | // signal handler - playing nice with sockets and dump1090 |
99 | 99 | if (function_exists('pcntl_fork')) { |
100 | - pcntl_signal(SIGINT, function() { |
|
101 | - global $sockets; |
|
102 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
103 | - die("Bye!\n"); |
|
104 | - }); |
|
105 | - pcntl_signal_dispatch(); |
|
100 | + pcntl_signal(SIGINT, function() { |
|
101 | + global $sockets; |
|
102 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
103 | + die("Bye!\n"); |
|
104 | + }); |
|
105 | + pcntl_signal_dispatch(); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | // let's try and connect |
@@ -112,36 +112,36 @@ discard block |
||
112 | 112 | $reset = 0; |
113 | 113 | |
114 | 114 | function connect_all($hosts) { |
115 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
116 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
117 | - $reset++; |
|
118 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
119 | - foreach ($hosts as $id => $value) { |
|
115 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
116 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
117 | + $reset++; |
|
118 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
119 | + foreach ($hosts as $id => $value) { |
|
120 | 120 | $host = $value['host']; |
121 | 121 | $globalSources[$id]['last_exec'] = 0; |
122 | 122 | // Here we check type of source(s) |
123 | 123 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
124 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
125 | - //$formats[$id] = 'deltadbtxt'; |
|
126 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
127 | - //$last_exec['deltadbtxt'] = 0; |
|
128 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
129 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
130 | - //$formats[$id] = 'vatsimtxt'; |
|
131 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
132 | - //$last_exec['vatsimtxt'] = 0; |
|
133 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
134 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
135 | - //$formats[$id] = 'aircraftlistjson'; |
|
136 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
137 | - //$last_exec['aircraftlistjson'] = 0; |
|
138 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
139 | - } else if (preg_match('/opensky/i',$host)) { |
|
140 | - //$formats[$id] = 'aircraftlistjson'; |
|
141 | - $globalSources[$id]['format'] = 'opensky'; |
|
142 | - //$last_exec['aircraftlistjson'] = 0; |
|
143 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
144 | - /* |
|
124 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
125 | + //$formats[$id] = 'deltadbtxt'; |
|
126 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
127 | + //$last_exec['deltadbtxt'] = 0; |
|
128 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
129 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
130 | + //$formats[$id] = 'vatsimtxt'; |
|
131 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
132 | + //$last_exec['vatsimtxt'] = 0; |
|
133 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
134 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
135 | + //$formats[$id] = 'aircraftlistjson'; |
|
136 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
137 | + //$last_exec['aircraftlistjson'] = 0; |
|
138 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
139 | + } else if (preg_match('/opensky/i',$host)) { |
|
140 | + //$formats[$id] = 'aircraftlistjson'; |
|
141 | + $globalSources[$id]['format'] = 'opensky'; |
|
142 | + //$last_exec['aircraftlistjson'] = 0; |
|
143 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
144 | + /* |
|
145 | 145 | // Disabled for now, site change source format |
146 | 146 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
147 | 147 | //$formats[$id] = 'radarvirtueljson'; |
@@ -153,121 +153,121 @@ discard block |
||
153 | 153 | exit(0); |
154 | 154 | } |
155 | 155 | */ |
156 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
157 | - //$formats[$id] = 'planeupdatefaa'; |
|
158 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
159 | - //$last_exec['planeupdatefaa'] = 0; |
|
160 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
161 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
162 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
163 | - exit(0); |
|
164 | - } |
|
165 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
166 | - //$formats[$id] = 'phpvmacars'; |
|
167 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
168 | - //$last_exec['phpvmacars'] = 0; |
|
169 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
170 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
171 | - //$formats[$id] = 'phpvmacars'; |
|
172 | - $globalSources[$id]['format'] = 'vam'; |
|
173 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
174 | - } else if (preg_match('/whazzup/i',$host)) { |
|
175 | - //$formats[$id] = 'whazzup'; |
|
176 | - $globalSources[$id]['format'] = 'whazzup'; |
|
177 | - //$last_exec['whazzup'] = 0; |
|
178 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
179 | - } else if (preg_match('/blitzortung/i',$host)) { |
|
180 | - $globalSources[$id]['format'] = 'blitzortung'; |
|
181 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
182 | - } else if (preg_match('/airwhere/i',$host)) { |
|
183 | - $globalSources[$id]['format'] = 'airwhere'; |
|
184 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
185 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
186 | - //$formats[$id] = 'pirepsjson'; |
|
187 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
188 | - //$last_exec['pirepsjson'] = 0; |
|
189 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
190 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
191 | - //$formats[$id] = 'fr24json'; |
|
192 | - $globalSources[$id]['format'] = 'fr24json'; |
|
193 | - //$last_exec['fr24json'] = 0; |
|
194 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
195 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
196 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
197 | - exit(0); |
|
198 | - } |
|
199 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
200 | - //$formats[$id] = 'fr24json'; |
|
201 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
202 | - //$last_exec['fr24json'] = 0; |
|
203 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
204 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
205 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
206 | - exit(0); |
|
207 | - } |
|
208 | - //} else if (preg_match('/10001/',$host)) { |
|
209 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
210 | - //$formats[$id] = 'tsv'; |
|
211 | - $globalSources[$id]['format'] = 'tsv'; |
|
212 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
213 | - } |
|
214 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
215 | - if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
216 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
217 | - if ($idf !== false) { |
|
218 | - $httpfeeds[$id] = $idf; |
|
219 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
220 | - } |
|
221 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
222 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
223 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
224 | - $hostport = explode(':',$host); |
|
225 | - if (isset($hostport[1])) { |
|
156 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
157 | + //$formats[$id] = 'planeupdatefaa'; |
|
158 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
159 | + //$last_exec['planeupdatefaa'] = 0; |
|
160 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
161 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
162 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
163 | + exit(0); |
|
164 | + } |
|
165 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
166 | + //$formats[$id] = 'phpvmacars'; |
|
167 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
168 | + //$last_exec['phpvmacars'] = 0; |
|
169 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
170 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
171 | + //$formats[$id] = 'phpvmacars'; |
|
172 | + $globalSources[$id]['format'] = 'vam'; |
|
173 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
174 | + } else if (preg_match('/whazzup/i',$host)) { |
|
175 | + //$formats[$id] = 'whazzup'; |
|
176 | + $globalSources[$id]['format'] = 'whazzup'; |
|
177 | + //$last_exec['whazzup'] = 0; |
|
178 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
179 | + } else if (preg_match('/blitzortung/i',$host)) { |
|
180 | + $globalSources[$id]['format'] = 'blitzortung'; |
|
181 | + if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
182 | + } else if (preg_match('/airwhere/i',$host)) { |
|
183 | + $globalSources[$id]['format'] = 'airwhere'; |
|
184 | + if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
185 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
186 | + //$formats[$id] = 'pirepsjson'; |
|
187 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
188 | + //$last_exec['pirepsjson'] = 0; |
|
189 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
190 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
191 | + //$formats[$id] = 'fr24json'; |
|
192 | + $globalSources[$id]['format'] = 'fr24json'; |
|
193 | + //$last_exec['fr24json'] = 0; |
|
194 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
195 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
196 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
197 | + exit(0); |
|
198 | + } |
|
199 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
200 | + //$formats[$id] = 'fr24json'; |
|
201 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
202 | + //$last_exec['fr24json'] = 0; |
|
203 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
204 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
205 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
206 | + exit(0); |
|
207 | + } |
|
208 | + //} else if (preg_match('/10001/',$host)) { |
|
209 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
210 | + //$formats[$id] = 'tsv'; |
|
211 | + $globalSources[$id]['format'] = 'tsv'; |
|
212 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
213 | + } |
|
214 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
215 | + if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
216 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
217 | + if ($idf !== false) { |
|
218 | + $httpfeeds[$id] = $idf; |
|
219 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
220 | + } |
|
221 | + elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
222 | + } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
223 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
224 | + $hostport = explode(':',$host); |
|
225 | + if (isset($hostport[1])) { |
|
226 | 226 | $port = $hostport[1]; |
227 | 227 | $hostn = $hostport[0]; |
228 | - } else { |
|
228 | + } else { |
|
229 | 229 | $port = $globalSources[$id]['port']; |
230 | 230 | $hostn = $globalSources[$id]['host']; |
231 | - } |
|
232 | - $Common = new Common(); |
|
233 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
234 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
235 | - } else { |
|
236 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
237 | - } |
|
238 | - if ($s) { |
|
239 | - $sockets[$id] = $s; |
|
240 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
241 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
231 | + } |
|
232 | + $Common = new Common(); |
|
233 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
234 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
235 | + } else { |
|
236 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
237 | + } |
|
238 | + if ($s) { |
|
239 | + $sockets[$id] = $s; |
|
240 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
241 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
242 | 242 | //$formats[$id] = 'aprs'; |
243 | 243 | $globalSources[$id]['format'] = 'aprs'; |
244 | 244 | //$aprs_connect = 0; |
245 | 245 | //$use_aprs = true; |
246 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
246 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
247 | 247 | $globalSources[$id]['format'] = 'vrstcp'; |
248 | - } elseif ($port == '10001') { |
|
249 | - //$formats[$id] = 'tsv'; |
|
250 | - $globalSources[$id]['format'] = 'tsv'; |
|
251 | - } elseif ($port == '30002') { |
|
252 | - //$formats[$id] = 'raw'; |
|
253 | - $globalSources[$id]['format'] = 'raw'; |
|
254 | - } elseif ($port == '5001') { |
|
255 | - //$formats[$id] = 'raw'; |
|
256 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
257 | - } elseif ($port == '30005') { |
|
248 | + } elseif ($port == '10001') { |
|
249 | + //$formats[$id] = 'tsv'; |
|
250 | + $globalSources[$id]['format'] = 'tsv'; |
|
251 | + } elseif ($port == '30002') { |
|
252 | + //$formats[$id] = 'raw'; |
|
253 | + $globalSources[$id]['format'] = 'raw'; |
|
254 | + } elseif ($port == '5001') { |
|
255 | + //$formats[$id] = 'raw'; |
|
256 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
257 | + } elseif ($port == '30005') { |
|
258 | 258 | // Not yet supported |
259 | - //$formats[$id] = 'beast'; |
|
260 | - $globalSources[$id]['format'] = 'beast'; |
|
261 | - //} else $formats[$id] = 'sbs'; |
|
262 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
263 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
259 | + //$formats[$id] = 'beast'; |
|
260 | + $globalSources[$id]['format'] = 'beast'; |
|
261 | + //} else $formats[$id] = 'sbs'; |
|
262 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
263 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
264 | 264 | } |
265 | 265 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
266 | - } else { |
|
266 | + } else { |
|
267 | 267 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
268 | - } |
|
269 | - } |
|
270 | - } |
|
268 | + } |
|
269 | + } |
|
270 | + } |
|
271 | 271 | } |
272 | 272 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
273 | 273 | |
@@ -290,9 +290,9 @@ discard block |
||
290 | 290 | //connect_all($globalSources); |
291 | 291 | |
292 | 292 | if (isset($globalProxy) && $globalProxy) { |
293 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
293 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
294 | 294 | } else { |
295 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
295 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | // APRS Configuration |
@@ -301,21 +301,21 @@ discard block |
||
301 | 301 | die; |
302 | 302 | } |
303 | 303 | foreach ($globalSources as $key => $source) { |
304 | - if (!isset($source['format'])) { |
|
305 | - $globalSources[$key]['format'] = 'auto'; |
|
306 | - } |
|
307 | - if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
308 | - unset($globalSources[$key]); |
|
309 | - } |
|
304 | + if (!isset($source['format'])) { |
|
305 | + $globalSources[$key]['format'] = 'auto'; |
|
306 | + } |
|
307 | + if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
308 | + unset($globalSources[$key]); |
|
309 | + } |
|
310 | 310 | } |
311 | 311 | connect_all($globalSources); |
312 | 312 | foreach ($globalSources as $key => $source) { |
313 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
313 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
314 | 314 | $aprs_connect = 0; |
315 | 315 | $use_aprs = true; |
316 | 316 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
317 | 317 | break; |
318 | - } |
|
318 | + } |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | if ($use_aprs) { |
@@ -356,115 +356,115 @@ discard block |
||
356 | 356 | |
357 | 357 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
358 | 358 | while ($i > 0) { |
359 | - if (!$globalDaemon) $i = $endtime-time(); |
|
360 | - // Delete old ATC |
|
361 | - if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
359 | + if (!$globalDaemon) $i = $endtime-time(); |
|
360 | + // Delete old ATC |
|
361 | + if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
362 | 362 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
363 | - $ATC->deleteOldATC(); |
|
364 | - } |
|
363 | + $ATC->deleteOldATC(); |
|
364 | + } |
|
365 | 365 | |
366 | - if (count($last_exec) == count($globalSources)) { |
|
366 | + if (count($last_exec) == count($globalSources)) { |
|
367 | 367 | $max = $globalMinFetch; |
368 | 368 | foreach ($last_exec as $last) { |
369 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
369 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
370 | 370 | } |
371 | 371 | if ($max != $globalMinFetch) { |
372 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
373 | - sleep($globalMinFetch-$max+2); |
|
372 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
373 | + sleep($globalMinFetch-$max+2); |
|
374 | + } |
|
374 | 375 | } |
375 | - } |
|
376 | 376 | |
377 | 377 | |
378 | - //foreach ($formats as $id => $value) { |
|
379 | - foreach ($globalSources as $id => $value) { |
|
378 | + //foreach ($formats as $id => $value) { |
|
379 | + foreach ($globalSources as $id => $value) { |
|
380 | 380 | date_default_timezone_set('UTC'); |
381 | 381 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
382 | 382 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
383 | - //$buffer = $Common->getData($hosts[$id]); |
|
384 | - $buffer = $Common->getData($value['host']); |
|
385 | - if ($buffer != '') $reset = 0; |
|
386 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
387 | - $buffer = explode('\n',$buffer); |
|
388 | - foreach ($buffer as $line) { |
|
389 | - if ($line != '' && count($line) > 7) { |
|
390 | - $line = explode(',', $line); |
|
391 | - $data = array(); |
|
392 | - $data['hex'] = $line[1]; // hex |
|
393 | - $data['ident'] = $line[2]; // ident |
|
394 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
395 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
396 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
397 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
398 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
399 | - $data['verticalrate'] = ''; // vertical rate |
|
400 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
401 | - $data['emergency'] = ''; // emergency |
|
402 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
403 | - $data['format_source'] = 'deltadbtxt'; |
|
404 | - $data['id_source'] = $id_source; |
|
405 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
406 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
407 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
408 | - $SI->add($data); |
|
409 | - unset($data); |
|
410 | - } |
|
411 | - } |
|
412 | - $last_exec[$id]['last'] = time(); |
|
383 | + //$buffer = $Common->getData($hosts[$id]); |
|
384 | + $buffer = $Common->getData($value['host']); |
|
385 | + if ($buffer != '') $reset = 0; |
|
386 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
387 | + $buffer = explode('\n',$buffer); |
|
388 | + foreach ($buffer as $line) { |
|
389 | + if ($line != '' && count($line) > 7) { |
|
390 | + $line = explode(',', $line); |
|
391 | + $data = array(); |
|
392 | + $data['hex'] = $line[1]; // hex |
|
393 | + $data['ident'] = $line[2]; // ident |
|
394 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
395 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
396 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
397 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
398 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
399 | + $data['verticalrate'] = ''; // vertical rate |
|
400 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
401 | + $data['emergency'] = ''; // emergency |
|
402 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
403 | + $data['format_source'] = 'deltadbtxt'; |
|
404 | + $data['id_source'] = $id_source; |
|
405 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
406 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
407 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
408 | + $SI->add($data); |
|
409 | + unset($data); |
|
410 | + } |
|
411 | + } |
|
412 | + $last_exec[$id]['last'] = time(); |
|
413 | 413 | } elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
414 | - date_default_timezone_set('CET'); |
|
415 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
416 | - date_default_timezone_set('UTC'); |
|
417 | - if ($buffer != '') $reset = 0; |
|
418 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
419 | - $buffer = explode('\n',$buffer); |
|
420 | - foreach ($buffer as $line) { |
|
414 | + date_default_timezone_set('CET'); |
|
415 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
416 | + date_default_timezone_set('UTC'); |
|
417 | + if ($buffer != '') $reset = 0; |
|
418 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
419 | + $buffer = explode('\n',$buffer); |
|
420 | + foreach ($buffer as $line) { |
|
421 | 421 | if ($line != '') { |
422 | - //echo "'".$line."'\n"; |
|
423 | - $add = false; |
|
424 | - $ais_data = $AIS->parse_line(trim($line)); |
|
425 | - $data = array(); |
|
426 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
427 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
428 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
429 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
430 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
431 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
432 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
433 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
434 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
435 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
436 | - if (isset($ais_data['timestamp'])) { |
|
422 | + //echo "'".$line."'\n"; |
|
423 | + $add = false; |
|
424 | + $ais_data = $AIS->parse_line(trim($line)); |
|
425 | + $data = array(); |
|
426 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
427 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
428 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
429 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
430 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
431 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
432 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
433 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
434 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
435 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
436 | + if (isset($ais_data['timestamp'])) { |
|
437 | 437 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
438 | 438 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
439 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
440 | - $add = true; |
|
439 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
440 | + $add = true; |
|
441 | 441 | } |
442 | - } else { |
|
442 | + } else { |
|
443 | 443 | $data['datetime'] = date('Y-m-d H:i:s'); |
444 | 444 | $add = true; |
445 | - } |
|
446 | - $data['format_source'] = 'aisnmeatxt'; |
|
447 | - $data['id_source'] = $id_source; |
|
448 | - //print_r($data); |
|
449 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
450 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
451 | - unset($data); |
|
445 | + } |
|
446 | + $data['format_source'] = 'aisnmeatxt'; |
|
447 | + $data['id_source'] = $id_source; |
|
448 | + //print_r($data); |
|
449 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
450 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
451 | + unset($data); |
|
452 | 452 | } |
453 | - } |
|
454 | - $last_exec[$id]['last'] = time(); |
|
453 | + } |
|
454 | + $last_exec[$id]['last'] = time(); |
|
455 | 455 | } elseif ($value['format'] == 'aisnmeahttp') { |
456 | - $arr = $httpfeeds; |
|
457 | - $w = $e = null; |
|
456 | + $arr = $httpfeeds; |
|
457 | + $w = $e = null; |
|
458 | 458 | |
459 | - if (isset($arr[$id])) { |
|
459 | + if (isset($arr[$id])) { |
|
460 | 460 | $nn = stream_select($arr,$w,$e,$timeout); |
461 | 461 | if ($nn > 0) { |
462 | - foreach ($httpfeeds as $feed) { |
|
462 | + foreach ($httpfeeds as $feed) { |
|
463 | 463 | $buffer = stream_get_line($feed,2000,"\n"); |
464 | 464 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
465 | 465 | $buffer = explode('\n',$buffer); |
466 | 466 | foreach ($buffer as $line) { |
467 | - if ($line != '') { |
|
467 | + if ($line != '') { |
|
468 | 468 | $ais_data = $AIS->parse_line(trim($line)); |
469 | 469 | $data = array(); |
470 | 470 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
@@ -482,96 +482,96 @@ discard block |
||
482 | 482 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
483 | 483 | if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
484 | 484 | if (isset($ais_data['timestamp'])) { |
485 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
485 | + $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
486 | 486 | } else { |
487 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
487 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
488 | 488 | } |
489 | 489 | $data['format_source'] = 'aisnmeahttp'; |
490 | 490 | $data['id_source'] = $id_source; |
491 | 491 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
492 | 492 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
493 | 493 | unset($data); |
494 | - } |
|
494 | + } |
|
495 | + } |
|
495 | 496 | } |
496 | - } |
|
497 | 497 | } else { |
498 | - $format = $value['format']; |
|
499 | - if (isset($tt[$format])) $tt[$format]++; |
|
500 | - else $tt[$format] = 0; |
|
501 | - if ($tt[$format] > 30) { |
|
498 | + $format = $value['format']; |
|
499 | + if (isset($tt[$format])) $tt[$format]++; |
|
500 | + else $tt[$format] = 0; |
|
501 | + if ($tt[$format] > 30) { |
|
502 | 502 | if ($globalDebug) echo 'Reconnect...'."\n"; |
503 | 503 | sleep(2); |
504 | 504 | $sourceeen[] = $value; |
505 | 505 | connect_all($sourceeen); |
506 | 506 | $sourceeen = array(); |
507 | - } |
|
507 | + } |
|
508 | + } |
|
508 | 509 | } |
509 | - } |
|
510 | 510 | } elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
511 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
512 | - if ($buffer != '') { |
|
511 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
512 | + if ($buffer != '') { |
|
513 | 513 | //echo $buffer; |
514 | 514 | $all_data = json_decode($buffer,true); |
515 | 515 | //print_r($all_data); |
516 | 516 | if (isset($all_data[0]['DATA'])) { |
517 | - foreach ($all_data[0]['DATA'] as $line) { |
|
517 | + foreach ($all_data[0]['DATA'] as $line) { |
|
518 | 518 | if ($line != '') { |
519 | - $data = array(); |
|
520 | - $data['ident'] = $line['NAME']; |
|
521 | - $data['mmsi'] = $line['MMSI']; |
|
522 | - $data['speed'] = $line['SOG']; |
|
523 | - $data['heading'] = $line['COG']; |
|
524 | - $data['latitude'] = $line['LAT']; |
|
525 | - $data['longitude'] = $line['LNG']; |
|
526 | - // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
527 | - $data['imo'] = $line['IMO']; |
|
528 | - //$data['arrival_code'] = $ais_data['destination']; |
|
529 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
530 | - $data['format_source'] = 'myshiptracking'; |
|
531 | - $data['id_source'] = $id_source; |
|
532 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
533 | - $MI->add($data); |
|
534 | - unset($data); |
|
519 | + $data = array(); |
|
520 | + $data['ident'] = $line['NAME']; |
|
521 | + $data['mmsi'] = $line['MMSI']; |
|
522 | + $data['speed'] = $line['SOG']; |
|
523 | + $data['heading'] = $line['COG']; |
|
524 | + $data['latitude'] = $line['LAT']; |
|
525 | + $data['longitude'] = $line['LNG']; |
|
526 | + // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
527 | + $data['imo'] = $line['IMO']; |
|
528 | + //$data['arrival_code'] = $ais_data['destination']; |
|
529 | + $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
530 | + $data['format_source'] = 'myshiptracking'; |
|
531 | + $data['id_source'] = $id_source; |
|
532 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
533 | + $MI->add($data); |
|
534 | + unset($data); |
|
535 | + } |
|
535 | 536 | } |
536 | - } |
|
537 | 537 | } |
538 | - } |
|
539 | - $last_exec[$id]['last'] = time(); |
|
538 | + } |
|
539 | + $last_exec[$id]['last'] = time(); |
|
540 | 540 | } elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
541 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
542 | - if ($buffer != '') { |
|
541 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
542 | + if ($buffer != '') { |
|
543 | 543 | $all_data = json_decode($buffer,true); |
544 | 544 | if (isset($all_data[0]['mmsi'])) { |
545 | - foreach ($all_data as $line) { |
|
545 | + foreach ($all_data as $line) { |
|
546 | 546 | if ($line != '') { |
547 | - $data = array(); |
|
548 | - $data['ident'] = $line['shipname']; |
|
549 | - $data['callsign'] = $line['callsign']; |
|
550 | - $data['mmsi'] = $line['mmsi']; |
|
551 | - $data['speed'] = $line['sog']; |
|
552 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
553 | - $data['latitude'] = $line['latitude']; |
|
554 | - $data['longitude'] = $line['longitude']; |
|
555 | - $data['type_id'] = $line['shiptype']; |
|
556 | - $data['arrival_code'] = $line['destination']; |
|
557 | - $data['datetime'] = $line['time']; |
|
558 | - $data['format_source'] = 'boatbeaconapp'; |
|
559 | - $data['id_source'] = $id_source; |
|
560 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
561 | - $MI->add($data); |
|
562 | - unset($data); |
|
547 | + $data = array(); |
|
548 | + $data['ident'] = $line['shipname']; |
|
549 | + $data['callsign'] = $line['callsign']; |
|
550 | + $data['mmsi'] = $line['mmsi']; |
|
551 | + $data['speed'] = $line['sog']; |
|
552 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
553 | + $data['latitude'] = $line['latitude']; |
|
554 | + $data['longitude'] = $line['longitude']; |
|
555 | + $data['type_id'] = $line['shiptype']; |
|
556 | + $data['arrival_code'] = $line['destination']; |
|
557 | + $data['datetime'] = $line['time']; |
|
558 | + $data['format_source'] = 'boatbeaconapp'; |
|
559 | + $data['id_source'] = $id_source; |
|
560 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
561 | + $MI->add($data); |
|
562 | + unset($data); |
|
563 | + } |
|
563 | 564 | } |
564 | - } |
|
565 | 565 | } |
566 | 566 | |
567 | - } |
|
568 | - $last_exec[$id]['last'] = time(); |
|
567 | + } |
|
568 | + $last_exec[$id]['last'] = time(); |
|
569 | 569 | } elseif ($value['format'] == 'boatnerd' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
570 | - $buffer = $Common->getData($value['host']); |
|
571 | - if ($buffer != '') { |
|
570 | + $buffer = $Common->getData($value['host']); |
|
571 | + if ($buffer != '') { |
|
572 | 572 | $all_data = json_decode($buffer,true); |
573 | 573 | if (isset($all_data['features'][0]['id'])) { |
574 | - foreach ($all_data['features'] as $line) { |
|
574 | + foreach ($all_data['features'] as $line) { |
|
575 | 575 | $data = array(); |
576 | 576 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
577 | 577 | if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
@@ -590,59 +590,59 @@ discard block |
||
590 | 590 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
591 | 591 | if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
592 | 592 | unset($data); |
593 | - } |
|
593 | + } |
|
594 | 594 | } |
595 | 595 | |
596 | - } |
|
597 | - $last_exec[$id]['last'] = time(); |
|
596 | + } |
|
597 | + $last_exec[$id]['last'] = time(); |
|
598 | 598 | } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
599 | - echo 'download...'; |
|
600 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
601 | - echo 'done !'."\n"; |
|
602 | - if ($buffer != '') $reset = 0; |
|
603 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
604 | - $buffer = explode('\n',$buffer); |
|
605 | - foreach ($buffer as $line) { |
|
599 | + echo 'download...'; |
|
600 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
601 | + echo 'done !'."\n"; |
|
602 | + if ($buffer != '') $reset = 0; |
|
603 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
604 | + $buffer = explode('\n',$buffer); |
|
605 | + foreach ($buffer as $line) { |
|
606 | 606 | if ($line != '') { |
607 | - $data = array(); |
|
608 | - $data['mmsi'] = (int)substr($line,0,9); |
|
609 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
610 | - //$data['status'] = substr($line,21,2); |
|
611 | - //$data['type'] = substr($line,24,3); |
|
612 | - $data['latitude'] = substr($line,29,9); |
|
613 | - $data['longitude'] = substr($line,41,9); |
|
614 | - $data['speed'] = round(substr($line,51,5)); |
|
615 | - //$data['course'] = substr($line,57,5); |
|
616 | - $data['heading'] = round(substr($line,63,3)); |
|
617 | - //$data['draft'] = substr($line,67,4); |
|
618 | - //$data['length'] = substr($line,72,3); |
|
619 | - //$data['beam'] = substr($line,76,2); |
|
620 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
621 | - //$data['callsign'] = trim(substr($line,100,7); |
|
622 | - //$data['dest'] = substr($line,108,20); |
|
623 | - //$data['etaDate'] = substr($line,129,5); |
|
624 | - //$data['etaTime'] = substr($line,135,5); |
|
625 | - $data['format_source'] = 'shipplotter'; |
|
626 | - $data['id_source'] = $id_source; |
|
627 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
628 | - //print_r($data); |
|
629 | - echo 'Add...'."\n"; |
|
630 | - $MI->add($data); |
|
631 | - unset($data); |
|
607 | + $data = array(); |
|
608 | + $data['mmsi'] = (int)substr($line,0,9); |
|
609 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
610 | + //$data['status'] = substr($line,21,2); |
|
611 | + //$data['type'] = substr($line,24,3); |
|
612 | + $data['latitude'] = substr($line,29,9); |
|
613 | + $data['longitude'] = substr($line,41,9); |
|
614 | + $data['speed'] = round(substr($line,51,5)); |
|
615 | + //$data['course'] = substr($line,57,5); |
|
616 | + $data['heading'] = round(substr($line,63,3)); |
|
617 | + //$data['draft'] = substr($line,67,4); |
|
618 | + //$data['length'] = substr($line,72,3); |
|
619 | + //$data['beam'] = substr($line,76,2); |
|
620 | + $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
621 | + //$data['callsign'] = trim(substr($line,100,7); |
|
622 | + //$data['dest'] = substr($line,108,20); |
|
623 | + //$data['etaDate'] = substr($line,129,5); |
|
624 | + //$data['etaTime'] = substr($line,135,5); |
|
625 | + $data['format_source'] = 'shipplotter'; |
|
626 | + $data['id_source'] = $id_source; |
|
627 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
628 | + //print_r($data); |
|
629 | + echo 'Add...'."\n"; |
|
630 | + $MI->add($data); |
|
631 | + unset($data); |
|
632 | 632 | } |
633 | - } |
|
634 | - $last_exec[$id]['last'] = time(); |
|
633 | + } |
|
634 | + $last_exec[$id]['last'] = time(); |
|
635 | 635 | //} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
636 | 636 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
637 | - //$buffer = $Common->getData($hosts[$id]); |
|
638 | - $buffer = $Common->getData($value['host']); |
|
639 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
640 | - $buffer = explode('\n',$buffer); |
|
641 | - $reset = 0; |
|
642 | - foreach ($buffer as $line) { |
|
643 | - if ($line != '') { |
|
644 | - $line = explode(':', $line); |
|
645 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
637 | + //$buffer = $Common->getData($hosts[$id]); |
|
638 | + $buffer = $Common->getData($value['host']); |
|
639 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
640 | + $buffer = explode('\n',$buffer); |
|
641 | + $reset = 0; |
|
642 | + foreach ($buffer as $line) { |
|
643 | + if ($line != '') { |
|
644 | + $line = explode(':', $line); |
|
645 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
646 | 646 | $data = array(); |
647 | 647 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
648 | 648 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -655,37 +655,37 @@ discard block |
||
655 | 655 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
656 | 656 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
657 | 657 | $data['latitude'] = $line[5]; // lat |
658 | - $data['longitude'] = $line[6]; // long |
|
659 | - $data['verticalrate'] = ''; // vertical rate |
|
660 | - $data['squawk'] = ''; // squawk |
|
661 | - $data['emergency'] = ''; // emergency |
|
662 | - $data['waypoints'] = $line[30]; |
|
658 | + $data['longitude'] = $line[6]; // long |
|
659 | + $data['verticalrate'] = ''; // vertical rate |
|
660 | + $data['squawk'] = ''; // squawk |
|
661 | + $data['emergency'] = ''; // emergency |
|
662 | + $data['waypoints'] = $line[30]; |
|
663 | 663 | $data['datetime'] = date('Y-m-d H:i:s'); |
664 | 664 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
665 | 665 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
666 | - $data['departure_airport_icao'] = $line[11]; |
|
667 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
668 | - $data['arrival_airport_icao'] = $line[13]; |
|
666 | + $data['departure_airport_icao'] = $line[11]; |
|
667 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
668 | + $data['arrival_airport_icao'] = $line[13]; |
|
669 | 669 | $data['frequency'] = $line[4]; |
670 | 670 | $data['type'] = $line[18]; |
671 | 671 | $data['range'] = $line[19]; |
672 | 672 | if (isset($line[35])) $data['info'] = $line[35]; |
673 | - $data['id_source'] = $id_source; |
|
674 | - //$data['arrival_airport_time'] = ; |
|
675 | - if ($line[9] != '') { |
|
676 | - $aircraft_data = explode('/',$line[9]); |
|
677 | - if (isset($aircraft_data[1])) { |
|
678 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
679 | - } |
|
680 | - } |
|
681 | - /* |
|
673 | + $data['id_source'] = $id_source; |
|
674 | + //$data['arrival_airport_time'] = ; |
|
675 | + if ($line[9] != '') { |
|
676 | + $aircraft_data = explode('/',$line[9]); |
|
677 | + if (isset($aircraft_data[1])) { |
|
678 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
679 | + } |
|
680 | + } |
|
681 | + /* |
|
682 | 682 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; |
683 | 683 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
684 | 684 | */ |
685 | - $data['format_source'] = $value['format']; |
|
685 | + $data['format_source'] = $value['format']; |
|
686 | 686 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
687 | 687 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
688 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
688 | + if ($line[3] == 'PILOT') $SI->add($data); |
|
689 | 689 | elseif ($line[3] == 'ATC') { |
690 | 690 | //print_r($data); |
691 | 691 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -706,16 +706,16 @@ discard block |
||
706 | 706 | else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
707 | 707 | } |
708 | 708 | } |
709 | - unset($data); |
|
710 | - } |
|
711 | - } |
|
712 | - } |
|
713 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
714 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
715 | - $last_exec[$id]['last'] = time(); |
|
716 | - } elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
717 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
718 | - if ($buffer != '') { |
|
709 | + unset($data); |
|
710 | + } |
|
711 | + } |
|
712 | + } |
|
713 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
714 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
715 | + $last_exec[$id]['last'] = time(); |
|
716 | + } elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
717 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
718 | + if ($buffer != '') { |
|
719 | 719 | $all_data = simplexml_load_string($buffer); |
720 | 720 | foreach($all_data->children() as $childdata) { |
721 | 721 | $data = array(); |
@@ -737,10 +737,10 @@ discard block |
||
737 | 737 | $SI->add($data); |
738 | 738 | unset($data); |
739 | 739 | } |
740 | - } |
|
741 | - $Source->deleteOldLocationByType('gs'); |
|
742 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
743 | - if ($buffer != '') { |
|
740 | + } |
|
741 | + $Source->deleteOldLocationByType('gs'); |
|
742 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
743 | + if ($buffer != '') { |
|
744 | 744 | $all_data = simplexml_load_string($buffer); |
745 | 745 | foreach($all_data->children() as $childdata) { |
746 | 746 | $data = array(); |
@@ -758,249 +758,249 @@ discard block |
||
758 | 758 | } |
759 | 759 | unset($data); |
760 | 760 | } |
761 | - } |
|
762 | - $last_exec[$id]['last'] = time(); |
|
761 | + } |
|
762 | + $last_exec[$id]['last'] = time(); |
|
763 | 763 | } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
764 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
765 | - if ($buffer != '') { |
|
766 | - $all_data = json_decode($buffer,true); |
|
767 | - if (isset($all_data['acList'])) { |
|
764 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
765 | + if ($buffer != '') { |
|
766 | + $all_data = json_decode($buffer,true); |
|
767 | + if (isset($all_data['acList'])) { |
|
768 | 768 | $reset = 0; |
769 | 769 | foreach ($all_data['acList'] as $line) { |
770 | - $data = array(); |
|
771 | - $data['hex'] = $line['Icao']; // hex |
|
772 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
773 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
774 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
775 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
776 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
777 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
778 | - //$data['verticalrate'] = $line['']; // verticale rate |
|
779 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
780 | - $data['emergency'] = ''; // emergency |
|
781 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
770 | + $data = array(); |
|
771 | + $data['hex'] = $line['Icao']; // hex |
|
772 | + if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
773 | + if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
774 | + if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
775 | + if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
776 | + if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
777 | + if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
778 | + //$data['verticalrate'] = $line['']; // verticale rate |
|
779 | + if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
780 | + $data['emergency'] = ''; // emergency |
|
781 | + if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
782 | 782 | |
783 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
784 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
783 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
784 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
785 | 785 | |
786 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
787 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
788 | - $data['format_source'] = 'aircraftlistjson'; |
|
789 | - $data['id_source'] = $id_source; |
|
790 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
791 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
792 | - if (isset($data['latitude'])) $SI->add($data); |
|
793 | - unset($data); |
|
786 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
787 | + if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
788 | + $data['format_source'] = 'aircraftlistjson'; |
|
789 | + $data['id_source'] = $id_source; |
|
790 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
791 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
792 | + if (isset($data['latitude'])) $SI->add($data); |
|
793 | + unset($data); |
|
794 | 794 | } |
795 | - } elseif (is_array($all_data)) { |
|
795 | + } elseif (is_array($all_data)) { |
|
796 | 796 | $reset = 0; |
797 | 797 | foreach ($all_data as $line) { |
798 | - $data = array(); |
|
799 | - $data['hex'] = $line['hex']; // hex |
|
800 | - $data['ident'] = $line['flight']; // ident |
|
801 | - $data['altitude'] = $line['altitude']; // altitude |
|
802 | - $data['speed'] = $line['speed']; // speed |
|
803 | - $data['heading'] = $line['track']; // heading |
|
804 | - $data['latitude'] = $line['lat']; // lat |
|
805 | - $data['longitude'] = $line['lon']; // long |
|
806 | - $data['verticalrate'] = $line['vrt']; // verticale rate |
|
807 | - $data['squawk'] = $line['squawk']; // squawk |
|
808 | - $data['emergency'] = ''; // emergency |
|
809 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
810 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
811 | - $data['format_source'] = 'aircraftlistjson'; |
|
812 | - $data['id_source'] = $id_source; |
|
813 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
814 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
815 | - $SI->add($data); |
|
816 | - unset($data); |
|
798 | + $data = array(); |
|
799 | + $data['hex'] = $line['hex']; // hex |
|
800 | + $data['ident'] = $line['flight']; // ident |
|
801 | + $data['altitude'] = $line['altitude']; // altitude |
|
802 | + $data['speed'] = $line['speed']; // speed |
|
803 | + $data['heading'] = $line['track']; // heading |
|
804 | + $data['latitude'] = $line['lat']; // lat |
|
805 | + $data['longitude'] = $line['lon']; // long |
|
806 | + $data['verticalrate'] = $line['vrt']; // verticale rate |
|
807 | + $data['squawk'] = $line['squawk']; // squawk |
|
808 | + $data['emergency'] = ''; // emergency |
|
809 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
810 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
811 | + $data['format_source'] = 'aircraftlistjson'; |
|
812 | + $data['id_source'] = $id_source; |
|
813 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
814 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
815 | + $SI->add($data); |
|
816 | + unset($data); |
|
817 | 817 | } |
818 | - } |
|
819 | - } |
|
820 | - //$last_exec['aircraftlistjson'] = time(); |
|
821 | - $last_exec[$id]['last'] = time(); |
|
822 | - //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
823 | - } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
824 | - $buffer = $Common->getData($value['host']); |
|
825 | - $all_data = json_decode($buffer,true); |
|
826 | - if (isset($all_data['planes'])) { |
|
818 | + } |
|
819 | + } |
|
820 | + //$last_exec['aircraftlistjson'] = time(); |
|
821 | + $last_exec[$id]['last'] = time(); |
|
822 | + //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
823 | + } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
824 | + $buffer = $Common->getData($value['host']); |
|
825 | + $all_data = json_decode($buffer,true); |
|
826 | + if (isset($all_data['planes'])) { |
|
827 | 827 | $reset = 0; |
828 | 828 | foreach ($all_data['planes'] as $key => $line) { |
829 | - $data = array(); |
|
830 | - $data['hex'] = $key; // hex |
|
831 | - $data['ident'] = $line[3]; // ident |
|
832 | - $data['altitude'] = $line[6]; // altitude |
|
833 | - $data['speed'] = $line[8]; // speed |
|
834 | - $data['heading'] = $line[7]; // heading |
|
835 | - $data['latitude'] = $line[4]; // lat |
|
836 | - $data['longitude'] = $line[5]; // long |
|
837 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
838 | - $data['squawk'] = $line[10]; // squawk |
|
839 | - $data['emergency'] = ''; // emergency |
|
840 | - $data['registration'] = $line[2]; |
|
841 | - $data['aircraft_icao'] = $line[0]; |
|
842 | - $deparr = explode('-',$line[1]); |
|
843 | - if (count($deparr) == 2) { |
|
829 | + $data = array(); |
|
830 | + $data['hex'] = $key; // hex |
|
831 | + $data['ident'] = $line[3]; // ident |
|
832 | + $data['altitude'] = $line[6]; // altitude |
|
833 | + $data['speed'] = $line[8]; // speed |
|
834 | + $data['heading'] = $line[7]; // heading |
|
835 | + $data['latitude'] = $line[4]; // lat |
|
836 | + $data['longitude'] = $line[5]; // long |
|
837 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
838 | + $data['squawk'] = $line[10]; // squawk |
|
839 | + $data['emergency'] = ''; // emergency |
|
840 | + $data['registration'] = $line[2]; |
|
841 | + $data['aircraft_icao'] = $line[0]; |
|
842 | + $deparr = explode('-',$line[1]); |
|
843 | + if (count($deparr) == 2) { |
|
844 | 844 | $data['departure_airport_icao'] = $deparr[0]; |
845 | 845 | $data['arrival_airport_icao'] = $deparr[1]; |
846 | - } |
|
847 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
848 | - $data['format_source'] = 'planeupdatefaa'; |
|
849 | - $data['id_source'] = $id_source; |
|
850 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
851 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
852 | - $SI->add($data); |
|
853 | - unset($data); |
|
846 | + } |
|
847 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
848 | + $data['format_source'] = 'planeupdatefaa'; |
|
849 | + $data['id_source'] = $id_source; |
|
850 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
851 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
852 | + $SI->add($data); |
|
853 | + unset($data); |
|
854 | + } |
|
854 | 855 | } |
855 | - } |
|
856 | - //$last_exec['planeupdatefaa'] = time(); |
|
857 | - $last_exec[$id]['last'] = time(); |
|
858 | - } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
859 | - $buffer = $Common->getData($value['host']); |
|
860 | - $all_data = json_decode($buffer,true); |
|
861 | - if (isset($all_data['states'])) { |
|
856 | + //$last_exec['planeupdatefaa'] = time(); |
|
857 | + $last_exec[$id]['last'] = time(); |
|
858 | + } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
859 | + $buffer = $Common->getData($value['host']); |
|
860 | + $all_data = json_decode($buffer,true); |
|
861 | + if (isset($all_data['states'])) { |
|
862 | 862 | $reset = 0; |
863 | 863 | foreach ($all_data['states'] as $key => $line) { |
864 | - $data = array(); |
|
865 | - $data['hex'] = $line[0]; // hex |
|
866 | - $data['ident'] = trim($line[1]); // ident |
|
867 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
868 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
869 | - $data['heading'] = round($line[10]); // heading |
|
870 | - $data['latitude'] = $line[6]; // lat |
|
871 | - $data['longitude'] = $line[5]; // long |
|
872 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
873 | - //$data['squawk'] = $line[10]; // squawk |
|
874 | - //$data['emergency'] = ''; // emergency |
|
875 | - //$data['registration'] = $line[2]; |
|
876 | - //$data['aircraft_icao'] = $line[0]; |
|
877 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
878 | - $data['format_source'] = 'opensky'; |
|
879 | - $data['id_source'] = $id_source; |
|
880 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
881 | - $SI->add($data); |
|
882 | - unset($data); |
|
864 | + $data = array(); |
|
865 | + $data['hex'] = $line[0]; // hex |
|
866 | + $data['ident'] = trim($line[1]); // ident |
|
867 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
868 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
869 | + $data['heading'] = round($line[10]); // heading |
|
870 | + $data['latitude'] = $line[6]; // lat |
|
871 | + $data['longitude'] = $line[5]; // long |
|
872 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
873 | + //$data['squawk'] = $line[10]; // squawk |
|
874 | + //$data['emergency'] = ''; // emergency |
|
875 | + //$data['registration'] = $line[2]; |
|
876 | + //$data['aircraft_icao'] = $line[0]; |
|
877 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
878 | + $data['format_source'] = 'opensky'; |
|
879 | + $data['id_source'] = $id_source; |
|
880 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
881 | + $SI->add($data); |
|
882 | + unset($data); |
|
883 | + } |
|
883 | 884 | } |
884 | - } |
|
885 | - //$last_exec['planeupdatefaa'] = time(); |
|
886 | - $last_exec[$id]['last'] = time(); |
|
887 | - //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
888 | - } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
889 | - //$buffer = $Common->getData($hosts[$id]); |
|
890 | - $buffer = $Common->getData($value['host']); |
|
891 | - $all_data = json_decode($buffer,true); |
|
892 | - if (!empty($all_data)) $reset = 0; |
|
893 | - foreach ($all_data as $key => $line) { |
|
885 | + //$last_exec['planeupdatefaa'] = time(); |
|
886 | + $last_exec[$id]['last'] = time(); |
|
887 | + //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
888 | + } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
889 | + //$buffer = $Common->getData($hosts[$id]); |
|
890 | + $buffer = $Common->getData($value['host']); |
|
891 | + $all_data = json_decode($buffer,true); |
|
892 | + if (!empty($all_data)) $reset = 0; |
|
893 | + foreach ($all_data as $key => $line) { |
|
894 | 894 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
895 | - $data = array(); |
|
896 | - $data['hex'] = $line[0]; |
|
897 | - $data['ident'] = $line[16]; //$line[13] |
|
898 | - $data['altitude'] = $line[4]; // altitude |
|
899 | - $data['speed'] = $line[5]; // speed |
|
900 | - $data['heading'] = $line[3]; // heading |
|
901 | - $data['latitude'] = $line[1]; // lat |
|
902 | - $data['longitude'] = $line[2]; // long |
|
903 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
904 | - $data['squawk'] = $line[6]; // squawk |
|
905 | - $data['aircraft_icao'] = $line[8]; |
|
906 | - $data['registration'] = $line[9]; |
|
907 | - $data['departure_airport_iata'] = $line[11]; |
|
908 | - $data['arrival_airport_iata'] = $line[12]; |
|
909 | - $data['emergency'] = ''; // emergency |
|
910 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
911 | - $data['format_source'] = 'fr24json'; |
|
912 | - $data['id_source'] = $id_source; |
|
913 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
914 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
915 | - $SI->add($data); |
|
916 | - unset($data); |
|
895 | + $data = array(); |
|
896 | + $data['hex'] = $line[0]; |
|
897 | + $data['ident'] = $line[16]; //$line[13] |
|
898 | + $data['altitude'] = $line[4]; // altitude |
|
899 | + $data['speed'] = $line[5]; // speed |
|
900 | + $data['heading'] = $line[3]; // heading |
|
901 | + $data['latitude'] = $line[1]; // lat |
|
902 | + $data['longitude'] = $line[2]; // long |
|
903 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
904 | + $data['squawk'] = $line[6]; // squawk |
|
905 | + $data['aircraft_icao'] = $line[8]; |
|
906 | + $data['registration'] = $line[9]; |
|
907 | + $data['departure_airport_iata'] = $line[11]; |
|
908 | + $data['arrival_airport_iata'] = $line[12]; |
|
909 | + $data['emergency'] = ''; // emergency |
|
910 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
911 | + $data['format_source'] = 'fr24json'; |
|
912 | + $data['id_source'] = $id_source; |
|
913 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
914 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
915 | + $SI->add($data); |
|
916 | + unset($data); |
|
917 | 917 | } |
918 | - } |
|
919 | - //$last_exec['fr24json'] = time(); |
|
920 | - $last_exec[$id]['last'] = time(); |
|
921 | - //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
922 | - } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
923 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
924 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
925 | - //echo $buffer; |
|
926 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
927 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
928 | - $all_data = json_decode($buffer,true); |
|
929 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
918 | + } |
|
919 | + //$last_exec['fr24json'] = time(); |
|
920 | + $last_exec[$id]['last'] = time(); |
|
921 | + //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
922 | + } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
923 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
924 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
925 | + //echo $buffer; |
|
926 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
927 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
928 | + $all_data = json_decode($buffer,true); |
|
929 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
930 | 930 | die(json_last_error_msg()); |
931 | - } |
|
932 | - if (isset($all_data['mrkrs'])) { |
|
931 | + } |
|
932 | + if (isset($all_data['mrkrs'])) { |
|
933 | 933 | $reset = 0; |
934 | 934 | foreach ($all_data['mrkrs'] as $key => $line) { |
935 | - if (isset($line['inf'])) { |
|
935 | + if (isset($line['inf'])) { |
|
936 | 936 | $data = array(); |
937 | 937 | $data['hex'] = $line['inf']['ia']; |
938 | 938 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
939 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
940 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
941 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
942 | - $data['latitude'] = $line['pt'][0]; // lat |
|
943 | - $data['longitude'] = $line['pt'][1]; // long |
|
944 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
945 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
946 | - //$data['aircraft_icao'] = $line[8]; |
|
947 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
939 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
940 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
941 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
942 | + $data['latitude'] = $line['pt'][0]; // lat |
|
943 | + $data['longitude'] = $line['pt'][1]; // long |
|
944 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
945 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
946 | + //$data['aircraft_icao'] = $line[8]; |
|
947 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
948 | 948 | //$data['departure_airport_iata'] = $line[11]; |
949 | 949 | //$data['arrival_airport_iata'] = $line[12]; |
950 | - //$data['emergency'] = ''; // emergency |
|
950 | + //$data['emergency'] = ''; // emergency |
|
951 | 951 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
952 | - $data['format_source'] = 'radarvirtueljson'; |
|
953 | - $data['id_source'] = $id_source; |
|
952 | + $data['format_source'] = 'radarvirtueljson'; |
|
953 | + $data['id_source'] = $id_source; |
|
954 | 954 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
955 | 955 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
956 | 956 | $SI->add($data); |
957 | 957 | unset($data); |
958 | - } |
|
958 | + } |
|
959 | + } |
|
959 | 960 | } |
960 | - } |
|
961 | - //$last_exec['radarvirtueljson'] = time(); |
|
962 | - $last_exec[$id]['last'] = time(); |
|
963 | - //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
964 | - } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
965 | - //$buffer = $Common->getData($hosts[$id]); |
|
966 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
967 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
961 | + //$last_exec['radarvirtueljson'] = time(); |
|
962 | + $last_exec[$id]['last'] = time(); |
|
963 | + //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
964 | + } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
965 | + //$buffer = $Common->getData($hosts[$id]); |
|
966 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
967 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
968 | 968 | |
969 | - if (isset($all_data['pireps'])) { |
|
969 | + if (isset($all_data['pireps'])) { |
|
970 | 970 | $reset = 0; |
971 | - foreach ($all_data['pireps'] as $line) { |
|
972 | - $data = array(); |
|
973 | - $data['id'] = $line['id']; |
|
974 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
975 | - $data['ident'] = $line['callsign']; // ident |
|
976 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
977 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
978 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
979 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
980 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
981 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
982 | - $data['latitude'] = $line['lat']; // lat |
|
983 | - $data['longitude'] = $line['lon']; // long |
|
984 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
985 | - //$data['squawk'] = $line['squawk']; // squawk |
|
986 | - //$data['emergency'] = ''; // emergency |
|
987 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
988 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
989 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
990 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
991 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
992 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
993 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
994 | - else $data['info'] = ''; |
|
995 | - $data['format_source'] = 'pireps'; |
|
996 | - $data['id_source'] = $id_source; |
|
997 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
998 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
999 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1000 | - if ($line['icon'] == 'plane') { |
|
971 | + foreach ($all_data['pireps'] as $line) { |
|
972 | + $data = array(); |
|
973 | + $data['id'] = $line['id']; |
|
974 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
975 | + $data['ident'] = $line['callsign']; // ident |
|
976 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
977 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
978 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
979 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
980 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
981 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
982 | + $data['latitude'] = $line['lat']; // lat |
|
983 | + $data['longitude'] = $line['lon']; // long |
|
984 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
985 | + //$data['squawk'] = $line['squawk']; // squawk |
|
986 | + //$data['emergency'] = ''; // emergency |
|
987 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
988 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
989 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
990 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
991 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
992 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
993 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
994 | + else $data['info'] = ''; |
|
995 | + $data['format_source'] = 'pireps'; |
|
996 | + $data['id_source'] = $id_source; |
|
997 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
998 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
999 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1000 | + if ($line['icon'] == 'plane') { |
|
1001 | 1001 | $SI->add($data); |
1002 | - // print_r($data); |
|
1003 | - } elseif ($line['icon'] == 'ct') { |
|
1002 | + // print_r($data); |
|
1003 | + } elseif ($line['icon'] == 'ct') { |
|
1004 | 1004 | $data['info'] = str_replace('^§','<br />',$data['info']); |
1005 | 1005 | $data['info'] = str_replace('&sect;','',$data['info']); |
1006 | 1006 | $typec = substr($data['ident'],-3); |
@@ -1015,133 +1015,133 @@ discard block |
||
1015 | 1015 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
1016 | 1016 | else $data['type'] = 'Observer'; |
1017 | 1017 | 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']); |
1018 | - } |
|
1019 | - unset($data); |
|
1018 | + } |
|
1019 | + unset($data); |
|
1020 | + } |
|
1020 | 1021 | } |
1021 | - } |
|
1022 | - //$last_exec['pirepsjson'] = time(); |
|
1023 | - $last_exec[$id]['last'] = time(); |
|
1024 | - //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
1025 | - } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
1026 | - //$buffer = $Common->getData($hosts[$id]); |
|
1027 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1028 | - $buffer = $Common->getData($value['host']); |
|
1029 | - $all_data = json_decode($buffer,true); |
|
1030 | - if ($buffer != '' && is_array($all_data)) { |
|
1022 | + //$last_exec['pirepsjson'] = time(); |
|
1023 | + $last_exec[$id]['last'] = time(); |
|
1024 | + //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
1025 | + } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
1026 | + //$buffer = $Common->getData($hosts[$id]); |
|
1027 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1028 | + $buffer = $Common->getData($value['host']); |
|
1029 | + $all_data = json_decode($buffer,true); |
|
1030 | + if ($buffer != '' && is_array($all_data)) { |
|
1031 | 1031 | $reset = 0; |
1032 | 1032 | foreach ($all_data as $line) { |
1033 | - $data = array(); |
|
1034 | - //$data['id'] = $line['id']; // id not usable |
|
1035 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1036 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1037 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1038 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1039 | - $data['ident'] = $line['flightnum']; // ident |
|
1040 | - $data['altitude'] = $line['alt']; // altitude |
|
1041 | - $data['speed'] = $line['gs']; // speed |
|
1042 | - $data['heading'] = $line['heading']; // heading |
|
1043 | - $data['latitude'] = $line['lat']; // lat |
|
1044 | - $data['longitude'] = $line['lng']; // long |
|
1045 | - $data['verticalrate'] = ''; // verticale rate |
|
1046 | - $data['squawk'] = ''; // squawk |
|
1047 | - $data['emergency'] = ''; // emergency |
|
1048 | - //$data['datetime'] = $line['lastupdate']; |
|
1049 | - //$data['last_update'] = $line['lastupdate']; |
|
1050 | - if (isset($value['timezone'])) { |
|
1051 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1052 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1053 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1054 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1055 | - $data['departure_airport_icao'] = $line['depicao']; |
|
1056 | - $data['departure_airport_time'] = $line['deptime']; |
|
1057 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
1058 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
1059 | - $data['registration'] = $line['aircraft']; |
|
1060 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1061 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1062 | - if (isset($line['aircraftname'])) { |
|
1033 | + $data = array(); |
|
1034 | + //$data['id'] = $line['id']; // id not usable |
|
1035 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1036 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1037 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1038 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1039 | + $data['ident'] = $line['flightnum']; // ident |
|
1040 | + $data['altitude'] = $line['alt']; // altitude |
|
1041 | + $data['speed'] = $line['gs']; // speed |
|
1042 | + $data['heading'] = $line['heading']; // heading |
|
1043 | + $data['latitude'] = $line['lat']; // lat |
|
1044 | + $data['longitude'] = $line['lng']; // long |
|
1045 | + $data['verticalrate'] = ''; // verticale rate |
|
1046 | + $data['squawk'] = ''; // squawk |
|
1047 | + $data['emergency'] = ''; // emergency |
|
1048 | + //$data['datetime'] = $line['lastupdate']; |
|
1049 | + //$data['last_update'] = $line['lastupdate']; |
|
1050 | + if (isset($value['timezone'])) { |
|
1051 | + $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1052 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1053 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1054 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1055 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1056 | + $data['departure_airport_time'] = $line['deptime']; |
|
1057 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1058 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
1059 | + $data['registration'] = $line['aircraft']; |
|
1060 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1061 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1062 | + if (isset($line['aircraftname'])) { |
|
1063 | 1063 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1064 | 1064 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1065 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1066 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1067 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1068 | - else { |
|
1069 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1070 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1071 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1072 | - } |
|
1073 | - } |
|
1074 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1075 | - $data['id_source'] = $id_source; |
|
1076 | - $data['format_source'] = 'phpvmacars'; |
|
1077 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1078 | - $SI->add($data); |
|
1079 | - unset($data); |
|
1065 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
1066 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1067 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1068 | + else { |
|
1069 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
1070 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1071 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1072 | + } |
|
1073 | + } |
|
1074 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1075 | + $data['id_source'] = $id_source; |
|
1076 | + $data['format_source'] = 'phpvmacars'; |
|
1077 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1078 | + $SI->add($data); |
|
1079 | + unset($data); |
|
1080 | 1080 | } |
1081 | 1081 | if ($globalDebug) echo 'No more data...'."\n"; |
1082 | 1082 | unset($buffer); |
1083 | 1083 | unset($all_data); |
1084 | - } |
|
1085 | - //$last_exec['phpvmacars'] = time(); |
|
1086 | - $last_exec[$id]['last'] = time(); |
|
1087 | - } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
1088 | - //$buffer = $Common->getData($hosts[$id]); |
|
1089 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1090 | - $buffer = $Common->getData($value['host']); |
|
1091 | - $all_data = json_decode($buffer,true); |
|
1092 | - if ($buffer != '' && is_array($all_data)) { |
|
1084 | + } |
|
1085 | + //$last_exec['phpvmacars'] = time(); |
|
1086 | + $last_exec[$id]['last'] = time(); |
|
1087 | + } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
1088 | + //$buffer = $Common->getData($hosts[$id]); |
|
1089 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1090 | + $buffer = $Common->getData($value['host']); |
|
1091 | + $all_data = json_decode($buffer,true); |
|
1092 | + if ($buffer != '' && is_array($all_data)) { |
|
1093 | 1093 | $reset = 0; |
1094 | 1094 | foreach ($all_data as $line) { |
1095 | - $data = array(); |
|
1096 | - //$data['id'] = $line['id']; // id not usable |
|
1097 | - $data['id'] = trim($line['flight_id']); |
|
1098 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1099 | - $data['pilot_name'] = $line['pilot_name']; |
|
1100 | - $data['pilot_id'] = $line['pilot_id']; |
|
1101 | - $data['ident'] = trim($line['callsign']); // ident |
|
1102 | - $data['altitude'] = $line['altitude']; // altitude |
|
1103 | - $data['speed'] = $line['gs']; // speed |
|
1104 | - $data['heading'] = $line['heading']; // heading |
|
1105 | - $data['latitude'] = $line['latitude']; // lat |
|
1106 | - $data['longitude'] = $line['longitude']; // long |
|
1107 | - $data['verticalrate'] = ''; // verticale rate |
|
1108 | - $data['squawk'] = ''; // squawk |
|
1109 | - $data['emergency'] = ''; // emergency |
|
1110 | - //$data['datetime'] = $line['lastupdate']; |
|
1111 | - $data['last_update'] = $line['last_update']; |
|
1112 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1113 | - $data['departure_airport_icao'] = $line['departure']; |
|
1114 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
1115 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
1116 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1117 | - //$data['registration'] = $line['aircraft']; |
|
1118 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1119 | - $data['aircraft_icao'] = $line['plane_type']; |
|
1120 | - $data['id_source'] = $id_source; |
|
1121 | - $data['format_source'] = 'vam'; |
|
1122 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1123 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1124 | - $SI->add($data); |
|
1125 | - unset($data); |
|
1095 | + $data = array(); |
|
1096 | + //$data['id'] = $line['id']; // id not usable |
|
1097 | + $data['id'] = trim($line['flight_id']); |
|
1098 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1099 | + $data['pilot_name'] = $line['pilot_name']; |
|
1100 | + $data['pilot_id'] = $line['pilot_id']; |
|
1101 | + $data['ident'] = trim($line['callsign']); // ident |
|
1102 | + $data['altitude'] = $line['altitude']; // altitude |
|
1103 | + $data['speed'] = $line['gs']; // speed |
|
1104 | + $data['heading'] = $line['heading']; // heading |
|
1105 | + $data['latitude'] = $line['latitude']; // lat |
|
1106 | + $data['longitude'] = $line['longitude']; // long |
|
1107 | + $data['verticalrate'] = ''; // verticale rate |
|
1108 | + $data['squawk'] = ''; // squawk |
|
1109 | + $data['emergency'] = ''; // emergency |
|
1110 | + //$data['datetime'] = $line['lastupdate']; |
|
1111 | + $data['last_update'] = $line['last_update']; |
|
1112 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1113 | + $data['departure_airport_icao'] = $line['departure']; |
|
1114 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
1115 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
1116 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1117 | + //$data['registration'] = $line['aircraft']; |
|
1118 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1119 | + $data['aircraft_icao'] = $line['plane_type']; |
|
1120 | + $data['id_source'] = $id_source; |
|
1121 | + $data['format_source'] = 'vam'; |
|
1122 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1123 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1124 | + $SI->add($data); |
|
1125 | + unset($data); |
|
1126 | 1126 | } |
1127 | 1127 | if ($globalDebug) echo 'No more data...'."\n"; |
1128 | 1128 | unset($buffer); |
1129 | 1129 | unset($all_data); |
1130 | - } |
|
1131 | - //$last_exec['phpvmacars'] = time(); |
|
1132 | - $last_exec[$id]['last'] = time(); |
|
1133 | - } elseif ($value['format'] == 'blitzortung' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
1134 | - //$buffer = $Common->getData($hosts[$id]); |
|
1135 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1136 | - $buffer = $Common->getData($value['host']); |
|
1137 | - $all_data = json_decode($buffer,true); |
|
1138 | - if ($buffer != '') { |
|
1130 | + } |
|
1131 | + //$last_exec['phpvmacars'] = time(); |
|
1132 | + $last_exec[$id]['last'] = time(); |
|
1133 | + } elseif ($value['format'] == 'blitzortung' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
1134 | + //$buffer = $Common->getData($hosts[$id]); |
|
1135 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1136 | + $buffer = $Common->getData($value['host']); |
|
1137 | + $all_data = json_decode($buffer,true); |
|
1138 | + if ($buffer != '') { |
|
1139 | 1139 | $Source->deleteLocationBySource('blitzortung'); |
1140 | 1140 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
1141 | 1141 | $buffer = explode('\n',$buffer); |
1142 | 1142 | foreach ($buffer as $buffer_line) { |
1143 | - $line = json_decode($buffer_line,true); |
|
1144 | - if (isset($line['time'])) { |
|
1143 | + $line = json_decode($buffer_line,true); |
|
1144 | + if (isset($line['time'])) { |
|
1145 | 1145 | $data = array(); |
1146 | 1146 | $data['altitude'] = $line['alt']; // altitude |
1147 | 1147 | $data['latitude'] = $line['lat']; // lat |
@@ -1153,94 +1153,94 @@ discard block |
||
1153 | 1153 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1154 | 1154 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
1155 | 1155 | unset($data); |
1156 | - } |
|
1156 | + } |
|
1157 | 1157 | } |
1158 | 1158 | if ($globalDebug) echo 'No more data...'."\n"; |
1159 | 1159 | unset($buffer); |
1160 | - } |
|
1161 | - $last_exec[$id]['last'] = time(); |
|
1160 | + } |
|
1161 | + $last_exec[$id]['last'] = time(); |
|
1162 | 1162 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
1163 | 1163 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { |
1164 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1165 | - //$last_exec[$id]['last'] = time(); |
|
1164 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1165 | + //$last_exec[$id]['last'] = time(); |
|
1166 | 1166 | |
1167 | - //$read = array( $sockets[$id] ); |
|
1168 | - $read = $sockets; |
|
1169 | - $write = NULL; |
|
1170 | - $e = NULL; |
|
1171 | - $n = socket_select($read, $write, $e, $timeout); |
|
1172 | - if ($e != NULL) var_dump($e); |
|
1173 | - if ($n > 0) { |
|
1167 | + //$read = array( $sockets[$id] ); |
|
1168 | + $read = $sockets; |
|
1169 | + $write = NULL; |
|
1170 | + $e = NULL; |
|
1171 | + $n = socket_select($read, $write, $e, $timeout); |
|
1172 | + if ($e != NULL) var_dump($e); |
|
1173 | + if ($n > 0) { |
|
1174 | 1174 | $reset = 0; |
1175 | 1175 | foreach ($read as $nb => $r) { |
1176 | - //$value = $formats[$nb]; |
|
1177 | - $format = $globalSources[$nb]['format']; |
|
1178 | - if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1176 | + //$value = $formats[$nb]; |
|
1177 | + $format = $globalSources[$nb]['format']; |
|
1178 | + if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1179 | 1179 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
1180 | - } elseif ($format == 'vrstcp') { |
|
1180 | + } elseif ($format == 'vrstcp') { |
|
1181 | 1181 | $buffer = @socket_read($r, 6000); |
1182 | - } else { |
|
1182 | + } else { |
|
1183 | 1183 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
1184 | - } |
|
1185 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1186 | - //echo $buffer."\n"; |
|
1187 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
1188 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1189 | - $error = false; |
|
1190 | - //$SI::del(); |
|
1191 | - if ($format == 'vrstcp') { |
|
1184 | + } |
|
1185 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1186 | + //echo $buffer."\n"; |
|
1187 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
1188 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1189 | + $error = false; |
|
1190 | + //$SI::del(); |
|
1191 | + if ($format == 'vrstcp') { |
|
1192 | 1192 | $buffer = explode('},{',$buffer); |
1193 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1194 | - // SBS format is CSV format |
|
1195 | - if ($buffer !== FALSE && $buffer != '') { |
|
1193 | + } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1194 | + // SBS format is CSV format |
|
1195 | + if ($buffer !== FALSE && $buffer != '') { |
|
1196 | 1196 | $tt[$format] = 0; |
1197 | 1197 | if ($format == 'acarssbs3') { |
1198 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1199 | - $ACARS->add(trim($buffer)); |
|
1200 | - $ACARS->deleteLiveAcarsData(); |
|
1198 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1199 | + $ACARS->add(trim($buffer)); |
|
1200 | + $ACARS->deleteLiveAcarsData(); |
|
1201 | 1201 | } elseif ($format == 'raw') { |
1202 | - // AVR format |
|
1203 | - $data = $SBS->parse($buffer); |
|
1204 | - if (is_array($data)) { |
|
1202 | + // AVR format |
|
1203 | + $data = $SBS->parse($buffer); |
|
1204 | + if (is_array($data)) { |
|
1205 | 1205 | $data['datetime'] = date('Y-m-d H:i:s'); |
1206 | 1206 | $data['format_source'] = 'raw'; |
1207 | 1207 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1208 | 1208 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1209 | 1209 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1210 | 1210 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1211 | - } |
|
1211 | + } |
|
1212 | 1212 | } elseif ($format == 'ais') { |
1213 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
1214 | - $data = array(); |
|
1215 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1216 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1217 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1218 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1219 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1220 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1221 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1222 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1223 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1224 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1225 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1226 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1227 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1228 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1229 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1230 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1213 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
1214 | + $data = array(); |
|
1215 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1216 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1217 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1218 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1219 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1220 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1221 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1222 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1223 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1224 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1225 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1226 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1227 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1228 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1229 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1230 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1231 | 1231 | |
1232 | - if (isset($ais_data['timestamp'])) { |
|
1232 | + if (isset($ais_data['timestamp'])) { |
|
1233 | 1233 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
1234 | - } else { |
|
1234 | + } else { |
|
1235 | 1235 | $data['datetime'] = date('Y-m-d H:i:s'); |
1236 | - } |
|
1237 | - $data['format_source'] = 'aisnmea'; |
|
1238 | - $data['id_source'] = $id_source; |
|
1239 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1240 | - unset($data); |
|
1241 | - } elseif ($format == 'flightgearsp') { |
|
1242 | - //echo $buffer."\n"; |
|
1243 | - if (strlen($buffer) > 5) { |
|
1236 | + } |
|
1237 | + $data['format_source'] = 'aisnmea'; |
|
1238 | + $data['id_source'] = $id_source; |
|
1239 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1240 | + unset($data); |
|
1241 | + } elseif ($format == 'flightgearsp') { |
|
1242 | + //echo $buffer."\n"; |
|
1243 | + if (strlen($buffer) > 5) { |
|
1244 | 1244 | $line = explode(',',$buffer); |
1245 | 1245 | $data = array(); |
1246 | 1246 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1257,38 +1257,38 @@ discard block |
||
1257 | 1257 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1258 | 1258 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1259 | 1259 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1260 | - } |
|
1261 | - } elseif ($format == 'acars') { |
|
1262 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1263 | - $ACARS->add(trim($buffer)); |
|
1264 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1265 | - $ACARS->deleteLiveAcarsData(); |
|
1260 | + } |
|
1261 | + } elseif ($format == 'acars') { |
|
1262 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1263 | + $ACARS->add(trim($buffer)); |
|
1264 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1265 | + $ACARS->deleteLiveAcarsData(); |
|
1266 | 1266 | } elseif ($format == 'flightgearmp') { |
1267 | - if (substr($buffer,0,1) != '#') { |
|
1267 | + if (substr($buffer,0,1) != '#') { |
|
1268 | 1268 | $data = array(); |
1269 | 1269 | //echo $buffer."\n"; |
1270 | 1270 | $line = explode(' ',$buffer); |
1271 | 1271 | if (count($line) == 11) { |
1272 | - $userserver = explode('@',$line[0]); |
|
1273 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1274 | - $data['ident'] = $userserver[0]; |
|
1275 | - $data['registration'] = $userserver[0]; |
|
1276 | - $data['latitude'] = $line[4]; |
|
1277 | - $data['longitude'] = $line[5]; |
|
1278 | - $data['altitude'] = $line[6]; |
|
1279 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1280 | - $aircraft_type = $line[10]; |
|
1281 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1282 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1283 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1284 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1272 | + $userserver = explode('@',$line[0]); |
|
1273 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1274 | + $data['ident'] = $userserver[0]; |
|
1275 | + $data['registration'] = $userserver[0]; |
|
1276 | + $data['latitude'] = $line[4]; |
|
1277 | + $data['longitude'] = $line[5]; |
|
1278 | + $data['altitude'] = $line[6]; |
|
1279 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1280 | + $aircraft_type = $line[10]; |
|
1281 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1282 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1283 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1284 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1285 | + } |
|
1285 | 1286 | } |
1286 | - } |
|
1287 | 1287 | } elseif ($format == 'beast') { |
1288 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1289 | - die; |
|
1288 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1289 | + die; |
|
1290 | 1290 | } elseif ($format == 'vrstcp') { |
1291 | - foreach($buffer as $all_data) { |
|
1291 | + foreach($buffer as $all_data) { |
|
1292 | 1292 | $line = json_decode('{'.$all_data.'}',true); |
1293 | 1293 | $data = array(); |
1294 | 1294 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1308,148 +1308,148 @@ discard block |
||
1308 | 1308 | */ |
1309 | 1309 | $data['datetime'] = date('Y-m-d H:i:s'); |
1310 | 1310 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
1311 | - $data['format_source'] = 'vrstcp'; |
|
1311 | + $data['format_source'] = 'vrstcp'; |
|
1312 | 1312 | $data['id_source'] = $id_source; |
1313 | 1313 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1314 | 1314 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1315 | 1315 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1316 | 1316 | unset($data); |
1317 | - } |
|
1317 | + } |
|
1318 | 1318 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
1319 | - $line = explode("\t", $buffer); |
|
1320 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1319 | + $line = explode("\t", $buffer); |
|
1320 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
1321 | 1321 | $key = $line[$k]; |
1322 | - $lined[$key] = $line[$k+1]; |
|
1323 | - } |
|
1324 | - if (count($lined) > 3) { |
|
1325 | - $data['hex'] = $lined['hexid']; |
|
1326 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1327 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1328 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1329 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1330 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1331 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1332 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1333 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1334 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1335 | - $data['id_source'] = $id_source; |
|
1336 | - $data['format_source'] = 'tsv'; |
|
1337 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1338 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1322 | + $lined[$key] = $line[$k+1]; |
|
1323 | + } |
|
1324 | + if (count($lined) > 3) { |
|
1325 | + $data['hex'] = $lined['hexid']; |
|
1326 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1327 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
1328 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1329 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1330 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1331 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1332 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1333 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1334 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1335 | + $data['id_source'] = $id_source; |
|
1336 | + $data['format_source'] = 'tsv'; |
|
1337 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1338 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1339 | 1339 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1340 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1341 | - unset($lined); |
|
1342 | - unset($data); |
|
1343 | - } else $error = true; |
|
1340 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1341 | + unset($lined); |
|
1342 | + unset($data); |
|
1343 | + } else $error = true; |
|
1344 | 1344 | } elseif ($format == 'aprs' && $use_aprs) { |
1345 | - if ($aprs_connect == 0) { |
|
1345 | + if ($aprs_connect == 0) { |
|
1346 | 1346 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
1347 | 1347 | $aprs_connect = 1; |
1348 | - } |
|
1348 | + } |
|
1349 | 1349 | |
1350 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1350 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1351 | 1351 | $aprs_last_tx = time(); |
1352 | 1352 | $data_aprs = "# Keep alive"; |
1353 | 1353 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1354 | - } |
|
1354 | + } |
|
1355 | 1355 | |
1356 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1357 | - //echo 'APRS data : '.$buffer."\n"; |
|
1358 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1359 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1360 | - //echo $buffer."\n"; |
|
1361 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1356 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1357 | + //echo 'APRS data : '.$buffer."\n"; |
|
1358 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
1359 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
1360 | + //echo $buffer."\n"; |
|
1361 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1362 | 1362 | $line = $APRS->parse($buffer); |
1363 | 1363 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1364 | 1364 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
1365 | - $aprs_last_tx = time(); |
|
1366 | - $data = array(); |
|
1367 | - //print_r($line); |
|
1368 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1369 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1370 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1371 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1372 | - if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
1373 | - if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
1374 | - if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
1375 | - if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
1376 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1377 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1378 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1379 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1380 | - $data['latitude'] = $line['latitude']; |
|
1381 | - $data['longitude'] = $line['longitude']; |
|
1382 | - //$data['verticalrate'] = $line[16]; |
|
1383 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1384 | - //else $data['speed'] = 0; |
|
1385 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1386 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1387 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1388 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1389 | - //else $data['heading'] = 0; |
|
1390 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1391 | - //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1392 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1393 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1394 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1395 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1396 | - $data['id_source'] = $id_source; |
|
1397 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1398 | - else $data['format_source'] = 'aprs'; |
|
1399 | - $data['source_name'] = $line['source']; |
|
1400 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1401 | - else $data['source_type'] = 'flarm'; |
|
1402 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1403 | - $currentdate = date('Y-m-d H:i:s'); |
|
1404 | - $aprsdate = strtotime($data['datetime']); |
|
1405 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1406 | - // Accept data if time <= system time + 20s |
|
1407 | - //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'])))) { |
|
1408 | - if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1365 | + $aprs_last_tx = time(); |
|
1366 | + $data = array(); |
|
1367 | + //print_r($line); |
|
1368 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1369 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1370 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1371 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1372 | + if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
1373 | + if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
1374 | + if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
1375 | + if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
1376 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1377 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1378 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1379 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1380 | + $data['latitude'] = $line['latitude']; |
|
1381 | + $data['longitude'] = $line['longitude']; |
|
1382 | + //$data['verticalrate'] = $line[16]; |
|
1383 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1384 | + //else $data['speed'] = 0; |
|
1385 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1386 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1387 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1388 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1389 | + //else $data['heading'] = 0; |
|
1390 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1391 | + //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1392 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1393 | + elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1394 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1395 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1396 | + $data['id_source'] = $id_source; |
|
1397 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1398 | + else $data['format_source'] = 'aprs'; |
|
1399 | + $data['source_name'] = $line['source']; |
|
1400 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1401 | + else $data['source_type'] = 'flarm'; |
|
1402 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1403 | + $currentdate = date('Y-m-d H:i:s'); |
|
1404 | + $aprsdate = strtotime($data['datetime']); |
|
1405 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1406 | + // Accept data if time <= system time + 20s |
|
1407 | + //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'])))) { |
|
1408 | + if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1409 | 1409 | $send = $SI->add($data); |
1410 | - } elseif ($data['source_type'] == 'ais') { |
|
1410 | + } elseif ($data['source_type'] == 'ais') { |
|
1411 | 1411 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
1412 | - } elseif (isset($line['stealth'])) { |
|
1412 | + } elseif (isset($line['stealth'])) { |
|
1413 | 1413 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
1414 | 1414 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
1415 | - } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1416 | - //$line['symbol'] == 'Balloon' || |
|
1417 | - $line['symbol'] == 'Glider' || |
|
1418 | - $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1419 | - if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1420 | - if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1421 | - $send = $SI->add($data); |
|
1422 | - } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1423 | - $line['symbol'] == 'Yacht (Sail)' || |
|
1424 | - $line['symbol'] == 'Ship (Power Boat)')) { |
|
1425 | - $send = $MI->add($data); |
|
1426 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1427 | - $line['symbol'] == 'Car' || |
|
1428 | - $line['symbol'] == 'Ambulance' || |
|
1429 | - $line['symbol'] == 'Van' || |
|
1430 | - $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || |
|
1431 | - $line['symbol'] == 'Motorcycle' || |
|
1432 | - $line['symbol'] == 'Tractor' || |
|
1433 | - $line['symbol'] == 'Police' || |
|
1434 | - $line['symbol'] == 'Bike' || |
|
1435 | - $line['symbol'] == 'Jogger' || |
|
1436 | - $line['symbol'] == 'Horse' || |
|
1437 | - $line['symbol'] == 'Bus' || |
|
1438 | - $line['symbol'] == 'Jeep' || |
|
1439 | - $line['symbol'] == 'Recreational Vehicle' || |
|
1440 | - $line['symbol'] == 'Yacht (Sail)' || |
|
1441 | - $line['symbol'] == 'Ship (Power Boat)' || |
|
1442 | - $line['symbol'] == 'Firetruck' || |
|
1443 | - $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || |
|
1444 | - $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || |
|
1445 | - $line['symbol'] == 'SUV' || |
|
1446 | - $line['symbol'] == 'Snowmobile' || |
|
1447 | - $line['symbol'] == 'Mobile Satellite Station')) { |
|
1448 | - //} 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') { |
|
1415 | + } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1416 | + //$line['symbol'] == 'Balloon' || |
|
1417 | + $line['symbol'] == 'Glider' || |
|
1418 | + $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1419 | + if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1420 | + if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1421 | + $send = $SI->add($data); |
|
1422 | + } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1423 | + $line['symbol'] == 'Yacht (Sail)' || |
|
1424 | + $line['symbol'] == 'Ship (Power Boat)')) { |
|
1425 | + $send = $MI->add($data); |
|
1426 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1427 | + $line['symbol'] == 'Car' || |
|
1428 | + $line['symbol'] == 'Ambulance' || |
|
1429 | + $line['symbol'] == 'Van' || |
|
1430 | + $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || |
|
1431 | + $line['symbol'] == 'Motorcycle' || |
|
1432 | + $line['symbol'] == 'Tractor' || |
|
1433 | + $line['symbol'] == 'Police' || |
|
1434 | + $line['symbol'] == 'Bike' || |
|
1435 | + $line['symbol'] == 'Jogger' || |
|
1436 | + $line['symbol'] == 'Horse' || |
|
1437 | + $line['symbol'] == 'Bus' || |
|
1438 | + $line['symbol'] == 'Jeep' || |
|
1439 | + $line['symbol'] == 'Recreational Vehicle' || |
|
1440 | + $line['symbol'] == 'Yacht (Sail)' || |
|
1441 | + $line['symbol'] == 'Ship (Power Boat)' || |
|
1442 | + $line['symbol'] == 'Firetruck' || |
|
1443 | + $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || |
|
1444 | + $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || |
|
1445 | + $line['symbol'] == 'SUV' || |
|
1446 | + $line['symbol'] == 'Snowmobile' || |
|
1447 | + $line['symbol'] == 'Mobile Satellite Station')) { |
|
1448 | + //} 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') { |
|
1449 | 1449 | // } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
1450 | 1450 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1451 | 1451 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
1452 | - } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1452 | + } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1453 | 1453 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
1454 | 1454 | $Source->deleteOldLocationByType('gs'); |
1455 | 1455 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
@@ -1457,7 +1457,7 @@ discard block |
||
1457 | 1457 | } else { |
1458 | 1458 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
1459 | 1459 | } |
1460 | - } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
1460 | + } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
1461 | 1461 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1462 | 1462 | if ($globalDebug) echo '# Weather Station added'."\n"; |
1463 | 1463 | $Source->deleteOldLocationByType('wx'); |
@@ -1467,7 +1467,7 @@ discard block |
||
1467 | 1467 | } else { |
1468 | 1468 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
1469 | 1469 | } |
1470 | - } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') { |
|
1470 | + } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') { |
|
1471 | 1471 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1472 | 1472 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1473 | 1473 | $Source->deleteOldLocationByType('lightning'); |
@@ -1476,11 +1476,11 @@ discard block |
||
1476 | 1476 | } else { |
1477 | 1477 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
1478 | 1478 | } |
1479 | - } elseif ($globalDebug) { |
|
1480 | - echo '/!\ Not added: '.$buffer."\n"; |
|
1481 | - print_r($line); |
|
1482 | - } |
|
1483 | - unset($data); |
|
1479 | + } elseif ($globalDebug) { |
|
1480 | + echo '/!\ Not added: '.$buffer."\n"; |
|
1481 | + print_r($line); |
|
1482 | + } |
|
1483 | + unset($data); |
|
1484 | 1484 | } |
1485 | 1485 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
1486 | 1486 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
@@ -1499,12 +1499,12 @@ discard block |
||
1499 | 1499 | } elseif (!isset($globalSources[$nb]['last_weather_clean'])) { |
1500 | 1500 | $globalSources[$nb]['last_weather_clean'] = time(); |
1501 | 1501 | } |
1502 | - } |
|
1502 | + } |
|
1503 | 1503 | } else { |
1504 | - $line = explode(',', $buffer); |
|
1505 | - if (count($line) > 20) { |
|
1506 | - $data['hex'] = $line[4]; |
|
1507 | - /* |
|
1504 | + $line = explode(',', $buffer); |
|
1505 | + if (count($line) > 20) { |
|
1506 | + $data['hex'] = $line[4]; |
|
1507 | + /* |
|
1508 | 1508 | $data['datetime'] = $line[6].' '.$line[7]; |
1509 | 1509 | date_default_timezone_set($globalTimezone); |
1510 | 1510 | $datetime = new DateTime($data['datetime']); |
@@ -1512,30 +1512,30 @@ discard block |
||
1512 | 1512 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1513 | 1513 | date_default_timezone_set('UTC'); |
1514 | 1514 | */ |
1515 | - // Force datetime to current UTC datetime |
|
1516 | - date_default_timezone_set('UTC'); |
|
1517 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1518 | - $data['ident'] = trim($line[10]); |
|
1519 | - $data['latitude'] = $line[14]; |
|
1520 | - $data['longitude'] = $line[15]; |
|
1521 | - $data['verticalrate'] = $line[16]; |
|
1522 | - $data['emergency'] = $line[20]; |
|
1523 | - $data['speed'] = $line[12]; |
|
1524 | - $data['squawk'] = $line[17]; |
|
1525 | - $data['altitude'] = $line[11]; |
|
1526 | - $data['heading'] = $line[13]; |
|
1527 | - $data['ground'] = $line[21]; |
|
1528 | - $data['emergency'] = $line[19]; |
|
1529 | - $data['format_source'] = 'sbs'; |
|
1515 | + // Force datetime to current UTC datetime |
|
1516 | + date_default_timezone_set('UTC'); |
|
1517 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1518 | + $data['ident'] = trim($line[10]); |
|
1519 | + $data['latitude'] = $line[14]; |
|
1520 | + $data['longitude'] = $line[15]; |
|
1521 | + $data['verticalrate'] = $line[16]; |
|
1522 | + $data['emergency'] = $line[20]; |
|
1523 | + $data['speed'] = $line[12]; |
|
1524 | + $data['squawk'] = $line[17]; |
|
1525 | + $data['altitude'] = $line[11]; |
|
1526 | + $data['heading'] = $line[13]; |
|
1527 | + $data['ground'] = $line[21]; |
|
1528 | + $data['emergency'] = $line[19]; |
|
1529 | + $data['format_source'] = 'sbs'; |
|
1530 | 1530 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1531 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1531 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1532 | 1532 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1533 | - $data['id_source'] = $id_source; |
|
1534 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1535 | - else $error = true; |
|
1536 | - unset($data); |
|
1537 | - } else $error = true; |
|
1538 | - if ($error) { |
|
1533 | + $data['id_source'] = $id_source; |
|
1534 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1535 | + else $error = true; |
|
1536 | + unset($data); |
|
1537 | + } else $error = true; |
|
1538 | + if ($error) { |
|
1539 | 1539 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
1540 | 1540 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
1541 | 1541 | } else { |
@@ -1551,13 +1551,13 @@ discard block |
||
1551 | 1551 | connect_all($sourceer); |
1552 | 1552 | $sourceer = array(); |
1553 | 1553 | } |
1554 | - } |
|
1554 | + } |
|
1555 | 1555 | } |
1556 | 1556 | // Sleep for xxx microseconds |
1557 | 1557 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
1558 | - } else { |
|
1558 | + } else { |
|
1559 | 1559 | if ($format == 'flightgearmp') { |
1560 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1560 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1561 | 1561 | //@socket_close($r); |
1562 | 1562 | sleep($globalMinFetch); |
1563 | 1563 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1566,9 +1566,9 @@ discard block |
||
1566 | 1566 | break; |
1567 | 1567 | |
1568 | 1568 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1569 | - if (isset($tt[$format])) $tt[$format]++; |
|
1570 | - else $tt[$format] = 0; |
|
1571 | - if ($tt[$format] > 30) { |
|
1569 | + if (isset($tt[$format])) $tt[$format]++; |
|
1570 | + else $tt[$format] = 0; |
|
1571 | + if ($tt[$format] > 30) { |
|
1572 | 1572 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
1573 | 1573 | //@socket_close($r); |
1574 | 1574 | sleep(2); |
@@ -1579,23 +1579,23 @@ discard block |
||
1579 | 1579 | //connect_all($globalSources); |
1580 | 1580 | $tt[$format]=0; |
1581 | 1581 | break; |
1582 | - } |
|
1582 | + } |
|
1583 | + } |
|
1583 | 1584 | } |
1584 | - } |
|
1585 | 1585 | } |
1586 | - } else { |
|
1586 | + } else { |
|
1587 | 1587 | $error = socket_strerror(socket_last_error()); |
1588 | 1588 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1589 | 1589 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
1590 | 1590 | if (isset($globalDebug)) echo "Restarting...\n"; |
1591 | 1591 | // Restart the script if possible |
1592 | 1592 | if (is_array($sockets)) { |
1593 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
1593 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
1594 | 1594 | |
1595 | - foreach ($sockets as $sock) { |
|
1595 | + foreach ($sockets as $sock) { |
|
1596 | 1596 | @socket_shutdown($sock,2); |
1597 | 1597 | @socket_close($sock); |
1598 | - } |
|
1598 | + } |
|
1599 | 1599 | |
1600 | 1600 | } |
1601 | 1601 | if ($globalDebug) echo "Waiting..."; |
@@ -1610,15 +1610,15 @@ discard block |
||
1610 | 1610 | if ($globalDebug) echo "Restart all connections..."; |
1611 | 1611 | connect_all($globalSources); |
1612 | 1612 | } |
1613 | - } |
|
1613 | + } |
|
1614 | 1614 | } |
1615 | 1615 | if ($globalDaemon === false) { |
1616 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1617 | - if (isset($SI)) $SI->checkAll(); |
|
1618 | - if (isset($TI)) $TI->checkAll(); |
|
1619 | - if (isset($MI)) $MI->checkAll(); |
|
1616 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
1617 | + if (isset($SI)) $SI->checkAll(); |
|
1618 | + if (isset($TI)) $TI->checkAll(); |
|
1619 | + if (isset($MI)) $MI->checkAll(); |
|
1620 | + } |
|
1620 | 1621 | } |
1621 | - } |
|
1622 | 1622 | } |
1623 | 1623 | |
1624 | 1624 | ?> |