@@ -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>'; |
@@ -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 |
@@ -14,31 +14,31 @@ discard block |
||
14 | 14 | { |
15 | 15 | $coords = explode(',',$_GET['coord']); |
16 | 16 | if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') |
17 | - || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) { |
|
17 | + || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) { |
|
18 | 18 | //$spotter_array = $Source->getAllLocationInfo(); |
19 | 19 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('gs')); |
20 | 20 | } |
21 | 21 | if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true') |
22 | - || (!isset($_COOKIE['show_WeatherStation']) && (!isset($globalMapWeatherStation) || $globalMapWeatherStation === TRUE))) { |
|
22 | + || (!isset($_COOKIE['show_WeatherStation']) && (!isset($globalMapWeatherStation) || $globalMapWeatherStation === TRUE))) { |
|
23 | 23 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('wx')); |
24 | 24 | } |
25 | 25 | if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true') |
26 | - || (!isset($_COOKIE['show_Lightning']) && (!isset($globalMapLightning) || $globalMapLightning === TRUE))) { |
|
26 | + || (!isset($_COOKIE['show_Lightning']) && (!isset($globalMapLightning) || $globalMapLightning === TRUE))) { |
|
27 | 27 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('lightning')); |
28 | 28 | } |
29 | 29 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('')); |
30 | 30 | } else { |
31 | 31 | if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') |
32 | - || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) { |
|
32 | + || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) { |
|
33 | 33 | //$spotter_array = $Source->getAllLocationInfo(); |
34 | 34 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('gs')); |
35 | 35 | } |
36 | 36 | if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true') |
37 | - || (!isset($_COOKIE['show_WeatherStation']) && (!isset($globalMapWeatherStation) || $globalMapWeatherStation === TRUE))) { |
|
37 | + || (!isset($_COOKIE['show_WeatherStation']) && (!isset($globalMapWeatherStation) || $globalMapWeatherStation === TRUE))) { |
|
38 | 38 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('wx')); |
39 | 39 | } |
40 | 40 | if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true') |
41 | - || (!isset($_COOKIE['show_Lightning']) && (!isset($globalMapLightning) || $globalMapLightning === TRUE))) { |
|
41 | + || (!isset($_COOKIE['show_Lightning']) && (!isset($globalMapLightning) || $globalMapLightning === TRUE))) { |
|
42 | 42 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('lightning')); |
43 | 43 | } |
44 | 44 | $spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('')); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | date_default_timezone_set('UTC'); |
54 | 54 | //waypoint plotting |
55 | 55 | $output .= '{"type": "Feature",'; |
56 | - $output .= '"properties": {'; |
|
56 | + $output .= '"properties": {'; |
|
57 | 57 | $output .= '"id": "'.$spotter_item['id'].'",'; |
58 | 58 | $output .= '"location_id": "'.$spotter_item['location_id'].'",'; |
59 | 59 | $output .= '"name": "'.$spotter_item['name'].'",'; |
@@ -71,13 +71,13 @@ discard block |
||
71 | 71 | if (isset($weather['temp'])) $output.= '"temp": "'.$weather['temp'].'",'; |
72 | 72 | } |
73 | 73 | $output .= '"image_thumb": "'.$spotter_item['image_thumb'].'"'; |
74 | - $output .= '},'; |
|
75 | - $output .= '"geometry": {'; |
|
74 | + $output .= '},'; |
|
75 | + $output .= '"geometry": {'; |
|
76 | 76 | $output .= '"type": "Point",'; |
77 | 77 | $output .= '"coordinates": ['; |
78 | - $output .= $spotter_item['longitude'].', '.$spotter_item['latitude']; |
|
78 | + $output .= $spotter_item['longitude'].', '.$spotter_item['latitude']; |
|
79 | 79 | $output .= ']'; |
80 | - $output .= '}'; |
|
80 | + $output .= '}'; |
|
81 | 81 | $output .= '},'; |
82 | 82 | } |
83 | 83 | $output = substr($output, 0, -1); |
@@ -385,10 +385,10 @@ discard block |
||
385 | 385 | setInterval(function(){update_locationsLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>); |
386 | 386 | |
387 | 387 | <?php |
388 | - // Add support for custom json via $globalMapJson |
|
389 | - if (isset($globalMapJson) && is_array($globalMapJson)) { |
|
388 | + // Add support for custom json via $globalMapJson |
|
389 | + if (isset($globalMapJson) && is_array($globalMapJson)) { |
|
390 | 390 | foreach ($globalMapJson as $json) { |
391 | - if (isset($json['url'])) { |
|
391 | + if (isset($json['url'])) { |
|
392 | 392 | ?> |
393 | 393 | update_genLayer('<?php print $json['url']; ?>'); |
394 | 394 | <?php |
@@ -397,9 +397,9 @@ discard block |
||
397 | 397 | setInterval(function(){update_genLayer('<?php print $json['url']; ?>')}, <?php print $json['refresh']; ?>); |
398 | 398 | <?php |
399 | 399 | } |
400 | - } |
|
400 | + } |
|
401 | + } |
|
401 | 402 | } |
402 | - } |
|
403 | 403 | |
404 | 404 | ?> |
405 | 405 | //adds the bootstrap tooltip to the map icons |
@@ -7,16 +7,16 @@ discard block |
||
7 | 7 | require_once(dirname(__FILE__).'/class.Source.php'); |
8 | 8 | |
9 | 9 | class TrackerImport { |
10 | - private $all_tracked = array(); |
|
11 | - private $last_delete_hourly = 0; |
|
12 | - private $last_delete = 0; |
|
13 | - private $stats = array(); |
|
14 | - private $tmd = 0; |
|
15 | - private $source_location = array(); |
|
16 | - public $db = null; |
|
17 | - public $nb = 0; |
|
10 | + private $all_tracked = array(); |
|
11 | + private $last_delete_hourly = 0; |
|
12 | + private $last_delete = 0; |
|
13 | + private $stats = array(); |
|
14 | + private $tmd = 0; |
|
15 | + private $source_location = array(); |
|
16 | + public $db = null; |
|
17 | + public $nb = 0; |
|
18 | 18 | |
19 | - public function __construct($dbc = null) { |
|
19 | + public function __construct($dbc = null) { |
|
20 | 20 | global $globalBeta; |
21 | 21 | $Connection = new Connection($dbc); |
22 | 22 | $this->db = $Connection->db(); |
@@ -38,50 +38,50 @@ discard block |
||
38 | 38 | } |
39 | 39 | } |
40 | 40 | */ |
41 | - } |
|
41 | + } |
|
42 | 42 | |
43 | - public function checkAll() { |
|
43 | + public function checkAll() { |
|
44 | 44 | global $globalDebug; |
45 | 45 | if ($globalDebug) echo "Update last seen tracked data...\n"; |
46 | 46 | foreach ($this->all_tracked as $key => $flight) { |
47 | - if (isset($this->all_tracked[$key]['id'])) { |
|
47 | + if (isset($this->all_tracked[$key]['id'])) { |
|
48 | 48 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
49 | - $Tracker = new Tracker($this->db); |
|
50 | - $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
51 | - } |
|
49 | + $Tracker = new Tracker($this->db); |
|
50 | + $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
51 | + } |
|
52 | + } |
|
52 | 53 | } |
53 | - } |
|
54 | 54 | |
55 | - public function del() { |
|
55 | + public function del() { |
|
56 | 56 | global $globalDebug; |
57 | 57 | // Delete old infos |
58 | 58 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
59 | 59 | foreach ($this->all_tracked as $key => $flight) { |
60 | - if (isset($flight['lastupdate'])) { |
|
61 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
62 | - if (isset($this->all_tracked[$key]['id'])) { |
|
63 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
60 | + if (isset($flight['lastupdate'])) { |
|
61 | + if ($flight['lastupdate'] < (time()-3000)) { |
|
62 | + if (isset($this->all_tracked[$key]['id'])) { |
|
63 | + if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
64 | 64 | /* |
65 | 65 | $TrackerLive = new TrackerLive(); |
66 | 66 | $TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']); |
67 | 67 | $TrackerLive->db = null; |
68 | 68 | */ |
69 | - //$real_arrival = $this->arrival($key); |
|
70 | - $Tracker = new Tracker($this->db); |
|
71 | - if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
69 | + //$real_arrival = $this->arrival($key); |
|
70 | + $Tracker = new Tracker($this->db); |
|
71 | + if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
72 | 72 | $result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']); |
73 | 73 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
74 | 74 | } |
75 | 75 | // Put in archive |
76 | 76 | // $Tracker->db = null; |
77 | - } |
|
78 | - unset($this->all_tracked[$key]); |
|
79 | - } |
|
80 | - } |
|
81 | - } |
|
82 | - } |
|
77 | + } |
|
78 | + unset($this->all_tracked[$key]); |
|
79 | + } |
|
80 | + } |
|
81 | + } |
|
82 | + } |
|
83 | 83 | |
84 | - public function add($line) { |
|
84 | + public function add($line) { |
|
85 | 85 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChangeTracker, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked; |
86 | 86 | if (!isset($globalCoordMinChangeTracker) || $globalCoordMinChangeTracker == '') $globalCoordMinChangeTracker = '0.015'; |
87 | 87 | date_default_timezone_set('UTC'); |
@@ -90,47 +90,47 @@ discard block |
||
90 | 90 | |
91 | 91 | // SBS format is CSV format |
92 | 92 | if(is_array($line) && isset($line['ident'])) { |
93 | - //print_r($line); |
|
94 | - if (isset($line['ident'])) { |
|
93 | + //print_r($line); |
|
94 | + if (isset($line['ident'])) { |
|
95 | 95 | |
96 | 96 | |
97 | 97 | // Increment message number |
98 | 98 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
99 | - $current_date = date('Y-m-d'); |
|
100 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
101 | - else $source = ''; |
|
102 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
103 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
104 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
105 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
106 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
99 | + $current_date = date('Y-m-d'); |
|
100 | + if (isset($line['source_name'])) $source = $line['source_name']; |
|
101 | + else $source = ''; |
|
102 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
103 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
104 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
105 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
106 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | |
110 | 110 | $Common = new Common(); |
111 | - if (!isset($line['id'])) $id = trim($line['ident']); |
|
112 | - else $id = trim($line['id']); |
|
111 | + if (!isset($line['id'])) $id = trim($line['ident']); |
|
112 | + else $id = trim($line['id']); |
|
113 | 113 | |
114 | 114 | if (!isset($this->all_tracked[$id])) { |
115 | - $this->all_tracked[$id] = array(); |
|
116 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0)); |
|
117 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
|
118 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
119 | - if (!isset($line['id'])) { |
|
115 | + $this->all_tracked[$id] = array(); |
|
116 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0)); |
|
117 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
|
118 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
119 | + if (!isset($line['id'])) { |
|
120 | 120 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
121 | 121 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
122 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
123 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
122 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
123 | + if ($globalAllTracked !== FALSE) $dataFound = true; |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
127 | - if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
|
127 | + if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
|
128 | 128 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
129 | - } else { |
|
129 | + } else { |
|
130 | 130 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
131 | 131 | elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
132 | 132 | return ''; |
133 | - } |
|
133 | + } |
|
134 | 134 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
135 | 135 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
136 | 136 | return ''; |
@@ -147,38 +147,38 @@ discard block |
||
147 | 147 | |
148 | 148 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
149 | 149 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
150 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
151 | - if ($this->all_tracked[$id]['addedTracker'] == 1) { |
|
150 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
151 | + if ($this->all_tracked[$id]['addedTracker'] == 1) { |
|
152 | 152 | $timeelapsed = microtime(true); |
153 | - $Tracker = new Tracker($this->db); |
|
154 | - $fromsource = NULL; |
|
155 | - $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
153 | + $Tracker = new Tracker($this->db); |
|
154 | + $fromsource = NULL; |
|
155 | + $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
156 | 156 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
157 | 157 | $Tracker->db = null; |
158 | 158 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
159 | - } |
|
160 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
159 | + } |
|
160 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | if (isset($line['speed']) && $line['speed'] != '') { |
164 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
165 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
164 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
165 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
166 | 166 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
167 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
168 | - if ($distance > 100 && $distance < 10000) { |
|
167 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
168 | + if ($distance > 100 && $distance < 10000) { |
|
169 | 169 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
170 | 170 | $speed = $speed*3.6; |
171 | 171 | if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
172 | 172 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n"; |
173 | - } |
|
173 | + } |
|
174 | 174 | } |
175 | 175 | |
176 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
177 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
178 | - else unset($timediff); |
|
179 | - if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
176 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
177 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
178 | + else unset($timediff); |
|
179 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
180 | 180 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
181 | - if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'],0.1)) { |
|
181 | + if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'],0.1)) { |
|
182 | 182 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
183 | 183 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
184 | 184 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -192,30 +192,30 @@ discard block |
||
192 | 192 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
193 | 193 | $this->tmd = 0; |
194 | 194 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
195 | - } |
|
195 | + } |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
199 | 199 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
200 | 200 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') { |
201 | - $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
202 | - $dataFound = true; |
|
203 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
201 | + $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
202 | + $dataFound = true; |
|
203 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
204 | 204 | } |
205 | 205 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
206 | 206 | } |
207 | 207 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
208 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
208 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
209 | 209 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
210 | 210 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') { |
211 | - $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
212 | - $dataFound = true; |
|
213 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
211 | + $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
212 | + $dataFound = true; |
|
213 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
214 | 214 | } |
215 | 215 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
216 | 216 | } |
217 | 217 | |
218 | - } else if ($globalDebug && $timediff > 20) { |
|
218 | + } else if ($globalDebug && $timediff > 20) { |
|
219 | 219 | $this->tmd = $this->tmd + 1; |
220 | 220 | if ($line['latitude'] != $this->all_tracked[$id]['latitude'] && $line['longitude'] != $this->all_tracked[$id]['longitude']) { |
221 | 221 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
@@ -223,131 +223,131 @@ discard block |
||
223 | 223 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
224 | 224 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
225 | 225 | } |
226 | - } |
|
226 | + } |
|
227 | 227 | } |
228 | 228 | if (isset($line['last_update']) && $line['last_update'] != '') { |
229 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
230 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
229 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
230 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
231 | 231 | } |
232 | 232 | if (isset($line['format_source']) && $line['format_source'] != '') { |
233 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
233 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
234 | 234 | } |
235 | 235 | if (isset($line['source_name']) && $line['source_name'] != '') { |
236 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
236 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
237 | 237 | } |
238 | 238 | if (isset($line['comment']) && $line['comment'] != '') { |
239 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment'])); |
|
240 | - //$dataFound = true; |
|
239 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment'])); |
|
240 | + //$dataFound = true; |
|
241 | 241 | } |
242 | 242 | if (isset($line['type']) && $line['type'] != '') { |
243 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
244 | - //$dataFound = true; |
|
243 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
244 | + //$dataFound = true; |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | if (isset($line['altitude']) && $line['altitude'] != '') { |
248 | - //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
248 | + //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
249 | 249 | if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true; |
250 | 250 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude'])); |
251 | 251 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude'])); |
252 | 252 | //$dataFound = true; |
253 | - //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
253 | + //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
257 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
257 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | if (isset($line['heading']) && $line['heading'] != '') { |
261 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
262 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
263 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
264 | - //$dataFound = true; |
|
261 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
262 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
263 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
264 | + //$dataFound = true; |
|
265 | 265 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
266 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
267 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
268 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
269 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
266 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
267 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
268 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
269 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
270 | 270 | } |
271 | 271 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
272 | 272 | |
273 | 273 | if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) { |
274 | - $this->all_tracked[$id]['lastupdate'] = time(); |
|
275 | - if ($this->all_tracked[$id]['addedTracker'] == 0) { |
|
276 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
277 | - if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
274 | + $this->all_tracked[$id]['lastupdate'] = time(); |
|
275 | + if ($this->all_tracked[$id]['addedTracker'] == 0) { |
|
276 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
277 | + if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
278 | 278 | if ($globalDebug) echo "Check if aircraft is already in DB..."; |
279 | 279 | $timeelapsed = microtime(true); |
280 | 280 | $TrackerLive = new TrackerLive($this->db); |
281 | 281 | if (isset($line['id'])) { |
282 | - $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
|
283 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
282 | + $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
|
283 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
284 | 284 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
285 | - $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
|
286 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
285 | + $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
|
286 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
287 | 287 | } else $recent_ident = ''; |
288 | 288 | $TrackerLive->db=null; |
289 | 289 | |
290 | 290 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
291 | 291 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
292 | - } else { |
|
292 | + } else { |
|
293 | 293 | $recent_ident = ''; |
294 | 294 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
295 | - } |
|
296 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
297 | - if($recent_ident == "") |
|
298 | - { |
|
295 | + } |
|
296 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
297 | + if($recent_ident == "") |
|
298 | + { |
|
299 | 299 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
300 | 300 | //adds the spotter data for the archive |
301 | - $highlight = ''; |
|
302 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
303 | - $timeelapsed = microtime(true); |
|
304 | - $Tracker = new Tracker($this->db); |
|
305 | - $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
306 | - $Tracker->db = null; |
|
307 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
308 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
301 | + $highlight = ''; |
|
302 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
303 | + $timeelapsed = microtime(true); |
|
304 | + $Tracker = new Tracker($this->db); |
|
305 | + $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
306 | + $Tracker->db = null; |
|
307 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
308 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
309 | 309 | |
310 | 310 | |
311 | - // Add source stat in DB |
|
312 | - $Stats = new Stats($this->db); |
|
313 | - if (!empty($this->stats)) { |
|
311 | + // Add source stat in DB |
|
312 | + $Stats = new Stats($this->db); |
|
313 | + if (!empty($this->stats)) { |
|
314 | 314 | if ($globalDebug) echo 'Add source stats : '; |
315 | - foreach($this->stats as $date => $data) { |
|
316 | - foreach($data as $source => $sourced) { |
|
317 | - //print_r($sourced); |
|
318 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date); |
|
319 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date); |
|
320 | - if (isset($sourced['msg'])) { |
|
321 | - if (time() - $sourced['msg']['date'] > 10) { |
|
322 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
323 | - echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date); |
|
324 | - unset($this->stats[$date][$source]['msg']); |
|
325 | - } |
|
326 | - } |
|
327 | - } |
|
328 | - if ($date != date('Y-m-d')) { |
|
329 | - unset($this->stats[$date]); |
|
330 | - } |
|
331 | - } |
|
332 | - if ($globalDebug) echo 'Done'."\n"; |
|
315 | + foreach($this->stats as $date => $data) { |
|
316 | + foreach($data as $source => $sourced) { |
|
317 | + //print_r($sourced); |
|
318 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date); |
|
319 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date); |
|
320 | + if (isset($sourced['msg'])) { |
|
321 | + if (time() - $sourced['msg']['date'] > 10) { |
|
322 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
323 | + echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date); |
|
324 | + unset($this->stats[$date][$source]['msg']); |
|
325 | + } |
|
326 | + } |
|
327 | + } |
|
328 | + if ($date != date('Y-m-d')) { |
|
329 | + unset($this->stats[$date]); |
|
330 | + } |
|
331 | + } |
|
332 | + if ($globalDebug) echo 'Done'."\n"; |
|
333 | 333 | |
334 | - } |
|
335 | - $Stats->db = null; |
|
334 | + } |
|
335 | + $Stats->db = null; |
|
336 | 336 | |
337 | - $this->del(); |
|
337 | + $this->del(); |
|
338 | 338 | //$ignoreImport = false; |
339 | 339 | $this->all_tracked[$id]['addedTracker'] = 1; |
340 | 340 | //print_r($this->all_tracked[$id]); |
341 | 341 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
342 | - if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
343 | - //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
344 | - $TrackerLive = new TrackerLive($this->db); |
|
345 | - $TrackerLive->deleteLiveTrackerData(); |
|
346 | - $TrackerLive->db=null; |
|
347 | - if ($globalDebug) echo " Done\n"; |
|
348 | - $this->last_delete = time(); |
|
342 | + if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
343 | + //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
344 | + $TrackerLive = new TrackerLive($this->db); |
|
345 | + $TrackerLive->deleteLiveTrackerData(); |
|
346 | + $TrackerLive->db=null; |
|
347 | + if ($globalDebug) echo " Done\n"; |
|
348 | + $this->last_delete = time(); |
|
349 | 349 | } |
350 | - } else { |
|
350 | + } else { |
|
351 | 351 | $this->all_tracked[$id]['id'] = $recent_ident; |
352 | 352 | $this->all_tracked[$id]['addedTracker'] = 1; |
353 | 353 | if (isset($globalDaemon) && !$globalDaemon) { |
@@ -356,16 +356,16 @@ discard block |
||
356 | 356 | $Tracker->db = null; |
357 | 357 | } |
358 | 358 | |
359 | - } |
|
359 | + } |
|
360 | 360 | } |
361 | - } |
|
362 | - //adds the spotter LIVE data |
|
363 | - if ($globalDebug) { |
|
361 | + } |
|
362 | + //adds the spotter LIVE data |
|
363 | + if ($globalDebug) { |
|
364 | 364 | echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Altitude : '.$this->all_tracked[$id]['altitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n"; |
365 | - } |
|
366 | - $ignoreImport = false; |
|
365 | + } |
|
366 | + $ignoreImport = false; |
|
367 | 367 | |
368 | - if (!$ignoreImport) { |
|
368 | + if (!$ignoreImport) { |
|
369 | 369 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
370 | 370 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
371 | 371 | $timeelapsed = microtime(true); |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | if ($stats_heading == 16) $stats_heading = 0; |
404 | 404 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
405 | 405 | for ($i=0;$i<=15;$i++) { |
406 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
406 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
407 | 407 | } |
408 | 408 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
409 | 409 | } else { |
@@ -416,11 +416,11 @@ discard block |
||
416 | 416 | //var_dump($this->stats); |
417 | 417 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
418 | 418 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
419 | - end($this->stats[$current_date][$source]['hist']); |
|
420 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
419 | + end($this->stats[$current_date][$source]['hist']); |
|
420 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
421 | 421 | } else $mini = 0; |
422 | 422 | for ($i=$mini;$i<=$distance;$i+=10) { |
423 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
423 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
424 | 424 | } |
425 | 425 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
426 | 426 | } else { |
@@ -436,22 +436,22 @@ discard block |
||
436 | 436 | |
437 | 437 | |
438 | 438 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
439 | - if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
440 | - $TrackerLive = new TrackerLive($this->db); |
|
441 | - $TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
442 | - $TrackerLive->db = null; |
|
443 | - //TrackerLive->deleteLiveTrackerData(); |
|
444 | - if ($globalDebug) echo " Done\n"; |
|
445 | - $this->last_delete_hourly = time(); |
|
439 | + if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
440 | + $TrackerLive = new TrackerLive($this->db); |
|
441 | + $TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
442 | + $TrackerLive->db = null; |
|
443 | + //TrackerLive->deleteLiveTrackerData(); |
|
444 | + if ($globalDebug) echo " Done\n"; |
|
445 | + $this->last_delete_hourly = time(); |
|
446 | 446 | } |
447 | 447 | |
448 | - } |
|
449 | - //$ignoreImport = false; |
|
448 | + } |
|
449 | + //$ignoreImport = false; |
|
450 | 450 | } |
451 | 451 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
452 | 452 | if ($send) return $this->all_tracked[$id]; |
453 | - } |
|
453 | + } |
|
454 | + } |
|
454 | 455 | } |
455 | - } |
|
456 | 456 | } |
457 | 457 | ?> |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | <?php }; if (isset($globalTracker) && $globalTracker) { ?><td><div id="ibxtracker"><h4><?php echo _("Trackers Detected"); ?></h4><br /><i class="fa fa-spinner fa-pulse fa-fw"></i></div></td><?php } ?> |
46 | 46 | </tr></table></div> |
47 | 47 | <?php |
48 | - if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) { |
|
48 | + if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) { |
|
49 | 49 | |
50 | 50 | ?> |
51 | 51 | <script src="<?php echo $globalURL; ?>/js/map.3d.js.php"></script> |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | <script src="<?php echo $globalURL; ?>/js/map-marine.3d.js.php"></script> |
66 | 66 | <?php |
67 | 67 | } |
68 | - } |
|
68 | + } |
|
69 | 69 | ?> |
70 | 70 | |
71 | 71 | <div id="sidebar" class="sidebar collapsed"> |
@@ -76,34 +76,34 @@ discard block |
||
76 | 76 | <li><a href="#" onclick="getUserLocation(); return false;" title="<?php echo _("Plot your Location"); ?>"><i class="fa fa-map-marker"></i></a></li> |
77 | 77 | <li><a href="#" onclick="getCompassDirection(); return false;" title="<?php echo _("Compass Mode"); ?>"><i class="fa fa-compass"></i></a></li> |
78 | 78 | <?php |
79 | - if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
79 | + if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
80 | 80 | if (isset($globalArchive) && $globalArchive == TRUE) { |
81 | 81 | ?> |
82 | 82 | <li><a href="#archive" role="tab" title="<?php echo _("Archive"); ?>"><i class="fa fa-archive"></i></a></li> |
83 | 83 | <?php |
84 | 84 | } |
85 | - } |
|
85 | + } |
|
86 | 86 | ?> |
87 | 87 | <li><a href="#home" role="tab" title="<?php echo _("Layers"); ?>"><i class="fa fa-map"></i></a></li> |
88 | 88 | <li><a href="#filters" role="tab" title="<?php echo _("Filters"); ?>"><i class="fa fa-filter"></i></a></li> |
89 | 89 | <li><a href="#settings" role="tab" title="<?php echo _("Settings"); ?>"><i class="fa fa-gears"></i></a></li> |
90 | 90 | <?php |
91 | - if (isset($globalMap3D) && $globalMap3D) { |
|
91 | + if (isset($globalMap3D) && $globalMap3D) { |
|
92 | 92 | if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
93 | 93 | ?> |
94 | 94 | <li><a href="#" onclick="show3D(); return false;" role="tab" title="3D"><b>3D</b></a></li> |
95 | 95 | <?php |
96 | - } else { |
|
97 | - if (isset($globalMapSatellites) && $globalMapSatellites) { |
|
96 | + } else { |
|
97 | + if (isset($globalMapSatellites) && $globalMapSatellites) { |
|
98 | 98 | ?> |
99 | 99 | <li><a href="#satellites" role="tab" title="<?php echo _("Satellites"); ?>"><i class="satellite"></i></a></li> |
100 | 100 | <?php |
101 | - } |
|
101 | + } |
|
102 | 102 | ?> |
103 | 103 | <li><a href="#" onclick="show2D(); return false;" role="tab" title="2D"><b>2D</b></a></li> |
104 | 104 | <?php |
105 | 105 | } |
106 | - } |
|
106 | + } |
|
107 | 107 | ?> |
108 | 108 | </ul> |
109 | 109 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | ?> |
179 | 179 | </div> |
180 | 180 | <?php |
181 | - if (isset($globalArchive) && $globalArchive == TRUE) { |
|
181 | + if (isset($globalArchive) && $globalArchive == TRUE) { |
|
182 | 182 | ?> |
183 | 183 | <div class="sidebar-pane" id="archive"> |
184 | 184 | <h1 class="sidebar-header"><?php echo _("Playback"); ?> <i>Bêta</i><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | </form> |
239 | 239 | </div> |
240 | 240 | <?php |
241 | - } |
|
241 | + } |
|
242 | 242 | ?> |
243 | 243 | <div class="sidebar-pane" id="settings"> |
244 | 244 | <h1 class="sidebar-header"><?php echo _("Settings"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
@@ -249,56 +249,56 @@ discard block |
||
249 | 249 | <?php |
250 | 250 | if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider; |
251 | 251 | else $MapType = $_COOKIE['MapType']; |
252 | - ?> |
|
252 | + ?> |
|
253 | 253 | <?php |
254 | 254 | if (isset($globalBingMapKey) && $globalBingMapKey != '') { |
255 | - ?> |
|
255 | + ?> |
|
256 | 256 | <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option> |
257 | 257 | <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option> |
258 | 258 | <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option> |
259 | 259 | <?php |
260 | 260 | } |
261 | - ?> |
|
261 | + ?> |
|
262 | 262 | <?php |
263 | - if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
264 | - ?> |
|
263 | + if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
264 | + ?> |
|
265 | 265 | <?php |
266 | - if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') { |
|
267 | - ?> |
|
266 | + if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') { |
|
267 | + ?> |
|
268 | 268 | <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option> |
269 | 269 | <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option> |
270 | 270 | <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option> |
271 | 271 | <?php |
272 | - } |
|
273 | - ?> |
|
272 | + } |
|
273 | + ?> |
|
274 | 274 | <?php |
275 | - if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') { |
|
276 | - ?> |
|
275 | + if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') { |
|
276 | + ?> |
|
277 | 277 | <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option> |
278 | 278 | <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option> |
279 | 279 | <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option> |
280 | 280 | <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option> |
281 | 281 | <?php |
282 | - } |
|
283 | - ?> |
|
282 | + } |
|
283 | + ?> |
|
284 | 284 | <?php |
285 | - if (isset($globalMapQuestKey) && $globalMapQuestKey != '') { |
|
286 | - ?> |
|
285 | + if (isset($globalMapQuestKey) && $globalMapQuestKey != '') { |
|
286 | + ?> |
|
287 | 287 | <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option> |
288 | 288 | <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option> |
289 | 289 | <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option> |
290 | 290 | <?php |
291 | - } |
|
292 | - ?> |
|
291 | + } |
|
292 | + ?> |
|
293 | 293 | <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option> |
294 | 294 | <?php |
295 | 295 | } |
296 | - ?> |
|
296 | + ?> |
|
297 | 297 | <?php |
298 | - if (isset($globalMapboxToken) && $globalMapboxToken != '') { |
|
298 | + if (isset($globalMapboxToken) && $globalMapboxToken != '') { |
|
299 | 299 | if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default'; |
300 | 300 | else $MapBoxId = $_COOKIE['MapTypeId']; |
301 | - ?> |
|
301 | + ?> |
|
302 | 302 | <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option> |
303 | 303 | <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option> |
304 | 304 | <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option> |
@@ -312,13 +312,13 @@ discard block |
||
312 | 312 | <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option> |
313 | 313 | <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option> |
314 | 314 | <?php |
315 | - } |
|
316 | - ?> |
|
315 | + } |
|
316 | + ?> |
|
317 | 317 | <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option> |
318 | 318 | </select> |
319 | 319 | </li> |
320 | 320 | <?php |
321 | - if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
321 | + if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
322 | 322 | ?> |
323 | 323 | <li><?php echo _("Type of Terrain:"); ?> |
324 | 324 | <select class="selectpicker" onchange="terrainType(this);"> |
@@ -329,10 +329,10 @@ discard block |
||
329 | 329 | </select> |
330 | 330 | </li> |
331 | 331 | <?php |
332 | - } |
|
332 | + } |
|
333 | 333 | ?> |
334 | 334 | <?php |
335 | - if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
335 | + if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
336 | 336 | ?> |
337 | 337 | |
338 | 338 | <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') print 'checked'; ?> ><?php echo _("Display flight info as popup"); ?></label></div></li> |
@@ -341,89 +341,89 @@ discard block |
||
341 | 341 | <li><div class="checkbox"><label><input type="checkbox" name="flightremainingroute" value="1" onclick="clickFlightRemainingRoute(this)" <?php if ((isset($_COOKIE['MapRemainingRoute']) && $_COOKIE['MapRemainingRoute'] == 'true') || !isset($_COOKIE['MapRemainingRoute']) || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)) print 'checked'; ?> ><?php echo _("Display flight remaining route on click"); ?></label></div></li> |
342 | 342 | <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Planes animate between updates"); ?></label></div></li> |
343 | 343 | <?php |
344 | - } |
|
344 | + } |
|
345 | 345 | ?> |
346 | 346 | <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true' || !isset($_COOKIE['displayairports'])) print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li> |
347 | 347 | <li><div class="checkbox"><label><input type="checkbox" name="displaygroundstation" value="1" onclick="clickDisplayGroundStation(this)" <?php if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) print 'checked'; ?> ><?php echo _("Display ground station on map"); ?></label></div></li> |
348 | 348 | <li><div class="checkbox"><label><input type="checkbox" name="displayweatherstation" value="1" onclick="clickDisplayWeatherStation(this)" <?php if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true') || (!isset($_COOKIE['show_WeatherStation']) && (!isset($globalMapWeatherStation) || $globalMapWeatherStation === TRUE))) print 'checked'; ?> ><?php echo _("Display weather station on map"); ?></label></div></li> |
349 | 349 | <li><div class="checkbox"><label><input type="checkbox" name="displaylightning" value="1" onclick="clickDisplayLightning(this)" <?php if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true') || (!isset($_COOKIE['show_Lightning']) && (!isset($globalMapLightning) || $globalMapLightning === TRUE))) print 'checked'; ?> ><?php echo _("Display lightning on map"); ?></label></div></li> |
350 | 350 | <?php |
351 | - if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
351 | + if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
352 | 352 | ?> |
353 | 353 | <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li> |
354 | 354 | <?php |
355 | - } |
|
356 | - if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) { |
|
355 | + } |
|
356 | + if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) { |
|
357 | 357 | ?> |
358 | 358 | <li><div class="checkbox"><label><input type="checkbox" name="displaysanta" value="1" onclick="clickSanta(this)"><i class="fa fa-snowflake-o" aria-hidden="true"></i> <?php echo _("Show Santa Claus now"); ?> <i class="fa fa-snowflake-o" aria-hidden="true"></i></label></div></li> |
359 | 359 | <?php |
360 | - } |
|
360 | + } |
|
361 | 361 | ?> |
362 | 362 | |
363 | 363 | <?php |
364 | 364 | if (function_exists('array_column')) { |
365 | - if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) { |
|
366 | - ?> |
|
365 | + if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) { |
|
366 | + ?> |
|
367 | 367 | <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li> |
368 | 368 | <?php |
369 | - } |
|
369 | + } |
|
370 | 370 | } elseif (isset($globalSources)) { |
371 | - $dispolar = false; |
|
372 | - foreach ($globalSources as $testsource) { |
|
373 | - if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true; |
|
374 | - } |
|
375 | - if ($dispolar) { |
|
376 | - ?> |
|
371 | + $dispolar = false; |
|
372 | + foreach ($globalSources as $testsource) { |
|
373 | + if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true; |
|
374 | + } |
|
375 | + if ($dispolar) { |
|
376 | + ?> |
|
377 | 377 | <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li> |
378 | 378 | <?php |
379 | - } |
|
380 | - } |
|
381 | - ?> |
|
379 | + } |
|
380 | + } |
|
381 | + ?> |
|
382 | 382 | <?php |
383 | - if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
383 | + if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
384 | 384 | ?> |
385 | 385 | |
386 | 386 | <?php |
387 | 387 | if (!isset($globalAircraft) || $globalAircraft === TRUE) { |
388 | - if (extension_loaded('gd') && function_exists('gd_info')) { |
|
389 | - ?> |
|
388 | + if (extension_loaded('gd') && function_exists('gd_info')) { |
|
389 | + ?> |
|
390 | 390 | <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') print 'checked'; ?> ><?php echo _("Aircraft icon color based on altitude"); ?></li> |
391 | 391 | <?php |
392 | 392 | if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') { |
393 | - ?> |
|
393 | + ?> |
|
394 | 394 | <li><?php echo _("Aircraft icon color:"); ?> |
395 | 395 | <input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>"> |
396 | 396 | </li> |
397 | 397 | <?php |
398 | 398 | } |
399 | - } |
|
400 | - } |
|
401 | - ?> |
|
399 | + } |
|
400 | + } |
|
401 | + ?> |
|
402 | 402 | <?php |
403 | 403 | if (isset($globalMarine) && $globalMarine === TRUE) { |
404 | - if (extension_loaded('gd') && function_exists('gd_info')) { |
|
405 | - ?> |
|
404 | + if (extension_loaded('gd') && function_exists('gd_info')) { |
|
405 | + ?> |
|
406 | 406 | <li><?php echo _("Marine icon color:"); ?> |
407 | 407 | <input type="color" name="marinecolor" id="html5colorpicker" onchange="MarineiconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print '1a3151'; ?>"> |
408 | 408 | </li> |
409 | 409 | <?php |
410 | - } |
|
411 | - } |
|
412 | - ?> |
|
410 | + } |
|
411 | + } |
|
412 | + ?> |
|
413 | 413 | <?php |
414 | 414 | if (isset($globalTracker) && $globalTracker === TRUE) { |
415 | - if (extension_loaded('gd') && function_exists('gd_info')) { |
|
416 | - ?> |
|
415 | + if (extension_loaded('gd') && function_exists('gd_info')) { |
|
416 | + ?> |
|
417 | 417 | <li><?php echo _("Tracker icon color:"); ?> |
418 | 418 | <input type="color" name="trackercolor" id="html5colorpicker" onchange="TrackericonColor(trackercolor.value);" value="#<?php if (isset($_COOKIE['TrackerIconColor'])) print $_COOKIE['TrackerIconColor']; elseif (isset($globalTrackerIconColor)) print $globalTrackerIconColor; else print '1a3151'; ?>"> |
419 | 419 | </li> |
420 | 420 | <?php |
421 | - } |
|
422 | - } |
|
423 | - ?> |
|
421 | + } |
|
422 | + } |
|
423 | + ?> |
|
424 | 424 | <?php |
425 | 425 | if (!isset($globalAircraft) || $globalAircraft === TRUE) { |
426 | - ?> |
|
426 | + ?> |
|
427 | 427 | <li><?php echo _("Show airport icon at zoom level:"); ?> |
428 | 428 | <div class="range"> |
429 | 429 | <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?>"> |
@@ -432,9 +432,9 @@ discard block |
||
432 | 432 | </li> |
433 | 433 | <?php |
434 | 434 | } |
435 | - ?> |
|
435 | + ?> |
|
436 | 436 | <?php |
437 | - } elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') { |
|
437 | + } elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') { |
|
438 | 438 | ?> |
439 | 439 | <?php |
440 | 440 | if (!isset($globalAircraft) || $globalAircraft === TRUE) { |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | </li> |
466 | 466 | <?php |
467 | 467 | } |
468 | - } |
|
468 | + } |
|
469 | 469 | ?> |
470 | 470 | <li><?php echo _("Distance unit:"); ?> |
471 | 471 | <select class="selectpicker" onchange="unitdistance(this);"> |
@@ -498,19 +498,19 @@ discard block |
||
498 | 498 | <ul> |
499 | 499 | <?php |
500 | 500 | if (!isset($globalAircraft) || $globalAircraft) { |
501 | - ?> |
|
501 | + ?> |
|
502 | 502 | <?php |
503 | 503 | if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) { |
504 | - ?> |
|
504 | + ?> |
|
505 | 505 | <?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?> |
506 | 506 | <?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?> |
507 | 507 | <?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?> |
508 | 508 | <?php |
509 | 509 | } |
510 | - ?> |
|
510 | + ?> |
|
511 | 511 | <?php |
512 | 512 | if (!(isset($globalVA) && $globalVA) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) { |
513 | - ?> |
|
513 | + ?> |
|
514 | 514 | <?php if (isset($globalSBS1) && $globalSBS1) { ?> |
515 | 515 | <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li> |
516 | 516 | <?php } ?> |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | <?php } ?> |
520 | 520 | <?php |
521 | 521 | } |
522 | - ?> |
|
522 | + ?> |
|
523 | 523 | <li><?php echo _("Display airlines:"); ?> |
524 | 524 | <br/> |
525 | 525 | <select class="selectpicker" multiple onchange="airlines(this);" id="display_airlines"> |
@@ -539,14 +539,14 @@ discard block |
||
539 | 539 | echo '<option value="'.$airline['airline_icao'].'">'.$airline_name.'</option>'; |
540 | 540 | } |
541 | 541 | } |
542 | - ?> |
|
542 | + ?> |
|
543 | 543 | </select> |
544 | 544 | </li> |
545 | 545 | <?php |
546 | 546 | $Spotter = new Spotter(); |
547 | 547 | $allalliancenames = $Spotter->getAllAllianceNames(); |
548 | 548 | if (!empty($allalliancenames)) { |
549 | - ?> |
|
549 | + ?> |
|
550 | 550 | <li><?php echo _("Display alliance:"); ?> |
551 | 551 | <br/> |
552 | 552 | <select class="selectpicker" onchange="alliance(this);" id="display_alliance"> |
@@ -560,18 +560,18 @@ discard block |
||
560 | 560 | echo '<option value="'.$alliance_name.'">'.$alliance_name.'</option>'; |
561 | 561 | } |
562 | 562 | } |
563 | - ?> |
|
563 | + ?> |
|
564 | 564 | </select> |
565 | 565 | </li> |
566 | 566 | <?php |
567 | 567 | } |
568 | - ?> |
|
568 | + ?> |
|
569 | 569 | <?php |
570 | 570 | } |
571 | - ?> |
|
571 | + ?> |
|
572 | 572 | <?php |
573 | 573 | if (isset($globalAPRS) && $globalAPRS) { |
574 | - ?> |
|
574 | + ?> |
|
575 | 575 | <li><?php echo _("Display APRS sources name:"); ?> |
576 | 576 | <select class="selectpicker" multiple onchange="sources(this);"> |
577 | 577 | <?php |
@@ -583,18 +583,18 @@ discard block |
||
583 | 583 | echo '<option value="'.$source['source_name'].'">'.$source['source_name'].'</option>'; |
584 | 584 | } |
585 | 585 | } |
586 | - ?> |
|
586 | + ?> |
|
587 | 587 | </select> |
588 | 588 | </li> |
589 | 589 | <?php |
590 | 590 | } |
591 | - ?> |
|
591 | + ?> |
|
592 | 592 | <?php |
593 | 593 | if (!isset($globalAircraft) && $globalAircraft) { |
594 | - ?> |
|
594 | + ?> |
|
595 | 595 | <?php |
596 | 596 | if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS)) { |
597 | - ?> |
|
597 | + ?> |
|
598 | 598 | <li><?php echo _("Display airlines of type:"); ?><br/> |
599 | 599 | <select class="selectpicker" onchange="airlinestype(this);"> |
600 | 600 | <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option> |
@@ -605,14 +605,14 @@ discard block |
||
605 | 605 | </li> |
606 | 606 | <?php |
607 | 607 | } |
608 | - ?> |
|
608 | + ?> |
|
609 | 609 | <li> |
610 | 610 | <?php echo _("Display flight with ident:"); ?> |
611 | 611 | <input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" /> |
612 | 612 | </li> |
613 | 613 | <?php |
614 | 614 | } |
615 | - ?> |
|
615 | + ?> |
|
616 | 616 | </ul> |
617 | 617 | </form> |
618 | 618 | <form method="post"> |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | </form> |
622 | 622 | </div> |
623 | 623 | <?php |
624 | - if (isset($globalMapSatellites) && $globalMapSatellites && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
624 | + if (isset($globalMapSatellites) && $globalMapSatellites && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
625 | 625 | ?> |
626 | 626 | <div class="sidebar-pane" id="satellites"> |
627 | 627 | <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
@@ -661,14 +661,14 @@ discard block |
||
661 | 661 | print '<option value="'.$type['tle_type'].'">'.$type_name.'</option>'; |
662 | 662 | } |
663 | 663 | } |
664 | - ?> |
|
664 | + ?> |
|
665 | 665 | </select> |
666 | 666 | </li> |
667 | 667 | </ul> |
668 | 668 | </form> |
669 | 669 | </div> |
670 | 670 | <?php |
671 | - } |
|
671 | + } |
|
672 | 672 | ?> |
673 | 673 | </div> |
674 | 674 | </div> |
@@ -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,126 +356,126 @@ 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 ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
382 | 382 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
383 | 383 | if ($value['format'] == 'deltadbtxt' && |
384 | - ( |
|
384 | + ( |
|
385 | 385 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
386 | 386 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
387 | - ) |
|
387 | + ) |
|
388 | 388 | ) { |
389 | - //$buffer = $Common->getData($hosts[$id]); |
|
390 | - $buffer = $Common->getData($value['host']); |
|
391 | - if ($buffer != '') $reset = 0; |
|
392 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
393 | - $buffer = explode('\n',$buffer); |
|
394 | - foreach ($buffer as $line) { |
|
395 | - if ($line != '' && count($line) > 7) { |
|
396 | - $line = explode(',', $line); |
|
397 | - $data = array(); |
|
398 | - $data['hex'] = $line[1]; // hex |
|
399 | - $data['ident'] = $line[2]; // ident |
|
400 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
401 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
402 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
403 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
404 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
405 | - $data['verticalrate'] = ''; // vertical rate |
|
406 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
407 | - $data['emergency'] = ''; // emergency |
|
408 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
409 | - $data['format_source'] = 'deltadbtxt'; |
|
410 | - $data['id_source'] = $id_source; |
|
411 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
412 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
413 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
414 | - $SI->add($data); |
|
415 | - unset($data); |
|
416 | - } |
|
417 | - } |
|
418 | - $last_exec[$id]['last'] = time(); |
|
389 | + //$buffer = $Common->getData($hosts[$id]); |
|
390 | + $buffer = $Common->getData($value['host']); |
|
391 | + if ($buffer != '') $reset = 0; |
|
392 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
393 | + $buffer = explode('\n',$buffer); |
|
394 | + foreach ($buffer as $line) { |
|
395 | + if ($line != '' && count($line) > 7) { |
|
396 | + $line = explode(',', $line); |
|
397 | + $data = array(); |
|
398 | + $data['hex'] = $line[1]; // hex |
|
399 | + $data['ident'] = $line[2]; // ident |
|
400 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
401 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
402 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
403 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
404 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
405 | + $data['verticalrate'] = ''; // vertical rate |
|
406 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
407 | + $data['emergency'] = ''; // emergency |
|
408 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
409 | + $data['format_source'] = 'deltadbtxt'; |
|
410 | + $data['id_source'] = $id_source; |
|
411 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
412 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
413 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
414 | + $SI->add($data); |
|
415 | + unset($data); |
|
416 | + } |
|
417 | + } |
|
418 | + $last_exec[$id]['last'] = time(); |
|
419 | 419 | } elseif ($value['format'] == 'aisnmeatxt' && |
420 | - ( |
|
420 | + ( |
|
421 | 421 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
422 | 422 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
423 | - ) |
|
423 | + ) |
|
424 | 424 | ) { |
425 | - date_default_timezone_set('CET'); |
|
426 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
427 | - date_default_timezone_set('UTC'); |
|
428 | - if ($buffer != '') $reset = 0; |
|
429 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
430 | - $buffer = explode('\n',$buffer); |
|
431 | - foreach ($buffer as $line) { |
|
425 | + date_default_timezone_set('CET'); |
|
426 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
427 | + date_default_timezone_set('UTC'); |
|
428 | + if ($buffer != '') $reset = 0; |
|
429 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
430 | + $buffer = explode('\n',$buffer); |
|
431 | + foreach ($buffer as $line) { |
|
432 | 432 | if ($line != '') { |
433 | - //echo "'".$line."'\n"; |
|
434 | - $add = false; |
|
435 | - $ais_data = $AIS->parse_line(trim($line)); |
|
436 | - $data = array(); |
|
437 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
438 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
439 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
440 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
441 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
442 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
443 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
444 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
445 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
446 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
447 | - if (isset($ais_data['timestamp'])) { |
|
433 | + //echo "'".$line."'\n"; |
|
434 | + $add = false; |
|
435 | + $ais_data = $AIS->parse_line(trim($line)); |
|
436 | + $data = array(); |
|
437 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
438 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
439 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
440 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
441 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
442 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
443 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
444 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
445 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
446 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
447 | + if (isset($ais_data['timestamp'])) { |
|
448 | 448 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
449 | 449 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
450 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
451 | - $add = true; |
|
450 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
451 | + $add = true; |
|
452 | 452 | } |
453 | - } else { |
|
453 | + } else { |
|
454 | 454 | $data['datetime'] = date('Y-m-d H:i:s'); |
455 | 455 | $add = true; |
456 | - } |
|
457 | - $data['format_source'] = 'aisnmeatxt'; |
|
458 | - $data['id_source'] = $id_source; |
|
459 | - //print_r($data); |
|
460 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
461 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
462 | - unset($data); |
|
456 | + } |
|
457 | + $data['format_source'] = 'aisnmeatxt'; |
|
458 | + $data['id_source'] = $id_source; |
|
459 | + //print_r($data); |
|
460 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
461 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
462 | + unset($data); |
|
463 | 463 | } |
464 | - } |
|
465 | - $last_exec[$id]['last'] = time(); |
|
464 | + } |
|
465 | + $last_exec[$id]['last'] = time(); |
|
466 | 466 | } elseif ($value['format'] == 'aisnmeahttp') { |
467 | - $arr = $httpfeeds; |
|
468 | - $w = $e = null; |
|
467 | + $arr = $httpfeeds; |
|
468 | + $w = $e = null; |
|
469 | 469 | |
470 | - if (isset($arr[$id])) { |
|
470 | + if (isset($arr[$id])) { |
|
471 | 471 | $nn = stream_select($arr,$w,$e,$timeout); |
472 | 472 | if ($nn > 0) { |
473 | - foreach ($httpfeeds as $feed) { |
|
473 | + foreach ($httpfeeds as $feed) { |
|
474 | 474 | $buffer = stream_get_line($feed,2000,"\n"); |
475 | 475 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
476 | 476 | $buffer = explode('\n',$buffer); |
477 | 477 | foreach ($buffer as $line) { |
478 | - if ($line != '') { |
|
478 | + if ($line != '') { |
|
479 | 479 | $ais_data = $AIS->parse_line(trim($line)); |
480 | 480 | $data = array(); |
481 | 481 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
@@ -493,111 +493,111 @@ discard block |
||
493 | 493 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
494 | 494 | if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
495 | 495 | if (isset($ais_data['timestamp'])) { |
496 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
496 | + $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
497 | 497 | } else { |
498 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
498 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
499 | 499 | } |
500 | 500 | $data['format_source'] = 'aisnmeahttp'; |
501 | 501 | $data['id_source'] = $id_source; |
502 | 502 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
503 | 503 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
504 | 504 | unset($data); |
505 | - } |
|
505 | + } |
|
506 | + } |
|
506 | 507 | } |
507 | - } |
|
508 | 508 | } else { |
509 | - $format = $value['format']; |
|
510 | - if (isset($tt[$format])) $tt[$format]++; |
|
511 | - else $tt[$format] = 0; |
|
512 | - if ($tt[$format] > 30) { |
|
509 | + $format = $value['format']; |
|
510 | + if (isset($tt[$format])) $tt[$format]++; |
|
511 | + else $tt[$format] = 0; |
|
512 | + if ($tt[$format] > 30) { |
|
513 | 513 | if ($globalDebug) echo 'Reconnect...'."\n"; |
514 | 514 | sleep(2); |
515 | 515 | $sourceeen[] = $value; |
516 | 516 | connect_all($sourceeen); |
517 | 517 | $sourceeen = array(); |
518 | - } |
|
518 | + } |
|
519 | + } |
|
519 | 520 | } |
520 | - } |
|
521 | 521 | } elseif ($value['format'] == 'myshiptracking' && |
522 | - ( |
|
522 | + ( |
|
523 | 523 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
524 | 524 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
525 | - ) |
|
525 | + ) |
|
526 | 526 | ) { |
527 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
528 | - if ($buffer != '') { |
|
527 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
528 | + if ($buffer != '') { |
|
529 | 529 | //echo $buffer; |
530 | 530 | $all_data = json_decode($buffer,true); |
531 | 531 | //print_r($all_data); |
532 | 532 | if (isset($all_data[0]['DATA'])) { |
533 | - foreach ($all_data[0]['DATA'] as $line) { |
|
533 | + foreach ($all_data[0]['DATA'] as $line) { |
|
534 | 534 | if ($line != '') { |
535 | - $data = array(); |
|
536 | - $data['ident'] = $line['NAME']; |
|
537 | - $data['mmsi'] = $line['MMSI']; |
|
538 | - $data['speed'] = $line['SOG']; |
|
539 | - $data['heading'] = $line['COG']; |
|
540 | - $data['latitude'] = $line['LAT']; |
|
541 | - $data['longitude'] = $line['LNG']; |
|
542 | - // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
543 | - $data['imo'] = $line['IMO']; |
|
544 | - //$data['arrival_code'] = $ais_data['destination']; |
|
545 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
546 | - $data['format_source'] = 'myshiptracking'; |
|
547 | - $data['id_source'] = $id_source; |
|
548 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
549 | - $MI->add($data); |
|
550 | - unset($data); |
|
535 | + $data = array(); |
|
536 | + $data['ident'] = $line['NAME']; |
|
537 | + $data['mmsi'] = $line['MMSI']; |
|
538 | + $data['speed'] = $line['SOG']; |
|
539 | + $data['heading'] = $line['COG']; |
|
540 | + $data['latitude'] = $line['LAT']; |
|
541 | + $data['longitude'] = $line['LNG']; |
|
542 | + // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
543 | + $data['imo'] = $line['IMO']; |
|
544 | + //$data['arrival_code'] = $ais_data['destination']; |
|
545 | + $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
546 | + $data['format_source'] = 'myshiptracking'; |
|
547 | + $data['id_source'] = $id_source; |
|
548 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
549 | + $MI->add($data); |
|
550 | + unset($data); |
|
551 | + } |
|
551 | 552 | } |
552 | - } |
|
553 | 553 | } |
554 | - } |
|
555 | - $last_exec[$id]['last'] = time(); |
|
554 | + } |
|
555 | + $last_exec[$id]['last'] = time(); |
|
556 | 556 | } elseif ($value['format'] == 'boatbeaconapp' && |
557 | - ( |
|
557 | + ( |
|
558 | 558 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
559 | 559 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
560 | - ) |
|
560 | + ) |
|
561 | 561 | ) { |
562 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
563 | - if ($buffer != '') { |
|
562 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
563 | + if ($buffer != '') { |
|
564 | 564 | $all_data = json_decode($buffer,true); |
565 | 565 | if (isset($all_data[0]['mmsi'])) { |
566 | - foreach ($all_data as $line) { |
|
566 | + foreach ($all_data as $line) { |
|
567 | 567 | if ($line != '') { |
568 | - $data = array(); |
|
569 | - $data['ident'] = $line['shipname']; |
|
570 | - $data['callsign'] = $line['callsign']; |
|
571 | - $data['mmsi'] = $line['mmsi']; |
|
572 | - $data['speed'] = $line['sog']; |
|
573 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
574 | - $data['latitude'] = $line['latitude']; |
|
575 | - $data['longitude'] = $line['longitude']; |
|
576 | - $data['type_id'] = $line['shiptype']; |
|
577 | - $data['arrival_code'] = $line['destination']; |
|
578 | - $data['datetime'] = $line['time']; |
|
579 | - $data['format_source'] = 'boatbeaconapp'; |
|
580 | - $data['id_source'] = $id_source; |
|
581 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
582 | - $MI->add($data); |
|
583 | - unset($data); |
|
568 | + $data = array(); |
|
569 | + $data['ident'] = $line['shipname']; |
|
570 | + $data['callsign'] = $line['callsign']; |
|
571 | + $data['mmsi'] = $line['mmsi']; |
|
572 | + $data['speed'] = $line['sog']; |
|
573 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
574 | + $data['latitude'] = $line['latitude']; |
|
575 | + $data['longitude'] = $line['longitude']; |
|
576 | + $data['type_id'] = $line['shiptype']; |
|
577 | + $data['arrival_code'] = $line['destination']; |
|
578 | + $data['datetime'] = $line['time']; |
|
579 | + $data['format_source'] = 'boatbeaconapp'; |
|
580 | + $data['id_source'] = $id_source; |
|
581 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
582 | + $MI->add($data); |
|
583 | + unset($data); |
|
584 | + } |
|
584 | 585 | } |
585 | - } |
|
586 | 586 | } |
587 | 587 | |
588 | - } |
|
589 | - $last_exec[$id]['last'] = time(); |
|
588 | + } |
|
589 | + $last_exec[$id]['last'] = time(); |
|
590 | 590 | } elseif ($value['format'] == 'boatnerd' && |
591 | - ( |
|
591 | + ( |
|
592 | 592 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
593 | 593 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
594 | - ) |
|
594 | + ) |
|
595 | 595 | ) { |
596 | - $buffer = $Common->getData($value['host']); |
|
597 | - if ($buffer != '') { |
|
596 | + $buffer = $Common->getData($value['host']); |
|
597 | + if ($buffer != '') { |
|
598 | 598 | $all_data = json_decode($buffer,true); |
599 | 599 | if (isset($all_data['features'][0]['id'])) { |
600 | - foreach ($all_data['features'] as $line) { |
|
600 | + foreach ($all_data['features'] as $line) { |
|
601 | 601 | $data = array(); |
602 | 602 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
603 | 603 | if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
@@ -616,78 +616,78 @@ discard block |
||
616 | 616 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
617 | 617 | if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
618 | 618 | unset($data); |
619 | - } |
|
619 | + } |
|
620 | 620 | } |
621 | 621 | |
622 | - } |
|
623 | - $last_exec[$id]['last'] = time(); |
|
622 | + } |
|
623 | + $last_exec[$id]['last'] = time(); |
|
624 | 624 | } elseif ($value['format'] == 'shipplotter' && |
625 | - ( |
|
625 | + ( |
|
626 | 626 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
627 | 627 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
628 | - ) |
|
628 | + ) |
|
629 | 629 | ) { |
630 | - echo 'download...'; |
|
631 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
632 | - echo 'done !'."\n"; |
|
633 | - if ($buffer != '') $reset = 0; |
|
634 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
635 | - $buffer = explode('\n',$buffer); |
|
636 | - foreach ($buffer as $line) { |
|
630 | + echo 'download...'; |
|
631 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
632 | + echo 'done !'."\n"; |
|
633 | + if ($buffer != '') $reset = 0; |
|
634 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
635 | + $buffer = explode('\n',$buffer); |
|
636 | + foreach ($buffer as $line) { |
|
637 | 637 | if ($line != '') { |
638 | - $data = array(); |
|
639 | - $data['mmsi'] = (int)substr($line,0,9); |
|
640 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
641 | - //$data['status'] = substr($line,21,2); |
|
642 | - //$data['type'] = substr($line,24,3); |
|
643 | - $data['latitude'] = substr($line,29,9); |
|
644 | - $data['longitude'] = substr($line,41,9); |
|
645 | - $data['speed'] = round(substr($line,51,5)); |
|
646 | - //$data['course'] = substr($line,57,5); |
|
647 | - $data['heading'] = round(substr($line,63,3)); |
|
648 | - //$data['draft'] = substr($line,67,4); |
|
649 | - //$data['length'] = substr($line,72,3); |
|
650 | - //$data['beam'] = substr($line,76,2); |
|
651 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
652 | - //$data['callsign'] = trim(substr($line,100,7); |
|
653 | - //$data['dest'] = substr($line,108,20); |
|
654 | - //$data['etaDate'] = substr($line,129,5); |
|
655 | - //$data['etaTime'] = substr($line,135,5); |
|
656 | - $data['format_source'] = 'shipplotter'; |
|
657 | - $data['id_source'] = $id_source; |
|
658 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
659 | - //print_r($data); |
|
660 | - echo 'Add...'."\n"; |
|
661 | - $MI->add($data); |
|
662 | - unset($data); |
|
638 | + $data = array(); |
|
639 | + $data['mmsi'] = (int)substr($line,0,9); |
|
640 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
641 | + //$data['status'] = substr($line,21,2); |
|
642 | + //$data['type'] = substr($line,24,3); |
|
643 | + $data['latitude'] = substr($line,29,9); |
|
644 | + $data['longitude'] = substr($line,41,9); |
|
645 | + $data['speed'] = round(substr($line,51,5)); |
|
646 | + //$data['course'] = substr($line,57,5); |
|
647 | + $data['heading'] = round(substr($line,63,3)); |
|
648 | + //$data['draft'] = substr($line,67,4); |
|
649 | + //$data['length'] = substr($line,72,3); |
|
650 | + //$data['beam'] = substr($line,76,2); |
|
651 | + $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
652 | + //$data['callsign'] = trim(substr($line,100,7); |
|
653 | + //$data['dest'] = substr($line,108,20); |
|
654 | + //$data['etaDate'] = substr($line,129,5); |
|
655 | + //$data['etaTime'] = substr($line,135,5); |
|
656 | + $data['format_source'] = 'shipplotter'; |
|
657 | + $data['id_source'] = $id_source; |
|
658 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
659 | + //print_r($data); |
|
660 | + echo 'Add...'."\n"; |
|
661 | + $MI->add($data); |
|
662 | + unset($data); |
|
663 | 663 | } |
664 | - } |
|
665 | - $last_exec[$id]['last'] = time(); |
|
664 | + } |
|
665 | + $last_exec[$id]['last'] = time(); |
|
666 | 666 | //} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
667 | 667 | } elseif ( |
668 | - ( |
|
668 | + ( |
|
669 | 669 | $value['format'] == 'whazzup' && |
670 | 670 | ( |
671 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
672 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
671 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
672 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
673 | 673 | ) |
674 | - ) || ( |
|
674 | + ) || ( |
|
675 | 675 | $value['format'] == 'vatsimtxt' && |
676 | 676 | ( |
677 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
678 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
677 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
678 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
679 | + ) |
|
679 | 680 | ) |
680 | - ) |
|
681 | 681 | ) { |
682 | - //$buffer = $Common->getData($hosts[$id]); |
|
683 | - $buffer = $Common->getData($value['host']); |
|
684 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
685 | - $buffer = explode('\n',$buffer); |
|
686 | - $reset = 0; |
|
687 | - foreach ($buffer as $line) { |
|
688 | - if ($line != '') { |
|
689 | - $line = explode(':', $line); |
|
690 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
682 | + //$buffer = $Common->getData($hosts[$id]); |
|
683 | + $buffer = $Common->getData($value['host']); |
|
684 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
685 | + $buffer = explode('\n',$buffer); |
|
686 | + $reset = 0; |
|
687 | + foreach ($buffer as $line) { |
|
688 | + if ($line != '') { |
|
689 | + $line = explode(':', $line); |
|
690 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
691 | 691 | $data = array(); |
692 | 692 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
693 | 693 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -700,37 +700,37 @@ discard block |
||
700 | 700 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
701 | 701 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
702 | 702 | $data['latitude'] = $line[5]; // lat |
703 | - $data['longitude'] = $line[6]; // long |
|
704 | - $data['verticalrate'] = ''; // vertical rate |
|
705 | - $data['squawk'] = ''; // squawk |
|
706 | - $data['emergency'] = ''; // emergency |
|
707 | - $data['waypoints'] = $line[30]; |
|
703 | + $data['longitude'] = $line[6]; // long |
|
704 | + $data['verticalrate'] = ''; // vertical rate |
|
705 | + $data['squawk'] = ''; // squawk |
|
706 | + $data['emergency'] = ''; // emergency |
|
707 | + $data['waypoints'] = $line[30]; |
|
708 | 708 | $data['datetime'] = date('Y-m-d H:i:s'); |
709 | 709 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
710 | 710 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
711 | - $data['departure_airport_icao'] = $line[11]; |
|
712 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
713 | - $data['arrival_airport_icao'] = $line[13]; |
|
711 | + $data['departure_airport_icao'] = $line[11]; |
|
712 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
713 | + $data['arrival_airport_icao'] = $line[13]; |
|
714 | 714 | $data['frequency'] = $line[4]; |
715 | 715 | $data['type'] = $line[18]; |
716 | 716 | $data['range'] = $line[19]; |
717 | 717 | if (isset($line[35])) $data['info'] = $line[35]; |
718 | - $data['id_source'] = $id_source; |
|
719 | - //$data['arrival_airport_time'] = ; |
|
720 | - if ($line[9] != '') { |
|
721 | - $aircraft_data = explode('/',$line[9]); |
|
722 | - if (isset($aircraft_data[1])) { |
|
723 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
724 | - } |
|
725 | - } |
|
726 | - /* |
|
718 | + $data['id_source'] = $id_source; |
|
719 | + //$data['arrival_airport_time'] = ; |
|
720 | + if ($line[9] != '') { |
|
721 | + $aircraft_data = explode('/',$line[9]); |
|
722 | + if (isset($aircraft_data[1])) { |
|
723 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
724 | + } |
|
725 | + } |
|
726 | + /* |
|
727 | 727 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; |
728 | 728 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
729 | 729 | */ |
730 | - $data['format_source'] = $value['format']; |
|
730 | + $data['format_source'] = $value['format']; |
|
731 | 731 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
732 | 732 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
733 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
733 | + if ($line[3] == 'PILOT') $SI->add($data); |
|
734 | 734 | elseif ($line[3] == 'ATC') { |
735 | 735 | //print_r($data); |
736 | 736 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -751,21 +751,21 @@ discard block |
||
751 | 751 | 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']); |
752 | 752 | } |
753 | 753 | } |
754 | - unset($data); |
|
755 | - } |
|
756 | - } |
|
757 | - } |
|
758 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
759 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
760 | - $last_exec[$id]['last'] = time(); |
|
761 | - } elseif ($value['format'] == 'airwhere' && |
|
762 | - ( |
|
763 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
764 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
765 | - ) |
|
766 | - ) { |
|
767 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
768 | - if ($buffer != '') { |
|
754 | + unset($data); |
|
755 | + } |
|
756 | + } |
|
757 | + } |
|
758 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
759 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
760 | + $last_exec[$id]['last'] = time(); |
|
761 | + } elseif ($value['format'] == 'airwhere' && |
|
762 | + ( |
|
763 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
764 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
765 | + ) |
|
766 | + ) { |
|
767 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
768 | + if ($buffer != '') { |
|
769 | 769 | $all_data = simplexml_load_string($buffer); |
770 | 770 | foreach($all_data->children() as $childdata) { |
771 | 771 | $data = array(); |
@@ -787,10 +787,10 @@ discard block |
||
787 | 787 | $SI->add($data); |
788 | 788 | unset($data); |
789 | 789 | } |
790 | - } |
|
791 | - $Source->deleteOldLocationByType('gs'); |
|
792 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
793 | - if ($buffer != '') { |
|
790 | + } |
|
791 | + $Source->deleteOldLocationByType('gs'); |
|
792 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
793 | + if ($buffer != '') { |
|
794 | 794 | $all_data = simplexml_load_string($buffer); |
795 | 795 | foreach($all_data->children() as $childdata) { |
796 | 796 | $data = array(); |
@@ -808,8 +808,8 @@ discard block |
||
808 | 808 | } |
809 | 809 | unset($data); |
810 | 810 | } |
811 | - } |
|
812 | - $last_exec[$id]['last'] = time(); |
|
811 | + } |
|
812 | + $last_exec[$id]['last'] = time(); |
|
813 | 813 | /* |
814 | 814 | } if ($value['format'] == 'aircraftlistjson') { |
815 | 815 | print_r($globalSources); |
@@ -817,17 +817,17 @@ discard block |
||
817 | 817 | echo $globalMinFetch; |
818 | 818 | */ |
819 | 819 | } elseif ($value['format'] == 'aircraftlistjson' && |
820 | - ( |
|
820 | + ( |
|
821 | 821 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
822 | 822 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
823 | - ) |
|
823 | + ) |
|
824 | 824 | ) { |
825 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
826 | - if ($buffer != '') { |
|
827 | - $all_data = json_decode($buffer,true); |
|
825 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
826 | + if ($buffer != '') { |
|
827 | + $all_data = json_decode($buffer,true); |
|
828 | 828 | if (isset($all_data['acList'])) { |
829 | - $reset = 0; |
|
830 | - foreach ($all_data['acList'] as $line) { |
|
829 | + $reset = 0; |
|
830 | + foreach ($all_data['acList'] as $line) { |
|
831 | 831 | $data = array(); |
832 | 832 | $data['hex'] = $line['Icao']; // hex |
833 | 833 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -850,10 +850,10 @@ discard block |
||
850 | 850 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
851 | 851 | if (isset($data['latitude'])) $SI->add($data); |
852 | 852 | unset($data); |
853 | - } |
|
853 | + } |
|
854 | 854 | } elseif (is_array($all_data)) { |
855 | - $reset = 0; |
|
856 | - foreach ($all_data as $line) { |
|
855 | + $reset = 0; |
|
856 | + foreach ($all_data as $line) { |
|
857 | 857 | $data = array(); |
858 | 858 | $data['hex'] = $line['hex']; // hex |
859 | 859 | $data['ident'] = $line['flight']; // ident |
@@ -873,218 +873,218 @@ discard block |
||
873 | 873 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
874 | 874 | $SI->add($data); |
875 | 875 | unset($data); |
876 | - } |
|
876 | + } |
|
877 | 877 | } |
878 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
879 | - //$last_exec['aircraftlistjson'] = time(); |
|
880 | - $last_exec[$id]['last'] = time(); |
|
881 | - //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
882 | - } elseif ($value['format'] == 'planeupdatefaa' && |
|
883 | - ( |
|
884 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
885 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
886 | - ) |
|
887 | - ) { |
|
888 | - $buffer = $Common->getData($value['host']); |
|
889 | - $all_data = json_decode($buffer,true); |
|
890 | - if (isset($all_data['planes'])) { |
|
878 | + } elseif ($globalDebug) echo 'No data'."\n"; |
|
879 | + //$last_exec['aircraftlistjson'] = time(); |
|
880 | + $last_exec[$id]['last'] = time(); |
|
881 | + //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
882 | + } elseif ($value['format'] == 'planeupdatefaa' && |
|
883 | + ( |
|
884 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
885 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
886 | + ) |
|
887 | + ) { |
|
888 | + $buffer = $Common->getData($value['host']); |
|
889 | + $all_data = json_decode($buffer,true); |
|
890 | + if (isset($all_data['planes'])) { |
|
891 | 891 | $reset = 0; |
892 | 892 | foreach ($all_data['planes'] as $key => $line) { |
893 | - $data = array(); |
|
894 | - $data['hex'] = $key; // hex |
|
895 | - $data['ident'] = $line[3]; // ident |
|
896 | - $data['altitude'] = $line[6]; // altitude |
|
897 | - $data['speed'] = $line[8]; // speed |
|
898 | - $data['heading'] = $line[7]; // heading |
|
899 | - $data['latitude'] = $line[4]; // lat |
|
900 | - $data['longitude'] = $line[5]; // long |
|
901 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
902 | - $data['squawk'] = $line[10]; // squawk |
|
903 | - $data['emergency'] = ''; // emergency |
|
904 | - $data['registration'] = $line[2]; |
|
905 | - $data['aircraft_icao'] = $line[0]; |
|
906 | - $deparr = explode('-',$line[1]); |
|
907 | - if (count($deparr) == 2) { |
|
893 | + $data = array(); |
|
894 | + $data['hex'] = $key; // hex |
|
895 | + $data['ident'] = $line[3]; // ident |
|
896 | + $data['altitude'] = $line[6]; // altitude |
|
897 | + $data['speed'] = $line[8]; // speed |
|
898 | + $data['heading'] = $line[7]; // heading |
|
899 | + $data['latitude'] = $line[4]; // lat |
|
900 | + $data['longitude'] = $line[5]; // long |
|
901 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
902 | + $data['squawk'] = $line[10]; // squawk |
|
903 | + $data['emergency'] = ''; // emergency |
|
904 | + $data['registration'] = $line[2]; |
|
905 | + $data['aircraft_icao'] = $line[0]; |
|
906 | + $deparr = explode('-',$line[1]); |
|
907 | + if (count($deparr) == 2) { |
|
908 | 908 | $data['departure_airport_icao'] = $deparr[0]; |
909 | 909 | $data['arrival_airport_icao'] = $deparr[1]; |
910 | - } |
|
911 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
912 | - $data['format_source'] = 'planeupdatefaa'; |
|
913 | - $data['id_source'] = $id_source; |
|
914 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
915 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
916 | - $SI->add($data); |
|
917 | - unset($data); |
|
910 | + } |
|
911 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
912 | + $data['format_source'] = 'planeupdatefaa'; |
|
913 | + $data['id_source'] = $id_source; |
|
914 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
915 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
916 | + $SI->add($data); |
|
917 | + unset($data); |
|
918 | + } |
|
918 | 919 | } |
919 | - } |
|
920 | - //$last_exec['planeupdatefaa'] = time(); |
|
921 | - $last_exec[$id]['last'] = time(); |
|
920 | + //$last_exec['planeupdatefaa'] = time(); |
|
921 | + $last_exec[$id]['last'] = time(); |
|
922 | 922 | } elseif ($value['format'] == 'opensky' && |
923 | - ( |
|
923 | + ( |
|
924 | 924 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
925 | 925 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
926 | - ) |
|
926 | + ) |
|
927 | 927 | ) { |
928 | - $buffer = $Common->getData($value['host']); |
|
929 | - $all_data = json_decode($buffer,true); |
|
930 | - if (isset($all_data['states'])) { |
|
928 | + $buffer = $Common->getData($value['host']); |
|
929 | + $all_data = json_decode($buffer,true); |
|
930 | + if (isset($all_data['states'])) { |
|
931 | 931 | $reset = 0; |
932 | 932 | foreach ($all_data['states'] as $key => $line) { |
933 | - $data = array(); |
|
934 | - $data['hex'] = $line[0]; // hex |
|
935 | - $data['ident'] = trim($line[1]); // ident |
|
936 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
937 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
938 | - $data['heading'] = round($line[10]); // heading |
|
939 | - $data['latitude'] = $line[6]; // lat |
|
940 | - $data['longitude'] = $line[5]; // long |
|
941 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
942 | - //$data['squawk'] = $line[10]; // squawk |
|
943 | - //$data['emergency'] = ''; // emergency |
|
944 | - //$data['registration'] = $line[2]; |
|
945 | - //$data['aircraft_icao'] = $line[0]; |
|
946 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
947 | - $data['format_source'] = 'opensky'; |
|
948 | - $data['id_source'] = $id_source; |
|
949 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
950 | - $SI->add($data); |
|
951 | - unset($data); |
|
933 | + $data = array(); |
|
934 | + $data['hex'] = $line[0]; // hex |
|
935 | + $data['ident'] = trim($line[1]); // ident |
|
936 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
937 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
938 | + $data['heading'] = round($line[10]); // heading |
|
939 | + $data['latitude'] = $line[6]; // lat |
|
940 | + $data['longitude'] = $line[5]; // long |
|
941 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
942 | + //$data['squawk'] = $line[10]; // squawk |
|
943 | + //$data['emergency'] = ''; // emergency |
|
944 | + //$data['registration'] = $line[2]; |
|
945 | + //$data['aircraft_icao'] = $line[0]; |
|
946 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
947 | + $data['format_source'] = 'opensky'; |
|
948 | + $data['id_source'] = $id_source; |
|
949 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
950 | + $SI->add($data); |
|
951 | + unset($data); |
|
952 | 952 | } |
953 | - } |
|
954 | - //$last_exec['planeupdatefaa'] = time(); |
|
955 | - $last_exec[$id]['last'] = time(); |
|
953 | + } |
|
954 | + //$last_exec['planeupdatefaa'] = time(); |
|
955 | + $last_exec[$id]['last'] = time(); |
|
956 | 956 | //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
957 | 957 | } elseif ($value['format'] == 'fr24json' && |
958 | - ( |
|
958 | + ( |
|
959 | 959 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
960 | 960 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
961 | - ) |
|
961 | + ) |
|
962 | 962 | ) { |
963 | - //$buffer = $Common->getData($hosts[$id]); |
|
964 | - $buffer = $Common->getData($value['host']); |
|
965 | - $all_data = json_decode($buffer,true); |
|
966 | - if (!empty($all_data)) $reset = 0; |
|
967 | - foreach ($all_data as $key => $line) { |
|
963 | + //$buffer = $Common->getData($hosts[$id]); |
|
964 | + $buffer = $Common->getData($value['host']); |
|
965 | + $all_data = json_decode($buffer,true); |
|
966 | + if (!empty($all_data)) $reset = 0; |
|
967 | + foreach ($all_data as $key => $line) { |
|
968 | 968 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
969 | - $data = array(); |
|
970 | - $data['hex'] = $line[0]; |
|
971 | - $data['ident'] = $line[16]; //$line[13] |
|
972 | - $data['altitude'] = $line[4]; // altitude |
|
973 | - $data['speed'] = $line[5]; // speed |
|
974 | - $data['heading'] = $line[3]; // heading |
|
975 | - $data['latitude'] = $line[1]; // lat |
|
976 | - $data['longitude'] = $line[2]; // long |
|
977 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
978 | - $data['squawk'] = $line[6]; // squawk |
|
979 | - $data['aircraft_icao'] = $line[8]; |
|
980 | - $data['registration'] = $line[9]; |
|
981 | - $data['departure_airport_iata'] = $line[11]; |
|
982 | - $data['arrival_airport_iata'] = $line[12]; |
|
983 | - $data['emergency'] = ''; // emergency |
|
984 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
985 | - $data['format_source'] = 'fr24json'; |
|
986 | - $data['id_source'] = $id_source; |
|
987 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
988 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
989 | - $SI->add($data); |
|
990 | - unset($data); |
|
969 | + $data = array(); |
|
970 | + $data['hex'] = $line[0]; |
|
971 | + $data['ident'] = $line[16]; //$line[13] |
|
972 | + $data['altitude'] = $line[4]; // altitude |
|
973 | + $data['speed'] = $line[5]; // speed |
|
974 | + $data['heading'] = $line[3]; // heading |
|
975 | + $data['latitude'] = $line[1]; // lat |
|
976 | + $data['longitude'] = $line[2]; // long |
|
977 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
978 | + $data['squawk'] = $line[6]; // squawk |
|
979 | + $data['aircraft_icao'] = $line[8]; |
|
980 | + $data['registration'] = $line[9]; |
|
981 | + $data['departure_airport_iata'] = $line[11]; |
|
982 | + $data['arrival_airport_iata'] = $line[12]; |
|
983 | + $data['emergency'] = ''; // emergency |
|
984 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
985 | + $data['format_source'] = 'fr24json'; |
|
986 | + $data['id_source'] = $id_source; |
|
987 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
988 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
989 | + $SI->add($data); |
|
990 | + unset($data); |
|
991 | 991 | } |
992 | - } |
|
993 | - //$last_exec['fr24json'] = time(); |
|
994 | - $last_exec[$id]['last'] = time(); |
|
992 | + } |
|
993 | + //$last_exec['fr24json'] = time(); |
|
994 | + $last_exec[$id]['last'] = time(); |
|
995 | 995 | //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
996 | 996 | } elseif ($value['format'] == 'radarvirtueljson' && |
997 | - ( |
|
997 | + ( |
|
998 | 998 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
999 | 999 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1000 | - ) |
|
1000 | + ) |
|
1001 | 1001 | ) { |
1002 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
1003 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1004 | - //echo $buffer; |
|
1005 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1006 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1007 | - $all_data = json_decode($buffer,true); |
|
1008 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
1002 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
1003 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1004 | + //echo $buffer; |
|
1005 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1006 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1007 | + $all_data = json_decode($buffer,true); |
|
1008 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
1009 | 1009 | die(json_last_error_msg()); |
1010 | - } |
|
1011 | - if (isset($all_data['mrkrs'])) { |
|
1010 | + } |
|
1011 | + if (isset($all_data['mrkrs'])) { |
|
1012 | 1012 | $reset = 0; |
1013 | 1013 | foreach ($all_data['mrkrs'] as $key => $line) { |
1014 | - if (isset($line['inf'])) { |
|
1014 | + if (isset($line['inf'])) { |
|
1015 | 1015 | $data = array(); |
1016 | 1016 | $data['hex'] = $line['inf']['ia']; |
1017 | 1017 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
1018 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
1019 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1020 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1021 | - $data['latitude'] = $line['pt'][0]; // lat |
|
1022 | - $data['longitude'] = $line['pt'][1]; // long |
|
1023 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
1024 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1025 | - //$data['aircraft_icao'] = $line[8]; |
|
1026 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1018 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
1019 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1020 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1021 | + $data['latitude'] = $line['pt'][0]; // lat |
|
1022 | + $data['longitude'] = $line['pt'][1]; // long |
|
1023 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
1024 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1025 | + //$data['aircraft_icao'] = $line[8]; |
|
1026 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1027 | 1027 | //$data['departure_airport_iata'] = $line[11]; |
1028 | 1028 | //$data['arrival_airport_iata'] = $line[12]; |
1029 | - //$data['emergency'] = ''; // emergency |
|
1029 | + //$data['emergency'] = ''; // emergency |
|
1030 | 1030 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
1031 | - $data['format_source'] = 'radarvirtueljson'; |
|
1032 | - $data['id_source'] = $id_source; |
|
1031 | + $data['format_source'] = 'radarvirtueljson'; |
|
1032 | + $data['id_source'] = $id_source; |
|
1033 | 1033 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
1034 | 1034 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1035 | 1035 | $SI->add($data); |
1036 | 1036 | unset($data); |
1037 | - } |
|
1037 | + } |
|
1038 | + } |
|
1038 | 1039 | } |
1039 | - } |
|
1040 | - //$last_exec['radarvirtueljson'] = time(); |
|
1041 | - $last_exec[$id]['last'] = time(); |
|
1040 | + //$last_exec['radarvirtueljson'] = time(); |
|
1041 | + $last_exec[$id]['last'] = time(); |
|
1042 | 1042 | //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
1043 | 1043 | } elseif ($value['format'] == 'pirepsjson' && |
1044 | - ( |
|
1044 | + ( |
|
1045 | 1045 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1046 | 1046 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1047 | - ) |
|
1047 | + ) |
|
1048 | 1048 | ) { |
1049 | - //$buffer = $Common->getData($hosts[$id]); |
|
1050 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
1051 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
1049 | + //$buffer = $Common->getData($hosts[$id]); |
|
1050 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
1051 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
1052 | 1052 | |
1053 | - if (isset($all_data['pireps'])) { |
|
1053 | + if (isset($all_data['pireps'])) { |
|
1054 | 1054 | $reset = 0; |
1055 | - foreach ($all_data['pireps'] as $line) { |
|
1056 | - $data = array(); |
|
1057 | - $data['id'] = $line['id']; |
|
1058 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1059 | - $data['ident'] = $line['callsign']; // ident |
|
1060 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1061 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1062 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1063 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1064 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1065 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1066 | - $data['latitude'] = $line['lat']; // lat |
|
1067 | - $data['longitude'] = $line['lon']; // long |
|
1068 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
1069 | - //$data['squawk'] = $line['squawk']; // squawk |
|
1070 | - //$data['emergency'] = ''; // emergency |
|
1071 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1072 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1073 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1074 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
1075 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1076 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1077 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1078 | - else $data['info'] = ''; |
|
1079 | - $data['format_source'] = 'pireps'; |
|
1080 | - $data['id_source'] = $id_source; |
|
1081 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1082 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1083 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1084 | - if ($line['icon'] == 'plane') { |
|
1055 | + foreach ($all_data['pireps'] as $line) { |
|
1056 | + $data = array(); |
|
1057 | + $data['id'] = $line['id']; |
|
1058 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1059 | + $data['ident'] = $line['callsign']; // ident |
|
1060 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1061 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1062 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1063 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1064 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1065 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1066 | + $data['latitude'] = $line['lat']; // lat |
|
1067 | + $data['longitude'] = $line['lon']; // long |
|
1068 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
1069 | + //$data['squawk'] = $line['squawk']; // squawk |
|
1070 | + //$data['emergency'] = ''; // emergency |
|
1071 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1072 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1073 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1074 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
1075 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1076 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1077 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1078 | + else $data['info'] = ''; |
|
1079 | + $data['format_source'] = 'pireps'; |
|
1080 | + $data['id_source'] = $id_source; |
|
1081 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1082 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1083 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1084 | + if ($line['icon'] == 'plane') { |
|
1085 | 1085 | $SI->add($data); |
1086 | - // print_r($data); |
|
1087 | - } elseif ($line['icon'] == 'ct') { |
|
1086 | + // print_r($data); |
|
1087 | + } elseif ($line['icon'] == 'ct') { |
|
1088 | 1088 | $data['info'] = str_replace('^§','<br />',$data['info']); |
1089 | 1089 | $data['info'] = str_replace('&sect;','',$data['info']); |
1090 | 1090 | $typec = substr($data['ident'],-3); |
@@ -1099,148 +1099,148 @@ discard block |
||
1099 | 1099 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
1100 | 1100 | else $data['type'] = 'Observer'; |
1101 | 1101 | 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']); |
1102 | - } |
|
1103 | - unset($data); |
|
1102 | + } |
|
1103 | + unset($data); |
|
1104 | + } |
|
1104 | 1105 | } |
1105 | - } |
|
1106 | - //$last_exec['pirepsjson'] = time(); |
|
1107 | - $last_exec[$id]['last'] = time(); |
|
1106 | + //$last_exec['pirepsjson'] = time(); |
|
1107 | + $last_exec[$id]['last'] = time(); |
|
1108 | 1108 | //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
1109 | 1109 | } elseif ($value['format'] == 'phpvmacars' && |
1110 | - ( |
|
1110 | + ( |
|
1111 | 1111 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1112 | 1112 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1113 | - ) |
|
1113 | + ) |
|
1114 | 1114 | ) { |
1115 | - //$buffer = $Common->getData($hosts[$id]); |
|
1116 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1117 | - $buffer = $Common->getData($value['host']); |
|
1118 | - $all_data = json_decode($buffer,true); |
|
1119 | - if ($buffer != '' && is_array($all_data)) { |
|
1115 | + //$buffer = $Common->getData($hosts[$id]); |
|
1116 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1117 | + $buffer = $Common->getData($value['host']); |
|
1118 | + $all_data = json_decode($buffer,true); |
|
1119 | + if ($buffer != '' && is_array($all_data)) { |
|
1120 | 1120 | $reset = 0; |
1121 | 1121 | foreach ($all_data as $line) { |
1122 | - $data = array(); |
|
1123 | - //$data['id'] = $line['id']; // id not usable |
|
1124 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1125 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1126 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1127 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1128 | - $data['ident'] = $line['flightnum']; // ident |
|
1129 | - $data['altitude'] = $line['alt']; // altitude |
|
1130 | - $data['speed'] = $line['gs']; // speed |
|
1131 | - $data['heading'] = $line['heading']; // heading |
|
1132 | - $data['latitude'] = $line['lat']; // lat |
|
1133 | - $data['longitude'] = $line['lng']; // long |
|
1134 | - $data['verticalrate'] = ''; // verticale rate |
|
1135 | - $data['squawk'] = ''; // squawk |
|
1136 | - $data['emergency'] = ''; // emergency |
|
1137 | - //$data['datetime'] = $line['lastupdate']; |
|
1138 | - //$data['last_update'] = $line['lastupdate']; |
|
1139 | - if (isset($value['timezone'])) { |
|
1140 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1141 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1142 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1143 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1144 | - $data['departure_airport_icao'] = $line['depicao']; |
|
1145 | - $data['departure_airport_time'] = $line['deptime']; |
|
1146 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
1147 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
1148 | - $data['registration'] = $line['aircraft']; |
|
1149 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1150 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1151 | - if (isset($line['aircraftname'])) { |
|
1122 | + $data = array(); |
|
1123 | + //$data['id'] = $line['id']; // id not usable |
|
1124 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1125 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1126 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1127 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1128 | + $data['ident'] = $line['flightnum']; // ident |
|
1129 | + $data['altitude'] = $line['alt']; // altitude |
|
1130 | + $data['speed'] = $line['gs']; // speed |
|
1131 | + $data['heading'] = $line['heading']; // heading |
|
1132 | + $data['latitude'] = $line['lat']; // lat |
|
1133 | + $data['longitude'] = $line['lng']; // long |
|
1134 | + $data['verticalrate'] = ''; // verticale rate |
|
1135 | + $data['squawk'] = ''; // squawk |
|
1136 | + $data['emergency'] = ''; // emergency |
|
1137 | + //$data['datetime'] = $line['lastupdate']; |
|
1138 | + //$data['last_update'] = $line['lastupdate']; |
|
1139 | + if (isset($value['timezone'])) { |
|
1140 | + $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1141 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1142 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1143 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1144 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1145 | + $data['departure_airport_time'] = $line['deptime']; |
|
1146 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1147 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
1148 | + $data['registration'] = $line['aircraft']; |
|
1149 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1150 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1151 | + if (isset($line['aircraftname'])) { |
|
1152 | 1152 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1153 | 1153 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1154 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1155 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1156 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1157 | - else { |
|
1158 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1159 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1160 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1161 | - } |
|
1162 | - } |
|
1163 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1164 | - $data['id_source'] = $id_source; |
|
1165 | - $data['format_source'] = 'phpvmacars'; |
|
1166 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1167 | - $SI->add($data); |
|
1168 | - unset($data); |
|
1154 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
1155 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1156 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1157 | + else { |
|
1158 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
1159 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1160 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1161 | + } |
|
1162 | + } |
|
1163 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1164 | + $data['id_source'] = $id_source; |
|
1165 | + $data['format_source'] = 'phpvmacars'; |
|
1166 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1167 | + $SI->add($data); |
|
1168 | + unset($data); |
|
1169 | 1169 | } |
1170 | 1170 | if ($globalDebug) echo 'No more data...'."\n"; |
1171 | 1171 | unset($buffer); |
1172 | 1172 | unset($all_data); |
1173 | - } |
|
1174 | - //$last_exec['phpvmacars'] = time(); |
|
1175 | - $last_exec[$id]['last'] = time(); |
|
1173 | + } |
|
1174 | + //$last_exec['phpvmacars'] = time(); |
|
1175 | + $last_exec[$id]['last'] = time(); |
|
1176 | 1176 | } elseif ($value['format'] == 'vam' && |
1177 | - ( |
|
1177 | + ( |
|
1178 | 1178 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1179 | 1179 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1180 | - ) |
|
1180 | + ) |
|
1181 | 1181 | ) { |
1182 | - //$buffer = $Common->getData($hosts[$id]); |
|
1183 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1184 | - $buffer = $Common->getData($value['host']); |
|
1185 | - $all_data = json_decode($buffer,true); |
|
1186 | - if ($buffer != '' && is_array($all_data)) { |
|
1182 | + //$buffer = $Common->getData($hosts[$id]); |
|
1183 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1184 | + $buffer = $Common->getData($value['host']); |
|
1185 | + $all_data = json_decode($buffer,true); |
|
1186 | + if ($buffer != '' && is_array($all_data)) { |
|
1187 | 1187 | $reset = 0; |
1188 | 1188 | foreach ($all_data as $line) { |
1189 | - $data = array(); |
|
1190 | - //$data['id'] = $line['id']; // id not usable |
|
1191 | - $data['id'] = trim($line['flight_id']); |
|
1192 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1193 | - $data['pilot_name'] = $line['pilot_name']; |
|
1194 | - $data['pilot_id'] = $line['pilot_id']; |
|
1195 | - $data['ident'] = trim($line['callsign']); // ident |
|
1196 | - $data['altitude'] = $line['altitude']; // altitude |
|
1197 | - $data['speed'] = $line['gs']; // speed |
|
1198 | - $data['heading'] = $line['heading']; // heading |
|
1199 | - $data['latitude'] = $line['latitude']; // lat |
|
1200 | - $data['longitude'] = $line['longitude']; // long |
|
1201 | - $data['verticalrate'] = ''; // verticale rate |
|
1202 | - $data['squawk'] = ''; // squawk |
|
1203 | - $data['emergency'] = ''; // emergency |
|
1204 | - //$data['datetime'] = $line['lastupdate']; |
|
1205 | - $data['last_update'] = $line['last_update']; |
|
1206 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1207 | - $data['departure_airport_icao'] = $line['departure']; |
|
1208 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
1209 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
1210 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1211 | - //$data['registration'] = $line['aircraft']; |
|
1212 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1213 | - $data['aircraft_icao'] = $line['plane_type']; |
|
1214 | - $data['id_source'] = $id_source; |
|
1215 | - $data['format_source'] = 'vam'; |
|
1216 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1217 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1218 | - $SI->add($data); |
|
1219 | - unset($data); |
|
1189 | + $data = array(); |
|
1190 | + //$data['id'] = $line['id']; // id not usable |
|
1191 | + $data['id'] = trim($line['flight_id']); |
|
1192 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1193 | + $data['pilot_name'] = $line['pilot_name']; |
|
1194 | + $data['pilot_id'] = $line['pilot_id']; |
|
1195 | + $data['ident'] = trim($line['callsign']); // ident |
|
1196 | + $data['altitude'] = $line['altitude']; // altitude |
|
1197 | + $data['speed'] = $line['gs']; // speed |
|
1198 | + $data['heading'] = $line['heading']; // heading |
|
1199 | + $data['latitude'] = $line['latitude']; // lat |
|
1200 | + $data['longitude'] = $line['longitude']; // long |
|
1201 | + $data['verticalrate'] = ''; // verticale rate |
|
1202 | + $data['squawk'] = ''; // squawk |
|
1203 | + $data['emergency'] = ''; // emergency |
|
1204 | + //$data['datetime'] = $line['lastupdate']; |
|
1205 | + $data['last_update'] = $line['last_update']; |
|
1206 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1207 | + $data['departure_airport_icao'] = $line['departure']; |
|
1208 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
1209 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
1210 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1211 | + //$data['registration'] = $line['aircraft']; |
|
1212 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1213 | + $data['aircraft_icao'] = $line['plane_type']; |
|
1214 | + $data['id_source'] = $id_source; |
|
1215 | + $data['format_source'] = 'vam'; |
|
1216 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1217 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1218 | + $SI->add($data); |
|
1219 | + unset($data); |
|
1220 | 1220 | } |
1221 | 1221 | if ($globalDebug) echo 'No more data...'."\n"; |
1222 | 1222 | unset($buffer); |
1223 | 1223 | unset($all_data); |
1224 | - } |
|
1225 | - //$last_exec['phpvmacars'] = time(); |
|
1226 | - $last_exec[$id]['last'] = time(); |
|
1224 | + } |
|
1225 | + //$last_exec['phpvmacars'] = time(); |
|
1226 | + $last_exec[$id]['last'] = time(); |
|
1227 | 1227 | } elseif ($value['format'] == 'blitzortung' && |
1228 | - ( |
|
1228 | + ( |
|
1229 | 1229 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1230 | 1230 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1231 | - ) |
|
1231 | + ) |
|
1232 | 1232 | ) { |
1233 | - //$buffer = $Common->getData($hosts[$id]); |
|
1234 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1235 | - $buffer = $Common->getData($value['host']); |
|
1236 | - $all_data = json_decode($buffer,true); |
|
1237 | - if ($buffer != '') { |
|
1233 | + //$buffer = $Common->getData($hosts[$id]); |
|
1234 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1235 | + $buffer = $Common->getData($value['host']); |
|
1236 | + $all_data = json_decode($buffer,true); |
|
1237 | + if ($buffer != '') { |
|
1238 | 1238 | $Source->deleteLocationBySource('blitzortung'); |
1239 | 1239 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
1240 | 1240 | $buffer = explode('\n',$buffer); |
1241 | 1241 | foreach ($buffer as $buffer_line) { |
1242 | - $line = json_decode($buffer_line,true); |
|
1243 | - if (isset($line['time'])) { |
|
1242 | + $line = json_decode($buffer_line,true); |
|
1243 | + if (isset($line['time'])) { |
|
1244 | 1244 | $data = array(); |
1245 | 1245 | $data['altitude'] = $line['alt']; // altitude |
1246 | 1246 | $data['latitude'] = $line['lat']; // lat |
@@ -1252,94 +1252,94 @@ discard block |
||
1252 | 1252 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1253 | 1253 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
1254 | 1254 | unset($data); |
1255 | - } |
|
1255 | + } |
|
1256 | 1256 | } |
1257 | 1257 | if ($globalDebug) echo 'No more data...'."\n"; |
1258 | 1258 | unset($buffer); |
1259 | - } |
|
1260 | - $last_exec[$id]['last'] = time(); |
|
1259 | + } |
|
1260 | + $last_exec[$id]['last'] = time(); |
|
1261 | 1261 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
1262 | 1262 | } 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') { |
1263 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1264 | - //$last_exec[$id]['last'] = time(); |
|
1263 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1264 | + //$last_exec[$id]['last'] = time(); |
|
1265 | 1265 | |
1266 | - //$read = array( $sockets[$id] ); |
|
1267 | - $read = $sockets; |
|
1268 | - $write = NULL; |
|
1269 | - $e = NULL; |
|
1270 | - $n = socket_select($read, $write, $e, $timeout); |
|
1271 | - if ($e != NULL) var_dump($e); |
|
1272 | - if ($n > 0) { |
|
1266 | + //$read = array( $sockets[$id] ); |
|
1267 | + $read = $sockets; |
|
1268 | + $write = NULL; |
|
1269 | + $e = NULL; |
|
1270 | + $n = socket_select($read, $write, $e, $timeout); |
|
1271 | + if ($e != NULL) var_dump($e); |
|
1272 | + if ($n > 0) { |
|
1273 | 1273 | $reset = 0; |
1274 | 1274 | foreach ($read as $nb => $r) { |
1275 | - //$value = $formats[$nb]; |
|
1276 | - $format = $globalSources[$nb]['format']; |
|
1277 | - if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1275 | + //$value = $formats[$nb]; |
|
1276 | + $format = $globalSources[$nb]['format']; |
|
1277 | + if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1278 | 1278 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
1279 | - } elseif ($format == 'vrstcp') { |
|
1279 | + } elseif ($format == 'vrstcp') { |
|
1280 | 1280 | $buffer = @socket_read($r, 6000); |
1281 | - } else { |
|
1281 | + } else { |
|
1282 | 1282 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
1283 | - } |
|
1284 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1285 | - //echo $buffer."\n"; |
|
1286 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
1287 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1288 | - $error = false; |
|
1289 | - //$SI::del(); |
|
1290 | - if ($format == 'vrstcp') { |
|
1283 | + } |
|
1284 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1285 | + //echo $buffer."\n"; |
|
1286 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
1287 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1288 | + $error = false; |
|
1289 | + //$SI::del(); |
|
1290 | + if ($format == 'vrstcp') { |
|
1291 | 1291 | $buffer = explode('},{',$buffer); |
1292 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1293 | - // SBS format is CSV format |
|
1294 | - if ($buffer !== FALSE && $buffer != '') { |
|
1292 | + } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1293 | + // SBS format is CSV format |
|
1294 | + if ($buffer !== FALSE && $buffer != '') { |
|
1295 | 1295 | $tt[$format] = 0; |
1296 | 1296 | if ($format == 'acarssbs3') { |
1297 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1298 | - $ACARS->add(trim($buffer)); |
|
1299 | - $ACARS->deleteLiveAcarsData(); |
|
1297 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1298 | + $ACARS->add(trim($buffer)); |
|
1299 | + $ACARS->deleteLiveAcarsData(); |
|
1300 | 1300 | } elseif ($format == 'raw') { |
1301 | - // AVR format |
|
1302 | - $data = $SBS->parse($buffer); |
|
1303 | - if (is_array($data)) { |
|
1301 | + // AVR format |
|
1302 | + $data = $SBS->parse($buffer); |
|
1303 | + if (is_array($data)) { |
|
1304 | 1304 | $data['datetime'] = date('Y-m-d H:i:s'); |
1305 | 1305 | $data['format_source'] = 'raw'; |
1306 | 1306 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1307 | 1307 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1308 | 1308 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1309 | 1309 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1310 | - } |
|
1310 | + } |
|
1311 | 1311 | } elseif ($format == 'ais') { |
1312 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
1313 | - $data = array(); |
|
1314 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1315 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1316 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1317 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1318 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1319 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1320 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1321 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1322 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1323 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1324 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1325 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1326 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1327 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1328 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1329 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1312 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
1313 | + $data = array(); |
|
1314 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1315 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1316 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1317 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1318 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1319 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1320 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1321 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1322 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1323 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1324 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1325 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1326 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1327 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1328 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1329 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1330 | 1330 | |
1331 | - if (isset($ais_data['timestamp'])) { |
|
1331 | + if (isset($ais_data['timestamp'])) { |
|
1332 | 1332 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
1333 | - } else { |
|
1333 | + } else { |
|
1334 | 1334 | $data['datetime'] = date('Y-m-d H:i:s'); |
1335 | - } |
|
1336 | - $data['format_source'] = 'aisnmea'; |
|
1337 | - $data['id_source'] = $id_source; |
|
1338 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1339 | - unset($data); |
|
1340 | - } elseif ($format == 'flightgearsp') { |
|
1341 | - //echo $buffer."\n"; |
|
1342 | - if (strlen($buffer) > 5) { |
|
1335 | + } |
|
1336 | + $data['format_source'] = 'aisnmea'; |
|
1337 | + $data['id_source'] = $id_source; |
|
1338 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1339 | + unset($data); |
|
1340 | + } elseif ($format == 'flightgearsp') { |
|
1341 | + //echo $buffer."\n"; |
|
1342 | + if (strlen($buffer) > 5) { |
|
1343 | 1343 | $line = explode(',',$buffer); |
1344 | 1344 | $data = array(); |
1345 | 1345 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1356,38 +1356,38 @@ discard block |
||
1356 | 1356 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1357 | 1357 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1358 | 1358 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1359 | - } |
|
1360 | - } elseif ($format == 'acars') { |
|
1361 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1362 | - $ACARS->add(trim($buffer)); |
|
1363 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1364 | - $ACARS->deleteLiveAcarsData(); |
|
1359 | + } |
|
1360 | + } elseif ($format == 'acars') { |
|
1361 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1362 | + $ACARS->add(trim($buffer)); |
|
1363 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1364 | + $ACARS->deleteLiveAcarsData(); |
|
1365 | 1365 | } elseif ($format == 'flightgearmp') { |
1366 | - if (substr($buffer,0,1) != '#') { |
|
1366 | + if (substr($buffer,0,1) != '#') { |
|
1367 | 1367 | $data = array(); |
1368 | 1368 | //echo $buffer."\n"; |
1369 | 1369 | $line = explode(' ',$buffer); |
1370 | 1370 | if (count($line) == 11) { |
1371 | - $userserver = explode('@',$line[0]); |
|
1372 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1373 | - $data['ident'] = $userserver[0]; |
|
1374 | - $data['registration'] = $userserver[0]; |
|
1375 | - $data['latitude'] = $line[4]; |
|
1376 | - $data['longitude'] = $line[5]; |
|
1377 | - $data['altitude'] = $line[6]; |
|
1378 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1379 | - $aircraft_type = $line[10]; |
|
1380 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1381 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1382 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1383 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1371 | + $userserver = explode('@',$line[0]); |
|
1372 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1373 | + $data['ident'] = $userserver[0]; |
|
1374 | + $data['registration'] = $userserver[0]; |
|
1375 | + $data['latitude'] = $line[4]; |
|
1376 | + $data['longitude'] = $line[5]; |
|
1377 | + $data['altitude'] = $line[6]; |
|
1378 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1379 | + $aircraft_type = $line[10]; |
|
1380 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1381 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1382 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1383 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1384 | + } |
|
1384 | 1385 | } |
1385 | - } |
|
1386 | 1386 | } elseif ($format == 'beast') { |
1387 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1388 | - die; |
|
1387 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1388 | + die; |
|
1389 | 1389 | } elseif ($format == 'vrstcp') { |
1390 | - foreach($buffer as $all_data) { |
|
1390 | + foreach($buffer as $all_data) { |
|
1391 | 1391 | $line = json_decode('{'.$all_data.'}',true); |
1392 | 1392 | $data = array(); |
1393 | 1393 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1407,148 +1407,148 @@ discard block |
||
1407 | 1407 | */ |
1408 | 1408 | $data['datetime'] = date('Y-m-d H:i:s'); |
1409 | 1409 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
1410 | - $data['format_source'] = 'vrstcp'; |
|
1410 | + $data['format_source'] = 'vrstcp'; |
|
1411 | 1411 | $data['id_source'] = $id_source; |
1412 | 1412 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1413 | 1413 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1414 | 1414 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1415 | 1415 | unset($data); |
1416 | - } |
|
1416 | + } |
|
1417 | 1417 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
1418 | - $line = explode("\t", $buffer); |
|
1419 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1418 | + $line = explode("\t", $buffer); |
|
1419 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
1420 | 1420 | $key = $line[$k]; |
1421 | - $lined[$key] = $line[$k+1]; |
|
1422 | - } |
|
1423 | - if (count($lined) > 3) { |
|
1424 | - $data['hex'] = $lined['hexid']; |
|
1425 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1426 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1427 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1428 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1429 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1430 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1431 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1432 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1433 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1434 | - $data['id_source'] = $id_source; |
|
1435 | - $data['format_source'] = 'tsv'; |
|
1436 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1437 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1421 | + $lined[$key] = $line[$k+1]; |
|
1422 | + } |
|
1423 | + if (count($lined) > 3) { |
|
1424 | + $data['hex'] = $lined['hexid']; |
|
1425 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1426 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
1427 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1428 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1429 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1430 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1431 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1432 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1433 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1434 | + $data['id_source'] = $id_source; |
|
1435 | + $data['format_source'] = 'tsv'; |
|
1436 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1437 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1438 | 1438 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1439 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1440 | - unset($lined); |
|
1441 | - unset($data); |
|
1442 | - } else $error = true; |
|
1439 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1440 | + unset($lined); |
|
1441 | + unset($data); |
|
1442 | + } else $error = true; |
|
1443 | 1443 | } elseif ($format == 'aprs' && $use_aprs) { |
1444 | - if ($aprs_connect == 0) { |
|
1444 | + if ($aprs_connect == 0) { |
|
1445 | 1445 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
1446 | 1446 | $aprs_connect = 1; |
1447 | - } |
|
1447 | + } |
|
1448 | 1448 | |
1449 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1449 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1450 | 1450 | $aprs_last_tx = time(); |
1451 | 1451 | $data_aprs = "# Keep alive"; |
1452 | 1452 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1453 | - } |
|
1453 | + } |
|
1454 | 1454 | |
1455 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1456 | - //echo 'APRS data : '.$buffer."\n"; |
|
1457 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1458 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1459 | - //echo $buffer."\n"; |
|
1460 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1455 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1456 | + //echo 'APRS data : '.$buffer."\n"; |
|
1457 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
1458 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
1459 | + //echo $buffer."\n"; |
|
1460 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1461 | 1461 | $line = $APRS->parse($buffer); |
1462 | 1462 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1463 | 1463 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
1464 | - $aprs_last_tx = time(); |
|
1465 | - $data = array(); |
|
1466 | - //print_r($line); |
|
1467 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1468 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1469 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1470 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1471 | - if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
1472 | - if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
1473 | - if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
1474 | - if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
1475 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1476 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1477 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1478 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1479 | - $data['latitude'] = $line['latitude']; |
|
1480 | - $data['longitude'] = $line['longitude']; |
|
1481 | - //$data['verticalrate'] = $line[16]; |
|
1482 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1483 | - //else $data['speed'] = 0; |
|
1484 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1485 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1486 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1487 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1488 | - //else $data['heading'] = 0; |
|
1489 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1490 | - //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1491 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1492 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1493 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1494 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1495 | - $data['id_source'] = $id_source; |
|
1496 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1497 | - else $data['format_source'] = 'aprs'; |
|
1498 | - $data['source_name'] = $line['source']; |
|
1499 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1500 | - else $data['source_type'] = 'flarm'; |
|
1501 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1502 | - $currentdate = date('Y-m-d H:i:s'); |
|
1503 | - $aprsdate = strtotime($data['datetime']); |
|
1504 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1505 | - // Accept data if time <= system time + 20s |
|
1506 | - //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'])))) { |
|
1507 | - 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'])))) { |
|
1464 | + $aprs_last_tx = time(); |
|
1465 | + $data = array(); |
|
1466 | + //print_r($line); |
|
1467 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1468 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1469 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1470 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1471 | + if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
1472 | + if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
1473 | + if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
1474 | + if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
1475 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1476 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1477 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1478 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1479 | + $data['latitude'] = $line['latitude']; |
|
1480 | + $data['longitude'] = $line['longitude']; |
|
1481 | + //$data['verticalrate'] = $line[16]; |
|
1482 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1483 | + //else $data['speed'] = 0; |
|
1484 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1485 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1486 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1487 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1488 | + //else $data['heading'] = 0; |
|
1489 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1490 | + //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1491 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1492 | + elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1493 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1494 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1495 | + $data['id_source'] = $id_source; |
|
1496 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1497 | + else $data['format_source'] = 'aprs'; |
|
1498 | + $data['source_name'] = $line['source']; |
|
1499 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1500 | + else $data['source_type'] = 'flarm'; |
|
1501 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1502 | + $currentdate = date('Y-m-d H:i:s'); |
|
1503 | + $aprsdate = strtotime($data['datetime']); |
|
1504 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1505 | + // Accept data if time <= system time + 20s |
|
1506 | + //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'])))) { |
|
1507 | + 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'])))) { |
|
1508 | 1508 | $send = $SI->add($data); |
1509 | - } elseif ($data['source_type'] == 'ais') { |
|
1509 | + } elseif ($data['source_type'] == 'ais') { |
|
1510 | 1510 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
1511 | - } elseif (isset($line['stealth'])) { |
|
1511 | + } elseif (isset($line['stealth'])) { |
|
1512 | 1512 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
1513 | 1513 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
1514 | - } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1515 | - //$line['symbol'] == 'Balloon' || |
|
1516 | - $line['symbol'] == 'Glider' || |
|
1517 | - $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1518 | - if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1519 | - if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1520 | - $send = $SI->add($data); |
|
1521 | - } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1522 | - $line['symbol'] == 'Yacht (Sail)' || |
|
1523 | - $line['symbol'] == 'Ship (Power Boat)')) { |
|
1524 | - $send = $MI->add($data); |
|
1525 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1526 | - $line['symbol'] == 'Car' || |
|
1527 | - $line['symbol'] == 'Ambulance' || |
|
1528 | - $line['symbol'] == 'Van' || |
|
1529 | - $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || |
|
1530 | - $line['symbol'] == 'Motorcycle' || |
|
1531 | - $line['symbol'] == 'Tractor' || |
|
1532 | - $line['symbol'] == 'Police' || |
|
1533 | - $line['symbol'] == 'Bike' || |
|
1534 | - $line['symbol'] == 'Jogger' || |
|
1535 | - $line['symbol'] == 'Horse' || |
|
1536 | - $line['symbol'] == 'Bus' || |
|
1537 | - $line['symbol'] == 'Jeep' || |
|
1538 | - $line['symbol'] == 'Recreational Vehicle' || |
|
1539 | - $line['symbol'] == 'Yacht (Sail)' || |
|
1540 | - $line['symbol'] == 'Ship (Power Boat)' || |
|
1541 | - $line['symbol'] == 'Firetruck' || |
|
1542 | - $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || |
|
1543 | - $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || |
|
1544 | - $line['symbol'] == 'SUV' || |
|
1545 | - $line['symbol'] == 'Snowmobile' || |
|
1546 | - $line['symbol'] == 'Mobile Satellite Station')) { |
|
1547 | - //} 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') { |
|
1514 | + } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1515 | + //$line['symbol'] == 'Balloon' || |
|
1516 | + $line['symbol'] == 'Glider' || |
|
1517 | + $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1518 | + if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1519 | + if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1520 | + $send = $SI->add($data); |
|
1521 | + } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1522 | + $line['symbol'] == 'Yacht (Sail)' || |
|
1523 | + $line['symbol'] == 'Ship (Power Boat)')) { |
|
1524 | + $send = $MI->add($data); |
|
1525 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1526 | + $line['symbol'] == 'Car' || |
|
1527 | + $line['symbol'] == 'Ambulance' || |
|
1528 | + $line['symbol'] == 'Van' || |
|
1529 | + $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || |
|
1530 | + $line['symbol'] == 'Motorcycle' || |
|
1531 | + $line['symbol'] == 'Tractor' || |
|
1532 | + $line['symbol'] == 'Police' || |
|
1533 | + $line['symbol'] == 'Bike' || |
|
1534 | + $line['symbol'] == 'Jogger' || |
|
1535 | + $line['symbol'] == 'Horse' || |
|
1536 | + $line['symbol'] == 'Bus' || |
|
1537 | + $line['symbol'] == 'Jeep' || |
|
1538 | + $line['symbol'] == 'Recreational Vehicle' || |
|
1539 | + $line['symbol'] == 'Yacht (Sail)' || |
|
1540 | + $line['symbol'] == 'Ship (Power Boat)' || |
|
1541 | + $line['symbol'] == 'Firetruck' || |
|
1542 | + $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || |
|
1543 | + $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || |
|
1544 | + $line['symbol'] == 'SUV' || |
|
1545 | + $line['symbol'] == 'Snowmobile' || |
|
1546 | + $line['symbol'] == 'Mobile Satellite Station')) { |
|
1547 | + //} 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') { |
|
1548 | 1548 | // } 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') { |
1549 | 1549 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1550 | 1550 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
1551 | - } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1551 | + } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1552 | 1552 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
1553 | 1553 | $Source->deleteOldLocationByType('gs'); |
1554 | 1554 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
@@ -1556,7 +1556,7 @@ discard block |
||
1556 | 1556 | } else { |
1557 | 1557 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
1558 | 1558 | } |
1559 | - } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
1559 | + } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
1560 | 1560 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1561 | 1561 | if ($globalDebug) echo '# Weather Station added'."\n"; |
1562 | 1562 | $Source->deleteOldLocationByType('wx'); |
@@ -1566,7 +1566,7 @@ discard block |
||
1566 | 1566 | } else { |
1567 | 1567 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
1568 | 1568 | } |
1569 | - } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') { |
|
1569 | + } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') { |
|
1570 | 1570 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1571 | 1571 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1572 | 1572 | $Source->deleteOldLocationByType('lightning'); |
@@ -1575,11 +1575,11 @@ discard block |
||
1575 | 1575 | } else { |
1576 | 1576 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
1577 | 1577 | } |
1578 | - } elseif ($globalDebug) { |
|
1579 | - echo '/!\ Not added: '.$buffer."\n"; |
|
1580 | - print_r($line); |
|
1581 | - } |
|
1582 | - unset($data); |
|
1578 | + } elseif ($globalDebug) { |
|
1579 | + echo '/!\ Not added: '.$buffer."\n"; |
|
1580 | + print_r($line); |
|
1581 | + } |
|
1582 | + unset($data); |
|
1583 | 1583 | } |
1584 | 1584 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
1585 | 1585 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
@@ -1598,12 +1598,12 @@ discard block |
||
1598 | 1598 | } elseif (!isset($globalSources[$nb]['last_weather_clean'])) { |
1599 | 1599 | $globalSources[$nb]['last_weather_clean'] = time(); |
1600 | 1600 | } |
1601 | - } |
|
1601 | + } |
|
1602 | 1602 | } else { |
1603 | - $line = explode(',', $buffer); |
|
1604 | - if (count($line) > 20) { |
|
1605 | - $data['hex'] = $line[4]; |
|
1606 | - /* |
|
1603 | + $line = explode(',', $buffer); |
|
1604 | + if (count($line) > 20) { |
|
1605 | + $data['hex'] = $line[4]; |
|
1606 | + /* |
|
1607 | 1607 | $data['datetime'] = $line[6].' '.$line[7]; |
1608 | 1608 | date_default_timezone_set($globalTimezone); |
1609 | 1609 | $datetime = new DateTime($data['datetime']); |
@@ -1611,30 +1611,30 @@ discard block |
||
1611 | 1611 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1612 | 1612 | date_default_timezone_set('UTC'); |
1613 | 1613 | */ |
1614 | - // Force datetime to current UTC datetime |
|
1615 | - date_default_timezone_set('UTC'); |
|
1616 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1617 | - $data['ident'] = trim($line[10]); |
|
1618 | - $data['latitude'] = $line[14]; |
|
1619 | - $data['longitude'] = $line[15]; |
|
1620 | - $data['verticalrate'] = $line[16]; |
|
1621 | - $data['emergency'] = $line[20]; |
|
1622 | - $data['speed'] = $line[12]; |
|
1623 | - $data['squawk'] = $line[17]; |
|
1624 | - $data['altitude'] = $line[11]; |
|
1625 | - $data['heading'] = $line[13]; |
|
1626 | - $data['ground'] = $line[21]; |
|
1627 | - $data['emergency'] = $line[19]; |
|
1628 | - $data['format_source'] = 'sbs'; |
|
1614 | + // Force datetime to current UTC datetime |
|
1615 | + date_default_timezone_set('UTC'); |
|
1616 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1617 | + $data['ident'] = trim($line[10]); |
|
1618 | + $data['latitude'] = $line[14]; |
|
1619 | + $data['longitude'] = $line[15]; |
|
1620 | + $data['verticalrate'] = $line[16]; |
|
1621 | + $data['emergency'] = $line[20]; |
|
1622 | + $data['speed'] = $line[12]; |
|
1623 | + $data['squawk'] = $line[17]; |
|
1624 | + $data['altitude'] = $line[11]; |
|
1625 | + $data['heading'] = $line[13]; |
|
1626 | + $data['ground'] = $line[21]; |
|
1627 | + $data['emergency'] = $line[19]; |
|
1628 | + $data['format_source'] = 'sbs'; |
|
1629 | 1629 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1630 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1630 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1631 | 1631 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1632 | - $data['id_source'] = $id_source; |
|
1633 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1634 | - else $error = true; |
|
1635 | - unset($data); |
|
1636 | - } else $error = true; |
|
1637 | - if ($error) { |
|
1632 | + $data['id_source'] = $id_source; |
|
1633 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1634 | + else $error = true; |
|
1635 | + unset($data); |
|
1636 | + } else $error = true; |
|
1637 | + if ($error) { |
|
1638 | 1638 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
1639 | 1639 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
1640 | 1640 | } else { |
@@ -1650,13 +1650,13 @@ discard block |
||
1650 | 1650 | connect_all($sourceer); |
1651 | 1651 | $sourceer = array(); |
1652 | 1652 | } |
1653 | - } |
|
1653 | + } |
|
1654 | 1654 | } |
1655 | 1655 | // Sleep for xxx microseconds |
1656 | 1656 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
1657 | - } else { |
|
1657 | + } else { |
|
1658 | 1658 | if ($format == 'flightgearmp') { |
1659 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1659 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1660 | 1660 | //@socket_close($r); |
1661 | 1661 | sleep($globalMinFetch); |
1662 | 1662 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1665,9 +1665,9 @@ discard block |
||
1665 | 1665 | break; |
1666 | 1666 | |
1667 | 1667 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1668 | - if (isset($tt[$format])) $tt[$format]++; |
|
1669 | - else $tt[$format] = 0; |
|
1670 | - if ($tt[$format] > 30) { |
|
1668 | + if (isset($tt[$format])) $tt[$format]++; |
|
1669 | + else $tt[$format] = 0; |
|
1670 | + if ($tt[$format] > 30) { |
|
1671 | 1671 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
1672 | 1672 | //@socket_close($r); |
1673 | 1673 | sleep(2); |
@@ -1678,23 +1678,23 @@ discard block |
||
1678 | 1678 | //connect_all($globalSources); |
1679 | 1679 | $tt[$format]=0; |
1680 | 1680 | break; |
1681 | - } |
|
1681 | + } |
|
1682 | + } |
|
1682 | 1683 | } |
1683 | - } |
|
1684 | 1684 | } |
1685 | - } else { |
|
1685 | + } else { |
|
1686 | 1686 | $error = socket_strerror(socket_last_error()); |
1687 | 1687 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1688 | 1688 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
1689 | 1689 | if (isset($globalDebug)) echo "Restarting...\n"; |
1690 | 1690 | // Restart the script if possible |
1691 | 1691 | if (is_array($sockets)) { |
1692 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
1692 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
1693 | 1693 | |
1694 | - foreach ($sockets as $sock) { |
|
1694 | + foreach ($sockets as $sock) { |
|
1695 | 1695 | @socket_shutdown($sock,2); |
1696 | 1696 | @socket_close($sock); |
1697 | - } |
|
1697 | + } |
|
1698 | 1698 | |
1699 | 1699 | } |
1700 | 1700 | if ($globalDebug) echo "Waiting..."; |
@@ -1709,15 +1709,15 @@ discard block |
||
1709 | 1709 | if ($globalDebug) echo "Restart all connections..."; |
1710 | 1710 | connect_all($globalSources); |
1711 | 1711 | } |
1712 | - } |
|
1712 | + } |
|
1713 | 1713 | } |
1714 | 1714 | if ($globalDaemon === false) { |
1715 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1716 | - if (isset($SI)) $SI->checkAll(); |
|
1717 | - if (isset($TI)) $TI->checkAll(); |
|
1718 | - if (isset($MI)) $MI->checkAll(); |
|
1715 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
1716 | + if (isset($SI)) $SI->checkAll(); |
|
1717 | + if (isset($TI)) $TI->checkAll(); |
|
1718 | + if (isset($MI)) $MI->checkAll(); |
|
1719 | + } |
|
1719 | 1720 | } |
1720 | - } |
|
1721 | 1721 | } |
1722 | 1722 | |
1723 | 1723 | ?> |
@@ -3,10 +3,10 @@ discard block |
||
3 | 3 | require_once(dirname(__FILE__).'/class.Common.php'); |
4 | 4 | require_once(dirname(__FILE__).'/class.GeoidHeight.php'); |
5 | 5 | class aprs { |
6 | - private $socket; |
|
7 | - private $connected = false; |
|
6 | + private $socket; |
|
7 | + private $connected = false; |
|
8 | 8 | |
9 | - protected $symbols = array('/!' => 'Police', |
|
9 | + protected $symbols = array('/!' => 'Police', |
|
10 | 10 | '/#' => 'DIGI', |
11 | 11 | '/$' => 'Phone', |
12 | 12 | '/%' => 'DX Cluster', |
@@ -166,13 +166,13 @@ discard block |
||
166 | 166 | '\~' => 'TNC Stream SW'); |
167 | 167 | |
168 | 168 | |
169 | - private function urshift($n, $s) { |
|
169 | + private function urshift($n, $s) { |
|
170 | 170 | return ($n >= 0) ? ($n >> $s) : |
171 | - (($n & 0x7fffffff) >> $s) | |
|
171 | + (($n & 0x7fffffff) >> $s) | |
|
172 | 172 | (0x40000000 >> ($s - 1)); |
173 | - } |
|
173 | + } |
|
174 | 174 | |
175 | - public function parse($input) { |
|
175 | + public function parse($input) { |
|
176 | 176 | global $globalDebug; |
177 | 177 | $debug = false; |
178 | 178 | $result = array(); |
@@ -184,8 +184,8 @@ discard block |
||
184 | 184 | |
185 | 185 | /* Check that end was found and body has at least one byte. */ |
186 | 186 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
187 | - if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; |
|
188 | - return false; |
|
187 | + if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; |
|
188 | + return false; |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | if ($debug) echo 'input : '.$input."\n"; |
@@ -199,34 +199,34 @@ discard block |
||
199 | 199 | /* Parse source, target and path. */ |
200 | 200 | //FLRDF0A52>APRS,qAS,LSTB |
201 | 201 | if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) { |
202 | - $ident = $matches[1]; |
|
203 | - $all_elements = $matches[2]; |
|
204 | - if ($ident == 'AIRCRAFT') { |
|
202 | + $ident = $matches[1]; |
|
203 | + $all_elements = $matches[2]; |
|
204 | + if ($ident == 'AIRCRAFT') { |
|
205 | 205 | $result['format_source'] = 'famaprs'; |
206 | 206 | $result['source_type'] = 'modes'; |
207 | - } elseif ($ident == 'MARINE') { |
|
207 | + } elseif ($ident == 'MARINE') { |
|
208 | 208 | $result['format_source'] = 'famaprs'; |
209 | 209 | $result['source_type'] = 'ais'; |
210 | - } else { |
|
210 | + } else { |
|
211 | 211 | if ($debug) echo 'ident : '.$ident."\n"; |
212 | 212 | $result['ident'] = $ident; |
213 | - } |
|
213 | + } |
|
214 | 214 | } else { |
215 | - if ($debug) 'No ident'."\n"; |
|
216 | - return false; |
|
215 | + if ($debug) 'No ident'."\n"; |
|
216 | + return false; |
|
217 | 217 | } |
218 | 218 | $elements = explode(',',$all_elements); |
219 | 219 | $source = end($elements); |
220 | 220 | $result['source'] = $source; |
221 | 221 | foreach ($elements as $element) { |
222 | - if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
223 | - //echo "ok"; |
|
224 | - //if ($element == 'TCPIP*') return false; |
|
225 | - } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
222 | + if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
223 | + //echo "ok"; |
|
224 | + //if ($element == 'TCPIP*') return false; |
|
225 | + } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
226 | 226 | if ($debug) echo 'element : '.$element."\n"; |
227 | 227 | return false; |
228 | - } |
|
229 | - /* |
|
228 | + } |
|
229 | + /* |
|
230 | 230 | } elseif (preg_match('/^([0-9A-F]{32})$/',$element)) { |
231 | 231 | //echo "ok"; |
232 | 232 | } else { |
@@ -253,48 +253,48 @@ discard block |
||
253 | 253 | $body_parse = substr($body,1); |
254 | 254 | //echo 'Body : '.$body."\n"; |
255 | 255 | if (preg_match('/^;(.){9}\*/',$body,$matches)) { |
256 | - $body_parse = substr($body_parse,10); |
|
257 | - $find = true; |
|
258 | - //echo $body_parse."\n"; |
|
256 | + $body_parse = substr($body_parse,10); |
|
257 | + $find = true; |
|
258 | + //echo $body_parse."\n"; |
|
259 | 259 | } |
260 | 260 | if (preg_match('/^`(.*)\//',$body,$matches)) { |
261 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
262 | - $find = true; |
|
263 | - //echo $body_parse."\n"; |
|
261 | + $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
262 | + $find = true; |
|
263 | + //echo $body_parse."\n"; |
|
264 | 264 | } |
265 | 265 | if (preg_match("/^'(.*)\//",$body,$matches)) { |
266 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
267 | - $find = true; |
|
268 | - //echo $body_parse."\n"; |
|
266 | + $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
267 | + $find = true; |
|
268 | + //echo $body_parse."\n"; |
|
269 | 269 | } |
270 | 270 | if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) { |
271 | - $find = true; |
|
272 | - //print_r($matches); |
|
273 | - $timestamp = $matches[0]; |
|
274 | - if ($matches[4] == 'h') { |
|
271 | + $find = true; |
|
272 | + //print_r($matches); |
|
273 | + $timestamp = $matches[0]; |
|
274 | + if ($matches[4] == 'h') { |
|
275 | 275 | $timestamp = strtotime(date('Ymd').' '.$matches[1].':'.$matches[2].':'.$matches[3]); |
276 | 276 | //echo 'timestamp : '.$timestamp.' - now : '.time()."\n"; |
277 | 277 | /* |
278 | 278 | if (time() + 3900 < $timestamp) $timestamp -= 86400; |
279 | 279 | elseif (time() - 82500 > $timestamp) $timestamp += 86400; |
280 | 280 | */ |
281 | - } elseif ($matches[4] == 'z' || $matches[4] == '/') { |
|
281 | + } elseif ($matches[4] == 'z' || $matches[4] == '/') { |
|
282 | 282 | // This work or not ? |
283 | 283 | $timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]); |
284 | - } |
|
285 | - $body_parse = substr($body_parse,7); |
|
286 | - $result['timestamp'] = $timestamp; |
|
287 | - //echo date('Ymd H:i:s',$timestamp); |
|
284 | + } |
|
285 | + $body_parse = substr($body_parse,7); |
|
286 | + $result['timestamp'] = $timestamp; |
|
287 | + //echo date('Ymd H:i:s',$timestamp); |
|
288 | 288 | } |
289 | 289 | if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) { |
290 | - $find = true; |
|
291 | - $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); |
|
292 | - $body_parse = substr($body_parse,8); |
|
293 | - $result['timestamp'] = $timestamp; |
|
294 | - //echo date('Ymd H:i:s',$timestamp); |
|
290 | + $find = true; |
|
291 | + $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); |
|
292 | + $body_parse = substr($body_parse,8); |
|
293 | + $result['timestamp'] = $timestamp; |
|
294 | + //echo date('Ymd H:i:s',$timestamp); |
|
295 | 295 | } |
296 | 296 | //if (strlen($body_parse) > 19) { |
297 | - 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 | + 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)) { |
|
298 | 298 | $find = true; |
299 | 299 | // 4658.70N/00707.78Ez |
300 | 300 | //print_r(str_split($body_parse)); |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | $lon = intval($lon_deg); |
314 | 314 | if ($lat > 89 || $lon > 179) return false; |
315 | 315 | |
316 | - /* |
|
316 | + /* |
|
317 | 317 | $tmp_5b = str_replace('.','',$lat_min); |
318 | 318 | if (preg_match('/^([0-9]{0,4})( {0,4})$/',$tmp_5b,$matches)) { |
319 | 319 | print_r($matches); |
@@ -327,9 +327,9 @@ discard block |
||
327 | 327 | $result['longitude'] = $longitude; |
328 | 328 | $body_parse = substr($body_parse,18); |
329 | 329 | $body_parse_len = strlen($body_parse); |
330 | - } |
|
331 | - $body_parse_len = strlen($body_parse); |
|
332 | - if ($body_parse_len > 0) { |
|
330 | + } |
|
331 | + $body_parse_len = strlen($body_parse); |
|
332 | + if ($body_parse_len > 0) { |
|
333 | 333 | /* |
334 | 334 | if (!isset($result['timestamp']) && !isset($result['latitude'])) { |
335 | 335 | $body_split = str_split($body); |
@@ -363,95 +363,95 @@ discard block |
||
363 | 363 | if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; |
364 | 364 | if ($symbol_code != '_') { |
365 | 365 | } |
366 | - //$body_parse = substr($body_parse,1); |
|
367 | - //$body_parse = trim($body_parse); |
|
368 | - //$body_parse_len = strlen($body_parse); |
|
369 | - if ($body_parse_len >= 7) { |
|
366 | + //$body_parse = substr($body_parse,1); |
|
367 | + //$body_parse = trim($body_parse); |
|
368 | + //$body_parse_len = strlen($body_parse); |
|
369 | + if ($body_parse_len >= 7) { |
|
370 | 370 | |
371 | - if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
372 | - $course = substr($body_parse,0,3); |
|
373 | - $tmp_s = intval($course); |
|
374 | - if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
|
375 | - $speed = substr($body_parse,4,3); |
|
376 | - if ($speed != '...') { |
|
377 | - //$result['speed'] = round($speed*1.852); |
|
378 | - $result['speed'] = intval($speed); |
|
379 | - } |
|
380 | - $body_parse = substr($body_parse,7); |
|
381 | - } |
|
382 | - // Check PHGR, PHG, RNG |
|
383 | - } |
|
384 | - /* |
|
371 | + if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
372 | + $course = substr($body_parse,0,3); |
|
373 | + $tmp_s = intval($course); |
|
374 | + if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
|
375 | + $speed = substr($body_parse,4,3); |
|
376 | + if ($speed != '...') { |
|
377 | + //$result['speed'] = round($speed*1.852); |
|
378 | + $result['speed'] = intval($speed); |
|
379 | + } |
|
380 | + $body_parse = substr($body_parse,7); |
|
381 | + } |
|
382 | + // Check PHGR, PHG, RNG |
|
383 | + } |
|
384 | + /* |
|
385 | 385 | else if ($body_parse_len > 0) { |
386 | 386 | $rest = $body_parse; |
387 | 387 | } |
388 | 388 | */ |
389 | - if (strlen($body_parse) > 0) { |
|
390 | - if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
391 | - $altitude = intval($matches[1]); |
|
392 | - //$result['altitude'] = round($altitude*0.3048); |
|
393 | - $result['altitude'] = $altitude; |
|
394 | - //$body_parse = trim(substr($body_parse,strlen($matches[0]))); |
|
395 | - $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); |
|
396 | - } |
|
397 | - } |
|
389 | + if (strlen($body_parse) > 0) { |
|
390 | + if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
391 | + $altitude = intval($matches[1]); |
|
392 | + //$result['altitude'] = round($altitude*0.3048); |
|
393 | + $result['altitude'] = $altitude; |
|
394 | + //$body_parse = trim(substr($body_parse,strlen($matches[0]))); |
|
395 | + $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); |
|
396 | + } |
|
397 | + } |
|
398 | 398 | |
399 | - // Telemetry |
|
400 | - /* |
|
399 | + // Telemetry |
|
400 | + /* |
|
401 | 401 | 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)) { |
402 | 402 | // Nothing yet... |
403 | 403 | } |
404 | 404 | */ |
405 | - // DAO |
|
405 | + // DAO |
|
406 | 406 | |
407 | - if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
407 | + if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
408 | 408 | |
409 | - $dao = $matches[1]; |
|
410 | - if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
409 | + $dao = $matches[1]; |
|
410 | + if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
411 | 411 | $dao_split = str_split($dao); |
412 | - $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
|
413 | - $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
|
412 | + $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
|
413 | + $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
|
414 | 414 | |
415 | 415 | if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
416 | 416 | else $result['latitude'] += $lat_off; |
417 | 417 | if ($result['longitude'] < 0) $result['longitude'] -= $lon_off; |
418 | 418 | else $result['longitude'] += $lon_off; |
419 | - } |
|
419 | + } |
|
420 | 420 | |
421 | - $body_parse = substr($body_parse,6); |
|
422 | - } |
|
421 | + $body_parse = substr($body_parse,6); |
|
422 | + } |
|
423 | 423 | |
424 | - if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
424 | + if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
425 | 425 | $result['ident'] = str_replace('_',' ',$matches[1]); |
426 | - } |
|
427 | - if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { |
|
426 | + } |
|
427 | + if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { |
|
428 | 428 | $result['squawk'] = $matches[1]; |
429 | - } |
|
430 | - if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { |
|
429 | + } |
|
430 | + if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { |
|
431 | 431 | $result['aircraft_icao'] = $matches[1]; |
432 | - } |
|
433 | - if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) { |
|
432 | + } |
|
433 | + if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) { |
|
434 | 434 | $result['verticalrate'] = $matches[1]; |
435 | - } |
|
436 | - if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { |
|
435 | + } |
|
436 | + if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { |
|
437 | 437 | $result['typeid'] = $matches[1]; |
438 | - } |
|
439 | - if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) { |
|
438 | + } |
|
439 | + if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) { |
|
440 | 440 | $result['statusid'] = $matches[1]; |
441 | - } |
|
442 | - if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { |
|
441 | + } |
|
442 | + if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { |
|
443 | 443 | $result['imo'] = $matches[1]; |
444 | - } |
|
445 | - if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { |
|
444 | + } |
|
445 | + if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { |
|
446 | 446 | $result['arrival_date'] = $matches[1]; |
447 | - } |
|
448 | - if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
447 | + } |
|
448 | + if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
449 | 449 | $result['arrival_code'] = str_replace('_',' ',$matches[1]); |
450 | - } |
|
451 | - // OGN comment |
|
450 | + } |
|
451 | + // OGN comment |
|
452 | 452 | // echo "Before OGN : ".$body_parse."\n"; |
453 | - //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
|
454 | - if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { |
|
453 | + //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
|
454 | + if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { |
|
455 | 455 | $id = $matches[1]; |
456 | 456 | //$mode = substr($id,0,2); |
457 | 457 | $address = substr($id,2); |
@@ -481,42 +481,42 @@ discard block |
||
481 | 481 | $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
482 | 482 | $result['stealth'] = $stealth; |
483 | 483 | $result['address'] = $address; |
484 | - } |
|
484 | + } |
|
485 | 485 | |
486 | - //Comment |
|
487 | - $result['comment'] = trim($body_parse); |
|
486 | + //Comment |
|
487 | + $result['comment'] = trim($body_parse); |
|
488 | 488 | //} else { |
489 | - // parse weather |
|
490 | - //$body_parse = substr($body_parse,1); |
|
491 | - //$body_parse_len = strlen($body_parse); |
|
492 | - //echo 'weather'."\n"; |
|
493 | - if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
494 | - $result['wind_dir'] = intval($matches[1]); |
|
495 | - $result['wind_speed'] = round(intval($matches[2])*1.60934,1); |
|
496 | - $result['wind_gust'] = round(intval($matches[3])*1.60934,1); |
|
497 | - $result['temp'] = round(5/9*((intval($matches[4]))-32),1); |
|
498 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
499 | - } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
489 | + // parse weather |
|
490 | + //$body_parse = substr($body_parse,1); |
|
491 | + //$body_parse_len = strlen($body_parse); |
|
492 | + //echo 'weather'."\n"; |
|
493 | + if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
494 | + $result['wind_dir'] = intval($matches[1]); |
|
495 | + $result['wind_speed'] = round(intval($matches[2])*1.60934,1); |
|
496 | + $result['wind_gust'] = round(intval($matches[3])*1.60934,1); |
|
497 | + $result['temp'] = round(5/9*((intval($matches[4]))-32),1); |
|
498 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
499 | + } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
500 | 500 | $result['wind_dir'] = intval($matches[1]); |
501 | 501 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
502 | 502 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
503 | 503 | $result['temp'] = round(5/9*(($matches[4])-32),1); |
504 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
505 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
504 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
505 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
506 | 506 | $result['wind_dir'] = intval($matches[1]); |
507 | 507 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
508 | 508 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
509 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
510 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { |
|
509 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
510 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { |
|
511 | 511 | $result['wind_dir'] = intval($matches[1]); |
512 | 512 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
513 | 513 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
514 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
515 | - } |
|
516 | - //if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
|
517 | - //g012t088r000p000P000h38b10110 |
|
518 | - //g011t086r000p000P000h29b10198 |
|
519 | - 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)) { |
|
514 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
515 | + } |
|
516 | + //if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
|
517 | + //g012t088r000p000P000h38b10110 |
|
518 | + //g011t086r000p000P000h29b10198 |
|
519 | + 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)) { |
|
520 | 520 | if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
521 | 521 | if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
522 | 522 | if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
@@ -524,8 +524,8 @@ discard block |
||
524 | 524 | if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); |
525 | 525 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
526 | 526 | if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1); |
527 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
528 | - } 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)) { |
|
527 | + $body_parse = substr($body_parse,strlen($matches[0])); |
|
528 | + } 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)) { |
|
529 | 529 | if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
530 | 530 | if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
531 | 531 | if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
@@ -533,8 +533,8 @@ discard block |
||
533 | 533 | if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); |
534 | 534 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
535 | 535 | if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1); |
536 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
537 | - } 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)) { |
|
536 | + $body_parse = substr($body_parse,strlen($matches[0])); |
|
537 | + } 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)) { |
|
538 | 538 | if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
539 | 539 | if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
540 | 540 | if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
@@ -542,58 +542,58 @@ discard block |
||
542 | 542 | if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); |
543 | 543 | if ($matches[7] != '...') $result['humidity'] = intval($matches[7]); |
544 | 544 | if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1); |
545 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
546 | - } 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)) { |
|
545 | + $body_parse = substr($body_parse,strlen($matches[0])); |
|
546 | + } 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)) { |
|
547 | 547 | if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
548 | 548 | if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
549 | 549 | if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
550 | 550 | if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); |
551 | 551 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
552 | 552 | if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); |
553 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
554 | - } 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)) { |
|
553 | + $body_parse = substr($body_parse,strlen($matches[0])); |
|
554 | + } 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)) { |
|
555 | 555 | if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
556 | 556 | if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
557 | 557 | if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
558 | 558 | if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
559 | 559 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
560 | 560 | if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); |
561 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
562 | - } 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)) { |
|
561 | + $body_parse = substr($body_parse,strlen($matches[0])); |
|
562 | + } 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)) { |
|
563 | 563 | if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
564 | 564 | if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
565 | 565 | if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
566 | 566 | if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
567 | 567 | if ($matches[5] != '...') $result['humidity'] = intval($matches[5]); |
568 | 568 | if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1); |
569 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
570 | - } 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)) { |
|
569 | + $body_parse = substr($body_parse,strlen($matches[0])); |
|
570 | + } 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)) { |
|
571 | 571 | if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
572 | 572 | if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
573 | 573 | if ($matches[2] != '...') $result['humidity'] = intval($matches[3]); |
574 | 574 | if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10),1); |
575 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
576 | - } 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)) { |
|
575 | + $body_parse = substr($body_parse,strlen($matches[0])); |
|
576 | + } 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)) { |
|
577 | 577 | if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
578 | 578 | if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
579 | 579 | if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
580 | 580 | if ($matches[4] != '...') $result['humidity'] = intval($matches[4]); |
581 | 581 | if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); |
582 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
583 | - } |
|
584 | - $result['comment'] = trim($body_parse); |
|
582 | + $body_parse = substr($body_parse,strlen($matches[0])); |
|
583 | + } |
|
584 | + $result['comment'] = trim($body_parse); |
|
585 | 585 | } |
586 | 586 | } else $result['comment'] = trim($body_parse); |
587 | 587 | |
588 | - } |
|
588 | + } |
|
589 | 589 | //} |
590 | 590 | if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
591 | 591 | if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
592 | 592 | if ($debug) print_r($result); |
593 | 593 | return $result; |
594 | - } |
|
594 | + } |
|
595 | 595 | |
596 | - public function connect() { |
|
596 | + public function connect() { |
|
597 | 597 | global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport; |
598 | 598 | $aprs_connect = 0; |
599 | 599 | $aprs_keep = 120; |
@@ -617,24 +617,24 @@ discard block |
||
617 | 617 | socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE,1); |
618 | 618 | while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) { |
619 | 619 | if (strpos($msgin, "$aprs_ssid verified") !== FALSE) { |
620 | - echo 'APRS user verified !'."\n"; |
|
621 | - $this->connected = true; |
|
622 | - return true; |
|
623 | - break; |
|
620 | + echo 'APRS user verified !'."\n"; |
|
621 | + $this->connected = true; |
|
622 | + return true; |
|
623 | + break; |
|
624 | 624 | } |
625 | 625 | if (time()-$authstart > 5) { |
626 | - echo 'APRS timeout'."\n"; |
|
627 | - break; |
|
626 | + echo 'APRS timeout'."\n"; |
|
627 | + break; |
|
628 | 628 | } |
629 | 629 | } |
630 | 630 | } |
631 | - } |
|
631 | + } |
|
632 | 632 | |
633 | - public function disconnect() { |
|
633 | + public function disconnect() { |
|
634 | 634 | socket_close($this->socket); |
635 | - } |
|
635 | + } |
|
636 | 636 | |
637 | - public function send($data) { |
|
637 | + public function send($data) { |
|
638 | 638 | global $globalDebug; |
639 | 639 | if ($this->connected === false) $this->connect(); |
640 | 640 | $send = socket_send( $this->socket , $data , strlen($data),0); |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | socket_close($this->socket); |
644 | 644 | $this->connect(); |
645 | 645 | } |
646 | - } |
|
646 | + } |
|
647 | 647 | } |
648 | 648 | |
649 | 649 | class APRSSpotter extends APRS { |