@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | } |
| 348 | 348 | } |
| 349 | 349 | } |
| 350 | - if ($type == 'aircraft') { |
|
| 350 | + if ($type == 'aircraft') { |
|
| 351 | 351 | if ((isset($globalUsePilot) && $globalUsePilot) || (!isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalVAM) && $globalVAM) || (isset($globalphpVMS) && $globalphpVMS)))) { |
| 352 | 352 | print '<th class="pilot"><span class="nomobile">'._("Pilot name").'</span><span class="mobile">'._("Pilot").'</span></a></th>'; |
| 353 | 353 | } |
@@ -689,7 +689,7 @@ discard block |
||
| 689 | 689 | } elseif(strtolower($current_page) != "currently" && strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive" && strtolower($current_page) != "accident-latest" && strtolower($current_page) != "incident-latest" && strtolower($current_page) != "accident-detailed" && strtolower($current_page) != "incident-detailed"){ |
| 690 | 690 | if ($type == 'aircraft') { |
| 691 | 691 | if (!isset($spotter_item['squawk']) || $spotter_item['squawk'] == 0) { |
| 692 | - $spotter_item['squawk'] = '-'; |
|
| 692 | + $spotter_item['squawk'] = '-'; |
|
| 693 | 693 | } |
| 694 | 694 | if ($spotter_item['image_thumbnail'] != "") |
| 695 | 695 | { |
@@ -728,7 +728,7 @@ discard block |
||
| 728 | 728 | print '</td>'."\n"; |
| 729 | 729 | } else { |
| 730 | 730 | print '<td class="aircraft_thumbnail">'."\n"; |
| 731 | - // print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$globalURL.'/images/placeholder_thumb.png" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>'; |
|
| 731 | + // print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$globalURL.'/images/placeholder_thumb.png" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>'; |
|
| 732 | 732 | //} |
| 733 | 733 | if (!isset($spotter_item['airline_name']) && !isset($spotter_item['aircraft_name'])) { |
| 734 | 734 | print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$globalURL.'/images/placeholder_thumb.png" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '._("Not available").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n"; |
@@ -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 | |
| 20 | 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
@@ -88,14 +88,14 @@ discard block |
||
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
| 91 | - * Executes the SQL statements to get the spotter information |
|
| 92 | - * |
|
| 93 | - * @param String $query the SQL query |
|
| 94 | - * @param Array $params parameter of the query |
|
| 95 | - * @param String $limitQuery the limit query |
|
| 96 | - * @return Array the spotter information |
|
| 97 | - * |
|
| 98 | - */ |
|
| 91 | + * Executes the SQL statements to get the spotter information |
|
| 92 | + * |
|
| 93 | + * @param String $query the SQL query |
|
| 94 | + * @param Array $params parameter of the query |
|
| 95 | + * @param String $limitQuery the limit query |
|
| 96 | + * @return Array the spotter information |
|
| 97 | + * |
|
| 98 | + */ |
|
| 99 | 99 | public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
| 100 | 100 | { |
| 101 | 101 | date_default_timezone_set('UTC'); |
@@ -231,11 +231,11 @@ discard block |
||
| 231 | 231 | |
| 232 | 232 | |
| 233 | 233 | /** |
| 234 | - * Gets all the spotter information based on the latest data entry |
|
| 235 | - * |
|
| 236 | - * @return Array the spotter information |
|
| 237 | - * |
|
| 238 | - */ |
|
| 234 | + * Gets all the spotter information based on the latest data entry |
|
| 235 | + * |
|
| 236 | + * @return Array the spotter information |
|
| 237 | + * |
|
| 238 | + */ |
|
| 239 | 239 | public function getLatestMarineData($limit = '', $sort = '', $filter = array()) |
| 240 | 240 | { |
| 241 | 241 | global $global_marine_query; |
@@ -284,11 +284,11 @@ discard block |
||
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | /** |
| 287 | - * Gets all the spotter information based on the callsign |
|
| 288 | - * |
|
| 289 | - * @return Array the spotter information |
|
| 290 | - * |
|
| 291 | - */ |
|
| 287 | + * Gets all the spotter information based on the callsign |
|
| 288 | + * |
|
| 289 | + * @return Array the spotter information |
|
| 290 | + * |
|
| 291 | + */ |
|
| 292 | 292 | public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array()) |
| 293 | 293 | { |
| 294 | 294 | global $global_marine_query; |
@@ -340,11 +340,11 @@ discard block |
||
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | /** |
| 343 | - * Gets all the marine information based on the type |
|
| 344 | - * |
|
| 345 | - * @return Array the marine information |
|
| 346 | - * |
|
| 347 | - */ |
|
| 343 | + * Gets all the marine information based on the type |
|
| 344 | + * |
|
| 345 | + * @return Array the marine information |
|
| 346 | + * |
|
| 347 | + */ |
|
| 348 | 348 | public function getMarineDataByType($type = '', $limit = '', $sort = '', $filter = array()) |
| 349 | 349 | { |
| 350 | 350 | global $global_marine_query; |
@@ -450,11 +450,11 @@ discard block |
||
| 450 | 450 | } |
| 451 | 451 | |
| 452 | 452 | /** |
| 453 | - * Gets all the marine information based on the captain |
|
| 454 | - * |
|
| 455 | - * @return Array the marine information |
|
| 456 | - * |
|
| 457 | - */ |
|
| 453 | + * Gets all the marine information based on the captain |
|
| 454 | + * |
|
| 455 | + * @return Array the marine information |
|
| 456 | + * |
|
| 457 | + */ |
|
| 458 | 458 | public function getMarineDataByCaptain($captain = '', $limit = '', $sort = '', $filter = array()) |
| 459 | 459 | { |
| 460 | 460 | global $global_marine_query; |
@@ -493,11 +493,11 @@ discard block |
||
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | /** |
| 496 | - * Gets all the marine information based on the race |
|
| 497 | - * |
|
| 498 | - * @return Array the marine information |
|
| 499 | - * |
|
| 500 | - */ |
|
| 496 | + * Gets all the marine information based on the race |
|
| 497 | + * |
|
| 498 | + * @return Array the marine information |
|
| 499 | + * |
|
| 500 | + */ |
|
| 501 | 501 | public function getMarineDataByRace($race = '', $limit = '', $sort = '', $filter = array()) |
| 502 | 502 | { |
| 503 | 503 | global $global_marine_query; |
@@ -536,11 +536,11 @@ discard block |
||
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | /** |
| 539 | - * Count races by captain |
|
| 540 | - * |
|
| 541 | - * @return String Duration of all races |
|
| 542 | - * |
|
| 543 | - */ |
|
| 539 | + * Count races by captain |
|
| 540 | + * |
|
| 541 | + * @return String Duration of all races |
|
| 542 | + * |
|
| 543 | + */ |
|
| 544 | 544 | public function countRacesByCaptain($captain,$filters = array()) |
| 545 | 545 | { |
| 546 | 546 | $captain = filter_var($captain,FILTER_SANITIZE_STRING); |
@@ -556,11 +556,11 @@ discard block |
||
| 556 | 556 | } |
| 557 | 557 | |
| 558 | 558 | /** |
| 559 | - * Count captains by race |
|
| 560 | - * |
|
| 561 | - * @return String Duration of all races |
|
| 562 | - * |
|
| 563 | - */ |
|
| 559 | + * Count captains by race |
|
| 560 | + * |
|
| 561 | + * @return String Duration of all races |
|
| 562 | + * |
|
| 563 | + */ |
|
| 564 | 564 | public function countCaptainsByRace($race,$filters = array()) |
| 565 | 565 | { |
| 566 | 566 | $race = filter_var($race,FILTER_SANITIZE_STRING); |
@@ -576,11 +576,11 @@ discard block |
||
| 576 | 576 | } |
| 577 | 577 | |
| 578 | 578 | /** |
| 579 | - * Gets all boat types that have been used by a captain |
|
| 580 | - * |
|
| 581 | - * @return Array the boat list |
|
| 582 | - * |
|
| 583 | - */ |
|
| 579 | + * Gets all boat types that have been used by a captain |
|
| 580 | + * |
|
| 581 | + * @return Array the boat list |
|
| 582 | + * |
|
| 583 | + */ |
|
| 584 | 584 | public function countAllBoatTypesByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '') |
| 585 | 585 | { |
| 586 | 586 | global $globalDBdriver; |
@@ -625,11 +625,11 @@ discard block |
||
| 625 | 625 | } |
| 626 | 626 | |
| 627 | 627 | /** |
| 628 | - * Gets all boat types that have been used on a race |
|
| 629 | - * |
|
| 630 | - * @return Array the boat list |
|
| 631 | - * |
|
| 632 | - */ |
|
| 628 | + * Gets all boat types that have been used on a race |
|
| 629 | + * |
|
| 630 | + * @return Array the boat list |
|
| 631 | + * |
|
| 632 | + */ |
|
| 633 | 633 | public function countAllBoatTypesByRace($race,$filters = array(),$year = '',$month = '',$day = '') |
| 634 | 634 | { |
| 635 | 635 | global $globalDBdriver; |
@@ -674,11 +674,11 @@ discard block |
||
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | /** |
| 677 | - * Gets race duration by captain |
|
| 678 | - * |
|
| 679 | - * @return String Duration of all race |
|
| 680 | - * |
|
| 681 | - */ |
|
| 677 | + * Gets race duration by captain |
|
| 678 | + * |
|
| 679 | + * @return String Duration of all race |
|
| 680 | + * |
|
| 681 | + */ |
|
| 682 | 682 | public function getRaceDurationByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '') |
| 683 | 683 | { |
| 684 | 684 | global $globalDBdriver; |
@@ -724,11 +724,11 @@ discard block |
||
| 724 | 724 | } |
| 725 | 725 | |
| 726 | 726 | /** |
| 727 | - * Gets a list of all captain names and captain ids |
|
| 728 | - * |
|
| 729 | - * @return Array list of captain names and captain ids |
|
| 730 | - * |
|
| 731 | - */ |
|
| 727 | + * Gets a list of all captain names and captain ids |
|
| 728 | + * |
|
| 729 | + * @return Array list of captain names and captain ids |
|
| 730 | + * |
|
| 731 | + */ |
|
| 732 | 732 | public function getAllCaptainNames($filters = array()) |
| 733 | 733 | { |
| 734 | 734 | $filter_query = $this->getFilter($filters,true,true); |
@@ -742,11 +742,11 @@ discard block |
||
| 742 | 742 | } |
| 743 | 743 | |
| 744 | 744 | /** |
| 745 | - * Gets a list of all race names and race ids |
|
| 746 | - * |
|
| 747 | - * @return Array list of race names and race ids |
|
| 748 | - * |
|
| 749 | - */ |
|
| 745 | + * Gets a list of all race names and race ids |
|
| 746 | + * |
|
| 747 | + * @return Array list of race names and race ids |
|
| 748 | + * |
|
| 749 | + */ |
|
| 750 | 750 | public function getAllRaceNames($filters = array()) |
| 751 | 751 | { |
| 752 | 752 | $filter_query = $this->getFilter($filters,true,true); |
@@ -760,12 +760,12 @@ discard block |
||
| 760 | 760 | } |
| 761 | 761 | |
| 762 | 762 | /** |
| 763 | - * Gets all source name |
|
| 764 | - * |
|
| 765 | - * @param String type format of source |
|
| 766 | - * @return Array list of source name |
|
| 767 | - * |
|
| 768 | - */ |
|
| 763 | + * Gets all source name |
|
| 764 | + * |
|
| 765 | + * @param String type format of source |
|
| 766 | + * @return Array list of source name |
|
| 767 | + * |
|
| 768 | + */ |
|
| 769 | 769 | public function getAllSourceName($type = '',$filters = array()) |
| 770 | 770 | { |
| 771 | 771 | $filter_query = $this->getFilter($filters,true,true); |
@@ -795,11 +795,11 @@ discard block |
||
| 795 | 795 | |
| 796 | 796 | |
| 797 | 797 | /** |
| 798 | - * Gets a list of all idents/callsigns |
|
| 799 | - * |
|
| 800 | - * @return Array list of ident/callsign names |
|
| 801 | - * |
|
| 802 | - */ |
|
| 798 | + * Gets a list of all idents/callsigns |
|
| 799 | + * |
|
| 800 | + * @return Array list of ident/callsign names |
|
| 801 | + * |
|
| 802 | + */ |
|
| 803 | 803 | public function getAllIdents($filters = array()) |
| 804 | 804 | { |
| 805 | 805 | $filter_query = $this->getFilter($filters,true,true); |
@@ -823,11 +823,11 @@ discard block |
||
| 823 | 823 | } |
| 824 | 824 | |
| 825 | 825 | /** |
| 826 | - * Gets all info from a mmsi |
|
| 827 | - * |
|
| 828 | - * @return Array ident |
|
| 829 | - * |
|
| 830 | - */ |
|
| 826 | + * Gets all info from a mmsi |
|
| 827 | + * |
|
| 828 | + * @return Array ident |
|
| 829 | + * |
|
| 830 | + */ |
|
| 831 | 831 | public function getIdentity($mmsi) |
| 832 | 832 | { |
| 833 | 833 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
@@ -840,9 +840,9 @@ discard block |
||
| 840 | 840 | } |
| 841 | 841 | |
| 842 | 842 | /** |
| 843 | - * Add identity |
|
| 844 | - * |
|
| 845 | - */ |
|
| 843 | + * Add identity |
|
| 844 | + * |
|
| 845 | + */ |
|
| 846 | 846 | public function addIdentity($mmsi,$imo,$ident,$callsign,$type) |
| 847 | 847 | { |
| 848 | 848 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
@@ -908,13 +908,13 @@ discard block |
||
| 908 | 908 | } |
| 909 | 909 | |
| 910 | 910 | /** |
| 911 | - * Update ident tracker data |
|
| 912 | - * |
|
| 913 | - * @param String $fammarine_id the ID |
|
| 914 | - * @param String $ident the marine ident |
|
| 915 | - * @return String success or false |
|
| 916 | - * |
|
| 917 | - */ |
|
| 911 | + * Update ident tracker data |
|
| 912 | + * |
|
| 913 | + * @param String $fammarine_id the ID |
|
| 914 | + * @param String $ident the marine ident |
|
| 915 | + * @return String success or false |
|
| 916 | + * |
|
| 917 | + */ |
|
| 918 | 918 | public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
| 919 | 919 | { |
| 920 | 920 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
@@ -929,13 +929,13 @@ discard block |
||
| 929 | 929 | } |
| 930 | 930 | |
| 931 | 931 | /** |
| 932 | - * Update arrival marine data |
|
| 933 | - * |
|
| 934 | - * @param String $fammarine_id the ID |
|
| 935 | - * @param String $arrival_code the marine ident |
|
| 936 | - * @return String success or false |
|
| 937 | - * |
|
| 938 | - */ |
|
| 932 | + * Update arrival marine data |
|
| 933 | + * |
|
| 934 | + * @param String $fammarine_id the ID |
|
| 935 | + * @param String $arrival_code the marine ident |
|
| 936 | + * @return String success or false |
|
| 937 | + * |
|
| 938 | + */ |
|
| 939 | 939 | public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL) |
| 940 | 940 | { |
| 941 | 941 | $query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id'; |
@@ -950,19 +950,19 @@ discard block |
||
| 950 | 950 | } |
| 951 | 951 | |
| 952 | 952 | /** |
| 953 | - * Update Status data |
|
| 954 | - * |
|
| 955 | - * @param String $fammarine_id the ID |
|
| 956 | - * @param String $status_id the marine status id |
|
| 957 | - * @param String $status the marine status |
|
| 958 | - * @return String success or false |
|
| 959 | - * |
|
| 960 | - */ |
|
| 953 | + * Update Status data |
|
| 954 | + * |
|
| 955 | + * @param String $fammarine_id the ID |
|
| 956 | + * @param String $status_id the marine status id |
|
| 957 | + * @param String $status the marine status |
|
| 958 | + * @return String success or false |
|
| 959 | + * |
|
| 960 | + */ |
|
| 961 | 961 | public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') |
| 962 | 962 | { |
| 963 | 963 | |
| 964 | 964 | $query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; |
| 965 | - $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
| 965 | + $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
| 966 | 966 | |
| 967 | 967 | try { |
| 968 | 968 | $sth = $this->db->prepare($query); |
@@ -975,17 +975,17 @@ discard block |
||
| 975 | 975 | |
| 976 | 976 | } |
| 977 | 977 | /** |
| 978 | - * Update latest marine data |
|
| 979 | - * |
|
| 980 | - * @param String $fammarine_id the ID |
|
| 981 | - * @param String $ident the marine ident |
|
| 982 | - * @return String success or false |
|
| 983 | - * |
|
| 984 | - */ |
|
| 978 | + * Update latest marine data |
|
| 979 | + * |
|
| 980 | + * @param String $fammarine_id the ID |
|
| 981 | + * @param String $ident the marine ident |
|
| 982 | + * @return String success or false |
|
| 983 | + * |
|
| 984 | + */ |
|
| 985 | 985 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '',$distance = NULL,$race_rank = NULL, $race_time = NULL) |
| 986 | 986 | { |
| 987 | 987 | $query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed, distance = :distance, race_rank = :race_rank, race_time = :race_time WHERE fammarine_id = :fammarine_id'; |
| 988 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time); |
|
| 988 | + $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time); |
|
| 989 | 989 | |
| 990 | 990 | try { |
| 991 | 991 | $sth = $this->db->prepare($query); |
@@ -999,30 +999,30 @@ discard block |
||
| 999 | 999 | } |
| 1000 | 1000 | |
| 1001 | 1001 | /** |
| 1002 | - * Adds a new marine data |
|
| 1003 | - * |
|
| 1004 | - * @param String $fammarine_id the ID |
|
| 1005 | - * @param String $ident the marine ident |
|
| 1006 | - * @param String $departure_airport_icao the departure airport |
|
| 1007 | - * @param String $arrival_airport_icao the arrival airport |
|
| 1008 | - * @param String $latitude latitude of flight |
|
| 1009 | - * @param String $longitude latitude of flight |
|
| 1010 | - * @param String $waypoints waypoints of flight |
|
| 1011 | - * @param String $heading heading of flight |
|
| 1012 | - * @param String $groundspeed speed of flight |
|
| 1013 | - * @param String $date date of flight |
|
| 1014 | - * @param String $departure_airport_time departure time of flight |
|
| 1015 | - * @param String $arrival_airport_time arrival time of flight |
|
| 1016 | - * @param String $squawk squawk code of flight |
|
| 1017 | - * @param String $route_stop route stop of flight |
|
| 1018 | - * @param String $highlight highlight or not |
|
| 1019 | - * @param String $ModeS ModesS code of flight |
|
| 1020 | - * @param String $registration registration code of flight |
|
| 1021 | - * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
| 1022 | - * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
| 1023 | - * @param String $verticalrate vertival rate of flight |
|
| 1024 | - * @return String success or false |
|
| 1025 | - */ |
|
| 1002 | + * Adds a new marine data |
|
| 1003 | + * |
|
| 1004 | + * @param String $fammarine_id the ID |
|
| 1005 | + * @param String $ident the marine ident |
|
| 1006 | + * @param String $departure_airport_icao the departure airport |
|
| 1007 | + * @param String $arrival_airport_icao the arrival airport |
|
| 1008 | + * @param String $latitude latitude of flight |
|
| 1009 | + * @param String $longitude latitude of flight |
|
| 1010 | + * @param String $waypoints waypoints of flight |
|
| 1011 | + * @param String $heading heading of flight |
|
| 1012 | + * @param String $groundspeed speed of flight |
|
| 1013 | + * @param String $date date of flight |
|
| 1014 | + * @param String $departure_airport_time departure time of flight |
|
| 1015 | + * @param String $arrival_airport_time arrival time of flight |
|
| 1016 | + * @param String $squawk squawk code of flight |
|
| 1017 | + * @param String $route_stop route stop of flight |
|
| 1018 | + * @param String $highlight highlight or not |
|
| 1019 | + * @param String $ModeS ModesS code of flight |
|
| 1020 | + * @param String $registration registration code of flight |
|
| 1021 | + * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
| 1022 | + * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
| 1023 | + * @param String $verticalrate vertival rate of flight |
|
| 1024 | + * @return String success or false |
|
| 1025 | + */ |
|
| 1026 | 1026 | public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '', $captain_id = '',$captain_name = '',$race_id = '', $race_name = '', $distance = '',$race_rank = '', $race_time = '') |
| 1027 | 1027 | { |
| 1028 | 1028 | global $globalURL, $globalMarineImageFetch; |
@@ -1155,11 +1155,11 @@ discard block |
||
| 1155 | 1155 | |
| 1156 | 1156 | |
| 1157 | 1157 | /** |
| 1158 | - * Gets the aircraft ident within the last hour |
|
| 1159 | - * |
|
| 1160 | - * @return String the ident |
|
| 1161 | - * |
|
| 1162 | - */ |
|
| 1158 | + * Gets the aircraft ident within the last hour |
|
| 1159 | + * |
|
| 1160 | + * @return String the ident |
|
| 1161 | + * |
|
| 1162 | + */ |
|
| 1163 | 1163 | public function getIdentFromLastHour($ident) |
| 1164 | 1164 | { |
| 1165 | 1165 | global $globalDBdriver, $globalTimezone; |
@@ -1175,11 +1175,11 @@ discard block |
||
| 1175 | 1175 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 1176 | 1176 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
| 1177 | 1177 | $query_data = array(':ident' => $ident); |
| 1178 | - } |
|
| 1178 | + } |
|
| 1179 | 1179 | |
| 1180 | 1180 | $sth = $this->db->prepare($query); |
| 1181 | 1181 | $sth->execute($query_data); |
| 1182 | - $ident_result=''; |
|
| 1182 | + $ident_result=''; |
|
| 1183 | 1183 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 1184 | 1184 | { |
| 1185 | 1185 | $ident_result = $row['ident']; |
@@ -1190,11 +1190,11 @@ discard block |
||
| 1190 | 1190 | |
| 1191 | 1191 | |
| 1192 | 1192 | /** |
| 1193 | - * Gets the aircraft data from the last 20 seconds |
|
| 1194 | - * |
|
| 1195 | - * @return Array the marine data |
|
| 1196 | - * |
|
| 1197 | - */ |
|
| 1193 | + * Gets the aircraft data from the last 20 seconds |
|
| 1194 | + * |
|
| 1195 | + * @return Array the marine data |
|
| 1196 | + * |
|
| 1197 | + */ |
|
| 1198 | 1198 | public function getRealTimeData($q = '') |
| 1199 | 1199 | { |
| 1200 | 1200 | global $globalDBdriver; |
@@ -1232,11 +1232,11 @@ discard block |
||
| 1232 | 1232 | |
| 1233 | 1233 | |
| 1234 | 1234 | /** |
| 1235 | - * Gets all number of flight over countries |
|
| 1236 | - * |
|
| 1237 | - * @return Array the airline country list |
|
| 1238 | - * |
|
| 1239 | - */ |
|
| 1235 | + * Gets all number of flight over countries |
|
| 1236 | + * |
|
| 1237 | + * @return Array the airline country list |
|
| 1238 | + * |
|
| 1239 | + */ |
|
| 1240 | 1240 | |
| 1241 | 1241 | public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
| 1242 | 1242 | { |
@@ -1309,11 +1309,11 @@ discard block |
||
| 1309 | 1309 | |
| 1310 | 1310 | |
| 1311 | 1311 | /** |
| 1312 | - * Gets all callsigns that have flown over |
|
| 1313 | - * |
|
| 1314 | - * @return Array the callsign list |
|
| 1315 | - * |
|
| 1316 | - */ |
|
| 1312 | + * Gets all callsigns that have flown over |
|
| 1313 | + * |
|
| 1314 | + * @return Array the callsign list |
|
| 1315 | + * |
|
| 1316 | + */ |
|
| 1317 | 1317 | public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
| 1318 | 1318 | { |
| 1319 | 1319 | global $globalDBdriver; |
@@ -1380,11 +1380,11 @@ discard block |
||
| 1380 | 1380 | |
| 1381 | 1381 | |
| 1382 | 1382 | /** |
| 1383 | - * Counts all dates |
|
| 1384 | - * |
|
| 1385 | - * @return Array the date list |
|
| 1386 | - * |
|
| 1387 | - */ |
|
| 1383 | + * Counts all dates |
|
| 1384 | + * |
|
| 1385 | + * @return Array the date list |
|
| 1386 | + * |
|
| 1387 | + */ |
|
| 1388 | 1388 | public function countAllDates($filters = array()) |
| 1389 | 1389 | { |
| 1390 | 1390 | global $globalTimezone, $globalDBdriver; |
@@ -1430,11 +1430,11 @@ discard block |
||
| 1430 | 1430 | |
| 1431 | 1431 | |
| 1432 | 1432 | /** |
| 1433 | - * Counts all dates during the last 7 days |
|
| 1434 | - * |
|
| 1435 | - * @return Array the date list |
|
| 1436 | - * |
|
| 1437 | - */ |
|
| 1433 | + * Counts all dates during the last 7 days |
|
| 1434 | + * |
|
| 1435 | + * @return Array the date list |
|
| 1436 | + * |
|
| 1437 | + */ |
|
| 1438 | 1438 | public function countAllDatesLast7Days($filters = array()) |
| 1439 | 1439 | { |
| 1440 | 1440 | global $globalTimezone, $globalDBdriver; |
@@ -1456,7 +1456,7 @@ discard block |
||
| 1456 | 1456 | $query .= " GROUP BY date_name |
| 1457 | 1457 | ORDER BY date_name ASC"; |
| 1458 | 1458 | $query_data = array(':offset' => $offset); |
| 1459 | - } |
|
| 1459 | + } |
|
| 1460 | 1460 | |
| 1461 | 1461 | $sth = $this->db->prepare($query); |
| 1462 | 1462 | $sth->execute($query_data); |
@@ -1476,11 +1476,11 @@ discard block |
||
| 1476 | 1476 | } |
| 1477 | 1477 | |
| 1478 | 1478 | /** |
| 1479 | - * Counts all dates during the last month |
|
| 1480 | - * |
|
| 1481 | - * @return Array the date list |
|
| 1482 | - * |
|
| 1483 | - */ |
|
| 1479 | + * Counts all dates during the last month |
|
| 1480 | + * |
|
| 1481 | + * @return Array the date list |
|
| 1482 | + * |
|
| 1483 | + */ |
|
| 1484 | 1484 | public function countAllDatesLastMonth($filters = array()) |
| 1485 | 1485 | { |
| 1486 | 1486 | global $globalTimezone, $globalDBdriver; |
@@ -1502,7 +1502,7 @@ discard block |
||
| 1502 | 1502 | $query .= " GROUP BY date_name |
| 1503 | 1503 | ORDER BY date_name ASC"; |
| 1504 | 1504 | $query_data = array(':offset' => $offset); |
| 1505 | - } |
|
| 1505 | + } |
|
| 1506 | 1506 | |
| 1507 | 1507 | $sth = $this->db->prepare($query); |
| 1508 | 1508 | $sth->execute($query_data); |
@@ -1524,11 +1524,11 @@ discard block |
||
| 1524 | 1524 | |
| 1525 | 1525 | |
| 1526 | 1526 | /** |
| 1527 | - * Counts all month |
|
| 1528 | - * |
|
| 1529 | - * @return Array the month list |
|
| 1530 | - * |
|
| 1531 | - */ |
|
| 1527 | + * Counts all month |
|
| 1528 | + * |
|
| 1529 | + * @return Array the month list |
|
| 1530 | + * |
|
| 1531 | + */ |
|
| 1532 | 1532 | public function countAllMonths($filters = array()) |
| 1533 | 1533 | { |
| 1534 | 1534 | global $globalTimezone, $globalDBdriver; |
@@ -1573,11 +1573,11 @@ discard block |
||
| 1573 | 1573 | |
| 1574 | 1574 | |
| 1575 | 1575 | /** |
| 1576 | - * Counts all dates during the last year |
|
| 1577 | - * |
|
| 1578 | - * @return Array the date list |
|
| 1579 | - * |
|
| 1580 | - */ |
|
| 1576 | + * Counts all dates during the last year |
|
| 1577 | + * |
|
| 1578 | + * @return Array the date list |
|
| 1579 | + * |
|
| 1580 | + */ |
|
| 1581 | 1581 | public function countAllMonthsLastYear($filters) |
| 1582 | 1582 | { |
| 1583 | 1583 | global $globalTimezone, $globalDBdriver; |
@@ -1599,7 +1599,7 @@ discard block |
||
| 1599 | 1599 | $query .= " GROUP BY year_name, month_name |
| 1600 | 1600 | ORDER BY year_name, month_name ASC"; |
| 1601 | 1601 | $query_data = array(':offset' => $offset); |
| 1602 | - } |
|
| 1602 | + } |
|
| 1603 | 1603 | |
| 1604 | 1604 | $sth = $this->db->prepare($query); |
| 1605 | 1605 | $sth->execute($query_data); |
@@ -1622,11 +1622,11 @@ discard block |
||
| 1622 | 1622 | |
| 1623 | 1623 | |
| 1624 | 1624 | /** |
| 1625 | - * Counts all hours |
|
| 1626 | - * |
|
| 1627 | - * @return Array the hour list |
|
| 1628 | - * |
|
| 1629 | - */ |
|
| 1625 | + * Counts all hours |
|
| 1626 | + * |
|
| 1627 | + * @return Array the hour list |
|
| 1628 | + * |
|
| 1629 | + */ |
|
| 1630 | 1630 | public function countAllHours($orderby,$filters = array()) |
| 1631 | 1631 | { |
| 1632 | 1632 | global $globalTimezone, $globalDBdriver; |
@@ -1689,11 +1689,11 @@ discard block |
||
| 1689 | 1689 | |
| 1690 | 1690 | |
| 1691 | 1691 | /** |
| 1692 | - * Counts all hours by date |
|
| 1693 | - * |
|
| 1694 | - * @return Array the hour list |
|
| 1695 | - * |
|
| 1696 | - */ |
|
| 1692 | + * Counts all hours by date |
|
| 1693 | + * |
|
| 1694 | + * @return Array the hour list |
|
| 1695 | + * |
|
| 1696 | + */ |
|
| 1697 | 1697 | public function countAllHoursByDate($date, $filters = array()) |
| 1698 | 1698 | { |
| 1699 | 1699 | global $globalTimezone, $globalDBdriver; |
@@ -1737,11 +1737,11 @@ discard block |
||
| 1737 | 1737 | |
| 1738 | 1738 | |
| 1739 | 1739 | /** |
| 1740 | - * Counts all hours by a ident/callsign |
|
| 1741 | - * |
|
| 1742 | - * @return Array the hour list |
|
| 1743 | - * |
|
| 1744 | - */ |
|
| 1740 | + * Counts all hours by a ident/callsign |
|
| 1741 | + * |
|
| 1742 | + * @return Array the hour list |
|
| 1743 | + * |
|
| 1744 | + */ |
|
| 1745 | 1745 | public function countAllHoursByIdent($ident, $filters = array()) |
| 1746 | 1746 | { |
| 1747 | 1747 | global $globalTimezone, $globalDBdriver; |
@@ -1786,11 +1786,11 @@ discard block |
||
| 1786 | 1786 | |
| 1787 | 1787 | |
| 1788 | 1788 | /** |
| 1789 | - * Counts all vessels |
|
| 1790 | - * |
|
| 1791 | - * @return Integer the number of vessels |
|
| 1792 | - * |
|
| 1793 | - */ |
|
| 1789 | + * Counts all vessels |
|
| 1790 | + * |
|
| 1791 | + * @return Integer the number of vessels |
|
| 1792 | + * |
|
| 1793 | + */ |
|
| 1794 | 1794 | public function countOverallMarine($filters = array(),$year = '',$month = '') |
| 1795 | 1795 | { |
| 1796 | 1796 | global $globalDBdriver; |
@@ -1825,11 +1825,11 @@ discard block |
||
| 1825 | 1825 | } |
| 1826 | 1826 | |
| 1827 | 1827 | /** |
| 1828 | - * Counts all vessel type |
|
| 1829 | - * |
|
| 1830 | - * @return Integer the number of vessels |
|
| 1831 | - * |
|
| 1832 | - */ |
|
| 1828 | + * Counts all vessel type |
|
| 1829 | + * |
|
| 1830 | + * @return Integer the number of vessels |
|
| 1831 | + * |
|
| 1832 | + */ |
|
| 1833 | 1833 | public function countOverallMarineTypes($filters = array(),$year = '',$month = '') |
| 1834 | 1834 | { |
| 1835 | 1835 | global $globalDBdriver; |
@@ -1864,11 +1864,11 @@ discard block |
||
| 1864 | 1864 | |
| 1865 | 1865 | |
| 1866 | 1866 | /** |
| 1867 | - * Counts all hours of today |
|
| 1868 | - * |
|
| 1869 | - * @return Array the hour list |
|
| 1870 | - * |
|
| 1871 | - */ |
|
| 1867 | + * Counts all hours of today |
|
| 1868 | + * |
|
| 1869 | + * @return Array the hour list |
|
| 1870 | + * |
|
| 1871 | + */ |
|
| 1872 | 1872 | public function countAllHoursFromToday($filters = array()) |
| 1873 | 1873 | { |
| 1874 | 1874 | global $globalTimezone, $globalDBdriver; |
@@ -1908,12 +1908,12 @@ discard block |
||
| 1908 | 1908 | } |
| 1909 | 1909 | |
| 1910 | 1910 | |
| 1911 | - /** |
|
| 1912 | - * Gets the Barrie Spotter ID based on the FlightAware ID |
|
| 1913 | - * |
|
| 1914 | - * @return Integer the Barrie Spotter ID |
|
| 1911 | + /** |
|
| 1912 | + * Gets the Barrie Spotter ID based on the FlightAware ID |
|
| 1913 | + * |
|
| 1914 | + * @return Integer the Barrie Spotter ID |
|
| 1915 | 1915 | q * |
| 1916 | - */ |
|
| 1916 | + */ |
|
| 1917 | 1917 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
| 1918 | 1918 | { |
| 1919 | 1919 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
@@ -1934,13 +1934,13 @@ discard block |
||
| 1934 | 1934 | |
| 1935 | 1935 | |
| 1936 | 1936 | /** |
| 1937 | - * Parses a date string |
|
| 1938 | - * |
|
| 1939 | - * @param String $dateString the date string |
|
| 1940 | - * @param String $timezone the timezone of a user |
|
| 1941 | - * @return Array the time information |
|
| 1942 | - * |
|
| 1943 | - */ |
|
| 1937 | + * Parses a date string |
|
| 1938 | + * |
|
| 1939 | + * @param String $dateString the date string |
|
| 1940 | + * @param String $timezone the timezone of a user |
|
| 1941 | + * @return Array the time information |
|
| 1942 | + * |
|
| 1943 | + */ |
|
| 1944 | 1944 | public function parseDateString($dateString, $timezone = '') |
| 1945 | 1945 | { |
| 1946 | 1946 | $time_array = array(); |
@@ -1973,12 +1973,12 @@ discard block |
||
| 1973 | 1973 | } |
| 1974 | 1974 | |
| 1975 | 1975 | /** |
| 1976 | - * Parses the direction degrees to working |
|
| 1977 | - * |
|
| 1978 | - * @param Float $direction the direction in degrees |
|
| 1979 | - * @return Array the direction information |
|
| 1980 | - * |
|
| 1981 | - */ |
|
| 1976 | + * Parses the direction degrees to working |
|
| 1977 | + * |
|
| 1978 | + * @param Float $direction the direction in degrees |
|
| 1979 | + * @return Array the direction information |
|
| 1980 | + * |
|
| 1981 | + */ |
|
| 1982 | 1982 | public function parseDirection($direction = 0) |
| 1983 | 1983 | { |
| 1984 | 1984 | if ($direction == '') $direction = 0; |
@@ -2057,12 +2057,12 @@ discard block |
||
| 2057 | 2057 | |
| 2058 | 2058 | |
| 2059 | 2059 | /** |
| 2060 | - * Gets Country from latitude/longitude |
|
| 2061 | - * |
|
| 2062 | - * @param Float $latitude latitute of the flight |
|
| 2063 | - * @param Float $longitude longitute of the flight |
|
| 2064 | - * @return String the countrie |
|
| 2065 | - */ |
|
| 2060 | + * Gets Country from latitude/longitude |
|
| 2061 | + * |
|
| 2062 | + * @param Float $latitude latitute of the flight |
|
| 2063 | + * @param Float $longitude longitute of the flight |
|
| 2064 | + * @return String the countrie |
|
| 2065 | + */ |
|
| 2066 | 2066 | public function getCountryFromLatitudeLongitude($latitude,$longitude) |
| 2067 | 2067 | { |
| 2068 | 2068 | global $globalDBdriver, $globalDebug; |
@@ -2099,11 +2099,11 @@ discard block |
||
| 2099 | 2099 | } |
| 2100 | 2100 | |
| 2101 | 2101 | /** |
| 2102 | - * Gets Country from iso2 |
|
| 2103 | - * |
|
| 2104 | - * @param String $iso2 ISO2 country code |
|
| 2105 | - * @return String the countrie |
|
| 2106 | - */ |
|
| 2102 | + * Gets Country from iso2 |
|
| 2103 | + * |
|
| 2104 | + * @param String $iso2 ISO2 country code |
|
| 2105 | + * @return String the countrie |
|
| 2106 | + */ |
|
| 2107 | 2107 | public function getCountryFromISO2($iso2) |
| 2108 | 2108 | { |
| 2109 | 2109 | global $globalDBdriver, $globalDebug; |
@@ -2132,12 +2132,12 @@ discard block |
||
| 2132 | 2132 | |
| 2133 | 2133 | |
| 2134 | 2134 | /** |
| 2135 | - * Gets the short url from bit.ly |
|
| 2136 | - * |
|
| 2137 | - * @param String $url the full url |
|
| 2138 | - * @return String the bit.ly url |
|
| 2139 | - * |
|
| 2140 | - */ |
|
| 2135 | + * Gets the short url from bit.ly |
|
| 2136 | + * |
|
| 2137 | + * @param String $url the full url |
|
| 2138 | + * @return String the bit.ly url |
|
| 2139 | + * |
|
| 2140 | + */ |
|
| 2141 | 2141 | public function getBitlyURL($url) |
| 2142 | 2142 | { |
| 2143 | 2143 | global $globalBitlyAccessToken; |
@@ -2164,11 +2164,11 @@ discard block |
||
| 2164 | 2164 | |
| 2165 | 2165 | |
| 2166 | 2166 | /** |
| 2167 | - * Gets all vessels types that have flown over |
|
| 2168 | - * |
|
| 2169 | - * @return Array the vessel type list |
|
| 2170 | - * |
|
| 2171 | - */ |
|
| 2167 | + * Gets all vessels types that have flown over |
|
| 2168 | + * |
|
| 2169 | + * @return Array the vessel type list |
|
| 2170 | + * |
|
| 2171 | + */ |
|
| 2172 | 2172 | public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
| 2173 | 2173 | { |
| 2174 | 2174 | global $globalDBdriver; |
@@ -2234,11 +2234,11 @@ discard block |
||
| 2234 | 2234 | } |
| 2235 | 2235 | |
| 2236 | 2236 | /** |
| 2237 | - * Gets all the tracker information |
|
| 2238 | - * |
|
| 2239 | - * @return Array the tracker information |
|
| 2240 | - * |
|
| 2241 | - */ |
|
| 2237 | + * Gets all the tracker information |
|
| 2238 | + * |
|
| 2239 | + * @return Array the tracker information |
|
| 2240 | + * |
|
| 2241 | + */ |
|
| 2242 | 2242 | public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array()) |
| 2243 | 2243 | { |
| 2244 | 2244 | global $globalTimezone, $globalDBdriver; |
@@ -2367,11 +2367,11 @@ discard block |
||
| 2367 | 2367 | } |
| 2368 | 2368 | |
| 2369 | 2369 | /** |
| 2370 | - * Check marine by id |
|
| 2371 | - * |
|
| 2372 | - * @return String the ident |
|
| 2373 | - * |
|
| 2374 | - */ |
|
| 2370 | + * Check marine by id |
|
| 2371 | + * |
|
| 2372 | + * @return String the ident |
|
| 2373 | + * |
|
| 2374 | + */ |
|
| 2375 | 2375 | public function checkId($id) |
| 2376 | 2376 | { |
| 2377 | 2377 | global $globalDBdriver, $globalTimezone; |
@@ -13,10 +13,10 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | - * Get SQL query part for filter used |
|
| 17 | - * @param Array $filter the filter |
|
| 18 | - * @return Array the SQL part |
|
| 19 | - */ |
|
| 16 | + * Get SQL query part for filter used |
|
| 17 | + * @param Array $filter the filter |
|
| 18 | + * @return Array the SQL part |
|
| 19 | + */ |
|
| 20 | 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 22 | 22 | $filters = array(); |
@@ -96,11 +96,11 @@ discard block |
||
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
| 99 | - * Gets all the spotter information based on the latest data entry |
|
| 100 | - * |
|
| 101 | - * @return Array the spotter information |
|
| 102 | - * |
|
| 103 | - */ |
|
| 99 | + * Gets all the spotter information based on the latest data entry |
|
| 100 | + * |
|
| 101 | + * @return Array the spotter information |
|
| 102 | + * |
|
| 103 | + */ |
|
| 104 | 104 | public function getLiveMarineData($limit = '', $sort = '', $filter = array()) |
| 105 | 105 | { |
| 106 | 106 | global $globalDBdriver, $globalLiveInterval; |
@@ -143,11 +143,11 @@ discard block |
||
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** |
| 146 | - * Gets Minimal Live Spotter data |
|
| 147 | - * |
|
| 148 | - * @return Array the spotter information |
|
| 149 | - * |
|
| 150 | - */ |
|
| 146 | + * Gets Minimal Live Spotter data |
|
| 147 | + * |
|
| 148 | + * @return Array the spotter information |
|
| 149 | + * |
|
| 150 | + */ |
|
| 151 | 151 | public function getMinLiveMarineData($filter = array()) |
| 152 | 152 | { |
| 153 | 153 | global $globalDBdriver, $globalLiveInterval; |
@@ -177,11 +177,11 @@ discard block |
||
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /** |
| 180 | - * Gets Minimal Live Spotter data since xx seconds |
|
| 181 | - * |
|
| 182 | - * @return Array the spotter information |
|
| 183 | - * |
|
| 184 | - */ |
|
| 180 | + * Gets Minimal Live Spotter data since xx seconds |
|
| 181 | + * |
|
| 182 | + * @return Array the spotter information |
|
| 183 | + * |
|
| 184 | + */ |
|
| 185 | 185 | public function getMinLastLiveMarineData($coord = array(),$filter = array(), $limit = false, $id = '') |
| 186 | 186 | { |
| 187 | 187 | global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive; |
@@ -261,11 +261,11 @@ discard block |
||
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | /** |
| 264 | - * Gets number of latest data entry |
|
| 265 | - * |
|
| 266 | - * @return String number of entry |
|
| 267 | - * |
|
| 268 | - */ |
|
| 264 | + * Gets number of latest data entry |
|
| 265 | + * |
|
| 266 | + * @return String number of entry |
|
| 267 | + * |
|
| 268 | + */ |
|
| 269 | 269 | public function getLiveMarineCount($filter = array()) |
| 270 | 270 | { |
| 271 | 271 | global $globalDBdriver, $globalLiveInterval; |
@@ -290,11 +290,11 @@ discard block |
||
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | /** |
| 293 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 294 | - * |
|
| 295 | - * @return Array the spotter information |
|
| 296 | - * |
|
| 297 | - */ |
|
| 293 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 294 | + * |
|
| 295 | + * @return Array the spotter information |
|
| 296 | + * |
|
| 297 | + */ |
|
| 298 | 298 | public function getLiveMarineDatabyCoord($coord, $filter = array()) |
| 299 | 299 | { |
| 300 | 300 | global $globalDBdriver, $globalLiveInterval; |
@@ -318,11 +318,11 @@ discard block |
||
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | /** |
| 321 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 322 | - * |
|
| 323 | - * @return Array the spotter information |
|
| 324 | - * |
|
| 325 | - */ |
|
| 321 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 322 | + * |
|
| 323 | + * @return Array the spotter information |
|
| 324 | + * |
|
| 325 | + */ |
|
| 326 | 326 | public function getMinLiveMarineDatabyCoord($coord, $filter = array()) |
| 327 | 327 | { |
| 328 | 328 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -391,11 +391,11 @@ discard block |
||
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | /** |
| 394 | - * Gets all the spotter information based on a user's latitude and longitude |
|
| 395 | - * |
|
| 396 | - * @return Array the spotter information |
|
| 397 | - * |
|
| 398 | - */ |
|
| 394 | + * Gets all the spotter information based on a user's latitude and longitude |
|
| 395 | + * |
|
| 396 | + * @return Array the spotter information |
|
| 397 | + * |
|
| 398 | + */ |
|
| 399 | 399 | public function getLatestMarineForLayar($lat, $lng, $radius, $interval) |
| 400 | 400 | { |
| 401 | 401 | $Marine = new Marine($this->db); |
@@ -408,75 +408,75 @@ discard block |
||
| 408 | 408 | if ($lng != '') |
| 409 | 409 | { |
| 410 | 410 | if (!is_numeric($lng)) |
| 411 | - { |
|
| 412 | - return false; |
|
| 413 | - } |
|
| 414 | - } |
|
| 415 | - |
|
| 416 | - if ($radius != '') |
|
| 417 | - { |
|
| 418 | - if (!is_numeric($radius)) |
|
| 419 | - { |
|
| 420 | - return false; |
|
| 421 | - } |
|
| 422 | - } |
|
| 411 | + { |
|
| 412 | + return false; |
|
| 413 | + } |
|
| 414 | + } |
|
| 415 | + |
|
| 416 | + if ($radius != '') |
|
| 417 | + { |
|
| 418 | + if (!is_numeric($radius)) |
|
| 419 | + { |
|
| 420 | + return false; |
|
| 421 | + } |
|
| 422 | + } |
|
| 423 | 423 | $additional_query = ''; |
| 424 | 424 | if ($interval != '') |
| 425 | - { |
|
| 426 | - if (!is_string($interval)) |
|
| 427 | - { |
|
| 428 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 429 | - return false; |
|
| 430 | - } else { |
|
| 431 | - if ($interval == '1m') |
|
| 432 | - { |
|
| 433 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 434 | - } else if ($interval == '15m'){ |
|
| 435 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
| 436 | - } |
|
| 437 | - } |
|
| 438 | - } else { |
|
| 439 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 440 | - } |
|
| 441 | - |
|
| 442 | - $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
| 425 | + { |
|
| 426 | + if (!is_string($interval)) |
|
| 427 | + { |
|
| 428 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 429 | + return false; |
|
| 430 | + } else { |
|
| 431 | + if ($interval == '1m') |
|
| 432 | + { |
|
| 433 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 434 | + } else if ($interval == '15m'){ |
|
| 435 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
| 436 | + } |
|
| 437 | + } |
|
| 438 | + } else { |
|
| 439 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 440 | + } |
|
| 441 | + |
|
| 442 | + $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
| 443 | 443 | WHERE marine_live.latitude <> '' |
| 444 | 444 | AND marine_live.longitude <> '' |
| 445 | 445 | ".$additional_query." |
| 446 | 446 | HAVING distance < :radius |
| 447 | 447 | ORDER BY distance"; |
| 448 | 448 | |
| 449 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 449 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 450 | 450 | |
| 451 | - return $spotter_array; |
|
| 452 | - } |
|
| 451 | + return $spotter_array; |
|
| 452 | + } |
|
| 453 | 453 | |
| 454 | 454 | |
| 455 | - /** |
|
| 456 | - * Gets all the spotter information based on a particular callsign |
|
| 457 | - * |
|
| 458 | - * @return Array the spotter information |
|
| 459 | - * |
|
| 460 | - */ |
|
| 455 | + /** |
|
| 456 | + * Gets all the spotter information based on a particular callsign |
|
| 457 | + * |
|
| 458 | + * @return Array the spotter information |
|
| 459 | + * |
|
| 460 | + */ |
|
| 461 | 461 | public function getLastLiveMarineDataByIdent($ident) |
| 462 | 462 | { |
| 463 | 463 | $Marine = new Marine($this->db); |
| 464 | 464 | date_default_timezone_set('UTC'); |
| 465 | 465 | |
| 466 | 466 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 467 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 467 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 468 | 468 | |
| 469 | 469 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
| 470 | 470 | |
| 471 | 471 | return $spotter_array; |
| 472 | 472 | } |
| 473 | 473 | |
| 474 | - /** |
|
| 475 | - * Gets all the spotter information based on a particular callsign |
|
| 476 | - * |
|
| 477 | - * @return Array the spotter information |
|
| 478 | - * |
|
| 479 | - */ |
|
| 474 | + /** |
|
| 475 | + * Gets all the spotter information based on a particular callsign |
|
| 476 | + * |
|
| 477 | + * @return Array the spotter information |
|
| 478 | + * |
|
| 479 | + */ |
|
| 480 | 480 | public function getDateLiveMarineDataByIdent($ident,$date) |
| 481 | 481 | { |
| 482 | 482 | $Marine = new Marine($this->db); |
@@ -489,11 +489,11 @@ discard block |
||
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | /** |
| 492 | - * Gets all the spotter information based on a particular MMSI |
|
| 493 | - * |
|
| 494 | - * @return Array the spotter information |
|
| 495 | - * |
|
| 496 | - */ |
|
| 492 | + * Gets all the spotter information based on a particular MMSI |
|
| 493 | + * |
|
| 494 | + * @return Array the spotter information |
|
| 495 | + * |
|
| 496 | + */ |
|
| 497 | 497 | public function getDateLiveMarineDataByMMSI($mmsi,$date) |
| 498 | 498 | { |
| 499 | 499 | $Marine = new Marine($this->db); |
@@ -505,51 +505,51 @@ discard block |
||
| 505 | 505 | return $spotter_array; |
| 506 | 506 | } |
| 507 | 507 | |
| 508 | - /** |
|
| 509 | - * Gets last spotter information based on a particular callsign |
|
| 510 | - * |
|
| 511 | - * @return Array the spotter information |
|
| 512 | - * |
|
| 513 | - */ |
|
| 508 | + /** |
|
| 509 | + * Gets last spotter information based on a particular callsign |
|
| 510 | + * |
|
| 511 | + * @return Array the spotter information |
|
| 512 | + * |
|
| 513 | + */ |
|
| 514 | 514 | public function getLastLiveMarineDataById($id) |
| 515 | 515 | { |
| 516 | 516 | $Marine = new Marine($this->db); |
| 517 | 517 | date_default_timezone_set('UTC'); |
| 518 | 518 | |
| 519 | 519 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 520 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 520 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 521 | 521 | |
| 522 | 522 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
| 523 | 523 | |
| 524 | 524 | return $spotter_array; |
| 525 | 525 | } |
| 526 | 526 | |
| 527 | - /** |
|
| 528 | - * Gets last spotter information based on a particular callsign |
|
| 529 | - * |
|
| 530 | - * @return Array the spotter information |
|
| 531 | - * |
|
| 532 | - */ |
|
| 527 | + /** |
|
| 528 | + * Gets last spotter information based on a particular callsign |
|
| 529 | + * |
|
| 530 | + * @return Array the spotter information |
|
| 531 | + * |
|
| 532 | + */ |
|
| 533 | 533 | public function getDateLiveMarineDataById($id,$date) |
| 534 | 534 | { |
| 535 | 535 | $Marine = new Marine($this->db); |
| 536 | 536 | date_default_timezone_set('UTC'); |
| 537 | 537 | |
| 538 | 538 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 539 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 540 | - $date = date('c',$date); |
|
| 539 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 540 | + $date = date('c',$date); |
|
| 541 | 541 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
| 542 | 542 | |
| 543 | 543 | return $spotter_array; |
| 544 | 544 | } |
| 545 | 545 | |
| 546 | 546 | |
| 547 | - /** |
|
| 548 | - * Gets all the spotter information based on a particular id |
|
| 549 | - * |
|
| 550 | - * @return Array the spotter information |
|
| 551 | - * |
|
| 552 | - */ |
|
| 547 | + /** |
|
| 548 | + * Gets all the spotter information based on a particular id |
|
| 549 | + * |
|
| 550 | + * @return Array the spotter information |
|
| 551 | + * |
|
| 552 | + */ |
|
| 553 | 553 | public function getAllLiveMarineDataById($id,$liveinterval = false) |
| 554 | 554 | { |
| 555 | 555 | global $globalDBdriver, $globalLiveInterval; |
@@ -577,18 +577,18 @@ discard block |
||
| 577 | 577 | return $spotter_array; |
| 578 | 578 | } |
| 579 | 579 | |
| 580 | - /** |
|
| 581 | - * Gets all the spotter information based on a particular ident |
|
| 582 | - * |
|
| 583 | - * @return Array the spotter information |
|
| 584 | - * |
|
| 585 | - */ |
|
| 580 | + /** |
|
| 581 | + * Gets all the spotter information based on a particular ident |
|
| 582 | + * |
|
| 583 | + * @return Array the spotter information |
|
| 584 | + * |
|
| 585 | + */ |
|
| 586 | 586 | public function getAllLiveMarineDataByIdent($ident) |
| 587 | 587 | { |
| 588 | 588 | date_default_timezone_set('UTC'); |
| 589 | 589 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 590 | 590 | $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
| 591 | - try { |
|
| 591 | + try { |
|
| 592 | 592 | |
| 593 | 593 | $sth = $this->db->prepare($query); |
| 594 | 594 | $sth->execute(array(':ident' => $ident)); |
@@ -602,23 +602,23 @@ discard block |
||
| 602 | 602 | |
| 603 | 603 | |
| 604 | 604 | /** |
| 605 | - * Deletes all info in the table |
|
| 606 | - * |
|
| 607 | - * @return String success or false |
|
| 608 | - * |
|
| 609 | - */ |
|
| 605 | + * Deletes all info in the table |
|
| 606 | + * |
|
| 607 | + * @return String success or false |
|
| 608 | + * |
|
| 609 | + */ |
|
| 610 | 610 | public function deleteLiveMarineData() |
| 611 | 611 | { |
| 612 | 612 | global $globalDBdriver; |
| 613 | 613 | if ($globalDBdriver == 'mysql') { |
| 614 | 614 | //$query = "DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= marine_live.date"; |
| 615 | 615 | $query = 'DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= marine_live.date'; |
| 616 | - //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)"; |
|
| 616 | + //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)"; |
|
| 617 | 617 | } else { |
| 618 | 618 | $query = "DELETE FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date"; |
| 619 | 619 | } |
| 620 | 620 | |
| 621 | - try { |
|
| 621 | + try { |
|
| 622 | 622 | |
| 623 | 623 | $sth = $this->db->prepare($query); |
| 624 | 624 | $sth->execute(); |
@@ -630,18 +630,18 @@ discard block |
||
| 630 | 630 | } |
| 631 | 631 | |
| 632 | 632 | /** |
| 633 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 634 | - * |
|
| 635 | - * @return String success or false |
|
| 636 | - * |
|
| 637 | - */ |
|
| 633 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 634 | + * |
|
| 635 | + * @return String success or false |
|
| 636 | + * |
|
| 637 | + */ |
|
| 638 | 638 | public function deleteLiveMarineDataNotUpdated() |
| 639 | 639 | { |
| 640 | 640 | global $globalDBdriver, $globalDebug; |
| 641 | 641 | if ($globalDBdriver == 'mysql') { |
| 642 | 642 | //$query = 'SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < marine_live.date) LIMIT 800 OFFSET 0'; |
| 643 | - $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
| 644 | - try { |
|
| 643 | + $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
| 644 | + try { |
|
| 645 | 645 | |
| 646 | 646 | $sth = $this->db->prepare($query); |
| 647 | 647 | $sth->execute(); |
@@ -649,8 +649,8 @@ discard block |
||
| 649 | 649 | return "error"; |
| 650 | 650 | } |
| 651 | 651 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
| 652 | - $i = 0; |
|
| 653 | - $j =0; |
|
| 652 | + $i = 0; |
|
| 653 | + $j =0; |
|
| 654 | 654 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 655 | 655 | foreach($all as $row) |
| 656 | 656 | { |
@@ -658,20 +658,20 @@ discard block |
||
| 658 | 658 | $j++; |
| 659 | 659 | if ($j == 30) { |
| 660 | 660 | if ($globalDebug) echo "."; |
| 661 | - try { |
|
| 661 | + try { |
|
| 662 | 662 | |
| 663 | 663 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 664 | 664 | $sth->execute(); |
| 665 | 665 | } catch(PDOException $e) { |
| 666 | 666 | return "error"; |
| 667 | 667 | } |
| 668 | - $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
| 669 | - $j = 0; |
|
| 668 | + $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
| 669 | + $j = 0; |
|
| 670 | 670 | } |
| 671 | 671 | $query_delete .= "'".$row['fammarine_id']."',"; |
| 672 | 672 | } |
| 673 | 673 | if ($i > 0) { |
| 674 | - try { |
|
| 674 | + try { |
|
| 675 | 675 | |
| 676 | 676 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 677 | 677 | $sth->execute(); |
@@ -682,9 +682,9 @@ discard block |
||
| 682 | 682 | return "success"; |
| 683 | 683 | } elseif ($globalDBdriver == 'pgsql') { |
| 684 | 684 | //$query = "SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < marine_live.date) LIMIT 800 OFFSET 0"; |
| 685 | - //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
| 686 | - $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
| 687 | - try { |
|
| 685 | + //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
| 686 | + $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
| 687 | + try { |
|
| 688 | 688 | |
| 689 | 689 | $sth = $this->db->prepare($query); |
| 690 | 690 | $sth->execute(); |
@@ -728,17 +728,17 @@ discard block |
||
| 728 | 728 | } |
| 729 | 729 | |
| 730 | 730 | /** |
| 731 | - * Deletes all info in the table for an ident |
|
| 732 | - * |
|
| 733 | - * @return String success or false |
|
| 734 | - * |
|
| 735 | - */ |
|
| 731 | + * Deletes all info in the table for an ident |
|
| 732 | + * |
|
| 733 | + * @return String success or false |
|
| 734 | + * |
|
| 735 | + */ |
|
| 736 | 736 | public function deleteLiveMarineDataByIdent($ident) |
| 737 | 737 | { |
| 738 | 738 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 739 | 739 | $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
| 740 | 740 | |
| 741 | - try { |
|
| 741 | + try { |
|
| 742 | 742 | |
| 743 | 743 | $sth = $this->db->prepare($query); |
| 744 | 744 | $sth->execute(array(':ident' => $ident)); |
@@ -750,17 +750,17 @@ discard block |
||
| 750 | 750 | } |
| 751 | 751 | |
| 752 | 752 | /** |
| 753 | - * Deletes all info in the table for an id |
|
| 754 | - * |
|
| 755 | - * @return String success or false |
|
| 756 | - * |
|
| 757 | - */ |
|
| 753 | + * Deletes all info in the table for an id |
|
| 754 | + * |
|
| 755 | + * @return String success or false |
|
| 756 | + * |
|
| 757 | + */ |
|
| 758 | 758 | public function deleteLiveMarineDataById($id) |
| 759 | 759 | { |
| 760 | 760 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 761 | 761 | $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
| 762 | 762 | |
| 763 | - try { |
|
| 763 | + try { |
|
| 764 | 764 | |
| 765 | 765 | $sth = $this->db->prepare($query); |
| 766 | 766 | $sth->execute(array(':id' => $id)); |
@@ -773,11 +773,11 @@ discard block |
||
| 773 | 773 | |
| 774 | 774 | |
| 775 | 775 | /** |
| 776 | - * Gets the marine races |
|
| 777 | - * |
|
| 778 | - * @return Array all races |
|
| 779 | - * |
|
| 780 | - */ |
|
| 776 | + * Gets the marine races |
|
| 777 | + * |
|
| 778 | + * @return Array all races |
|
| 779 | + * |
|
| 780 | + */ |
|
| 781 | 781 | public function getAllRaces() |
| 782 | 782 | { |
| 783 | 783 | $query = 'SELECT DISTINCT marine_live.race_id, marine_live.race_name FROM marine_live ORDER BY marine_live.race_name'; |
@@ -787,11 +787,11 @@ discard block |
||
| 787 | 787 | } |
| 788 | 788 | |
| 789 | 789 | /** |
| 790 | - * Gets the aircraft ident within the last hour |
|
| 791 | - * |
|
| 792 | - * @return String the ident |
|
| 793 | - * |
|
| 794 | - */ |
|
| 790 | + * Gets the aircraft ident within the last hour |
|
| 791 | + * |
|
| 792 | + * @return String the ident |
|
| 793 | + * |
|
| 794 | + */ |
|
| 795 | 795 | public function getIdentFromLastHour($ident) |
| 796 | 796 | { |
| 797 | 797 | global $globalDBdriver, $globalTimezone; |
@@ -817,14 +817,14 @@ discard block |
||
| 817 | 817 | $ident_result = $row['ident']; |
| 818 | 818 | } |
| 819 | 819 | return $ident_result; |
| 820 | - } |
|
| 820 | + } |
|
| 821 | 821 | |
| 822 | 822 | /** |
| 823 | - * Check recent aircraft |
|
| 824 | - * |
|
| 825 | - * @return String the ident |
|
| 826 | - * |
|
| 827 | - */ |
|
| 823 | + * Check recent aircraft |
|
| 824 | + * |
|
| 825 | + * @return String the ident |
|
| 826 | + * |
|
| 827 | + */ |
|
| 828 | 828 | public function checkIdentRecent($ident) |
| 829 | 829 | { |
| 830 | 830 | global $globalDBdriver, $globalTimezone; |
@@ -850,14 +850,14 @@ discard block |
||
| 850 | 850 | $ident_result = $row['fammarine_id']; |
| 851 | 851 | } |
| 852 | 852 | return $ident_result; |
| 853 | - } |
|
| 853 | + } |
|
| 854 | 854 | |
| 855 | 855 | /** |
| 856 | - * Check recent aircraft by id |
|
| 857 | - * |
|
| 858 | - * @return String the ident |
|
| 859 | - * |
|
| 860 | - */ |
|
| 856 | + * Check recent aircraft by id |
|
| 857 | + * |
|
| 858 | + * @return String the ident |
|
| 859 | + * |
|
| 860 | + */ |
|
| 861 | 861 | public function checkIdRecent($id) |
| 862 | 862 | { |
| 863 | 863 | global $globalDBdriver, $globalTimezone; |
@@ -883,14 +883,14 @@ discard block |
||
| 883 | 883 | $ident_result = $row['fammarine_id']; |
| 884 | 884 | } |
| 885 | 885 | return $ident_result; |
| 886 | - } |
|
| 886 | + } |
|
| 887 | 887 | |
| 888 | 888 | /** |
| 889 | - * Check recent aircraft by mmsi |
|
| 890 | - * |
|
| 891 | - * @return String the ident |
|
| 892 | - * |
|
| 893 | - */ |
|
| 889 | + * Check recent aircraft by mmsi |
|
| 890 | + * |
|
| 891 | + * @return String the ident |
|
| 892 | + * |
|
| 893 | + */ |
|
| 894 | 894 | public function checkMMSIRecent($mmsi) |
| 895 | 895 | { |
| 896 | 896 | global $globalDBdriver, $globalTimezone; |
@@ -916,19 +916,19 @@ discard block |
||
| 916 | 916 | $ident_result = $row['fammarine_id']; |
| 917 | 917 | } |
| 918 | 918 | return $ident_result; |
| 919 | - } |
|
| 919 | + } |
|
| 920 | 920 | |
| 921 | 921 | /** |
| 922 | - * Adds a new spotter data |
|
| 923 | - * |
|
| 924 | - * @param String $fammarine_id the ID from flightaware |
|
| 925 | - * @param String $ident the flight ident |
|
| 926 | - * @param String $aircraft_icao the aircraft type |
|
| 927 | - * @param String $departure_airport_icao the departure airport |
|
| 928 | - * @param String $arrival_airport_icao the arrival airport |
|
| 929 | - * @return String success or false |
|
| 930 | - * |
|
| 931 | - */ |
|
| 922 | + * Adds a new spotter data |
|
| 923 | + * |
|
| 924 | + * @param String $fammarine_id the ID from flightaware |
|
| 925 | + * @param String $ident the flight ident |
|
| 926 | + * @param String $aircraft_icao the aircraft type |
|
| 927 | + * @param String $departure_airport_icao the departure airport |
|
| 928 | + * @param String $arrival_airport_icao the arrival airport |
|
| 929 | + * @return String success or false |
|
| 930 | + * |
|
| 931 | + */ |
|
| 932 | 932 | public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '',$captain_id = '',$captain_name = '',$race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '') |
| 933 | 933 | { |
| 934 | 934 | global $globalURL, $globalArchive, $globalDebug; |
@@ -1010,10 +1010,10 @@ discard block |
||
| 1010 | 1010 | if ($statusid == '') $statusid = NULL; |
| 1011 | 1011 | if ($distance == '') $distance = NULL; |
| 1012 | 1012 | |
| 1013 | - //if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1014 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1015 | - if ($arrival_date == '') $arrival_date = NULL; |
|
| 1016 | - $query = ''; |
|
| 1013 | + //if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1014 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1015 | + if ($arrival_date == '') $arrival_date = NULL; |
|
| 1016 | + $query = ''; |
|
| 1017 | 1017 | if ($globalArchive) { |
| 1018 | 1018 | if ($globalDebug) echo '-- Delete previous data -- '; |
| 1019 | 1019 | $query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;'; |
@@ -9,25 +9,25 @@ discard block |
||
| 9 | 9 | require_once(dirname(__FILE__).'/class.Stats.php'); |
| 10 | 10 | require_once(dirname(__FILE__).'/class.Source.php'); |
| 11 | 11 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
| 12 | - require_once(dirname(__FILE__).'/class.APRS.php'); |
|
| 12 | + require_once(dirname(__FILE__).'/class.APRS.php'); |
|
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | class MarineImport { |
| 16 | - private $all_tracked = array(); |
|
| 17 | - private $last_delete_hourly = 0; |
|
| 18 | - private $last_delete = 0; |
|
| 19 | - private $stats = array(); |
|
| 20 | - private $tmd = 0; |
|
| 21 | - private $source_location = array(); |
|
| 22 | - public $db = null; |
|
| 23 | - public $nb = 0; |
|
| 16 | + private $all_tracked = array(); |
|
| 17 | + private $last_delete_hourly = 0; |
|
| 18 | + private $last_delete = 0; |
|
| 19 | + private $stats = array(); |
|
| 20 | + private $tmd = 0; |
|
| 21 | + private $source_location = array(); |
|
| 22 | + public $db = null; |
|
| 23 | + public $nb = 0; |
|
| 24 | 24 | |
| 25 | - public function __construct($dbc = null) { |
|
| 25 | + public function __construct($dbc = null) { |
|
| 26 | 26 | global $globalBeta, $globalServerAPRS, $APRSMarine, $globalNoDB; |
| 27 | 27 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 28 | - $Connection = new Connection($dbc); |
|
| 29 | - $this->db = $Connection->db(); |
|
| 30 | - date_default_timezone_set('UTC'); |
|
| 28 | + $Connection = new Connection($dbc); |
|
| 29 | + $this->db = $Connection->db(); |
|
| 30 | + date_default_timezone_set('UTC'); |
|
| 31 | 31 | } |
| 32 | 32 | // Get previous source stats |
| 33 | 33 | /* |
@@ -46,57 +46,57 @@ discard block |
||
| 46 | 46 | } |
| 47 | 47 | */ |
| 48 | 48 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
| 49 | - $APRSMarine = new APRSMarine(); |
|
| 50 | - //$APRSSpotter->connect(); |
|
| 49 | + $APRSMarine = new APRSMarine(); |
|
| 50 | + //$APRSSpotter->connect(); |
|
| 51 | + } |
|
| 51 | 52 | } |
| 52 | - } |
|
| 53 | 53 | |
| 54 | - public function checkAll() { |
|
| 54 | + public function checkAll() { |
|
| 55 | 55 | global $globalDebug, $globalNoDB; |
| 56 | 56 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 57 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
| 58 | - foreach ($this->all_tracked as $key => $flight) { |
|
| 57 | + if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
| 58 | + foreach ($this->all_tracked as $key => $flight) { |
|
| 59 | 59 | if (isset($this->all_tracked[$key]['id'])) { |
| 60 | - //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
|
| 61 | - $Marine = new Marine($this->db); |
|
| 62 | - $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
| 60 | + //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
|
| 61 | + $Marine = new Marine($this->db); |
|
| 62 | + $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
| 63 | + } |
|
| 63 | 64 | } |
| 64 | - } |
|
| 65 | 65 | } |
| 66 | - } |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - public function del() { |
|
| 68 | + public function del() { |
|
| 69 | 69 | global $globalDebug, $globalNoDB, $globalNoImport; |
| 70 | 70 | // Delete old infos |
| 71 | 71 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
| 72 | 72 | foreach ($this->all_tracked as $key => $flight) { |
| 73 | - if (isset($flight['lastupdate'])) { |
|
| 74 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
| 75 | - if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
| 76 | - if (isset($this->all_tracked[$key]['id'])) { |
|
| 77 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 78 | - /* |
|
| 73 | + if (isset($flight['lastupdate'])) { |
|
| 74 | + if ($flight['lastupdate'] < (time()-3000)) { |
|
| 75 | + if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
| 76 | + if (isset($this->all_tracked[$key]['id'])) { |
|
| 77 | + if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 78 | + /* |
|
| 79 | 79 | $MarineLive = new MarineLive(); |
| 80 | 80 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
| 81 | 81 | $MarineLive->db = null; |
| 82 | 82 | */ |
| 83 | - //$real_arrival = $this->arrival($key); |
|
| 84 | - $Marine = new Marine($this->db); |
|
| 85 | - if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
| 83 | + //$real_arrival = $this->arrival($key); |
|
| 84 | + $Marine = new Marine($this->db); |
|
| 85 | + if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
| 86 | 86 | $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']); |
| 87 | 87 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 88 | - } |
|
| 89 | - // Put in archive |
|
| 88 | + } |
|
| 89 | + // Put in archive |
|
| 90 | 90 | // $Marine->db = null; |
| 91 | 91 | } |
| 92 | - } |
|
| 93 | - unset($this->all_tracked[$key]); |
|
| 94 | - } |
|
| 95 | - } |
|
| 96 | - } |
|
| 97 | - } |
|
| 92 | + } |
|
| 93 | + unset($this->all_tracked[$key]); |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - public function add($line) { |
|
| 99 | + public function add($line) { |
|
| 100 | 100 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine, $globalLiveInterval; |
| 101 | 101 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
| 102 | 102 | date_default_timezone_set('UTC'); |
@@ -105,106 +105,106 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | // SBS format is CSV format |
| 107 | 107 | if(is_array($line) && (isset($line['mmsi']) || isset($line['id']))) { |
| 108 | - //print_r($line); |
|
| 109 | - if (isset($line['mmsi']) || isset($line['id'])) { |
|
| 108 | + //print_r($line); |
|
| 109 | + if (isset($line['mmsi']) || isset($line['id'])) { |
|
| 110 | 110 | |
| 111 | 111 | |
| 112 | 112 | // Increment message number |
| 113 | 113 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
| 114 | - $current_date = date('Y-m-d'); |
|
| 115 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
| 116 | - else $source = ''; |
|
| 117 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 118 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
| 119 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
| 120 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
| 121 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 114 | + $current_date = date('Y-m-d'); |
|
| 115 | + if (isset($line['source_name'])) $source = $line['source_name']; |
|
| 116 | + else $source = ''; |
|
| 117 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 118 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
| 119 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
| 120 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
| 121 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | |
| 125 | 125 | $Common = new Common(); |
| 126 | 126 | $AIS = new AIS(); |
| 127 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
| 128 | - else $id = trim($line['id']); |
|
| 127 | + if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
| 128 | + else $id = trim($line['id']); |
|
| 129 | 129 | |
| 130 | 130 | if (!isset($this->all_tracked[$id])) { |
| 131 | - $this->all_tracked[$id] = array(); |
|
| 132 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
| 133 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => '','distance' => NULL)); |
|
| 134 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
| 135 | - if (!isset($line['id'])) { |
|
| 131 | + $this->all_tracked[$id] = array(); |
|
| 132 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
| 133 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => '','distance' => NULL)); |
|
| 134 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
| 135 | + if (!isset($line['id'])) { |
|
| 136 | 136 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 137 | 137 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
| 138 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 139 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
| 138 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 139 | + if ($globalAllTracked !== FALSE) $dataFound = true; |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
| 143 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
| 144 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 143 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
| 144 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 145 | 145 | $Marine = new Marine($this->db); |
| 146 | 146 | $identity = $Marine->getIdentity($line['mmsi']); |
| 147 | 147 | if (!empty($identity)) { |
| 148 | - $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
| 149 | - $this->all_tracked[$id]['type'] = $identity['type']; |
|
| 150 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type']))); |
|
| 148 | + $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
| 149 | + $this->all_tracked[$id]['type'] = $identity['type']; |
|
| 150 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type']))); |
|
| 151 | 151 | } |
| 152 | 152 | //print_r($identity); |
| 153 | 153 | unset($Marine); |
| 154 | 154 | //$dataFound = true; |
| 155 | - } |
|
| 155 | + } |
|
| 156 | 156 | } |
| 157 | 157 | if (isset($line['type_id'])) { |
| 158 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
| 159 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
| 158 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
| 159 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
| 160 | 160 | } |
| 161 | 161 | if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') { |
| 162 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
| 163 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type']))); |
|
| 162 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
| 163 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type']))); |
|
| 164 | 164 | } elseif (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] != '') { |
| 165 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
| 165 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
| 166 | 166 | } |
| 167 | 167 | if (isset($line['status']) && $line['status'] != '') { |
| 168 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
| 168 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
| 169 | 169 | } |
| 170 | 170 | if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) { |
| 171 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
| 172 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
| 171 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
| 172 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
| 173 | 173 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 174 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 174 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 175 | 175 | $Marine = new Marine($this->db); |
| 176 | 176 | $Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']); |
| 177 | 177 | unset($Marine); |
| 178 | - } |
|
| 178 | + } |
|
| 179 | + } |
|
| 179 | 180 | } |
| 180 | - } |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | |
| 184 | 184 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
| 185 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
| 185 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
| 186 | 186 | } |
| 187 | 187 | if (isset($line['imo']) && $line['imo'] != '') { |
| 188 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
| 188 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
| 189 | 189 | } |
| 190 | 190 | if (isset($line['callsign']) && $line['callsign'] != '') { |
| 191 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
| 191 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
| 192 | 192 | } |
| 193 | 193 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
| 194 | - if (!isset($this->all_tracked[$id]['arrival_code'])) { |
|
| 194 | + if (!isset($this->all_tracked[$id]['arrival_code'])) { |
|
| 195 | 195 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
| 196 | 196 | if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
| 197 | 197 | if ($this->all_tracked[$id]['addedMarine'] != 0) { |
| 198 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
| 198 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
| 199 | 199 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 200 | - $Marine = new Marine($this->db); |
|
| 201 | - $fromsource = NULL; |
|
| 202 | - $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource); |
|
| 203 | - $Marine->db = null; |
|
| 200 | + $Marine = new Marine($this->db); |
|
| 201 | + $fromsource = NULL; |
|
| 202 | + $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource); |
|
| 203 | + $Marine->db = null; |
|
| 204 | + } |
|
| 204 | 205 | } |
| 205 | - } |
|
| 206 | 206 | } |
| 207 | - } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) { |
|
| 207 | + } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) { |
|
| 208 | 208 | $this->all_tracked[$id]['arrival_code'] = $line['arrival_code']; |
| 209 | 209 | if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
| 210 | 210 | if (!isset($line['id'])) { |
@@ -212,47 +212,47 @@ discard block |
||
| 212 | 212 | $this->all_tracked[$id]['forcenew'] = 1; |
| 213 | 213 | $this->all_tracked[$id]['addedMarine'] = 0; |
| 214 | 214 | } |
| 215 | - } |
|
| 215 | + } |
|
| 216 | 216 | } |
| 217 | 217 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
| 218 | - if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
| 218 | + if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
| 219 | 219 | } |
| 220 | 220 | if (isset($line['captain_id']) && $line['captain_id'] != '') { |
| 221 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id'])); |
|
| 221 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id'])); |
|
| 222 | 222 | } |
| 223 | 223 | if (isset($line['captain_name']) && $line['captain_name'] != '') { |
| 224 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name'])); |
|
| 224 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name'])); |
|
| 225 | 225 | } |
| 226 | 226 | if (isset($line['race_id']) && $line['race_id'] != '') { |
| 227 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id'])); |
|
| 227 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id'])); |
|
| 228 | 228 | } |
| 229 | 229 | if (isset($line['race_name']) && $line['race_name'] != '') { |
| 230 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name'])); |
|
| 230 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name'])); |
|
| 231 | 231 | } |
| 232 | 232 | if (isset($line['race_rank']) && $line['race_rank'] != '') { |
| 233 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_rank' => $line['race_rank'])); |
|
| 233 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_rank' => $line['race_rank'])); |
|
| 234 | 234 | } |
| 235 | 235 | if (isset($line['race_time']) && $line['race_time'] != '') { |
| 236 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_time' => $line['race_time'])); |
|
| 236 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_time' => $line['race_time'])); |
|
| 237 | 237 | } |
| 238 | 238 | if (isset($line['distance']) && $line['distance'] != '') { |
| 239 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('distance' => $line['distance'])); |
|
| 239 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('distance' => $line['distance'])); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | //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'])) { |
| 243 | 243 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
| 244 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
| 244 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
| 245 | 245 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 246 | - $timeelapsed = microtime(true); |
|
| 247 | - $Marine = new Marine($this->db); |
|
| 248 | - $Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']); |
|
| 249 | - $Marine->db = null; |
|
| 246 | + $timeelapsed = microtime(true); |
|
| 247 | + $Marine = new Marine($this->db); |
|
| 248 | + $Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']); |
|
| 249 | + $Marine->db = null; |
|
| 250 | + } |
|
| 250 | 251 | } |
| 251 | - } |
|
| 252 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
| 253 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
| 252 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
| 253 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
| 254 | 254 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 255 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 255 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 256 | 256 | $timeelapsed = microtime(true); |
| 257 | 257 | $Marine = new Marine($this->db); |
| 258 | 258 | $fromsource = NULL; |
@@ -260,20 +260,20 @@ discard block |
||
| 260 | 260 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 261 | 261 | $Marine->db = null; |
| 262 | 262 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 263 | - } |
|
| 263 | + } |
|
| 264 | + } |
|
| 264 | 265 | } |
| 265 | - } |
|
| 266 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 266 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
| 270 | - if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
| 270 | + if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
| 271 | 271 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
| 272 | - } else { |
|
| 272 | + } else { |
|
| 273 | 273 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
| 274 | 274 | 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]['hex']." - format : ".$line['format_source']."\n"; |
| 275 | 275 | return ''; |
| 276 | - } |
|
| 276 | + } |
|
| 277 | 277 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
| 278 | 278 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
| 279 | 279 | return ''; |
@@ -290,33 +290,33 @@ discard block |
||
| 290 | 290 | |
| 291 | 291 | |
| 292 | 292 | if (isset($line['speed'])) { |
| 293 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'],2))); |
|
| 294 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
| 293 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'],2))); |
|
| 294 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
| 295 | 295 | } 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'])) { |
| 296 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
| 297 | - if ($distance > 1000 && $distance < 10000) { |
|
| 296 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
| 297 | + if ($distance > 1000 && $distance < 10000) { |
|
| 298 | 298 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
| 299 | 299 | $speed = $speed*3.6; |
| 300 | 300 | if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2))); |
| 301 | 301 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
| 302 | - } |
|
| 302 | + } |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
| 306 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 307 | - else unset($timediff); |
|
| 308 | - if ($this->tmd > 5 || |
|
| 309 | - !isset($timediff) || |
|
| 310 | - $timediff > $globalLiveInterval || |
|
| 311 | - ( |
|
| 312 | - $timediff > 30 && |
|
| 313 | - isset($this->all_tracked[$id]['latitude']) && |
|
| 314 | - isset($this->all_tracked[$id]['longitude']) && |
|
| 315 | - $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')) |
|
| 316 | - ) |
|
| 317 | - ) { |
|
| 305 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
| 306 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 307 | + else unset($timediff); |
|
| 308 | + if ($this->tmd > 5 || |
|
| 309 | + !isset($timediff) || |
|
| 310 | + $timediff > $globalLiveInterval || |
|
| 311 | + ( |
|
| 312 | + $timediff > 30 && |
|
| 313 | + isset($this->all_tracked[$id]['latitude']) && |
|
| 314 | + isset($this->all_tracked[$id]['longitude']) && |
|
| 315 | + $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')) |
|
| 316 | + ) |
|
| 317 | + ) { |
|
| 318 | 318 | 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'])) { |
| 319 | - 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'])) { |
|
| 319 | + 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'])) { |
|
| 320 | 320 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 321 | 321 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 322 | 322 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -324,200 +324,200 @@ discard block |
||
| 324 | 324 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
| 325 | 325 | $timeelapsed = microtime(true); |
| 326 | 326 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 327 | - $Marine = new Marine($this->db); |
|
| 328 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
| 329 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 330 | - $Marine->db = null; |
|
| 331 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 327 | + $Marine = new Marine($this->db); |
|
| 328 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
| 329 | + if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 330 | + $Marine->db = null; |
|
| 331 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 332 | 332 | } |
| 333 | 333 | $this->tmd = 0; |
| 334 | 334 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
| 335 | - } |
|
| 335 | + } |
|
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 339 | 339 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 340 | 340 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
| 341 | - $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
| 342 | - $dataFound = true; |
|
| 343 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 341 | + $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
| 342 | + $dataFound = true; |
|
| 343 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 344 | 344 | } |
| 345 | 345 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
| 346 | 346 | } |
| 347 | 347 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 348 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 348 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 349 | 349 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 350 | 350 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
| 351 | - $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
| 352 | - $dataFound = true; |
|
| 353 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 351 | + $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
| 352 | + $dataFound = true; |
|
| 353 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 354 | 354 | } |
| 355 | 355 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | - } else if ($globalDebug && $timediff > 20) { |
|
| 358 | + } else if ($globalDebug && $timediff > 20) { |
|
| 359 | 359 | $this->tmd = $this->tmd + 1; |
| 360 | 360 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
| 361 | 361 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
| 362 | 362 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
| 363 | 363 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
| 364 | - } |
|
| 364 | + } |
|
| 365 | 365 | } |
| 366 | 366 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 367 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 368 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
| 367 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 368 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
| 369 | 369 | } |
| 370 | 370 | if (isset($line['format_source']) && $line['format_source'] != '') { |
| 371 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
| 371 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
| 372 | 372 | } |
| 373 | 373 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 374 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
| 374 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
| 375 | 375 | } |
| 376 | 376 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
| 377 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
| 377 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | if (isset($line['heading']) && $line['heading'] != '') { |
| 381 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 382 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
| 383 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
| 384 | - //$dataFound = true; |
|
| 381 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 382 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
| 383 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
| 384 | + //$dataFound = true; |
|
| 385 | 385 | } 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']) { |
| 386 | - $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']); |
|
| 387 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
| 388 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 389 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 386 | + $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']); |
|
| 387 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
| 388 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 389 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 390 | 390 | } |
| 391 | 391 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
| 392 | 392 | |
| 393 | 393 | |
| 394 | 394 | |
| 395 | 395 | if ($dataFound === true && (isset($this->all_tracked[$id]['mmsi']) || isset($this->all_tracked[$id]['id']))) { |
| 396 | - $this->all_tracked[$id]['lastupdate'] = time(); |
|
| 397 | - if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
| 398 | - 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'])) { |
|
| 399 | - if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
| 396 | + $this->all_tracked[$id]['lastupdate'] = time(); |
|
| 397 | + if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
| 398 | + 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'])) { |
|
| 399 | + if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
| 400 | 400 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 401 | - if ($globalDebug) echo "Check if vessel is already in DB..."; |
|
| 402 | - $timeelapsed = microtime(true); |
|
| 403 | - $MarineLive = new MarineLive($this->db); |
|
| 404 | - if (isset($line['id']) && isset($globalVM) && $globalVM) { |
|
| 401 | + if ($globalDebug) echo "Check if vessel is already in DB..."; |
|
| 402 | + $timeelapsed = microtime(true); |
|
| 403 | + $MarineLive = new MarineLive($this->db); |
|
| 404 | + if (isset($line['id']) && isset($globalVM) && $globalVM) { |
|
| 405 | 405 | $Marine = new Marine($this->db); |
| 406 | 406 | $recent_ident = $Marine->checkId($line['id']); |
| 407 | 407 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 408 | 408 | $Marine->db=null; |
| 409 | - } elseif (isset($line['id'])) { |
|
| 409 | + } elseif (isset($line['id'])) { |
|
| 410 | 410 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
| 411 | 411 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 412 | - } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
| 412 | + } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
| 413 | 413 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
| 414 | 414 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 415 | - } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
| 415 | + } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
| 416 | 416 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
| 417 | 417 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 418 | - } else $recent_ident = ''; |
|
| 419 | - $MarineLive->db=null; |
|
| 420 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 421 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 418 | + } else $recent_ident = ''; |
|
| 419 | + $MarineLive->db=null; |
|
| 420 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 421 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 422 | 422 | } else $recent_ident = ''; |
| 423 | - } else { |
|
| 423 | + } else { |
|
| 424 | 424 | $recent_ident = ''; |
| 425 | 425 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
| 426 | - } |
|
| 427 | - //if there was no vessel with the same callsign within the last hour and go post it into the archive |
|
| 428 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
| 429 | - { |
|
| 426 | + } |
|
| 427 | + //if there was no vessel with the same callsign within the last hour and go post it into the archive |
|
| 428 | + if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
| 429 | + { |
|
| 430 | 430 | if ($globalDebug) { |
| 431 | 431 | if ($this->all_tracked[$id]['mmsi'] == '') echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
| 432 | 432 | else echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
| 433 | 433 | } |
| 434 | 434 | //adds the spotter data for the archive |
| 435 | - $highlight = ''; |
|
| 436 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
| 437 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
| 435 | + $highlight = ''; |
|
| 436 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
| 437 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
| 438 | 438 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 439 | - $timeelapsed = microtime(true); |
|
| 440 | - $Marine = new Marine($this->db); |
|
| 441 | - $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']); |
|
| 442 | - $Marine->db = null; |
|
| 443 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 444 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 439 | + $timeelapsed = microtime(true); |
|
| 440 | + $Marine = new Marine($this->db); |
|
| 441 | + $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']); |
|
| 442 | + $Marine->db = null; |
|
| 443 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 444 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 445 | + } |
|
| 445 | 446 | } |
| 446 | - } |
|
| 447 | - if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
|
| 447 | + if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
|
| 448 | 448 | // Add source stat in DB |
| 449 | 449 | $Stats = new Stats($this->db); |
| 450 | 450 | if (!empty($this->stats)) { |
| 451 | - if ($globalDebug) echo 'Add source stats : '; |
|
| 452 | - foreach($this->stats as $date => $data) { |
|
| 451 | + if ($globalDebug) echo 'Add source stats : '; |
|
| 452 | + foreach($this->stats as $date => $data) { |
|
| 453 | 453 | foreach($data as $source => $sourced) { |
| 454 | - //print_r($sourced); |
|
| 455 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
| 456 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
| 457 | - if (isset($sourced['msg'])) { |
|
| 458 | - if (time() - $sourced['msg']['date'] > 10) { |
|
| 459 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
| 460 | - echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
| 461 | - unset($this->stats[$date][$source]['msg']); |
|
| 462 | - } |
|
| 463 | - } |
|
| 464 | - } |
|
| 465 | - if ($date != date('Y-m-d')) { |
|
| 466 | - unset($this->stats[$date]); |
|
| 467 | - } |
|
| 468 | - } |
|
| 469 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 454 | + //print_r($sourced); |
|
| 455 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
| 456 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
| 457 | + if (isset($sourced['msg'])) { |
|
| 458 | + if (time() - $sourced['msg']['date'] > 10) { |
|
| 459 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
| 460 | + echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
| 461 | + unset($this->stats[$date][$source]['msg']); |
|
| 462 | + } |
|
| 463 | + } |
|
| 464 | + } |
|
| 465 | + if ($date != date('Y-m-d')) { |
|
| 466 | + unset($this->stats[$date]); |
|
| 467 | + } |
|
| 468 | + } |
|
| 469 | + if ($globalDebug) echo 'Done'."\n"; |
|
| 470 | 470 | } |
| 471 | 471 | $Stats->db = null; |
| 472 | - } |
|
| 472 | + } |
|
| 473 | 473 | |
| 474 | - $this->del(); |
|
| 474 | + $this->del(); |
|
| 475 | 475 | //$ignoreImport = false; |
| 476 | 476 | $this->all_tracked[$id]['addedMarine'] = 1; |
| 477 | 477 | //print_r($this->all_tracked[$id]); |
| 478 | 478 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 479 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
| 480 | - //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
| 481 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 479 | + if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
| 480 | + //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
| 481 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 482 | 482 | $MarineLive = new MarineLive($this->db); |
| 483 | 483 | $MarineLive->deleteLiveMarineData(); |
| 484 | 484 | $MarineLive->db=null; |
| 485 | 485 | if ($globalDebug) echo " Done\n"; |
| 486 | - } |
|
| 487 | - $this->last_delete = time(); |
|
| 486 | + } |
|
| 487 | + $this->last_delete = time(); |
|
| 488 | 488 | } |
| 489 | - } elseif ($recent_ident != '') { |
|
| 489 | + } elseif ($recent_ident != '') { |
|
| 490 | 490 | $this->all_tracked[$id]['id'] = $recent_ident; |
| 491 | 491 | $this->all_tracked[$id]['addedMarine'] = 1; |
| 492 | 492 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 493 | - if (isset($globalDaemon) && !$globalDaemon) { |
|
| 493 | + if (isset($globalDaemon) && !$globalDaemon) { |
|
| 494 | 494 | $Marine = new Marine($this->db); |
| 495 | 495 | $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']); |
| 496 | 496 | $Marine->db = null; |
| 497 | - } |
|
| 497 | + } |
|
| 498 | 498 | } |
| 499 | 499 | |
| 500 | - } |
|
| 500 | + } |
|
| 501 | 501 | } |
| 502 | - } |
|
| 503 | - //adds the spotter LIVE data |
|
| 504 | - if ($globalDebug) { |
|
| 502 | + } |
|
| 503 | + //adds the spotter LIVE data |
|
| 504 | + if ($globalDebug) { |
|
| 505 | 505 | 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'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n"; |
| 506 | - } |
|
| 507 | - $ignoreImport = false; |
|
| 506 | + } |
|
| 507 | + $ignoreImport = false; |
|
| 508 | 508 | |
| 509 | - if (!$ignoreImport) { |
|
| 509 | + if (!$ignoreImport) { |
|
| 510 | 510 | 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'])) { |
| 511 | 511 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
| 512 | 512 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 513 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 513 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 514 | 514 | $timeelapsed = microtime(true); |
| 515 | 515 | $MarineLive = new MarineLive($this->db); |
| 516 | 516 | $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']); |
| 517 | 517 | $MarineLive->db = null; |
| 518 | 518 | if ($globalDebug) echo $result."\n"; |
| 519 | 519 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 520 | - } |
|
| 520 | + } |
|
| 521 | 521 | } |
| 522 | 522 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
| 523 | 523 | $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
@@ -552,7 +552,7 @@ discard block |
||
| 552 | 552 | if ($stats_heading == 16) $stats_heading = 0; |
| 553 | 553 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 554 | 554 | for ($i=0;$i<=15;$i++) { |
| 555 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
| 555 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
| 556 | 556 | } |
| 557 | 557 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
| 558 | 558 | } else { |
@@ -565,11 +565,11 @@ discard block |
||
| 565 | 565 | //var_dump($this->stats); |
| 566 | 566 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
| 567 | 567 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 568 | - end($this->stats[$current_date][$source]['hist']); |
|
| 569 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
| 568 | + end($this->stats[$current_date][$source]['hist']); |
|
| 569 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
| 570 | 570 | } else $mini = 0; |
| 571 | 571 | for ($i=$mini;$i<=$distance;$i+=10) { |
| 572 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
| 572 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
| 573 | 573 | } |
| 574 | 574 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
| 575 | 575 | } else { |
@@ -585,24 +585,24 @@ discard block |
||
| 585 | 585 | |
| 586 | 586 | |
| 587 | 587 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 588 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 588 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 589 | 589 | if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
| 590 | 590 | $MarineLive = new MarineLive($this->db); |
| 591 | 591 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
| 592 | 592 | $MarineLive->db = null; |
| 593 | 593 | //MarineLive->deleteLiveMarineData(); |
| 594 | 594 | if ($globalDebug) echo " Done\n"; |
| 595 | - } |
|
| 596 | - $this->last_delete_hourly = time(); |
|
| 595 | + } |
|
| 596 | + $this->last_delete_hourly = time(); |
|
| 597 | 597 | } |
| 598 | 598 | |
| 599 | - } |
|
| 600 | - //$ignoreImport = false; |
|
| 599 | + } |
|
| 600 | + //$ignoreImport = false; |
|
| 601 | 601 | } |
| 602 | 602 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 603 | 603 | if ($send) return $this->all_tracked[$id]; |
| 604 | - } |
|
| 604 | + } |
|
| 605 | + } |
|
| 605 | 606 | } |
| 606 | - } |
|
| 607 | 607 | } |
| 608 | 608 | ?> |
@@ -16,8 +16,8 @@ discard block |
||
| 16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
| 17 | 17 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
| 18 | 18 | if (isset($globalMarine) && $globalMarine) { |
| 19 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
| 20 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
| 19 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
| 20 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | if (!isset($globalDebug)) $globalDebug = FALSE; |
@@ -25,46 +25,46 @@ discard block |
||
| 25 | 25 | // Check if schema is at latest version |
| 26 | 26 | $Connection = new Connection(); |
| 27 | 27 | if ($Connection->connectionExists() === false) { |
| 28 | - echo "Can't connect to your database. Check DB is running, user/password and database logs."; |
|
| 29 | - exit(); |
|
| 28 | + echo "Can't connect to your database. Check DB is running, user/password and database logs."; |
|
| 29 | + exit(); |
|
| 30 | 30 | } |
| 31 | 31 | if ($Connection->latest() === false) { |
| 32 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
| 33 | - exit(); |
|
| 32 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
| 33 | + exit(); |
|
| 34 | 34 | } |
| 35 | 35 | if (PHP_SAPI != 'cli') { |
| 36 | - echo "This script MUST be called from console, not a web browser."; |
|
| 36 | + echo "This script MUST be called from console, not a web browser."; |
|
| 37 | 37 | // exit(); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | // This is to be compatible with old version of settings.php |
| 41 | 41 | if (!isset($globalSources)) { |
| 42 | - if (isset($globalSBS1Hosts)) { |
|
| 43 | - //$hosts = $globalSBS1Hosts; |
|
| 44 | - foreach ($globalSBS1Hosts as $host) { |
|
| 45 | - $globalSources[] = array('host' => $host); |
|
| 46 | - } |
|
| 47 | - } else { |
|
| 48 | - if (!isset($globalSBS1Host)) { |
|
| 49 | - echo '$globalSources MUST be defined !'; |
|
| 50 | - die; |
|
| 42 | + if (isset($globalSBS1Hosts)) { |
|
| 43 | + //$hosts = $globalSBS1Hosts; |
|
| 44 | + foreach ($globalSBS1Hosts as $host) { |
|
| 45 | + $globalSources[] = array('host' => $host); |
|
| 46 | + } |
|
| 47 | + } else { |
|
| 48 | + if (!isset($globalSBS1Host)) { |
|
| 49 | + echo '$globalSources MUST be defined !'; |
|
| 50 | + die; |
|
| 51 | 51 | } |
| 52 | 52 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
| 53 | 53 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
| 54 | - } |
|
| 54 | + } |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine')); |
| 58 | 58 | //if (isset($options['s'])) $hosts = array($options['s']); |
| 59 | 59 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 60 | 60 | if (isset($options['s'])) { |
| 61 | - $globalSources = array(); |
|
| 62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 63 | - else $globalSources[] = array('host' => $options['s']); |
|
| 61 | + $globalSources = array(); |
|
| 62 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 63 | + else $globalSources[] = array('host' => $options['s']); |
|
| 64 | 64 | } elseif (isset($options['source'])) { |
| 65 | - $globalSources = array(); |
|
| 66 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 67 | - else $globalSources[] = array('host' => $options['source']); |
|
| 65 | + $globalSources = array(); |
|
| 66 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 67 | + else $globalSources[] = array('host' => $options['source']); |
|
| 68 | 68 | } |
| 69 | 69 | if (isset($options['aprsserverhost'])) { |
| 70 | 70 | $globalServerAPRS = TRUE; |
@@ -103,8 +103,8 @@ discard block |
||
| 103 | 103 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
| 104 | 104 | else $id_source = 1; |
| 105 | 105 | if (isset($globalServer) && $globalServer) { |
| 106 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 107 | - $SI=new SpotterServer(); |
|
| 106 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
| 107 | + $SI=new SpotterServer(); |
|
| 108 | 108 | /* |
| 109 | 109 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 110 | 110 | $SI = new adsb2aprs(); |
@@ -114,14 +114,14 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
| 116 | 116 | if (isset($globalMarine) && $globalMarine) { |
| 117 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
| 118 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
| 117 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
| 118 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
| 122 | 122 | if (isset($globalMarine) && $globalMarine) { |
| 123 | - $AIS = new AIS(); |
|
| 124 | - $MI = new MarineImport($Connection->db); |
|
| 123 | + $AIS = new AIS(); |
|
| 124 | + $MI = new MarineImport($Connection->db); |
|
| 125 | 125 | } |
| 126 | 126 | //$APRS=new APRS($Connection->db); |
| 127 | 127 | $SBS=new SBS(); |
@@ -134,12 +134,12 @@ discard block |
||
| 134 | 134 | //$servertz = system('date +%Z'); |
| 135 | 135 | // signal handler - playing nice with sockets and dump1090 |
| 136 | 136 | if (function_exists('pcntl_fork')) { |
| 137 | - pcntl_signal(SIGINT, function() { |
|
| 138 | - global $sockets; |
|
| 139 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
| 140 | - die("Bye!\n"); |
|
| 141 | - }); |
|
| 142 | - pcntl_signal_dispatch(); |
|
| 137 | + pcntl_signal(SIGINT, function() { |
|
| 138 | + global $sockets; |
|
| 139 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
| 140 | + die("Bye!\n"); |
|
| 141 | + }); |
|
| 142 | + pcntl_signal_dispatch(); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | // let's try and connect |
@@ -149,46 +149,46 @@ discard block |
||
| 149 | 149 | $reset = 0; |
| 150 | 150 | |
| 151 | 151 | function connect_all($hosts) { |
| 152 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 153 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
| 154 | - $reset++; |
|
| 155 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 156 | - foreach ($hosts as $id => $value) { |
|
| 152 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 153 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
| 154 | + $reset++; |
|
| 155 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 156 | + foreach ($hosts as $id => $value) { |
|
| 157 | 157 | $host = $value['host']; |
| 158 | 158 | $globalSources[$id]['last_exec'] = 0; |
| 159 | 159 | // Here we check type of source(s) |
| 160 | 160 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
| 161 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 162 | - //$formats[$id] = 'deltadbtxt'; |
|
| 163 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
| 164 | - //$last_exec['deltadbtxt'] = 0; |
|
| 165 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 166 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 167 | - //$formats[$id] = 'vatsimtxt'; |
|
| 168 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
| 169 | - //$last_exec['vatsimtxt'] = 0; |
|
| 170 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 171 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 172 | - //$formats[$id] = 'aircraftlistjson'; |
|
| 173 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
| 174 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 175 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 176 | - } else if (preg_match('/aircraft.json$/i',$host)) { |
|
| 177 | - //$formats[$id] = 'aircraftjson'; |
|
| 178 | - $globalSources[$id]['format'] = 'aircraftjson'; |
|
| 179 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 180 | - if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; |
|
| 181 | - } else if (preg_match('/aircraft$/i',$host)) { |
|
| 182 | - //$formats[$id] = 'planefinderclient'; |
|
| 183 | - $globalSources[$id]['format'] = 'planefinderclient'; |
|
| 184 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 185 | - if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; |
|
| 186 | - } else if (preg_match('/opensky/i',$host)) { |
|
| 187 | - //$formats[$id] = 'aircraftlistjson'; |
|
| 188 | - $globalSources[$id]['format'] = 'opensky'; |
|
| 189 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 190 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 191 | - /* |
|
| 161 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 162 | + //$formats[$id] = 'deltadbtxt'; |
|
| 163 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
| 164 | + //$last_exec['deltadbtxt'] = 0; |
|
| 165 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 166 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 167 | + //$formats[$id] = 'vatsimtxt'; |
|
| 168 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
| 169 | + //$last_exec['vatsimtxt'] = 0; |
|
| 170 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 171 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 172 | + //$formats[$id] = 'aircraftlistjson'; |
|
| 173 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
| 174 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 175 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 176 | + } else if (preg_match('/aircraft.json$/i',$host)) { |
|
| 177 | + //$formats[$id] = 'aircraftjson'; |
|
| 178 | + $globalSources[$id]['format'] = 'aircraftjson'; |
|
| 179 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 180 | + if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; |
|
| 181 | + } else if (preg_match('/aircraft$/i',$host)) { |
|
| 182 | + //$formats[$id] = 'planefinderclient'; |
|
| 183 | + $globalSources[$id]['format'] = 'planefinderclient'; |
|
| 184 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 185 | + if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; |
|
| 186 | + } else if (preg_match('/opensky/i',$host)) { |
|
| 187 | + //$formats[$id] = 'aircraftlistjson'; |
|
| 188 | + $globalSources[$id]['format'] = 'opensky'; |
|
| 189 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 190 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 191 | + /* |
|
| 192 | 192 | // Disabled for now, site change source format |
| 193 | 193 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
| 194 | 194 | //$formats[$id] = 'radarvirtueljson'; |
@@ -200,128 +200,128 @@ discard block |
||
| 200 | 200 | exit(0); |
| 201 | 201 | } |
| 202 | 202 | */ |
| 203 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 204 | - //$formats[$id] = 'planeupdatefaa'; |
|
| 205 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
| 206 | - //$last_exec['planeupdatefaa'] = 0; |
|
| 207 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 208 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 209 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 210 | - exit(0); |
|
| 211 | - } |
|
| 212 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 213 | - //$formats[$id] = 'phpvmacars'; |
|
| 214 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
| 215 | - //$last_exec['phpvmacars'] = 0; |
|
| 216 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 217 | - } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
| 218 | - //$formats[$id] = 'phpvmacars'; |
|
| 219 | - $globalSources[$id]['format'] = 'vaos'; |
|
| 220 | - //$last_exec['phpvmacars'] = 0; |
|
| 221 | - if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
| 222 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 223 | - //$formats[$id] = 'phpvmacars'; |
|
| 224 | - $globalSources[$id]['format'] = 'vam'; |
|
| 225 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 226 | - } else if (preg_match('/whazzup/i',$host)) { |
|
| 227 | - //$formats[$id] = 'whazzup'; |
|
| 228 | - $globalSources[$id]['format'] = 'whazzup'; |
|
| 229 | - //$last_exec['whazzup'] = 0; |
|
| 230 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 231 | - } else if (preg_match('/blitzortung/i',$host)) { |
|
| 232 | - $globalSources[$id]['format'] = 'blitzortung'; |
|
| 233 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
| 234 | - } else if (preg_match('/airwhere/i',$host)) { |
|
| 235 | - $globalSources[$id]['format'] = 'airwhere'; |
|
| 236 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
| 237 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
| 238 | - //$formats[$id] = 'pirepsjson'; |
|
| 239 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
| 240 | - //$last_exec['pirepsjson'] = 0; |
|
| 241 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 242 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 243 | - //$formats[$id] = 'fr24json'; |
|
| 244 | - $globalSources[$id]['format'] = 'fr24json'; |
|
| 245 | - //$last_exec['fr24json'] = 0; |
|
| 246 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 247 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 248 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 249 | - exit(0); |
|
| 250 | - } |
|
| 251 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
| 252 | - //$formats[$id] = 'fr24json'; |
|
| 253 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
| 254 | - //$last_exec['fr24json'] = 0; |
|
| 255 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 256 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 257 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 258 | - exit(0); |
|
| 259 | - } |
|
| 260 | - //} else if (preg_match('/10001/',$host)) { |
|
| 261 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 262 | - //$formats[$id] = 'tsv'; |
|
| 263 | - $globalSources[$id]['format'] = 'tsv'; |
|
| 264 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 265 | - } |
|
| 266 | - } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway')) { |
|
| 267 | - if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
| 268 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
| 269 | - if ($idf !== false) { |
|
| 270 | - $httpfeeds[$id] = $idf; |
|
| 271 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 272 | - } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 273 | - } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
| 274 | - elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 275 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 276 | - $hostport = explode(':',$host); |
|
| 277 | - if (isset($hostport[1])) { |
|
| 203 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 204 | + //$formats[$id] = 'planeupdatefaa'; |
|
| 205 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
| 206 | + //$last_exec['planeupdatefaa'] = 0; |
|
| 207 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 208 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 209 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 210 | + exit(0); |
|
| 211 | + } |
|
| 212 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 213 | + //$formats[$id] = 'phpvmacars'; |
|
| 214 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
| 215 | + //$last_exec['phpvmacars'] = 0; |
|
| 216 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 217 | + } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
| 218 | + //$formats[$id] = 'phpvmacars'; |
|
| 219 | + $globalSources[$id]['format'] = 'vaos'; |
|
| 220 | + //$last_exec['phpvmacars'] = 0; |
|
| 221 | + if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
| 222 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 223 | + //$formats[$id] = 'phpvmacars'; |
|
| 224 | + $globalSources[$id]['format'] = 'vam'; |
|
| 225 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 226 | + } else if (preg_match('/whazzup/i',$host)) { |
|
| 227 | + //$formats[$id] = 'whazzup'; |
|
| 228 | + $globalSources[$id]['format'] = 'whazzup'; |
|
| 229 | + //$last_exec['whazzup'] = 0; |
|
| 230 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 231 | + } else if (preg_match('/blitzortung/i',$host)) { |
|
| 232 | + $globalSources[$id]['format'] = 'blitzortung'; |
|
| 233 | + if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
| 234 | + } else if (preg_match('/airwhere/i',$host)) { |
|
| 235 | + $globalSources[$id]['format'] = 'airwhere'; |
|
| 236 | + if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
| 237 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
| 238 | + //$formats[$id] = 'pirepsjson'; |
|
| 239 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
| 240 | + //$last_exec['pirepsjson'] = 0; |
|
| 241 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 242 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 243 | + //$formats[$id] = 'fr24json'; |
|
| 244 | + $globalSources[$id]['format'] = 'fr24json'; |
|
| 245 | + //$last_exec['fr24json'] = 0; |
|
| 246 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 247 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 248 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 249 | + exit(0); |
|
| 250 | + } |
|
| 251 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
| 252 | + //$formats[$id] = 'fr24json'; |
|
| 253 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
| 254 | + //$last_exec['fr24json'] = 0; |
|
| 255 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 256 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 257 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 258 | + exit(0); |
|
| 259 | + } |
|
| 260 | + //} else if (preg_match('/10001/',$host)) { |
|
| 261 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 262 | + //$formats[$id] = 'tsv'; |
|
| 263 | + $globalSources[$id]['format'] = 'tsv'; |
|
| 264 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 265 | + } |
|
| 266 | + } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway')) { |
|
| 267 | + if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
| 268 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
| 269 | + if ($idf !== false) { |
|
| 270 | + $httpfeeds[$id] = $idf; |
|
| 271 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 272 | + } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 273 | + } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
| 274 | + elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 275 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 276 | + $hostport = explode(':',$host); |
|
| 277 | + if (isset($hostport[1])) { |
|
| 278 | 278 | $port = $hostport[1]; |
| 279 | 279 | $hostn = $hostport[0]; |
| 280 | - } else { |
|
| 280 | + } else { |
|
| 281 | 281 | $port = $globalSources[$id]['port']; |
| 282 | 282 | $hostn = $globalSources[$id]['host']; |
| 283 | - } |
|
| 284 | - $Common = new Common(); |
|
| 285 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
| 286 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
| 287 | - } else { |
|
| 288 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 289 | - } |
|
| 290 | - if ($s) { |
|
| 291 | - $sockets[$id] = $s; |
|
| 292 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
| 293 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
| 283 | + } |
|
| 284 | + $Common = new Common(); |
|
| 285 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
| 286 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
| 287 | + } else { |
|
| 288 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 289 | + } |
|
| 290 | + if ($s) { |
|
| 291 | + $sockets[$id] = $s; |
|
| 292 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
| 293 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
| 294 | 294 | //$formats[$id] = 'aprs'; |
| 295 | 295 | $globalSources[$id]['format'] = 'aprs'; |
| 296 | 296 | //$aprs_connect = 0; |
| 297 | 297 | //$use_aprs = true; |
| 298 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
| 298 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
| 299 | 299 | $globalSources[$id]['format'] = 'vrstcp'; |
| 300 | - } elseif ($port == '10001') { |
|
| 301 | - //$formats[$id] = 'tsv'; |
|
| 302 | - $globalSources[$id]['format'] = 'tsv'; |
|
| 303 | - } elseif ($port == '30002') { |
|
| 304 | - //$formats[$id] = 'raw'; |
|
| 305 | - $globalSources[$id]['format'] = 'raw'; |
|
| 306 | - } elseif ($port == '5001') { |
|
| 307 | - //$formats[$id] = 'raw'; |
|
| 308 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
| 309 | - } elseif ($port == '30005') { |
|
| 300 | + } elseif ($port == '10001') { |
|
| 301 | + //$formats[$id] = 'tsv'; |
|
| 302 | + $globalSources[$id]['format'] = 'tsv'; |
|
| 303 | + } elseif ($port == '30002') { |
|
| 304 | + //$formats[$id] = 'raw'; |
|
| 305 | + $globalSources[$id]['format'] = 'raw'; |
|
| 306 | + } elseif ($port == '5001') { |
|
| 307 | + //$formats[$id] = 'raw'; |
|
| 308 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
| 309 | + } elseif ($port == '30005') { |
|
| 310 | 310 | // Not yet supported |
| 311 | - //$formats[$id] = 'beast'; |
|
| 312 | - $globalSources[$id]['format'] = 'beast'; |
|
| 313 | - //} else $formats[$id] = 'sbs'; |
|
| 314 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 315 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
| 311 | + //$formats[$id] = 'beast'; |
|
| 312 | + $globalSources[$id]['format'] = 'beast'; |
|
| 313 | + //} else $formats[$id] = 'sbs'; |
|
| 314 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
| 315 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
| 316 | 316 | } |
| 317 | 317 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
| 318 | - } else { |
|
| 318 | + } else { |
|
| 319 | 319 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
| 320 | 320 | sleep(10); |
| 321 | 321 | connect_all($hosts); |
| 322 | - } |
|
| 323 | - } |
|
| 324 | - } |
|
| 322 | + } |
|
| 323 | + } |
|
| 324 | + } |
|
| 325 | 325 | } |
| 326 | 326 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
| 327 | 327 | |
@@ -344,9 +344,9 @@ discard block |
||
| 344 | 344 | //connect_all($globalSources); |
| 345 | 345 | |
| 346 | 346 | if (isset($globalProxy) && $globalProxy) { |
| 347 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
| 347 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
| 348 | 348 | } else { |
| 349 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
| 349 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | // APRS Configuration |
@@ -355,21 +355,21 @@ discard block |
||
| 355 | 355 | die; |
| 356 | 356 | } |
| 357 | 357 | foreach ($globalSources as $key => $source) { |
| 358 | - if (!isset($source['format'])) { |
|
| 359 | - $globalSources[$key]['format'] = 'auto'; |
|
| 360 | - } |
|
| 361 | - if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
| 362 | - unset($globalSources[$key]); |
|
| 363 | - } |
|
| 358 | + if (!isset($source['format'])) { |
|
| 359 | + $globalSources[$key]['format'] = 'auto'; |
|
| 360 | + } |
|
| 361 | + if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
| 362 | + unset($globalSources[$key]); |
|
| 363 | + } |
|
| 364 | 364 | } |
| 365 | 365 | connect_all($globalSources); |
| 366 | 366 | foreach ($globalSources as $key => $source) { |
| 367 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 367 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 368 | 368 | $aprs_connect = 0; |
| 369 | 369 | $use_aprs = true; |
| 370 | 370 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
| 371 | 371 | break; |
| 372 | - } |
|
| 372 | + } |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | if ($use_aprs) { |
@@ -410,133 +410,133 @@ discard block |
||
| 410 | 410 | |
| 411 | 411 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 412 | 412 | while ($i > 0) { |
| 413 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 413 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 414 | 414 | |
| 415 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 416 | - // Delete old ATC |
|
| 417 | - if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
| 415 | + if (!$globalDaemon) $i = $endtime-time(); |
|
| 416 | + // Delete old ATC |
|
| 417 | + if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
| 418 | 418 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
| 419 | - $ATC->deleteOldATC(); |
|
| 420 | - } |
|
| 419 | + $ATC->deleteOldATC(); |
|
| 420 | + } |
|
| 421 | 421 | |
| 422 | - if (count($last_exec) == count($globalSources)) { |
|
| 422 | + if (count($last_exec) == count($globalSources)) { |
|
| 423 | 423 | $max = $globalMinFetch; |
| 424 | 424 | foreach ($last_exec as $last) { |
| 425 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 425 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 426 | 426 | } |
| 427 | 427 | if ($max < $globalMinFetch) { |
| 428 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 429 | - sleep($globalMinFetch-$max+2); |
|
| 428 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 429 | + sleep($globalMinFetch-$max+2); |
|
| 430 | + } |
|
| 430 | 431 | } |
| 431 | - } |
|
| 432 | 432 | |
| 433 | 433 | |
| 434 | - //foreach ($formats as $id => $value) { |
|
| 435 | - foreach ($globalSources as $id => $value) { |
|
| 434 | + //foreach ($formats as $id => $value) { |
|
| 435 | + foreach ($globalSources as $id => $value) { |
|
| 436 | 436 | date_default_timezone_set('UTC'); |
| 437 | 437 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
| 438 | 438 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
| 439 | 439 | if ($value['format'] === 'deltadbtxt' && |
| 440 | - ( |
|
| 440 | + ( |
|
| 441 | 441 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 442 | 442 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 443 | - ) |
|
| 443 | + ) |
|
| 444 | 444 | ) { |
| 445 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 446 | - $buffer = $Common->getData($value['host']); |
|
| 447 | - if ($buffer != '') $reset = 0; |
|
| 448 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 449 | - $buffer = explode('\n',$buffer); |
|
| 450 | - foreach ($buffer as $line) { |
|
| 451 | - if ($line != '' && count($line) > 7) { |
|
| 452 | - $line = explode(',', $line); |
|
| 453 | - $data = array(); |
|
| 454 | - $data['hex'] = $line[1]; // hex |
|
| 455 | - $data['ident'] = $line[2]; // ident |
|
| 456 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 457 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 458 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 459 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 460 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 461 | - $data['verticalrate'] = ''; // vertical rate |
|
| 462 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
| 463 | - $data['emergency'] = ''; // emergency |
|
| 464 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 465 | - $data['format_source'] = 'deltadbtxt'; |
|
| 466 | - $data['id_source'] = $id_source; |
|
| 467 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 468 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 469 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 470 | - $SI->add($data); |
|
| 471 | - unset($data); |
|
| 472 | - } |
|
| 473 | - } |
|
| 474 | - $last_exec[$id]['last'] = time(); |
|
| 445 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 446 | + $buffer = $Common->getData($value['host']); |
|
| 447 | + if ($buffer != '') $reset = 0; |
|
| 448 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 449 | + $buffer = explode('\n',$buffer); |
|
| 450 | + foreach ($buffer as $line) { |
|
| 451 | + if ($line != '' && count($line) > 7) { |
|
| 452 | + $line = explode(',', $line); |
|
| 453 | + $data = array(); |
|
| 454 | + $data['hex'] = $line[1]; // hex |
|
| 455 | + $data['ident'] = $line[2]; // ident |
|
| 456 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 457 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 458 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 459 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 460 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 461 | + $data['verticalrate'] = ''; // vertical rate |
|
| 462 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
| 463 | + $data['emergency'] = ''; // emergency |
|
| 464 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 465 | + $data['format_source'] = 'deltadbtxt'; |
|
| 466 | + $data['id_source'] = $id_source; |
|
| 467 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 468 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 469 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 470 | + $SI->add($data); |
|
| 471 | + unset($data); |
|
| 472 | + } |
|
| 473 | + } |
|
| 474 | + $last_exec[$id]['last'] = time(); |
|
| 475 | 475 | } elseif ($value['format'] === 'aisnmeatxt' && |
| 476 | - ( |
|
| 476 | + ( |
|
| 477 | 477 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 478 | 478 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 479 | - ) |
|
| 479 | + ) |
|
| 480 | 480 | ) { |
| 481 | - date_default_timezone_set('CET'); |
|
| 482 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
| 483 | - date_default_timezone_set('UTC'); |
|
| 484 | - if ($buffer != '') $reset = 0; |
|
| 485 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 486 | - $buffer = explode('\n',$buffer); |
|
| 487 | - foreach ($buffer as $line) { |
|
| 481 | + date_default_timezone_set('CET'); |
|
| 482 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
| 483 | + date_default_timezone_set('UTC'); |
|
| 484 | + if ($buffer != '') $reset = 0; |
|
| 485 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 486 | + $buffer = explode('\n',$buffer); |
|
| 487 | + foreach ($buffer as $line) { |
|
| 488 | 488 | if ($line != '') { |
| 489 | - //echo "'".$line."'\n"; |
|
| 490 | - $add = false; |
|
| 491 | - $ais_data = $AIS->parse_line(trim($line)); |
|
| 492 | - $data = array(); |
|
| 493 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 494 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 495 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 496 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 497 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 498 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 499 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 500 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 501 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 502 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
| 503 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 504 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 505 | - if (isset($ais_data['timestamp'])) { |
|
| 489 | + //echo "'".$line."'\n"; |
|
| 490 | + $add = false; |
|
| 491 | + $ais_data = $AIS->parse_line(trim($line)); |
|
| 492 | + $data = array(); |
|
| 493 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 494 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 495 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 496 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 497 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 498 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 499 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 500 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 501 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 502 | + if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
| 503 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 504 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 505 | + if (isset($ais_data['timestamp'])) { |
|
| 506 | 506 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 507 | 507 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
| 508 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
| 509 | - $add = true; |
|
| 508 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
| 509 | + $add = true; |
|
| 510 | 510 | } |
| 511 | - } else { |
|
| 511 | + } else { |
|
| 512 | 512 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 513 | 513 | $add = true; |
| 514 | - } |
|
| 515 | - $data['format_source'] = 'aisnmeatxt'; |
|
| 516 | - $data['id_source'] = $id_source; |
|
| 517 | - //print_r($data); |
|
| 518 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 519 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 520 | - unset($data); |
|
| 514 | + } |
|
| 515 | + $data['format_source'] = 'aisnmeatxt'; |
|
| 516 | + $data['id_source'] = $id_source; |
|
| 517 | + //print_r($data); |
|
| 518 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 519 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 520 | + unset($data); |
|
| 521 | 521 | } |
| 522 | - } |
|
| 523 | - $last_exec[$id]['last'] = time(); |
|
| 522 | + } |
|
| 523 | + $last_exec[$id]['last'] = time(); |
|
| 524 | 524 | } elseif ($value['format'] === 'aisnmeahttp') { |
| 525 | - $arr = $httpfeeds; |
|
| 526 | - $w = $e = null; |
|
| 525 | + $arr = $httpfeeds; |
|
| 526 | + $w = $e = null; |
|
| 527 | 527 | |
| 528 | - if (isset($arr[$id])) { |
|
| 528 | + if (isset($arr[$id])) { |
|
| 529 | 529 | $nn = stream_select($arr,$w,$e,$timeout); |
| 530 | 530 | if ($nn > 0) { |
| 531 | - foreach ($httpfeeds as $feed) { |
|
| 531 | + foreach ($httpfeeds as $feed) { |
|
| 532 | 532 | $buffer = stream_get_line($feed,2000,"\n"); |
| 533 | 533 | if ($buffer === FALSE) { |
| 534 | - connect_all($globalSources); |
|
| 534 | + connect_all($globalSources); |
|
| 535 | 535 | } |
| 536 | 536 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 537 | 537 | $buffer = explode('\n',$buffer); |
| 538 | 538 | foreach ($buffer as $line) { |
| 539 | - if ($line != '') { |
|
| 539 | + if ($line != '') { |
|
| 540 | 540 | $ais_data = $AIS->parse_line(trim($line)); |
| 541 | 541 | $data = array(); |
| 542 | 542 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
@@ -554,117 +554,117 @@ discard block |
||
| 554 | 554 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
| 555 | 555 | if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
| 556 | 556 | if (isset($ais_data['timestamp'])) { |
| 557 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 557 | + $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 558 | 558 | } else { |
| 559 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 559 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 560 | 560 | } |
| 561 | 561 | $data['format_source'] = 'aisnmeahttp'; |
| 562 | 562 | $data['id_source'] = $id_source; |
| 563 | 563 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 564 | 564 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
| 565 | 565 | unset($data); |
| 566 | - } |
|
| 566 | + } |
|
| 567 | + } |
|
| 567 | 568 | } |
| 568 | - } |
|
| 569 | 569 | } else { |
| 570 | - $format = $value['format']; |
|
| 571 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 572 | - else $tt[$format] = 0; |
|
| 573 | - if ($tt[$format] > 30) { |
|
| 570 | + $format = $value['format']; |
|
| 571 | + if (isset($tt[$format])) $tt[$format]++; |
|
| 572 | + else $tt[$format] = 0; |
|
| 573 | + if ($tt[$format] > 30) { |
|
| 574 | 574 | if ($globalDebug) echo 'Reconnect...'."\n"; |
| 575 | 575 | sleep(2); |
| 576 | 576 | //$sourceeen[] = $value; |
| 577 | 577 | //connect_all($sourceeen); |
| 578 | 578 | //$sourceeen = array(); |
| 579 | 579 | connect_all($globalSources); |
| 580 | - } |
|
| 580 | + } |
|
| 581 | + } |
|
| 581 | 582 | } |
| 582 | - } |
|
| 583 | 583 | } elseif ($value['format'] === 'myshiptracking' && |
| 584 | - ( |
|
| 584 | + ( |
|
| 585 | 585 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 586 | 586 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 587 | - ) |
|
| 587 | + ) |
|
| 588 | 588 | ) { |
| 589 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 590 | - if ($buffer != '') { |
|
| 589 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 590 | + if ($buffer != '') { |
|
| 591 | 591 | //echo $buffer; |
| 592 | 592 | $all_data = json_decode($buffer,true); |
| 593 | 593 | //print_r($all_data); |
| 594 | 594 | if (isset($all_data[0]['DATA'])) { |
| 595 | - foreach ($all_data[0]['DATA'] as $line) { |
|
| 595 | + foreach ($all_data[0]['DATA'] as $line) { |
|
| 596 | 596 | if ($line != '') { |
| 597 | - $data = array(); |
|
| 598 | - $data['ident'] = $line['NAME']; |
|
| 599 | - $data['mmsi'] = $line['MMSI']; |
|
| 600 | - if (strlen($data['mmsi']) > 9) { |
|
| 597 | + $data = array(); |
|
| 598 | + $data['ident'] = $line['NAME']; |
|
| 599 | + $data['mmsi'] = $line['MMSI']; |
|
| 600 | + if (strlen($data['mmsi']) > 9) { |
|
| 601 | 601 | $data['mmsi'] = substr($data['mmsi'],-9); |
| 602 | - } |
|
| 603 | - $data['speed'] = $line['SOG']; |
|
| 604 | - $data['heading'] = $line['COG']; |
|
| 605 | - $data['latitude'] = $line['LAT']; |
|
| 606 | - $data['longitude'] = $line['LNG']; |
|
| 607 | - // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 608 | - //$data['type_id'] = $line['TYPE']; |
|
| 609 | - $data['imo'] = $line['IMO']; |
|
| 610 | - if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
| 611 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
| 612 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
| 613 | - $data['format_source'] = 'myshiptracking'; |
|
| 614 | - $data['id_source'] = $id_source; |
|
| 615 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 616 | - $MI->add($data); |
|
| 617 | - unset($data); |
|
| 602 | + } |
|
| 603 | + $data['speed'] = $line['SOG']; |
|
| 604 | + $data['heading'] = $line['COG']; |
|
| 605 | + $data['latitude'] = $line['LAT']; |
|
| 606 | + $data['longitude'] = $line['LNG']; |
|
| 607 | + // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 608 | + //$data['type_id'] = $line['TYPE']; |
|
| 609 | + $data['imo'] = $line['IMO']; |
|
| 610 | + if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
| 611 | + if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
| 612 | + $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
| 613 | + $data['format_source'] = 'myshiptracking'; |
|
| 614 | + $data['id_source'] = $id_source; |
|
| 615 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 616 | + $MI->add($data); |
|
| 617 | + unset($data); |
|
| 618 | + } |
|
| 618 | 619 | } |
| 619 | - } |
|
| 620 | 620 | } |
| 621 | - } |
|
| 622 | - $last_exec[$id]['last'] = time(); |
|
| 621 | + } |
|
| 622 | + $last_exec[$id]['last'] = time(); |
|
| 623 | 623 | } elseif ($value['format'] === 'boatbeaconapp' && |
| 624 | - ( |
|
| 624 | + ( |
|
| 625 | 625 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 626 | 626 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 627 | - ) |
|
| 627 | + ) |
|
| 628 | 628 | ) { |
| 629 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
| 630 | - if ($buffer != '') { |
|
| 629 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
| 630 | + if ($buffer != '') { |
|
| 631 | 631 | $all_data = json_decode($buffer,true); |
| 632 | 632 | if (isset($all_data[0]['mmsi'])) { |
| 633 | - foreach ($all_data as $line) { |
|
| 633 | + foreach ($all_data as $line) { |
|
| 634 | 634 | if ($line != '') { |
| 635 | - $data = array(); |
|
| 636 | - $data['ident'] = $line['shipname']; |
|
| 637 | - $data['callsign'] = $line['callsign']; |
|
| 638 | - $data['mmsi'] = substr($line['mmsi'],-9); |
|
| 639 | - $data['speed'] = $line['sog']; |
|
| 640 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 641 | - $data['latitude'] = $line['latitude']; |
|
| 642 | - $data['longitude'] = $line['longitude']; |
|
| 643 | - $data['type_id'] = $line['shiptype']; |
|
| 644 | - $data['arrival_code'] = $line['destination']; |
|
| 645 | - $data['datetime'] = $line['time']; |
|
| 646 | - $data['format_source'] = 'boatbeaconapp'; |
|
| 647 | - $data['id_source'] = $id_source; |
|
| 648 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 649 | - $MI->add($data); |
|
| 650 | - unset($data); |
|
| 635 | + $data = array(); |
|
| 636 | + $data['ident'] = $line['shipname']; |
|
| 637 | + $data['callsign'] = $line['callsign']; |
|
| 638 | + $data['mmsi'] = substr($line['mmsi'],-9); |
|
| 639 | + $data['speed'] = $line['sog']; |
|
| 640 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 641 | + $data['latitude'] = $line['latitude']; |
|
| 642 | + $data['longitude'] = $line['longitude']; |
|
| 643 | + $data['type_id'] = $line['shiptype']; |
|
| 644 | + $data['arrival_code'] = $line['destination']; |
|
| 645 | + $data['datetime'] = $line['time']; |
|
| 646 | + $data['format_source'] = 'boatbeaconapp'; |
|
| 647 | + $data['id_source'] = $id_source; |
|
| 648 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 649 | + $MI->add($data); |
|
| 650 | + unset($data); |
|
| 651 | + } |
|
| 651 | 652 | } |
| 652 | - } |
|
| 653 | 653 | } |
| 654 | 654 | |
| 655 | - } |
|
| 656 | - $last_exec[$id]['last'] = time(); |
|
| 655 | + } |
|
| 656 | + $last_exec[$id]['last'] = time(); |
|
| 657 | 657 | } elseif ($value['format'] === 'boatnerd' && |
| 658 | - ( |
|
| 658 | + ( |
|
| 659 | 659 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 660 | 660 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 661 | - ) |
|
| 661 | + ) |
|
| 662 | 662 | ) { |
| 663 | - $buffer = $Common->getData($value['host']); |
|
| 664 | - if ($buffer != '') { |
|
| 663 | + $buffer = $Common->getData($value['host']); |
|
| 664 | + if ($buffer != '') { |
|
| 665 | 665 | $all_data = json_decode($buffer,true); |
| 666 | 666 | if (isset($all_data['features'][0]['id'])) { |
| 667 | - foreach ($all_data['features'] as $line) { |
|
| 667 | + foreach ($all_data['features'] as $line) { |
|
| 668 | 668 | print_r($line); |
| 669 | 669 | $data = array(); |
| 670 | 670 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
@@ -684,67 +684,67 @@ discard block |
||
| 684 | 684 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 685 | 685 | if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
| 686 | 686 | unset($data); |
| 687 | - } |
|
| 687 | + } |
|
| 688 | 688 | } |
| 689 | 689 | |
| 690 | - } |
|
| 691 | - $last_exec[$id]['last'] = time(); |
|
| 690 | + } |
|
| 691 | + $last_exec[$id]['last'] = time(); |
|
| 692 | 692 | } elseif ($value['format'] === 'shipplotter' && |
| 693 | - ( |
|
| 693 | + ( |
|
| 694 | 694 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 695 | 695 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 696 | - ) |
|
| 696 | + ) |
|
| 697 | 697 | ) { |
| 698 | - if ($globalDebug) echo 'download...'; |
|
| 699 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
| 700 | - if ($globalDebug) echo 'done !'."\n"; |
|
| 701 | - // FIXME: Need more work |
|
| 702 | - if ($buffer != '') $reset = 0; |
|
| 703 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 704 | - $buffer = explode('\n',$buffer); |
|
| 705 | - foreach ($buffer as $line) { |
|
| 698 | + if ($globalDebug) echo 'download...'; |
|
| 699 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
| 700 | + if ($globalDebug) echo 'done !'."\n"; |
|
| 701 | + // FIXME: Need more work |
|
| 702 | + if ($buffer != '') $reset = 0; |
|
| 703 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 704 | + $buffer = explode('\n',$buffer); |
|
| 705 | + foreach ($buffer as $line) { |
|
| 706 | 706 | if ($line != '') { |
| 707 | - $data = array(); |
|
| 708 | - //echo $line."\n"; |
|
| 709 | - $data['mmsi'] = (int)substr($line,0,9); |
|
| 710 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
| 711 | - $data['status_id'] = substr($line,21,2); |
|
| 712 | - $data['type_id'] = substr($line,24,3); |
|
| 713 | - $data['latitude'] = substr($line,29,9); |
|
| 714 | - $data['longitude'] = substr($line,41,9); |
|
| 715 | - $data['speed'] = round(substr($line,51,5)); |
|
| 716 | - //$data['course'] = substr($line,57,5); |
|
| 717 | - $data['heading'] = round(substr($line,63,3)); |
|
| 718 | - //$data['draft'] = substr($line,67,4); |
|
| 719 | - //$data['length'] = substr($line,72,3); |
|
| 720 | - //$data['beam'] = substr($line,76,2); |
|
| 721 | - $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
| 722 | - //$data['callsign'] = trim(substr($line,100,7); |
|
| 723 | - $data['arrival_code'] = substr($line,108,20); |
|
| 724 | - //$data['etaDate'] = substr($line,129,5); |
|
| 725 | - //$data['etaTime'] = substr($line,135,5); |
|
| 726 | - $data['format_source'] = 'shipplotter'; |
|
| 727 | - $data['id_source'] = $id_source; |
|
| 728 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 729 | - //print_r($data); |
|
| 730 | - //echo 'Add...'."\n"; |
|
| 731 | - $MI->add($data); |
|
| 732 | - unset($data); |
|
| 707 | + $data = array(); |
|
| 708 | + //echo $line."\n"; |
|
| 709 | + $data['mmsi'] = (int)substr($line,0,9); |
|
| 710 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
| 711 | + $data['status_id'] = substr($line,21,2); |
|
| 712 | + $data['type_id'] = substr($line,24,3); |
|
| 713 | + $data['latitude'] = substr($line,29,9); |
|
| 714 | + $data['longitude'] = substr($line,41,9); |
|
| 715 | + $data['speed'] = round(substr($line,51,5)); |
|
| 716 | + //$data['course'] = substr($line,57,5); |
|
| 717 | + $data['heading'] = round(substr($line,63,3)); |
|
| 718 | + //$data['draft'] = substr($line,67,4); |
|
| 719 | + //$data['length'] = substr($line,72,3); |
|
| 720 | + //$data['beam'] = substr($line,76,2); |
|
| 721 | + $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
| 722 | + //$data['callsign'] = trim(substr($line,100,7); |
|
| 723 | + $data['arrival_code'] = substr($line,108,20); |
|
| 724 | + //$data['etaDate'] = substr($line,129,5); |
|
| 725 | + //$data['etaTime'] = substr($line,135,5); |
|
| 726 | + $data['format_source'] = 'shipplotter'; |
|
| 727 | + $data['id_source'] = $id_source; |
|
| 728 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 729 | + //print_r($data); |
|
| 730 | + //echo 'Add...'."\n"; |
|
| 731 | + $MI->add($data); |
|
| 732 | + unset($data); |
|
| 733 | 733 | } |
| 734 | - } |
|
| 735 | - $last_exec[$id]['last'] = time(); |
|
| 734 | + } |
|
| 735 | + $last_exec[$id]['last'] = time(); |
|
| 736 | 736 | } elseif ($value['format'] === 'sailaway' && |
| 737 | - ( |
|
| 737 | + ( |
|
| 738 | 738 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 739 | 739 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 740 | - ) |
|
| 740 | + ) |
|
| 741 | 741 | ) { |
| 742 | - if ($globalDebug) echo '! Download... '; |
|
| 743 | - for ($i =0; $i <= 1; $i++) { |
|
| 744 | - if ($globalDebug) echo 'Racetype: '.$i.' '; |
|
| 745 | - $buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i); |
|
| 746 | - if ($globalDebug) echo 'done'."\n"; |
|
| 747 | - if ($buffer != '') { |
|
| 742 | + if ($globalDebug) echo '! Download... '; |
|
| 743 | + for ($i =0; $i <= 1; $i++) { |
|
| 744 | + if ($globalDebug) echo 'Racetype: '.$i.' '; |
|
| 745 | + $buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i); |
|
| 746 | + if ($globalDebug) echo 'done'."\n"; |
|
| 747 | + if ($buffer != '') { |
|
| 748 | 748 | $all_data = json_decode($buffer,true); |
| 749 | 749 | if (isset($all_data['missions'])) { |
| 750 | 750 | foreach ($all_data['missions'] as $mission) { |
@@ -803,34 +803,34 @@ discard block |
||
| 803 | 803 | } |
| 804 | 804 | } |
| 805 | 805 | } |
| 806 | - } |
|
| 807 | - } |
|
| 808 | - $last_exec[$id]['last'] = time(); |
|
| 806 | + } |
|
| 807 | + } |
|
| 808 | + $last_exec[$id]['last'] = time(); |
|
| 809 | 809 | //} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
| 810 | 810 | } elseif ( |
| 811 | - ( |
|
| 811 | + ( |
|
| 812 | 812 | $value['format'] === 'whazzup' && |
| 813 | 813 | ( |
| 814 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 815 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 814 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 815 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 816 | 816 | ) |
| 817 | - ) || ( |
|
| 817 | + ) || ( |
|
| 818 | 818 | $value['format'] === 'vatsimtxt' && |
| 819 | 819 | ( |
| 820 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 821 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 820 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 821 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 822 | + ) |
|
| 822 | 823 | ) |
| 823 | - ) |
|
| 824 | 824 | ) { |
| 825 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 826 | - $buffer = $Common->getData($value['host']); |
|
| 827 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 828 | - $buffer = explode('\n',$buffer); |
|
| 829 | - $reset = 0; |
|
| 830 | - foreach ($buffer as $line) { |
|
| 831 | - if ($line != '') { |
|
| 832 | - $line = explode(':', $line); |
|
| 833 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
| 825 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 826 | + $buffer = $Common->getData($value['host']); |
|
| 827 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 828 | + $buffer = explode('\n',$buffer); |
|
| 829 | + $reset = 0; |
|
| 830 | + foreach ($buffer as $line) { |
|
| 831 | + if ($line != '') { |
|
| 832 | + $line = explode(':', $line); |
|
| 833 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
| 834 | 834 | $data = array(); |
| 835 | 835 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
| 836 | 836 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -843,37 +843,37 @@ discard block |
||
| 843 | 843 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
| 844 | 844 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
| 845 | 845 | $data['latitude'] = $line[5]; // lat |
| 846 | - $data['longitude'] = $line[6]; // long |
|
| 847 | - $data['verticalrate'] = ''; // vertical rate |
|
| 848 | - $data['squawk'] = ''; // squawk |
|
| 849 | - $data['emergency'] = ''; // emergency |
|
| 850 | - $data['waypoints'] = $line[30]; |
|
| 846 | + $data['longitude'] = $line[6]; // long |
|
| 847 | + $data['verticalrate'] = ''; // vertical rate |
|
| 848 | + $data['squawk'] = ''; // squawk |
|
| 849 | + $data['emergency'] = ''; // emergency |
|
| 850 | + $data['waypoints'] = $line[30]; |
|
| 851 | 851 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 852 | 852 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
| 853 | 853 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
| 854 | - $data['departure_airport_icao'] = $line[11]; |
|
| 855 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 856 | - $data['arrival_airport_icao'] = $line[13]; |
|
| 854 | + $data['departure_airport_icao'] = $line[11]; |
|
| 855 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 856 | + $data['arrival_airport_icao'] = $line[13]; |
|
| 857 | 857 | $data['frequency'] = $line[4]; |
| 858 | 858 | $data['type'] = $line[18]; |
| 859 | 859 | $data['range'] = $line[19]; |
| 860 | 860 | if (isset($line[35])) $data['info'] = $line[35]; |
| 861 | - $data['id_source'] = $id_source; |
|
| 862 | - //$data['arrival_airport_time'] = ; |
|
| 863 | - if ($line[9] != '') { |
|
| 864 | - $aircraft_data = explode('/',$line[9]); |
|
| 865 | - if (isset($aircraft_data[1])) { |
|
| 866 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 867 | - } |
|
| 868 | - } |
|
| 869 | - /* |
|
| 861 | + $data['id_source'] = $id_source; |
|
| 862 | + //$data['arrival_airport_time'] = ; |
|
| 863 | + if ($line[9] != '') { |
|
| 864 | + $aircraft_data = explode('/',$line[9]); |
|
| 865 | + if (isset($aircraft_data[1])) { |
|
| 866 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 867 | + } |
|
| 868 | + } |
|
| 869 | + /* |
|
| 870 | 870 | if ($value === 'whazzup') $data['format_source'] = 'whazzup'; |
| 871 | 871 | elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 872 | 872 | */ |
| 873 | - $data['format_source'] = $value['format']; |
|
| 873 | + $data['format_source'] = $value['format']; |
|
| 874 | 874 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 875 | 875 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 876 | - if ($line[3] === 'PILOT') $SI->add($data); |
|
| 876 | + if ($line[3] === 'PILOT') $SI->add($data); |
|
| 877 | 877 | elseif ($line[3] === 'ATC') { |
| 878 | 878 | //print_r($data); |
| 879 | 879 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -894,21 +894,21 @@ discard block |
||
| 894 | 894 | 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']); |
| 895 | 895 | } |
| 896 | 896 | } |
| 897 | - unset($data); |
|
| 898 | - } |
|
| 899 | - } |
|
| 900 | - } |
|
| 901 | - //if ($value === 'whazzup') $last_exec['whazzup'] = time(); |
|
| 902 | - //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
| 903 | - $last_exec[$id]['last'] = time(); |
|
| 904 | - } elseif ($value['format'] === 'airwhere' && |
|
| 905 | - ( |
|
| 906 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 907 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 908 | - ) |
|
| 909 | - ) { |
|
| 910 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
| 911 | - if ($buffer != '') { |
|
| 897 | + unset($data); |
|
| 898 | + } |
|
| 899 | + } |
|
| 900 | + } |
|
| 901 | + //if ($value === 'whazzup') $last_exec['whazzup'] = time(); |
|
| 902 | + //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
| 903 | + $last_exec[$id]['last'] = time(); |
|
| 904 | + } elseif ($value['format'] === 'airwhere' && |
|
| 905 | + ( |
|
| 906 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 907 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 908 | + ) |
|
| 909 | + ) { |
|
| 910 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
| 911 | + if ($buffer != '') { |
|
| 912 | 912 | $all_data = simplexml_load_string($buffer); |
| 913 | 913 | foreach($all_data->children() as $childdata) { |
| 914 | 914 | $data = array(); |
@@ -930,10 +930,10 @@ discard block |
||
| 930 | 930 | $SI->add($data); |
| 931 | 931 | unset($data); |
| 932 | 932 | } |
| 933 | - } |
|
| 934 | - $Source->deleteOldLocationByType('gs'); |
|
| 935 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
| 936 | - if ($buffer != '') { |
|
| 933 | + } |
|
| 934 | + $Source->deleteOldLocationByType('gs'); |
|
| 935 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
| 936 | + if ($buffer != '') { |
|
| 937 | 937 | $all_data = simplexml_load_string($buffer); |
| 938 | 938 | foreach($all_data->children() as $childdata) { |
| 939 | 939 | $data = array(); |
@@ -951,8 +951,8 @@ discard block |
||
| 951 | 951 | } |
| 952 | 952 | unset($data); |
| 953 | 953 | } |
| 954 | - } |
|
| 955 | - $last_exec[$id]['last'] = time(); |
|
| 954 | + } |
|
| 955 | + $last_exec[$id]['last'] = time(); |
|
| 956 | 956 | /* |
| 957 | 957 | } if ($value['format'] === 'aircraftlistjson') { |
| 958 | 958 | print_r($globalSources); |
@@ -960,17 +960,17 @@ discard block |
||
| 960 | 960 | echo $globalMinFetch; |
| 961 | 961 | */ |
| 962 | 962 | } elseif ($value['format'] === 'aircraftlistjson' && |
| 963 | - ( |
|
| 963 | + ( |
|
| 964 | 964 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 965 | 965 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 966 | - ) |
|
| 966 | + ) |
|
| 967 | 967 | ) { |
| 968 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 969 | - if ($buffer != '') { |
|
| 970 | - $all_data = json_decode($buffer,true); |
|
| 968 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 969 | + if ($buffer != '') { |
|
| 970 | + $all_data = json_decode($buffer,true); |
|
| 971 | 971 | if (isset($all_data['acList'])) { |
| 972 | - $reset = 0; |
|
| 973 | - foreach ($all_data['acList'] as $line) { |
|
| 972 | + $reset = 0; |
|
| 973 | + foreach ($all_data['acList'] as $line) { |
|
| 974 | 974 | $data = array(); |
| 975 | 975 | $data['hex'] = $line['Icao']; // hex |
| 976 | 976 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -993,10 +993,10 @@ discard block |
||
| 993 | 993 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 994 | 994 | if (isset($data['latitude'])) $SI->add($data); |
| 995 | 995 | unset($data); |
| 996 | - } |
|
| 996 | + } |
|
| 997 | 997 | } elseif (is_array($all_data)) { |
| 998 | - $reset = 0; |
|
| 999 | - foreach ($all_data as $line) { |
|
| 998 | + $reset = 0; |
|
| 999 | + foreach ($all_data as $line) { |
|
| 1000 | 1000 | $data = array(); |
| 1001 | 1001 | $data['hex'] = $line['hex']; // hex |
| 1002 | 1002 | $data['ident'] = $line['flight']; // ident |
@@ -1016,291 +1016,291 @@ discard block |
||
| 1016 | 1016 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 1017 | 1017 | $SI->add($data); |
| 1018 | 1018 | unset($data); |
| 1019 | - } |
|
| 1019 | + } |
|
| 1020 | 1020 | } |
| 1021 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
| 1022 | - //$last_exec['aircraftlistjson'] = time(); |
|
| 1023 | - $last_exec[$id]['last'] = time(); |
|
| 1024 | - //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
| 1025 | - } elseif ($value['format'] === 'planeupdatefaa' && |
|
| 1026 | - ( |
|
| 1027 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 1028 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 1029 | - ) |
|
| 1030 | - ) { |
|
| 1031 | - $buffer = $Common->getData($value['host']); |
|
| 1032 | - $all_data = json_decode($buffer,true); |
|
| 1033 | - if (isset($all_data['planes'])) { |
|
| 1021 | + } elseif ($globalDebug) echo 'No data'."\n"; |
|
| 1022 | + //$last_exec['aircraftlistjson'] = time(); |
|
| 1023 | + $last_exec[$id]['last'] = time(); |
|
| 1024 | + //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
| 1025 | + } elseif ($value['format'] === 'planeupdatefaa' && |
|
| 1026 | + ( |
|
| 1027 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
| 1028 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
| 1029 | + ) |
|
| 1030 | + ) { |
|
| 1031 | + $buffer = $Common->getData($value['host']); |
|
| 1032 | + $all_data = json_decode($buffer,true); |
|
| 1033 | + if (isset($all_data['planes'])) { |
|
| 1034 | 1034 | $reset = 0; |
| 1035 | 1035 | foreach ($all_data['planes'] as $key => $line) { |
| 1036 | - $data = array(); |
|
| 1037 | - $data['hex'] = $key; // hex |
|
| 1038 | - $data['ident'] = $line[3]; // ident |
|
| 1039 | - $data['altitude'] = $line[6]; // altitude |
|
| 1040 | - $data['speed'] = $line[8]; // speed |
|
| 1041 | - $data['heading'] = $line[7]; // heading |
|
| 1042 | - $data['latitude'] = $line[4]; // lat |
|
| 1043 | - $data['longitude'] = $line[5]; // long |
|
| 1044 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
| 1045 | - $data['squawk'] = $line[10]; // squawk |
|
| 1046 | - $data['emergency'] = ''; // emergency |
|
| 1047 | - $data['registration'] = $line[2]; |
|
| 1048 | - $data['aircraft_icao'] = $line[0]; |
|
| 1049 | - $deparr = explode('-',$line[1]); |
|
| 1050 | - if (count($deparr) === 2) { |
|
| 1036 | + $data = array(); |
|
| 1037 | + $data['hex'] = $key; // hex |
|
| 1038 | + $data['ident'] = $line[3]; // ident |
|
| 1039 | + $data['altitude'] = $line[6]; // altitude |
|
| 1040 | + $data['speed'] = $line[8]; // speed |
|
| 1041 | + $data['heading'] = $line[7]; // heading |
|
| 1042 | + $data['latitude'] = $line[4]; // lat |
|
| 1043 | + $data['longitude'] = $line[5]; // long |
|
| 1044 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
| 1045 | + $data['squawk'] = $line[10]; // squawk |
|
| 1046 | + $data['emergency'] = ''; // emergency |
|
| 1047 | + $data['registration'] = $line[2]; |
|
| 1048 | + $data['aircraft_icao'] = $line[0]; |
|
| 1049 | + $deparr = explode('-',$line[1]); |
|
| 1050 | + if (count($deparr) === 2) { |
|
| 1051 | 1051 | $data['departure_airport_icao'] = $deparr[0]; |
| 1052 | 1052 | $data['arrival_airport_icao'] = $deparr[1]; |
| 1053 | - } |
|
| 1054 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 1055 | - $data['format_source'] = 'planeupdatefaa'; |
|
| 1056 | - $data['id_source'] = $id_source; |
|
| 1057 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1058 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1059 | - $SI->add($data); |
|
| 1060 | - unset($data); |
|
| 1053 | + } |
|
| 1054 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 1055 | + $data['format_source'] = 'planeupdatefaa'; |
|
| 1056 | + $data['id_source'] = $id_source; |
|
| 1057 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1058 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1059 | + $SI->add($data); |
|
| 1060 | + unset($data); |
|
| 1061 | 1061 | } |
| 1062 | - } |
|
| 1063 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 1064 | - $last_exec[$id]['last'] = time(); |
|
| 1062 | + } |
|
| 1063 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 1064 | + $last_exec[$id]['last'] = time(); |
|
| 1065 | 1065 | } elseif ($value['format'] === 'opensky' && |
| 1066 | - ( |
|
| 1066 | + ( |
|
| 1067 | 1067 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1068 | 1068 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1069 | - ) |
|
| 1069 | + ) |
|
| 1070 | 1070 | ) { |
| 1071 | - $buffer = $Common->getData($value['host']); |
|
| 1072 | - $all_data = json_decode($buffer,true); |
|
| 1073 | - if (isset($all_data['states'])) { |
|
| 1071 | + $buffer = $Common->getData($value['host']); |
|
| 1072 | + $all_data = json_decode($buffer,true); |
|
| 1073 | + if (isset($all_data['states'])) { |
|
| 1074 | 1074 | $reset = 0; |
| 1075 | 1075 | foreach ($all_data['states'] as $key => $line) { |
| 1076 | - $data = array(); |
|
| 1077 | - $data['hex'] = $line[0]; // hex |
|
| 1078 | - $data['ident'] = trim($line[1]); // ident |
|
| 1079 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
| 1080 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
| 1081 | - $data['heading'] = round($line[10]); // heading |
|
| 1082 | - $data['latitude'] = $line[6]; // lat |
|
| 1083 | - $data['longitude'] = $line[5]; // long |
|
| 1084 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
| 1085 | - //$data['squawk'] = $line[10]; // squawk |
|
| 1086 | - //$data['emergency'] = ''; // emergency |
|
| 1087 | - //$data['registration'] = $line[2]; |
|
| 1088 | - //$data['aircraft_icao'] = $line[0]; |
|
| 1089 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 1090 | - $data['format_source'] = 'opensky'; |
|
| 1091 | - $data['id_source'] = $id_source; |
|
| 1092 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1093 | - $SI->add($data); |
|
| 1094 | - unset($data); |
|
| 1076 | + $data = array(); |
|
| 1077 | + $data['hex'] = $line[0]; // hex |
|
| 1078 | + $data['ident'] = trim($line[1]); // ident |
|
| 1079 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
| 1080 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
| 1081 | + $data['heading'] = round($line[10]); // heading |
|
| 1082 | + $data['latitude'] = $line[6]; // lat |
|
| 1083 | + $data['longitude'] = $line[5]; // long |
|
| 1084 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
| 1085 | + //$data['squawk'] = $line[10]; // squawk |
|
| 1086 | + //$data['emergency'] = ''; // emergency |
|
| 1087 | + //$data['registration'] = $line[2]; |
|
| 1088 | + //$data['aircraft_icao'] = $line[0]; |
|
| 1089 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 1090 | + $data['format_source'] = 'opensky'; |
|
| 1091 | + $data['id_source'] = $id_source; |
|
| 1092 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1093 | + $SI->add($data); |
|
| 1094 | + unset($data); |
|
| 1095 | + } |
|
| 1095 | 1096 | } |
| 1096 | - } |
|
| 1097 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 1098 | - $last_exec[$id]['last'] = time(); |
|
| 1097 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 1098 | + $last_exec[$id]['last'] = time(); |
|
| 1099 | 1099 | } elseif ($value['format'] === 'aircraftjson' && |
| 1100 | - ( |
|
| 1100 | + ( |
|
| 1101 | 1101 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1102 | 1102 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1103 | - ) |
|
| 1103 | + ) |
|
| 1104 | 1104 | ) { |
| 1105 | - $buffer = $Common->getData($value['host']); |
|
| 1106 | - $all_data = json_decode($buffer,true); |
|
| 1107 | - if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) { |
|
| 1105 | + $buffer = $Common->getData($value['host']); |
|
| 1106 | + $all_data = json_decode($buffer,true); |
|
| 1107 | + if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) { |
|
| 1108 | 1108 | $reset = 0; |
| 1109 | 1109 | foreach ($all_data['aircraft'] as $key => $line) { |
| 1110 | - $data = array(); |
|
| 1111 | - // add support for ground vehicule with ~ in front of hex |
|
| 1112 | - if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
| 1113 | - if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
| 1114 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1115 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1116 | - if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
| 1117 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1118 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1119 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1120 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1121 | - //$data['emergency'] = ''; // emergency |
|
| 1122 | - //$data['registration'] = $line[2]; |
|
| 1123 | - //$data['aircraft_icao'] = $line[0]; |
|
| 1124 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1125 | - $data['format_source'] = 'aircraftjson'; |
|
| 1126 | - $data['id_source'] = $id_source; |
|
| 1127 | - if (isset($value['name']) && $value['name'] != '') { |
|
| 1128 | - if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
| 1129 | - else $data['source_name'] = $value['name']; |
|
| 1130 | - } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
| 1131 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1132 | - $SI->add($data); |
|
| 1133 | - unset($data); |
|
| 1110 | + $data = array(); |
|
| 1111 | + // add support for ground vehicule with ~ in front of hex |
|
| 1112 | + if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
| 1113 | + if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
| 1114 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1115 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1116 | + if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
| 1117 | + if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1118 | + if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1119 | + if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1120 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1121 | + //$data['emergency'] = ''; // emergency |
|
| 1122 | + //$data['registration'] = $line[2]; |
|
| 1123 | + //$data['aircraft_icao'] = $line[0]; |
|
| 1124 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1125 | + $data['format_source'] = 'aircraftjson'; |
|
| 1126 | + $data['id_source'] = $id_source; |
|
| 1127 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1128 | + if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
| 1129 | + else $data['source_name'] = $value['name']; |
|
| 1130 | + } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
| 1131 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1132 | + $SI->add($data); |
|
| 1133 | + unset($data); |
|
| 1134 | 1134 | } |
| 1135 | - } |
|
| 1136 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 1137 | - $last_exec[$id]['last'] = time(); |
|
| 1135 | + } |
|
| 1136 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 1137 | + $last_exec[$id]['last'] = time(); |
|
| 1138 | 1138 | } elseif ($value['format'] === 'planefinderclient' && |
| 1139 | - ( |
|
| 1139 | + ( |
|
| 1140 | 1140 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1141 | 1141 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1142 | - ) |
|
| 1142 | + ) |
|
| 1143 | 1143 | ) { |
| 1144 | - $buffer = $Common->getData($value['host']); |
|
| 1145 | - $all_data = json_decode($buffer,true); |
|
| 1146 | - if (isset($all_data['aircraft'])) { |
|
| 1144 | + $buffer = $Common->getData($value['host']); |
|
| 1145 | + $all_data = json_decode($buffer,true); |
|
| 1146 | + if (isset($all_data['aircraft'])) { |
|
| 1147 | 1147 | $reset = 0; |
| 1148 | 1148 | foreach ($all_data['aircraft'] as $key => $line) { |
| 1149 | - $data = array(); |
|
| 1150 | - $data['hex'] = $key; // hex |
|
| 1151 | - if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident |
|
| 1152 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1153 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1154 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1155 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1156 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1157 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1158 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1159 | - //$data['emergency'] = ''; // emergency |
|
| 1160 | - if (isset($line['reg'])) $data['registration'] = $line['reg']; |
|
| 1161 | - if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
|
| 1162 | - $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
|
| 1163 | - $data['format_source'] = 'planefinderclient'; |
|
| 1164 | - $data['id_source'] = $id_source; |
|
| 1165 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1166 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1167 | - $SI->add($data); |
|
| 1168 | - unset($data); |
|
| 1149 | + $data = array(); |
|
| 1150 | + $data['hex'] = $key; // hex |
|
| 1151 | + if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident |
|
| 1152 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1153 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1154 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1155 | + if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1156 | + if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1157 | + if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1158 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1159 | + //$data['emergency'] = ''; // emergency |
|
| 1160 | + if (isset($line['reg'])) $data['registration'] = $line['reg']; |
|
| 1161 | + if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
|
| 1162 | + $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
|
| 1163 | + $data['format_source'] = 'planefinderclient'; |
|
| 1164 | + $data['id_source'] = $id_source; |
|
| 1165 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1166 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1167 | + $SI->add($data); |
|
| 1168 | + unset($data); |
|
| 1169 | + } |
|
| 1169 | 1170 | } |
| 1170 | - } |
|
| 1171 | - $last_exec[$id]['last'] = time(); |
|
| 1171 | + $last_exec[$id]['last'] = time(); |
|
| 1172 | 1172 | //} elseif ($value === 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
| 1173 | 1173 | } elseif ($value['format'] === 'fr24json' && |
| 1174 | - ( |
|
| 1174 | + ( |
|
| 1175 | 1175 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1176 | 1176 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1177 | - ) |
|
| 1177 | + ) |
|
| 1178 | 1178 | ) { |
| 1179 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1180 | - $buffer = $Common->getData($value['host']); |
|
| 1181 | - $all_data = json_decode($buffer,true); |
|
| 1182 | - if (!empty($all_data)) $reset = 0; |
|
| 1183 | - foreach ($all_data as $key => $line) { |
|
| 1179 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1180 | + $buffer = $Common->getData($value['host']); |
|
| 1181 | + $all_data = json_decode($buffer,true); |
|
| 1182 | + if (!empty($all_data)) $reset = 0; |
|
| 1183 | + foreach ($all_data as $key => $line) { |
|
| 1184 | 1184 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 1185 | - $data = array(); |
|
| 1186 | - $data['hex'] = $line[0]; |
|
| 1187 | - $data['ident'] = $line[16]; //$line[13] |
|
| 1188 | - $data['altitude'] = $line[4]; // altitude |
|
| 1189 | - $data['speed'] = $line[5]; // speed |
|
| 1190 | - $data['heading'] = $line[3]; // heading |
|
| 1191 | - $data['latitude'] = $line[1]; // lat |
|
| 1192 | - $data['longitude'] = $line[2]; // long |
|
| 1193 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
| 1194 | - $data['squawk'] = $line[6]; // squawk |
|
| 1195 | - $data['aircraft_icao'] = $line[8]; |
|
| 1196 | - $data['registration'] = $line[9]; |
|
| 1197 | - $data['departure_airport_iata'] = $line[11]; |
|
| 1198 | - $data['arrival_airport_iata'] = $line[12]; |
|
| 1199 | - $data['emergency'] = ''; // emergency |
|
| 1200 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
| 1201 | - $data['format_source'] = 'fr24json'; |
|
| 1202 | - $data['id_source'] = $id_source; |
|
| 1203 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1204 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1205 | - $SI->add($data); |
|
| 1206 | - unset($data); |
|
| 1185 | + $data = array(); |
|
| 1186 | + $data['hex'] = $line[0]; |
|
| 1187 | + $data['ident'] = $line[16]; //$line[13] |
|
| 1188 | + $data['altitude'] = $line[4]; // altitude |
|
| 1189 | + $data['speed'] = $line[5]; // speed |
|
| 1190 | + $data['heading'] = $line[3]; // heading |
|
| 1191 | + $data['latitude'] = $line[1]; // lat |
|
| 1192 | + $data['longitude'] = $line[2]; // long |
|
| 1193 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
| 1194 | + $data['squawk'] = $line[6]; // squawk |
|
| 1195 | + $data['aircraft_icao'] = $line[8]; |
|
| 1196 | + $data['registration'] = $line[9]; |
|
| 1197 | + $data['departure_airport_iata'] = $line[11]; |
|
| 1198 | + $data['arrival_airport_iata'] = $line[12]; |
|
| 1199 | + $data['emergency'] = ''; // emergency |
|
| 1200 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
| 1201 | + $data['format_source'] = 'fr24json'; |
|
| 1202 | + $data['id_source'] = $id_source; |
|
| 1203 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1204 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1205 | + $SI->add($data); |
|
| 1206 | + unset($data); |
|
| 1207 | 1207 | } |
| 1208 | - } |
|
| 1209 | - //$last_exec['fr24json'] = time(); |
|
| 1210 | - $last_exec[$id]['last'] = time(); |
|
| 1208 | + } |
|
| 1209 | + //$last_exec['fr24json'] = time(); |
|
| 1210 | + $last_exec[$id]['last'] = time(); |
|
| 1211 | 1211 | //} elseif ($value === 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
| 1212 | 1212 | } elseif ($value['format'] === 'radarvirtueljson' && |
| 1213 | - ( |
|
| 1213 | + ( |
|
| 1214 | 1214 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1215 | 1215 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1216 | - ) |
|
| 1216 | + ) |
|
| 1217 | 1217 | ) { |
| 1218 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
| 1219 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 1220 | - //echo $buffer; |
|
| 1221 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 1222 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 1223 | - $all_data = json_decode($buffer,true); |
|
| 1224 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
| 1218 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
| 1219 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 1220 | + //echo $buffer; |
|
| 1221 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 1222 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 1223 | + $all_data = json_decode($buffer,true); |
|
| 1224 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
| 1225 | 1225 | die(json_last_error_msg()); |
| 1226 | - } |
|
| 1227 | - if (isset($all_data['mrkrs'])) { |
|
| 1226 | + } |
|
| 1227 | + if (isset($all_data['mrkrs'])) { |
|
| 1228 | 1228 | $reset = 0; |
| 1229 | 1229 | foreach ($all_data['mrkrs'] as $key => $line) { |
| 1230 | - if (isset($line['inf'])) { |
|
| 1230 | + if (isset($line['inf'])) { |
|
| 1231 | 1231 | $data = array(); |
| 1232 | 1232 | $data['hex'] = $line['inf']['ia']; |
| 1233 | 1233 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
| 1234 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
| 1235 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 1236 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 1237 | - $data['latitude'] = $line['pt'][0]; // lat |
|
| 1238 | - $data['longitude'] = $line['pt'][1]; // long |
|
| 1239 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
| 1240 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 1241 | - //$data['aircraft_icao'] = $line[8]; |
|
| 1242 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 1234 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
| 1235 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 1236 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 1237 | + $data['latitude'] = $line['pt'][0]; // lat |
|
| 1238 | + $data['longitude'] = $line['pt'][1]; // long |
|
| 1239 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
| 1240 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 1241 | + //$data['aircraft_icao'] = $line[8]; |
|
| 1242 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 1243 | 1243 | //$data['departure_airport_iata'] = $line[11]; |
| 1244 | 1244 | //$data['arrival_airport_iata'] = $line[12]; |
| 1245 | - //$data['emergency'] = ''; // emergency |
|
| 1245 | + //$data['emergency'] = ''; // emergency |
|
| 1246 | 1246 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 1247 | - $data['format_source'] = 'radarvirtueljson'; |
|
| 1248 | - $data['id_source'] = $id_source; |
|
| 1247 | + $data['format_source'] = 'radarvirtueljson'; |
|
| 1248 | + $data['id_source'] = $id_source; |
|
| 1249 | 1249 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1250 | 1250 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 1251 | 1251 | $SI->add($data); |
| 1252 | 1252 | unset($data); |
| 1253 | - } |
|
| 1253 | + } |
|
| 1254 | + } |
|
| 1254 | 1255 | } |
| 1255 | - } |
|
| 1256 | - //$last_exec['radarvirtueljson'] = time(); |
|
| 1257 | - $last_exec[$id]['last'] = time(); |
|
| 1256 | + //$last_exec['radarvirtueljson'] = time(); |
|
| 1257 | + $last_exec[$id]['last'] = time(); |
|
| 1258 | 1258 | //} elseif ($value === 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
| 1259 | 1259 | } elseif ($value['format'] === 'pirepsjson' && |
| 1260 | - ( |
|
| 1260 | + ( |
|
| 1261 | 1261 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1262 | 1262 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1263 | - ) |
|
| 1263 | + ) |
|
| 1264 | 1264 | ) { |
| 1265 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1266 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
| 1267 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
| 1265 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1266 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
| 1267 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
| 1268 | 1268 | |
| 1269 | - if (isset($all_data['pireps'])) { |
|
| 1269 | + if (isset($all_data['pireps'])) { |
|
| 1270 | 1270 | $reset = 0; |
| 1271 | - foreach ($all_data['pireps'] as $line) { |
|
| 1272 | - $data = array(); |
|
| 1273 | - $data['id'] = $line['id']; |
|
| 1274 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 1275 | - $data['ident'] = $line['callsign']; // ident |
|
| 1276 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 1277 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 1278 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 1279 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 1280 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1281 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1282 | - $data['latitude'] = $line['lat']; // lat |
|
| 1283 | - $data['longitude'] = $line['lon']; // long |
|
| 1284 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 1285 | - //$data['squawk'] = $line['squawk']; // squawk |
|
| 1286 | - //$data['emergency'] = ''; // emergency |
|
| 1287 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 1288 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 1289 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1290 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
| 1291 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 1292 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 1293 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 1294 | - else $data['info'] = ''; |
|
| 1295 | - $data['format_source'] = 'pireps'; |
|
| 1296 | - $data['id_source'] = $id_source; |
|
| 1297 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1298 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1299 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1300 | - if ($line['icon'] === 'plane') { |
|
| 1271 | + foreach ($all_data['pireps'] as $line) { |
|
| 1272 | + $data = array(); |
|
| 1273 | + $data['id'] = $line['id']; |
|
| 1274 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 1275 | + $data['ident'] = $line['callsign']; // ident |
|
| 1276 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 1277 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 1278 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 1279 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 1280 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1281 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1282 | + $data['latitude'] = $line['lat']; // lat |
|
| 1283 | + $data['longitude'] = $line['lon']; // long |
|
| 1284 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 1285 | + //$data['squawk'] = $line['squawk']; // squawk |
|
| 1286 | + //$data['emergency'] = ''; // emergency |
|
| 1287 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 1288 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 1289 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1290 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
| 1291 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 1292 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 1293 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 1294 | + else $data['info'] = ''; |
|
| 1295 | + $data['format_source'] = 'pireps'; |
|
| 1296 | + $data['id_source'] = $id_source; |
|
| 1297 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1298 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1299 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1300 | + if ($line['icon'] === 'plane') { |
|
| 1301 | 1301 | $SI->add($data); |
| 1302 | - // print_r($data); |
|
| 1303 | - } elseif ($line['icon'] === 'ct') { |
|
| 1302 | + // print_r($data); |
|
| 1303 | + } elseif ($line['icon'] === 'ct') { |
|
| 1304 | 1304 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 1305 | 1305 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 1306 | 1306 | $typec = substr($data['ident'],-3); |
@@ -1315,209 +1315,209 @@ discard block |
||
| 1315 | 1315 | elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 1316 | 1316 | else $data['type'] = 'Observer'; |
| 1317 | 1317 | 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']); |
| 1318 | - } |
|
| 1319 | - unset($data); |
|
| 1318 | + } |
|
| 1319 | + unset($data); |
|
| 1320 | + } |
|
| 1320 | 1321 | } |
| 1321 | - } |
|
| 1322 | - //$last_exec['pirepsjson'] = time(); |
|
| 1323 | - $last_exec[$id]['last'] = time(); |
|
| 1322 | + //$last_exec['pirepsjson'] = time(); |
|
| 1323 | + $last_exec[$id]['last'] = time(); |
|
| 1324 | 1324 | //} elseif ($value === 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
| 1325 | 1325 | } elseif ($value['format'] === 'phpvmacars' && |
| 1326 | - ( |
|
| 1326 | + ( |
|
| 1327 | 1327 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1328 | 1328 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1329 | - ) |
|
| 1329 | + ) |
|
| 1330 | 1330 | ) { |
| 1331 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1332 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1333 | - $buffer = $Common->getData($value['host']); |
|
| 1334 | - $all_data = json_decode($buffer,true); |
|
| 1335 | - if ($buffer != '' && is_array($all_data)) { |
|
| 1331 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1332 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1333 | + $buffer = $Common->getData($value['host']); |
|
| 1334 | + $all_data = json_decode($buffer,true); |
|
| 1335 | + if ($buffer != '' && is_array($all_data)) { |
|
| 1336 | 1336 | $reset = 0; |
| 1337 | 1337 | foreach ($all_data as $line) { |
| 1338 | - $data = array(); |
|
| 1339 | - //$data['id'] = $line['id']; // id not usable |
|
| 1340 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1341 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1342 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 1343 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 1344 | - $data['ident'] = $line['flightnum']; // ident |
|
| 1345 | - $data['altitude'] = $line['alt']; // altitude |
|
| 1346 | - $data['speed'] = $line['gs']; // speed |
|
| 1347 | - $data['heading'] = $line['heading']; // heading |
|
| 1348 | - $data['latitude'] = $line['lat']; // lat |
|
| 1349 | - $data['longitude'] = $line['lng']; // long |
|
| 1350 | - $data['verticalrate'] = ''; // verticale rate |
|
| 1351 | - $data['squawk'] = ''; // squawk |
|
| 1352 | - $data['emergency'] = ''; // emergency |
|
| 1353 | - //$data['datetime'] = $line['lastupdate']; |
|
| 1354 | - //$data['last_update'] = $line['lastupdate']; |
|
| 1355 | - if (isset($value['timezone'])) { |
|
| 1356 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
| 1357 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
| 1358 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
| 1359 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1360 | - $data['departure_airport_icao'] = $line['depicao']; |
|
| 1361 | - $data['departure_airport_time'] = $line['deptime']; |
|
| 1362 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1363 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
| 1364 | - if (isset($line['registration'])) { |
|
| 1365 | - $data['registration'] = $line['registration']; |
|
| 1366 | - //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
|
| 1367 | - } else $data['registration'] = $line['aircraft']; |
|
| 1368 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1369 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1370 | - if (isset($line['aircraftname'])) { |
|
| 1338 | + $data = array(); |
|
| 1339 | + //$data['id'] = $line['id']; // id not usable |
|
| 1340 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1341 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1342 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 1343 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 1344 | + $data['ident'] = $line['flightnum']; // ident |
|
| 1345 | + $data['altitude'] = $line['alt']; // altitude |
|
| 1346 | + $data['speed'] = $line['gs']; // speed |
|
| 1347 | + $data['heading'] = $line['heading']; // heading |
|
| 1348 | + $data['latitude'] = $line['lat']; // lat |
|
| 1349 | + $data['longitude'] = $line['lng']; // long |
|
| 1350 | + $data['verticalrate'] = ''; // verticale rate |
|
| 1351 | + $data['squawk'] = ''; // squawk |
|
| 1352 | + $data['emergency'] = ''; // emergency |
|
| 1353 | + //$data['datetime'] = $line['lastupdate']; |
|
| 1354 | + //$data['last_update'] = $line['lastupdate']; |
|
| 1355 | + if (isset($value['timezone'])) { |
|
| 1356 | + $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
| 1357 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
| 1358 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
| 1359 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1360 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 1361 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 1362 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1363 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
| 1364 | + if (isset($line['registration'])) { |
|
| 1365 | + $data['registration'] = $line['registration']; |
|
| 1366 | + //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
|
| 1367 | + } else $data['registration'] = $line['aircraft']; |
|
| 1368 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1369 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1370 | + if (isset($line['aircraftname'])) { |
|
| 1371 | 1371 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 1372 | 1372 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 1373 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
| 1374 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1375 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1376 | - else { |
|
| 1377 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 1378 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1379 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1380 | - } |
|
| 1381 | - } |
|
| 1382 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 1383 | - $data['id_source'] = $id_source; |
|
| 1384 | - $data['format_source'] = 'phpvmacars'; |
|
| 1385 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1386 | - $SI->add($data); |
|
| 1387 | - unset($data); |
|
| 1373 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
| 1374 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1375 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1376 | + else { |
|
| 1377 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 1378 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1379 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1380 | + } |
|
| 1381 | + } |
|
| 1382 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 1383 | + $data['id_source'] = $id_source; |
|
| 1384 | + $data['format_source'] = 'phpvmacars'; |
|
| 1385 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1386 | + $SI->add($data); |
|
| 1387 | + unset($data); |
|
| 1388 | 1388 | } |
| 1389 | 1389 | if ($globalDebug) echo 'No more data...'."\n"; |
| 1390 | 1390 | unset($buffer); |
| 1391 | 1391 | unset($all_data); |
| 1392 | - } |
|
| 1393 | - //$last_exec['phpvmacars'] = time(); |
|
| 1394 | - $last_exec[$id]['last'] = time(); |
|
| 1392 | + } |
|
| 1393 | + //$last_exec['phpvmacars'] = time(); |
|
| 1394 | + $last_exec[$id]['last'] = time(); |
|
| 1395 | 1395 | } elseif ($value['format'] === 'vaos' && |
| 1396 | - ( |
|
| 1396 | + ( |
|
| 1397 | 1397 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1398 | 1398 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1399 | - ) |
|
| 1399 | + ) |
|
| 1400 | 1400 | ) { |
| 1401 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1402 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1403 | - $buffer = $Common->getData($value['host']); |
|
| 1404 | - $all_data = json_decode($buffer,true); |
|
| 1405 | - if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
|
| 1401 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1402 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1403 | + $buffer = $Common->getData($value['host']); |
|
| 1404 | + $all_data = json_decode($buffer,true); |
|
| 1405 | + if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
|
| 1406 | 1406 | $reset = 0; |
| 1407 | 1407 | foreach ($all_data['ACARSData'] as $line) { |
| 1408 | - //print_r($line); |
|
| 1409 | - $data = array(); |
|
| 1410 | - //$data['id'] = $line['id']; // id not usable |
|
| 1411 | - $data['id'] = $line['id']; |
|
| 1412 | - //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1413 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
| 1414 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
| 1415 | - $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
| 1416 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
| 1417 | - $data['altitude'] = $line['altitude']; // altitude |
|
| 1418 | - $data['speed'] = $line['groundspeed']; // speed |
|
| 1419 | - $data['heading'] = $line['heading']; // heading |
|
| 1420 | - $data['latitude'] = $line['lat']; // lat |
|
| 1421 | - $data['longitude'] = $line['lon']; // long |
|
| 1422 | - //$data['verticalrate'] = ''; // verticale rate |
|
| 1423 | - //$data['squawk'] = ''; // squawk |
|
| 1424 | - //$data['emergency'] = ''; // emergency |
|
| 1425 | - if (isset($value['timezone'])) { |
|
| 1426 | - $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
| 1427 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
| 1428 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
| 1429 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1408 | + //print_r($line); |
|
| 1409 | + $data = array(); |
|
| 1410 | + //$data['id'] = $line['id']; // id not usable |
|
| 1411 | + $data['id'] = $line['id']; |
|
| 1412 | + //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1413 | + if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
| 1414 | + if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
| 1415 | + $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
| 1416 | + if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
| 1417 | + $data['altitude'] = $line['altitude']; // altitude |
|
| 1418 | + $data['speed'] = $line['groundspeed']; // speed |
|
| 1419 | + $data['heading'] = $line['heading']; // heading |
|
| 1420 | + $data['latitude'] = $line['lat']; // lat |
|
| 1421 | + $data['longitude'] = $line['lon']; // long |
|
| 1422 | + //$data['verticalrate'] = ''; // verticale rate |
|
| 1423 | + //$data['squawk'] = ''; // squawk |
|
| 1424 | + //$data['emergency'] = ''; // emergency |
|
| 1425 | + if (isset($value['timezone'])) { |
|
| 1426 | + $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
| 1427 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
| 1428 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
| 1429 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1430 | 1430 | |
| 1431 | - $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
|
| 1432 | - $data['departure_airport_time'] = $line['bid']['deptime']; |
|
| 1433 | - $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao']; |
|
| 1434 | - $data['arrival_airport_time'] = $line['bid']['arrtime']; |
|
| 1435 | - $data['registration'] = $line['bid']['aircraft']['registration']; |
|
| 1431 | + $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
|
| 1432 | + $data['departure_airport_time'] = $line['bid']['deptime']; |
|
| 1433 | + $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao']; |
|
| 1434 | + $data['arrival_airport_time'] = $line['bid']['arrtime']; |
|
| 1435 | + $data['registration'] = $line['bid']['aircraft']['registration']; |
|
| 1436 | 1436 | |
| 1437 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1438 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
| 1439 | - $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
|
| 1437 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1438 | + if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
| 1439 | + $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
|
| 1440 | 1440 | |
| 1441 | - $data['id_source'] = $id_source; |
|
| 1442 | - $data['format_source'] = 'vaos'; |
|
| 1443 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1444 | - $SI->add($data); |
|
| 1445 | - unset($data); |
|
| 1441 | + $data['id_source'] = $id_source; |
|
| 1442 | + $data['format_source'] = 'vaos'; |
|
| 1443 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1444 | + $SI->add($data); |
|
| 1445 | + unset($data); |
|
| 1446 | 1446 | } |
| 1447 | 1447 | if ($globalDebug) echo 'No more data...'."\n"; |
| 1448 | 1448 | unset($buffer); |
| 1449 | 1449 | unset($all_data); |
| 1450 | - } |
|
| 1451 | - //$last_exec['phpvmacars'] = time(); |
|
| 1452 | - $last_exec[$id]['last'] = time(); |
|
| 1450 | + } |
|
| 1451 | + //$last_exec['phpvmacars'] = time(); |
|
| 1452 | + $last_exec[$id]['last'] = time(); |
|
| 1453 | 1453 | } elseif ($value['format'] === 'vam' && |
| 1454 | - ( |
|
| 1454 | + ( |
|
| 1455 | 1455 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1456 | 1456 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1457 | - ) |
|
| 1457 | + ) |
|
| 1458 | 1458 | ) { |
| 1459 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1460 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1461 | - $buffer = $Common->getData($value['host']); |
|
| 1462 | - $all_data = json_decode($buffer,true); |
|
| 1463 | - if ($buffer != '' && is_array($all_data)) { |
|
| 1459 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1460 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1461 | + $buffer = $Common->getData($value['host']); |
|
| 1462 | + $all_data = json_decode($buffer,true); |
|
| 1463 | + if ($buffer != '' && is_array($all_data)) { |
|
| 1464 | 1464 | $reset = 0; |
| 1465 | 1465 | foreach ($all_data as $line) { |
| 1466 | - $data = array(); |
|
| 1467 | - //$data['id'] = $line['id']; // id not usable |
|
| 1468 | - $data['id'] = trim($line['flight_id']); |
|
| 1469 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1470 | - $data['pilot_name'] = $line['pilot_name']; |
|
| 1471 | - $data['pilot_id'] = $line['pilot_id']; |
|
| 1472 | - $data['ident'] = trim($line['callsign']); // ident |
|
| 1473 | - $data['altitude'] = $line['altitude']; // altitude |
|
| 1474 | - $data['speed'] = $line['gs']; // speed |
|
| 1475 | - $data['heading'] = $line['heading']; // heading |
|
| 1476 | - $data['latitude'] = $line['latitude']; // lat |
|
| 1477 | - $data['longitude'] = $line['longitude']; // long |
|
| 1478 | - $data['verticalrate'] = ''; // verticale rate |
|
| 1479 | - $data['squawk'] = ''; // squawk |
|
| 1480 | - $data['emergency'] = ''; // emergency |
|
| 1481 | - //$data['datetime'] = $line['lastupdate']; |
|
| 1482 | - $data['last_update'] = $line['last_update']; |
|
| 1483 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1484 | - $data['departure_airport_icao'] = $line['departure']; |
|
| 1485 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
| 1486 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
| 1487 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
| 1488 | - //$data['registration'] = $line['aircraft']; |
|
| 1489 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1490 | - $data['aircraft_icao'] = $line['plane_type']; |
|
| 1491 | - $data['id_source'] = $id_source; |
|
| 1492 | - $data['format_source'] = 'vam'; |
|
| 1493 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1494 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1495 | - $SI->add($data); |
|
| 1496 | - unset($data); |
|
| 1466 | + $data = array(); |
|
| 1467 | + //$data['id'] = $line['id']; // id not usable |
|
| 1468 | + $data['id'] = trim($line['flight_id']); |
|
| 1469 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1470 | + $data['pilot_name'] = $line['pilot_name']; |
|
| 1471 | + $data['pilot_id'] = $line['pilot_id']; |
|
| 1472 | + $data['ident'] = trim($line['callsign']); // ident |
|
| 1473 | + $data['altitude'] = $line['altitude']; // altitude |
|
| 1474 | + $data['speed'] = $line['gs']; // speed |
|
| 1475 | + $data['heading'] = $line['heading']; // heading |
|
| 1476 | + $data['latitude'] = $line['latitude']; // lat |
|
| 1477 | + $data['longitude'] = $line['longitude']; // long |
|
| 1478 | + $data['verticalrate'] = ''; // verticale rate |
|
| 1479 | + $data['squawk'] = ''; // squawk |
|
| 1480 | + $data['emergency'] = ''; // emergency |
|
| 1481 | + //$data['datetime'] = $line['lastupdate']; |
|
| 1482 | + $data['last_update'] = $line['last_update']; |
|
| 1483 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1484 | + $data['departure_airport_icao'] = $line['departure']; |
|
| 1485 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
| 1486 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
| 1487 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
| 1488 | + //$data['registration'] = $line['aircraft']; |
|
| 1489 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1490 | + $data['aircraft_icao'] = $line['plane_type']; |
|
| 1491 | + $data['id_source'] = $id_source; |
|
| 1492 | + $data['format_source'] = 'vam'; |
|
| 1493 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1494 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1495 | + $SI->add($data); |
|
| 1496 | + unset($data); |
|
| 1497 | 1497 | } |
| 1498 | 1498 | if ($globalDebug) echo 'No more data...'."\n"; |
| 1499 | 1499 | unset($buffer); |
| 1500 | 1500 | unset($all_data); |
| 1501 | - } |
|
| 1502 | - //$last_exec['phpvmacars'] = time(); |
|
| 1503 | - $last_exec[$id]['last'] = time(); |
|
| 1501 | + } |
|
| 1502 | + //$last_exec['phpvmacars'] = time(); |
|
| 1503 | + $last_exec[$id]['last'] = time(); |
|
| 1504 | 1504 | } elseif ($value['format'] === 'blitzortung' && |
| 1505 | - ( |
|
| 1505 | + ( |
|
| 1506 | 1506 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
| 1507 | 1507 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1508 | - ) |
|
| 1508 | + ) |
|
| 1509 | 1509 | ) { |
| 1510 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 1511 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1512 | - $buffer = $Common->getData($value['host']); |
|
| 1513 | - $all_data = json_decode($buffer,true); |
|
| 1514 | - if ($buffer != '') { |
|
| 1510 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 1511 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1512 | + $buffer = $Common->getData($value['host']); |
|
| 1513 | + $all_data = json_decode($buffer,true); |
|
| 1514 | + if ($buffer != '') { |
|
| 1515 | 1515 | $Source->deleteLocationBySource('blitzortung'); |
| 1516 | 1516 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 1517 | 1517 | $buffer = explode('\n',$buffer); |
| 1518 | 1518 | foreach ($buffer as $buffer_line) { |
| 1519 | - $line = json_decode($buffer_line,true); |
|
| 1520 | - if (isset($line['time'])) { |
|
| 1519 | + $line = json_decode($buffer_line,true); |
|
| 1520 | + if (isset($line['time'])) { |
|
| 1521 | 1521 | $data = array(); |
| 1522 | 1522 | $data['altitude'] = $line['alt']; // altitude |
| 1523 | 1523 | $data['latitude'] = $line['lat']; // lat |
@@ -1529,94 +1529,94 @@ discard block |
||
| 1529 | 1529 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
| 1530 | 1530 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
| 1531 | 1531 | unset($data); |
| 1532 | - } |
|
| 1532 | + } |
|
| 1533 | 1533 | } |
| 1534 | 1534 | if ($globalDebug) echo 'No more data...'."\n"; |
| 1535 | 1535 | unset($buffer); |
| 1536 | - } |
|
| 1537 | - $last_exec[$id]['last'] = time(); |
|
| 1536 | + } |
|
| 1537 | + $last_exec[$id]['last'] = time(); |
|
| 1538 | 1538 | //} elseif ($value === 'sbs' || $value === 'tsv' || $value === 'raw' || $value === 'aprs' || $value === 'beast') { |
| 1539 | 1539 | } 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') { |
| 1540 | - //$last_exec[$id]['last'] = time(); |
|
| 1541 | - //$read = array( $sockets[$id] ); |
|
| 1542 | - $read = $sockets; |
|
| 1543 | - $write = NULL; |
|
| 1544 | - $e = NULL; |
|
| 1545 | - $n = socket_select($read, $write, $e, $timeout); |
|
| 1546 | - if ($e != NULL) var_dump($e); |
|
| 1547 | - if ($n > 0) { |
|
| 1540 | + //$last_exec[$id]['last'] = time(); |
|
| 1541 | + //$read = array( $sockets[$id] ); |
|
| 1542 | + $read = $sockets; |
|
| 1543 | + $write = NULL; |
|
| 1544 | + $e = NULL; |
|
| 1545 | + $n = socket_select($read, $write, $e, $timeout); |
|
| 1546 | + if ($e != NULL) var_dump($e); |
|
| 1547 | + if ($n > 0) { |
|
| 1548 | 1548 | $reset = 0; |
| 1549 | 1549 | foreach ($read as $nb => $r) { |
| 1550 | - //$value = $formats[$nb]; |
|
| 1551 | - $format = $globalSources[$nb]['format']; |
|
| 1552 | - if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
|
| 1550 | + //$value = $formats[$nb]; |
|
| 1551 | + $format = $globalSources[$nb]['format']; |
|
| 1552 | + if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
|
| 1553 | 1553 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
| 1554 | - } elseif ($format === 'vrstcp') { |
|
| 1554 | + } elseif ($format === 'vrstcp') { |
|
| 1555 | 1555 | $buffer = @socket_read($r, 6000); |
| 1556 | - } else { |
|
| 1556 | + } else { |
|
| 1557 | 1557 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
| 1558 | - } |
|
| 1559 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
| 1560 | - //echo $buffer."\n"; |
|
| 1561 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 1562 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1563 | - $error = false; |
|
| 1564 | - //$SI::del(); |
|
| 1565 | - if ($buffer !== FALSE) { |
|
| 1558 | + } |
|
| 1559 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
| 1560 | + //echo $buffer."\n"; |
|
| 1561 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 1562 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1563 | + $error = false; |
|
| 1564 | + //$SI::del(); |
|
| 1565 | + if ($buffer !== FALSE) { |
|
| 1566 | 1566 | if ($format === 'vrstcp') { |
| 1567 | - $buffer = explode('},{',$buffer); |
|
| 1567 | + $buffer = explode('},{',$buffer); |
|
| 1568 | 1568 | } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
| 1569 | - } |
|
| 1570 | - // SBS format is CSV format |
|
| 1571 | - if ($buffer !== FALSE && $buffer !== '') { |
|
| 1569 | + } |
|
| 1570 | + // SBS format is CSV format |
|
| 1571 | + if ($buffer !== FALSE && $buffer !== '') { |
|
| 1572 | 1572 | $tt[$format] = 0; |
| 1573 | 1573 | if ($format === 'acarssbs3') { |
| 1574 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1575 | - $ACARS->add(trim($buffer)); |
|
| 1576 | - $ACARS->deleteLiveAcarsData(); |
|
| 1574 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1575 | + $ACARS->add(trim($buffer)); |
|
| 1576 | + $ACARS->deleteLiveAcarsData(); |
|
| 1577 | 1577 | } elseif ($format === 'raw') { |
| 1578 | - // AVR format |
|
| 1579 | - $data = $SBS->parse($buffer); |
|
| 1580 | - if (is_array($data)) { |
|
| 1578 | + // AVR format |
|
| 1579 | + $data = $SBS->parse($buffer); |
|
| 1580 | + if (is_array($data)) { |
|
| 1581 | 1581 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1582 | 1582 | $data['format_source'] = 'raw'; |
| 1583 | 1583 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
| 1584 | 1584 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
| 1585 | 1585 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1586 | 1586 | if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1587 | - } |
|
| 1587 | + } |
|
| 1588 | 1588 | } elseif ($format === 'ais') { |
| 1589 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
| 1590 | - $data = array(); |
|
| 1591 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1592 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 1593 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1594 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1595 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1596 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1597 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1598 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 1599 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1600 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1601 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1602 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1603 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1604 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1605 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1606 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1589 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
| 1590 | + $data = array(); |
|
| 1591 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1592 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 1593 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1594 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1595 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1596 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1597 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1598 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 1599 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1600 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1601 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1602 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1603 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1604 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1605 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1606 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1607 | 1607 | |
| 1608 | - if (isset($ais_data['timestamp'])) { |
|
| 1608 | + if (isset($ais_data['timestamp'])) { |
|
| 1609 | 1609 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 1610 | - } else { |
|
| 1610 | + } else { |
|
| 1611 | 1611 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1612 | - } |
|
| 1613 | - $data['format_source'] = 'aisnmea'; |
|
| 1614 | - $data['id_source'] = $id_source; |
|
| 1615 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 1616 | - unset($data); |
|
| 1617 | - } elseif ($format === 'flightgearsp') { |
|
| 1618 | - //echo $buffer."\n"; |
|
| 1619 | - if (strlen($buffer) > 5) { |
|
| 1612 | + } |
|
| 1613 | + $data['format_source'] = 'aisnmea'; |
|
| 1614 | + $data['id_source'] = $id_source; |
|
| 1615 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 1616 | + unset($data); |
|
| 1617 | + } elseif ($format === 'flightgearsp') { |
|
| 1618 | + //echo $buffer."\n"; |
|
| 1619 | + if (strlen($buffer) > 5) { |
|
| 1620 | 1620 | $line = explode(',',$buffer); |
| 1621 | 1621 | $data = array(); |
| 1622 | 1622 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1633,38 +1633,38 @@ discard block |
||
| 1633 | 1633 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1634 | 1634 | if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1635 | 1635 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1636 | - } |
|
| 1637 | - } elseif ($format === 'acars') { |
|
| 1638 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1639 | - $ACARS->add(trim($buffer)); |
|
| 1640 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1641 | - $ACARS->deleteLiveAcarsData(); |
|
| 1636 | + } |
|
| 1637 | + } elseif ($format === 'acars') { |
|
| 1638 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1639 | + $ACARS->add(trim($buffer)); |
|
| 1640 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1641 | + $ACARS->deleteLiveAcarsData(); |
|
| 1642 | 1642 | } elseif ($format === 'flightgearmp') { |
| 1643 | - if (substr($buffer,0,1) != '#') { |
|
| 1643 | + if (substr($buffer,0,1) != '#') { |
|
| 1644 | 1644 | $data = array(); |
| 1645 | 1645 | //echo $buffer."\n"; |
| 1646 | 1646 | $line = explode(' ',$buffer); |
| 1647 | 1647 | if (count($line) === 11) { |
| 1648 | - $userserver = explode('@',$line[0]); |
|
| 1649 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 1650 | - $data['ident'] = $userserver[0]; |
|
| 1651 | - $data['registration'] = $userserver[0]; |
|
| 1652 | - $data['latitude'] = $line[4]; |
|
| 1653 | - $data['longitude'] = $line[5]; |
|
| 1654 | - $data['altitude'] = $line[6]; |
|
| 1655 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1656 | - $aircraft_type = $line[10]; |
|
| 1657 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 1658 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 1659 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1660 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1648 | + $userserver = explode('@',$line[0]); |
|
| 1649 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 1650 | + $data['ident'] = $userserver[0]; |
|
| 1651 | + $data['registration'] = $userserver[0]; |
|
| 1652 | + $data['latitude'] = $line[4]; |
|
| 1653 | + $data['longitude'] = $line[5]; |
|
| 1654 | + $data['altitude'] = $line[6]; |
|
| 1655 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1656 | + $aircraft_type = $line[10]; |
|
| 1657 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 1658 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 1659 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1660 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1661 | + } |
|
| 1661 | 1662 | } |
| 1662 | - } |
|
| 1663 | 1663 | } elseif ($format === 'beast') { |
| 1664 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
| 1665 | - die; |
|
| 1664 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
| 1665 | + die; |
|
| 1666 | 1666 | } elseif ($format === 'vrstcp') { |
| 1667 | - foreach($buffer as $all_data) { |
|
| 1667 | + foreach($buffer as $all_data) { |
|
| 1668 | 1668 | $line = json_decode('{'.$all_data.'}',true); |
| 1669 | 1669 | $data = array(); |
| 1670 | 1670 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1684,158 +1684,158 @@ discard block |
||
| 1684 | 1684 | */ |
| 1685 | 1685 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1686 | 1686 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
| 1687 | - $data['format_source'] = 'vrstcp'; |
|
| 1687 | + $data['format_source'] = 'vrstcp'; |
|
| 1688 | 1688 | $data['id_source'] = $id_source; |
| 1689 | 1689 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1690 | 1690 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 1691 | 1691 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
| 1692 | 1692 | unset($data); |
| 1693 | - } |
|
| 1693 | + } |
|
| 1694 | 1694 | } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
| 1695 | - $line = explode("\t", $buffer); |
|
| 1696 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
| 1695 | + $line = explode("\t", $buffer); |
|
| 1696 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
| 1697 | 1697 | $key = $line[$k]; |
| 1698 | - $lined[$key] = $line[$k+1]; |
|
| 1699 | - } |
|
| 1700 | - if (count($lined) > 3) { |
|
| 1701 | - $data['hex'] = $lined['hexid']; |
|
| 1702 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
| 1703 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 1704 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1705 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1706 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1707 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1708 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1709 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1710 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 1711 | - $data['id_source'] = $id_source; |
|
| 1712 | - $data['format_source'] = 'tsv'; |
|
| 1713 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1714 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1698 | + $lined[$key] = $line[$k+1]; |
|
| 1699 | + } |
|
| 1700 | + if (count($lined) > 3) { |
|
| 1701 | + $data['hex'] = $lined['hexid']; |
|
| 1702 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
| 1703 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 1704 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1705 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1706 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1707 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1708 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1709 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1710 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 1711 | + $data['id_source'] = $id_source; |
|
| 1712 | + $data['format_source'] = 'tsv'; |
|
| 1713 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1714 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1715 | 1715 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1716 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1717 | - unset($lined); |
|
| 1718 | - unset($data); |
|
| 1719 | - } else $error = true; |
|
| 1716 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1717 | + unset($lined); |
|
| 1718 | + unset($data); |
|
| 1719 | + } else $error = true; |
|
| 1720 | 1720 | } elseif ($format === 'aprs' && $use_aprs) { |
| 1721 | - if ($aprs_connect === 0) { |
|
| 1721 | + if ($aprs_connect === 0) { |
|
| 1722 | 1722 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
| 1723 | 1723 | $aprs_connect = 1; |
| 1724 | - } |
|
| 1724 | + } |
|
| 1725 | 1725 | |
| 1726 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 1726 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 1727 | 1727 | $aprs_last_tx = time(); |
| 1728 | 1728 | $data_aprs = "# Keep alive"; |
| 1729 | 1729 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1730 | - } |
|
| 1730 | + } |
|
| 1731 | 1731 | |
| 1732 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
| 1733 | - //echo 'APRS data : '.$buffer."\n"; |
|
| 1734 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
| 1735 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
| 1736 | - //echo $buffer."\n"; |
|
| 1737 | - date_default_timezone_set('UTC'); |
|
| 1738 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 1732 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
| 1733 | + //echo 'APRS data : '.$buffer."\n"; |
|
| 1734 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
| 1735 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
| 1736 | + //echo $buffer."\n"; |
|
| 1737 | + date_default_timezone_set('UTC'); |
|
| 1738 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 1739 | 1739 | $line = $APRS->parse($buffer); |
| 1740 | 1740 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
| 1741 | 1741 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
| 1742 | - $aprs_last_tx = time(); |
|
| 1743 | - $data = array(); |
|
| 1744 | - //print_r($line); |
|
| 1745 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1746 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
| 1747 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
| 1748 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
| 1749 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
| 1750 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
| 1751 | - if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
| 1752 | - if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
| 1753 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1754 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1755 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1756 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 1757 | - $data['latitude'] = $line['latitude']; |
|
| 1758 | - $data['longitude'] = $line['longitude']; |
|
| 1759 | - //$data['verticalrate'] = $line[16]; |
|
| 1760 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 1761 | - //else $data['speed'] = 0; |
|
| 1762 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1763 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1764 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 1765 | - //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 1742 | + $aprs_last_tx = time(); |
|
| 1743 | + $data = array(); |
|
| 1744 | + //print_r($line); |
|
| 1745 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1746 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
| 1747 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
| 1748 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
| 1749 | + if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
| 1750 | + if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
| 1751 | + if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
| 1752 | + if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
| 1753 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1754 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1755 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1756 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 1757 | + $data['latitude'] = $line['latitude']; |
|
| 1758 | + $data['longitude'] = $line['longitude']; |
|
| 1759 | + //$data['verticalrate'] = $line[16]; |
|
| 1760 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 1761 | + //else $data['speed'] = 0; |
|
| 1762 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1763 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1764 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 1765 | + //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 1766 | 1766 | |
| 1767 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
| 1768 | - //else echo 'No heading...'."\n"; |
|
| 1769 | - //else $data['heading'] = 0; |
|
| 1770 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 1771 | - //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
| 1772 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
| 1773 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
| 1774 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1775 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
| 1776 | - $data['id_source'] = $id_source; |
|
| 1777 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1778 | - else $data['format_source'] = 'aprs'; |
|
| 1779 | - $data['source_name'] = $line['source']; |
|
| 1780 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1781 | - else $data['source_type'] = 'flarm'; |
|
| 1782 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1783 | - $currentdate = date('Y-m-d H:i:s'); |
|
| 1784 | - $aprsdate = strtotime($data['datetime']); |
|
| 1785 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
| 1786 | - // Accept data if time <= system time + 20s |
|
| 1787 | - //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'])))) { |
|
| 1788 | - if ( |
|
| 1767 | + if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
| 1768 | + //else echo 'No heading...'."\n"; |
|
| 1769 | + //else $data['heading'] = 0; |
|
| 1770 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 1771 | + //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
| 1772 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
| 1773 | + elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
| 1774 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1775 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
| 1776 | + $data['id_source'] = $id_source; |
|
| 1777 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1778 | + else $data['format_source'] = 'aprs'; |
|
| 1779 | + $data['source_name'] = $line['source']; |
|
| 1780 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1781 | + else $data['source_type'] = 'flarm'; |
|
| 1782 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1783 | + $currentdate = date('Y-m-d H:i:s'); |
|
| 1784 | + $aprsdate = strtotime($data['datetime']); |
|
| 1785 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
| 1786 | + // Accept data if time <= system time + 20s |
|
| 1787 | + //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'])))) { |
|
| 1788 | + if ( |
|
| 1789 | 1789 | ($data['source_type'] === 'modes') || |
| 1790 | 1790 | isset($line['stealth']) && |
| 1791 | 1791 | (!isset($data['hex']) || $data['hex'] != 'FFFFFF') && |
| 1792 | 1792 | ($line['stealth'] === 0 || $line['stealth'] == '') && |
| 1793 | 1793 | (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
| 1794 | 1794 | $send = $SI->add($data); |
| 1795 | - } elseif ($data['source_type'] === 'ais') { |
|
| 1795 | + } elseif ($data['source_type'] === 'ais') { |
|
| 1796 | 1796 | $data['type'] = ''; |
| 1797 | 1797 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
| 1798 | - } elseif (isset($line['stealth']) && $line['stealth'] != 0) { |
|
| 1798 | + } elseif (isset($line['stealth']) && $line['stealth'] != 0) { |
|
| 1799 | 1799 | echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
| 1800 | - } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1801 | - //$line['symbol'] === 'Balloon' || |
|
| 1802 | - $line['symbol'] === 'Glider' || |
|
| 1803 | - $line['symbol'] === 'No. Plane' || |
|
| 1804 | - $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
|
| 1805 | - if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
| 1806 | - if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
| 1807 | - $send = $SI->add($data); |
|
| 1808 | - } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1809 | - $line['symbol'] === 'Yacht (Sail)' || |
|
| 1810 | - $line['symbol'] === 'Ship (Power Boat)')) { |
|
| 1811 | - $send = $MI->add($data); |
|
| 1812 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1813 | - $line['symbol'] === 'Car' || |
|
| 1814 | - $line['symbol'] === 'Ambulance' || |
|
| 1815 | - $line['symbol'] === 'Van' || |
|
| 1816 | - $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || |
|
| 1817 | - $line['symbol'] === 'Motorcycle' || |
|
| 1818 | - $line['symbol'] === 'Tractor' || |
|
| 1819 | - $line['symbol'] === 'Police' || |
|
| 1820 | - $line['symbol'] === 'Bike' || |
|
| 1821 | - $line['symbol'] === 'Jogger' || |
|
| 1822 | - $line['symbol'] === 'Horse' || |
|
| 1823 | - $line['symbol'] === 'Bus' || |
|
| 1824 | - $line['symbol'] === 'Jeep' || |
|
| 1825 | - $line['symbol'] === 'Recreational Vehicle' || |
|
| 1826 | - $line['symbol'] === 'Yacht (Sail)' || |
|
| 1827 | - $line['symbol'] === 'Ship (Power Boat)' || |
|
| 1828 | - $line['symbol'] === 'Firetruck' || |
|
| 1829 | - $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || |
|
| 1830 | - $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || |
|
| 1831 | - $line['symbol'] === 'SUV' || |
|
| 1832 | - $line['symbol'] === 'Snowmobile' || |
|
| 1833 | - $line['symbol'] === 'Mobile Satellite Station')) { |
|
| 1834 | - //} 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') { |
|
| 1800 | + } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1801 | + //$line['symbol'] === 'Balloon' || |
|
| 1802 | + $line['symbol'] === 'Glider' || |
|
| 1803 | + $line['symbol'] === 'No. Plane' || |
|
| 1804 | + $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
|
| 1805 | + if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
| 1806 | + if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
| 1807 | + $send = $SI->add($data); |
|
| 1808 | + } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1809 | + $line['symbol'] === 'Yacht (Sail)' || |
|
| 1810 | + $line['symbol'] === 'Ship (Power Boat)')) { |
|
| 1811 | + $send = $MI->add($data); |
|
| 1812 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
| 1813 | + $line['symbol'] === 'Car' || |
|
| 1814 | + $line['symbol'] === 'Ambulance' || |
|
| 1815 | + $line['symbol'] === 'Van' || |
|
| 1816 | + $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || |
|
| 1817 | + $line['symbol'] === 'Motorcycle' || |
|
| 1818 | + $line['symbol'] === 'Tractor' || |
|
| 1819 | + $line['symbol'] === 'Police' || |
|
| 1820 | + $line['symbol'] === 'Bike' || |
|
| 1821 | + $line['symbol'] === 'Jogger' || |
|
| 1822 | + $line['symbol'] === 'Horse' || |
|
| 1823 | + $line['symbol'] === 'Bus' || |
|
| 1824 | + $line['symbol'] === 'Jeep' || |
|
| 1825 | + $line['symbol'] === 'Recreational Vehicle' || |
|
| 1826 | + $line['symbol'] === 'Yacht (Sail)' || |
|
| 1827 | + $line['symbol'] === 'Ship (Power Boat)' || |
|
| 1828 | + $line['symbol'] === 'Firetruck' || |
|
| 1829 | + $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || |
|
| 1830 | + $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || |
|
| 1831 | + $line['symbol'] === 'SUV' || |
|
| 1832 | + $line['symbol'] === 'Snowmobile' || |
|
| 1833 | + $line['symbol'] === 'Mobile Satellite Station')) { |
|
| 1834 | + //} 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') { |
|
| 1835 | 1835 | // } 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') { |
| 1836 | 1836 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
| 1837 | 1837 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
| 1838 | - } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
| 1838 | + } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
| 1839 | 1839 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
| 1840 | 1840 | $Source->deleteOldLocationByType('gs'); |
| 1841 | 1841 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
@@ -1843,7 +1843,7 @@ discard block |
||
| 1843 | 1843 | } else { |
| 1844 | 1844 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
| 1845 | 1845 | } |
| 1846 | - } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
|
| 1846 | + } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
|
| 1847 | 1847 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 1848 | 1848 | if ($globalDebug) echo '# Weather Station added'."\n"; |
| 1849 | 1849 | $Source->deleteOldLocationByType('wx'); |
@@ -1853,7 +1853,7 @@ discard block |
||
| 1853 | 1853 | } else { |
| 1854 | 1854 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
| 1855 | 1855 | } |
| 1856 | - } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
|
| 1856 | + } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
|
| 1857 | 1857 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 1858 | 1858 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
| 1859 | 1859 | $Source->deleteOldLocationByType('lightning'); |
@@ -1862,11 +1862,11 @@ discard block |
||
| 1862 | 1862 | } else { |
| 1863 | 1863 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
| 1864 | 1864 | } |
| 1865 | - } elseif ($globalDebug) { |
|
| 1866 | - echo '/!\ Not added: '.$buffer."\n"; |
|
| 1867 | - print_r($line); |
|
| 1868 | - } |
|
| 1869 | - unset($data); |
|
| 1865 | + } elseif ($globalDebug) { |
|
| 1866 | + echo '/!\ Not added: '.$buffer."\n"; |
|
| 1867 | + print_r($line); |
|
| 1868 | + } |
|
| 1869 | + unset($data); |
|
| 1870 | 1870 | } |
| 1871 | 1871 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
| 1872 | 1872 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
@@ -1885,12 +1885,12 @@ discard block |
||
| 1885 | 1885 | } elseif (!isset($globalSources[$nb]['last_weather_clean'])) { |
| 1886 | 1886 | $globalSources[$nb]['last_weather_clean'] = time(); |
| 1887 | 1887 | } |
| 1888 | - } |
|
| 1888 | + } |
|
| 1889 | 1889 | } else { |
| 1890 | - $line = explode(',', $buffer); |
|
| 1891 | - if (count($line) > 20) { |
|
| 1892 | - $data['hex'] = $line[4]; |
|
| 1893 | - /* |
|
| 1890 | + $line = explode(',', $buffer); |
|
| 1891 | + if (count($line) > 20) { |
|
| 1892 | + $data['hex'] = $line[4]; |
|
| 1893 | + /* |
|
| 1894 | 1894 | $data['datetime'] = $line[6].' '.$line[7]; |
| 1895 | 1895 | date_default_timezone_set($globalTimezone); |
| 1896 | 1896 | $datetime = new DateTime($data['datetime']); |
@@ -1898,31 +1898,31 @@ discard block |
||
| 1898 | 1898 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1899 | 1899 | date_default_timezone_set('UTC'); |
| 1900 | 1900 | */ |
| 1901 | - // Force datetime to current UTC datetime |
|
| 1902 | - date_default_timezone_set('UTC'); |
|
| 1903 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1904 | - $data['ident'] = trim($line[10]); |
|
| 1905 | - $data['latitude'] = $line[14]; |
|
| 1906 | - $data['longitude'] = $line[15]; |
|
| 1907 | - $data['verticalrate'] = $line[16]; |
|
| 1908 | - $data['emergency'] = $line[20]; |
|
| 1909 | - $data['speed'] = $line[12]; |
|
| 1910 | - $data['squawk'] = $line[17]; |
|
| 1911 | - $data['altitude'] = $line[11]; |
|
| 1912 | - $data['heading'] = $line[13]; |
|
| 1913 | - $data['ground'] = $line[21]; |
|
| 1914 | - $data['emergency'] = $line[19]; |
|
| 1915 | - $data['format_source'] = 'sbs'; |
|
| 1901 | + // Force datetime to current UTC datetime |
|
| 1902 | + date_default_timezone_set('UTC'); |
|
| 1903 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1904 | + $data['ident'] = trim($line[10]); |
|
| 1905 | + $data['latitude'] = $line[14]; |
|
| 1906 | + $data['longitude'] = $line[15]; |
|
| 1907 | + $data['verticalrate'] = $line[16]; |
|
| 1908 | + $data['emergency'] = $line[20]; |
|
| 1909 | + $data['speed'] = $line[12]; |
|
| 1910 | + $data['squawk'] = $line[17]; |
|
| 1911 | + $data['altitude'] = $line[11]; |
|
| 1912 | + $data['heading'] = $line[13]; |
|
| 1913 | + $data['ground'] = $line[21]; |
|
| 1914 | + $data['emergency'] = $line[19]; |
|
| 1915 | + $data['format_source'] = 'sbs'; |
|
| 1916 | 1916 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
| 1917 | 1917 | elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT'; |
| 1918 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1918 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1919 | 1919 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1920 | - $data['id_source'] = $id_source; |
|
| 1921 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1922 | - else $error = true; |
|
| 1923 | - unset($data); |
|
| 1924 | - } else $error = true; |
|
| 1925 | - if ($error) { |
|
| 1920 | + $data['id_source'] = $id_source; |
|
| 1921 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1922 | + else $error = true; |
|
| 1923 | + unset($data); |
|
| 1924 | + } else $error = true; |
|
| 1925 | + if ($error) { |
|
| 1926 | 1926 | if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { |
| 1927 | 1927 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
| 1928 | 1928 | } else { |
@@ -1938,13 +1938,13 @@ discard block |
||
| 1938 | 1938 | connect_all($sourceer); |
| 1939 | 1939 | $sourceer = array(); |
| 1940 | 1940 | } |
| 1941 | - } |
|
| 1941 | + } |
|
| 1942 | 1942 | } |
| 1943 | 1943 | // Sleep for xxx microseconds |
| 1944 | 1944 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
| 1945 | - } else { |
|
| 1945 | + } else { |
|
| 1946 | 1946 | if ($format === 'flightgearmp') { |
| 1947 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 1947 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 1948 | 1948 | //@socket_close($r); |
| 1949 | 1949 | sleep($globalMinFetch); |
| 1950 | 1950 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1953,9 +1953,9 @@ discard block |
||
| 1953 | 1953 | break; |
| 1954 | 1954 | |
| 1955 | 1955 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 1956 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 1957 | - else $tt[$format] = 0; |
|
| 1958 | - if ($tt[$format] > 30 || $buffer === FALSE) { |
|
| 1956 | + if (isset($tt[$format])) $tt[$format]++; |
|
| 1957 | + else $tt[$format] = 0; |
|
| 1958 | + if ($tt[$format] > 30 || $buffer === FALSE) { |
|
| 1959 | 1959 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
| 1960 | 1960 | //@socket_close($r); |
| 1961 | 1961 | sleep(2); |
@@ -1966,24 +1966,24 @@ discard block |
||
| 1966 | 1966 | //connect_all($globalSources); |
| 1967 | 1967 | $tt[$format]=0; |
| 1968 | 1968 | break; |
| 1969 | - } |
|
| 1970 | - //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
| 1969 | + } |
|
| 1970 | + //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
| 1971 | + } |
|
| 1971 | 1972 | } |
| 1972 | - } |
|
| 1973 | 1973 | } |
| 1974 | - } else { |
|
| 1974 | + } else { |
|
| 1975 | 1975 | $error = socket_strerror(socket_last_error()); |
| 1976 | 1976 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 1977 | 1977 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
| 1978 | 1978 | if (isset($globalDebug)) echo "Restarting...\n"; |
| 1979 | 1979 | // Restart the script if possible |
| 1980 | 1980 | if (is_array($sockets)) { |
| 1981 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 1981 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 1982 | 1982 | |
| 1983 | - foreach ($sockets as $sock) { |
|
| 1983 | + foreach ($sockets as $sock) { |
|
| 1984 | 1984 | @socket_shutdown($sock,2); |
| 1985 | 1985 | @socket_close($sock); |
| 1986 | - } |
|
| 1986 | + } |
|
| 1987 | 1987 | |
| 1988 | 1988 | } |
| 1989 | 1989 | if ($globalDebug) echo "Waiting..."; |
@@ -1998,15 +1998,15 @@ discard block |
||
| 1998 | 1998 | if ($globalDebug) echo "Restart all connections..."; |
| 1999 | 1999 | connect_all($globalSources); |
| 2000 | 2000 | } |
| 2001 | - } |
|
| 2001 | + } |
|
| 2002 | 2002 | } |
| 2003 | 2003 | if ($globalDaemon === false) { |
| 2004 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
| 2005 | - if (isset($SI)) $SI->checkAll(); |
|
| 2006 | - if (isset($TI)) $TI->checkAll(); |
|
| 2007 | - if (isset($MI)) $MI->checkAll(); |
|
| 2004 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
| 2005 | + if (isset($SI)) $SI->checkAll(); |
|
| 2006 | + if (isset($TI)) $TI->checkAll(); |
|
| 2007 | + if (isset($MI)) $MI->checkAll(); |
|
| 2008 | + } |
|
| 2008 | 2009 | } |
| 2009 | - } |
|
| 2010 | 2010 | } |
| 2011 | 2011 | |
| 2012 | 2012 | ?> |