@@ -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'); |
@@ -233,11 +233,11 @@ discard block |
||
| 233 | 233 | |
| 234 | 234 | |
| 235 | 235 | /** |
| 236 | - * Gets all the spotter information based on the latest data entry |
|
| 237 | - * |
|
| 238 | - * @return Array the spotter information |
|
| 239 | - * |
|
| 240 | - */ |
|
| 236 | + * Gets all the spotter information based on the latest data entry |
|
| 237 | + * |
|
| 238 | + * @return Array the spotter information |
|
| 239 | + * |
|
| 240 | + */ |
|
| 241 | 241 | public function getLatestMarineData($limit = '', $sort = '', $filter = array()) |
| 242 | 242 | { |
| 243 | 243 | global $global_marine_query; |
@@ -286,11 +286,11 @@ discard block |
||
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | /** |
| 289 | - * Gets all the spotter information based on the callsign |
|
| 290 | - * |
|
| 291 | - * @return Array the spotter information |
|
| 292 | - * |
|
| 293 | - */ |
|
| 289 | + * Gets all the spotter information based on the callsign |
|
| 290 | + * |
|
| 291 | + * @return Array the spotter information |
|
| 292 | + * |
|
| 293 | + */ |
|
| 294 | 294 | public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array()) |
| 295 | 295 | { |
| 296 | 296 | global $global_marine_query; |
@@ -342,11 +342,11 @@ discard block |
||
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | /** |
| 345 | - * Gets all the marine information based on the type |
|
| 346 | - * |
|
| 347 | - * @return Array the marine information |
|
| 348 | - * |
|
| 349 | - */ |
|
| 345 | + * Gets all the marine information based on the type |
|
| 346 | + * |
|
| 347 | + * @return Array the marine information |
|
| 348 | + * |
|
| 349 | + */ |
|
| 350 | 350 | public function getMarineDataByType($type = '', $limit = '', $sort = '', $filter = array()) |
| 351 | 351 | { |
| 352 | 352 | global $global_marine_query; |
@@ -452,11 +452,11 @@ discard block |
||
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | /** |
| 455 | - * Gets all the marine information based on the captain |
|
| 456 | - * |
|
| 457 | - * @return Array the marine information |
|
| 458 | - * |
|
| 459 | - */ |
|
| 455 | + * Gets all the marine information based on the captain |
|
| 456 | + * |
|
| 457 | + * @return Array the marine information |
|
| 458 | + * |
|
| 459 | + */ |
|
| 460 | 460 | public function getMarineDataByCaptain($captain = '', $limit = '', $sort = '', $filter = array()) |
| 461 | 461 | { |
| 462 | 462 | global $global_marine_query; |
@@ -495,11 +495,11 @@ discard block |
||
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | /** |
| 498 | - * Gets all the marine information based on the race |
|
| 499 | - * |
|
| 500 | - * @return Array the marine information |
|
| 501 | - * |
|
| 502 | - */ |
|
| 498 | + * Gets all the marine information based on the race |
|
| 499 | + * |
|
| 500 | + * @return Array the marine information |
|
| 501 | + * |
|
| 502 | + */ |
|
| 503 | 503 | public function getMarineDataByRace($race = '', $limit = '', $sort = '', $filter = array()) |
| 504 | 504 | { |
| 505 | 505 | global $global_marine_query; |
@@ -538,11 +538,11 @@ discard block |
||
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | /** |
| 541 | - * Count races by captain |
|
| 542 | - * |
|
| 543 | - * @return String Duration of all races |
|
| 544 | - * |
|
| 545 | - */ |
|
| 541 | + * Count races by captain |
|
| 542 | + * |
|
| 543 | + * @return String Duration of all races |
|
| 544 | + * |
|
| 545 | + */ |
|
| 546 | 546 | public function countRacesByCaptain($captain,$filters = array()) |
| 547 | 547 | { |
| 548 | 548 | $captain = filter_var($captain,FILTER_SANITIZE_STRING); |
@@ -558,11 +558,11 @@ discard block |
||
| 558 | 558 | } |
| 559 | 559 | |
| 560 | 560 | /** |
| 561 | - * Count captains by race |
|
| 562 | - * |
|
| 563 | - * @return String Duration of all races |
|
| 564 | - * |
|
| 565 | - */ |
|
| 561 | + * Count captains by race |
|
| 562 | + * |
|
| 563 | + * @return String Duration of all races |
|
| 564 | + * |
|
| 565 | + */ |
|
| 566 | 566 | public function countCaptainsByRace($race,$filters = array()) |
| 567 | 567 | { |
| 568 | 568 | $race = filter_var($race,FILTER_SANITIZE_STRING); |
@@ -578,11 +578,11 @@ discard block |
||
| 578 | 578 | } |
| 579 | 579 | |
| 580 | 580 | /** |
| 581 | - * Gets all boat types that have been used by a captain |
|
| 582 | - * |
|
| 583 | - * @return Array the boat list |
|
| 584 | - * |
|
| 585 | - */ |
|
| 581 | + * Gets all boat types that have been used by a captain |
|
| 582 | + * |
|
| 583 | + * @return Array the boat list |
|
| 584 | + * |
|
| 585 | + */ |
|
| 586 | 586 | public function countAllBoatTypesByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '') |
| 587 | 587 | { |
| 588 | 588 | global $globalDBdriver; |
@@ -627,11 +627,11 @@ discard block |
||
| 627 | 627 | } |
| 628 | 628 | |
| 629 | 629 | /** |
| 630 | - * Gets all boat types that have been used on a race |
|
| 631 | - * |
|
| 632 | - * @return Array the boat list |
|
| 633 | - * |
|
| 634 | - */ |
|
| 630 | + * Gets all boat types that have been used on a race |
|
| 631 | + * |
|
| 632 | + * @return Array the boat list |
|
| 633 | + * |
|
| 634 | + */ |
|
| 635 | 635 | public function countAllBoatTypesByRace($race,$filters = array(),$year = '',$month = '',$day = '') |
| 636 | 636 | { |
| 637 | 637 | global $globalDBdriver; |
@@ -676,11 +676,11 @@ discard block |
||
| 676 | 676 | } |
| 677 | 677 | |
| 678 | 678 | /** |
| 679 | - * Gets race duration by captain |
|
| 680 | - * |
|
| 681 | - * @return String Duration of all race |
|
| 682 | - * |
|
| 683 | - */ |
|
| 679 | + * Gets race duration by captain |
|
| 680 | + * |
|
| 681 | + * @return String Duration of all race |
|
| 682 | + * |
|
| 683 | + */ |
|
| 684 | 684 | public function getRaceDurationByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '') |
| 685 | 685 | { |
| 686 | 686 | global $globalDBdriver; |
@@ -726,11 +726,11 @@ discard block |
||
| 726 | 726 | } |
| 727 | 727 | |
| 728 | 728 | /** |
| 729 | - * Gets a list of all captain names and captain ids |
|
| 730 | - * |
|
| 731 | - * @return Array list of captain names and captain ids |
|
| 732 | - * |
|
| 733 | - */ |
|
| 729 | + * Gets a list of all captain names and captain ids |
|
| 730 | + * |
|
| 731 | + * @return Array list of captain names and captain ids |
|
| 732 | + * |
|
| 733 | + */ |
|
| 734 | 734 | public function getAllCaptainNames($filters = array()) |
| 735 | 735 | { |
| 736 | 736 | $filter_query = $this->getFilter($filters,true,true); |
@@ -744,11 +744,11 @@ discard block |
||
| 744 | 744 | } |
| 745 | 745 | |
| 746 | 746 | /** |
| 747 | - * Gets a list of all race names and race ids |
|
| 748 | - * |
|
| 749 | - * @return Array list of race names and race ids |
|
| 750 | - * |
|
| 751 | - */ |
|
| 747 | + * Gets a list of all race names and race ids |
|
| 748 | + * |
|
| 749 | + * @return Array list of race names and race ids |
|
| 750 | + * |
|
| 751 | + */ |
|
| 752 | 752 | public function getAllRaceNames($filters = array()) |
| 753 | 753 | { |
| 754 | 754 | $filter_query = $this->getFilter($filters,true,true); |
@@ -762,12 +762,12 @@ discard block |
||
| 762 | 762 | } |
| 763 | 763 | |
| 764 | 764 | /** |
| 765 | - * Gets all source name |
|
| 766 | - * |
|
| 767 | - * @param String type format of source |
|
| 768 | - * @return Array list of source name |
|
| 769 | - * |
|
| 770 | - */ |
|
| 765 | + * Gets all source name |
|
| 766 | + * |
|
| 767 | + * @param String type format of source |
|
| 768 | + * @return Array list of source name |
|
| 769 | + * |
|
| 770 | + */ |
|
| 771 | 771 | public function getAllSourceName($type = '',$filters = array()) |
| 772 | 772 | { |
| 773 | 773 | $filter_query = $this->getFilter($filters,true,true); |
@@ -797,11 +797,11 @@ discard block |
||
| 797 | 797 | |
| 798 | 798 | |
| 799 | 799 | /** |
| 800 | - * Gets a list of all idents/callsigns |
|
| 801 | - * |
|
| 802 | - * @return Array list of ident/callsign names |
|
| 803 | - * |
|
| 804 | - */ |
|
| 800 | + * Gets a list of all idents/callsigns |
|
| 801 | + * |
|
| 802 | + * @return Array list of ident/callsign names |
|
| 803 | + * |
|
| 804 | + */ |
|
| 805 | 805 | public function getAllIdents($filters = array()) |
| 806 | 806 | { |
| 807 | 807 | $filter_query = $this->getFilter($filters,true,true); |
@@ -825,11 +825,11 @@ discard block |
||
| 825 | 825 | } |
| 826 | 826 | |
| 827 | 827 | /** |
| 828 | - * Gets all info from a mmsi |
|
| 829 | - * |
|
| 830 | - * @return Array ident |
|
| 831 | - * |
|
| 832 | - */ |
|
| 828 | + * Gets all info from a mmsi |
|
| 829 | + * |
|
| 830 | + * @return Array ident |
|
| 831 | + * |
|
| 832 | + */ |
|
| 833 | 833 | public function getIdentity($mmsi) |
| 834 | 834 | { |
| 835 | 835 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
@@ -842,9 +842,9 @@ discard block |
||
| 842 | 842 | } |
| 843 | 843 | |
| 844 | 844 | /** |
| 845 | - * Add identity |
|
| 846 | - * |
|
| 847 | - */ |
|
| 845 | + * Add identity |
|
| 846 | + * |
|
| 847 | + */ |
|
| 848 | 848 | public function addIdentity($mmsi,$imo,$ident,$callsign,$type) |
| 849 | 849 | { |
| 850 | 850 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
@@ -910,13 +910,13 @@ discard block |
||
| 910 | 910 | } |
| 911 | 911 | |
| 912 | 912 | /** |
| 913 | - * Update ident tracker data |
|
| 914 | - * |
|
| 915 | - * @param String $fammarine_id the ID |
|
| 916 | - * @param String $ident the marine ident |
|
| 917 | - * @return String success or false |
|
| 918 | - * |
|
| 919 | - */ |
|
| 913 | + * Update ident tracker data |
|
| 914 | + * |
|
| 915 | + * @param String $fammarine_id the ID |
|
| 916 | + * @param String $ident the marine ident |
|
| 917 | + * @return String success or false |
|
| 918 | + * |
|
| 919 | + */ |
|
| 920 | 920 | public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
| 921 | 921 | { |
| 922 | 922 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
@@ -931,13 +931,13 @@ discard block |
||
| 931 | 931 | } |
| 932 | 932 | |
| 933 | 933 | /** |
| 934 | - * Update arrival marine data |
|
| 935 | - * |
|
| 936 | - * @param String $fammarine_id the ID |
|
| 937 | - * @param String $arrival_code the marine ident |
|
| 938 | - * @return String success or false |
|
| 939 | - * |
|
| 940 | - */ |
|
| 934 | + * Update arrival marine data |
|
| 935 | + * |
|
| 936 | + * @param String $fammarine_id the ID |
|
| 937 | + * @param String $arrival_code the marine ident |
|
| 938 | + * @return String success or false |
|
| 939 | + * |
|
| 940 | + */ |
|
| 941 | 941 | public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL) |
| 942 | 942 | { |
| 943 | 943 | $query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id'; |
@@ -952,19 +952,19 @@ discard block |
||
| 952 | 952 | } |
| 953 | 953 | |
| 954 | 954 | /** |
| 955 | - * Update Status data |
|
| 956 | - * |
|
| 957 | - * @param String $fammarine_id the ID |
|
| 958 | - * @param String $status_id the marine status id |
|
| 959 | - * @param String $status the marine status |
|
| 960 | - * @return String success or false |
|
| 961 | - * |
|
| 962 | - */ |
|
| 955 | + * Update Status data |
|
| 956 | + * |
|
| 957 | + * @param String $fammarine_id the ID |
|
| 958 | + * @param String $status_id the marine status id |
|
| 959 | + * @param String $status the marine status |
|
| 960 | + * @return String success or false |
|
| 961 | + * |
|
| 962 | + */ |
|
| 963 | 963 | public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') |
| 964 | 964 | { |
| 965 | 965 | |
| 966 | 966 | $query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; |
| 967 | - $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
| 967 | + $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
| 968 | 968 | |
| 969 | 969 | try { |
| 970 | 970 | $sth = $this->db->prepare($query); |
@@ -977,13 +977,13 @@ discard block |
||
| 977 | 977 | |
| 978 | 978 | } |
| 979 | 979 | /** |
| 980 | - * Update latest marine data |
|
| 981 | - * |
|
| 982 | - * @param String $fammarine_id the ID |
|
| 983 | - * @param String $ident the marine ident |
|
| 984 | - * @return String success or false |
|
| 985 | - * |
|
| 986 | - */ |
|
| 980 | + * Update latest marine data |
|
| 981 | + * |
|
| 982 | + * @param String $fammarine_id the ID |
|
| 983 | + * @param String $ident the marine ident |
|
| 984 | + * @return String success or false |
|
| 985 | + * |
|
| 986 | + */ |
|
| 987 | 987 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '',$distance = NULL,$race_rank = NULL, $race_time = NULL, $status = '') |
| 988 | 988 | { |
| 989 | 989 | $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, status = :status WHERE fammarine_id = :fammarine_id'; |
@@ -1004,30 +1004,30 @@ discard block |
||
| 1004 | 1004 | } |
| 1005 | 1005 | |
| 1006 | 1006 | /** |
| 1007 | - * Adds a new marine data |
|
| 1008 | - * |
|
| 1009 | - * @param String $fammarine_id the ID |
|
| 1010 | - * @param String $ident the marine ident |
|
| 1011 | - * @param String $departure_airport_icao the departure airport |
|
| 1012 | - * @param String $arrival_airport_icao the arrival airport |
|
| 1013 | - * @param String $latitude latitude of flight |
|
| 1014 | - * @param String $longitude latitude of flight |
|
| 1015 | - * @param String $waypoints waypoints of flight |
|
| 1016 | - * @param String $heading heading of flight |
|
| 1017 | - * @param String $groundspeed speed of flight |
|
| 1018 | - * @param String $date date of flight |
|
| 1019 | - * @param String $departure_airport_time departure time of flight |
|
| 1020 | - * @param String $arrival_airport_time arrival time of flight |
|
| 1021 | - * @param String $squawk squawk code of flight |
|
| 1022 | - * @param String $route_stop route stop of flight |
|
| 1023 | - * @param String $highlight highlight or not |
|
| 1024 | - * @param String $ModeS ModesS code of flight |
|
| 1025 | - * @param String $registration registration code of flight |
|
| 1026 | - * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
| 1027 | - * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
| 1028 | - * @param String $verticalrate vertival rate of flight |
|
| 1029 | - * @return String success or false |
|
| 1030 | - */ |
|
| 1007 | + * Adds a new marine data |
|
| 1008 | + * |
|
| 1009 | + * @param String $fammarine_id the ID |
|
| 1010 | + * @param String $ident the marine ident |
|
| 1011 | + * @param String $departure_airport_icao the departure airport |
|
| 1012 | + * @param String $arrival_airport_icao the arrival airport |
|
| 1013 | + * @param String $latitude latitude of flight |
|
| 1014 | + * @param String $longitude latitude of flight |
|
| 1015 | + * @param String $waypoints waypoints of flight |
|
| 1016 | + * @param String $heading heading of flight |
|
| 1017 | + * @param String $groundspeed speed of flight |
|
| 1018 | + * @param String $date date of flight |
|
| 1019 | + * @param String $departure_airport_time departure time of flight |
|
| 1020 | + * @param String $arrival_airport_time arrival time of flight |
|
| 1021 | + * @param String $squawk squawk code of flight |
|
| 1022 | + * @param String $route_stop route stop of flight |
|
| 1023 | + * @param String $highlight highlight or not |
|
| 1024 | + * @param String $ModeS ModesS code of flight |
|
| 1025 | + * @param String $registration registration code of flight |
|
| 1026 | + * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
| 1027 | + * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
| 1028 | + * @param String $verticalrate vertival rate of flight |
|
| 1029 | + * @return String success or false |
|
| 1030 | + */ |
|
| 1031 | 1031 | 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 = '') |
| 1032 | 1032 | { |
| 1033 | 1033 | global $globalURL, $globalMarineImageFetch; |
@@ -1160,11 +1160,11 @@ discard block |
||
| 1160 | 1160 | |
| 1161 | 1161 | |
| 1162 | 1162 | /** |
| 1163 | - * Gets the aircraft ident within the last hour |
|
| 1164 | - * |
|
| 1165 | - * @return String the ident |
|
| 1166 | - * |
|
| 1167 | - */ |
|
| 1163 | + * Gets the aircraft ident within the last hour |
|
| 1164 | + * |
|
| 1165 | + * @return String the ident |
|
| 1166 | + * |
|
| 1167 | + */ |
|
| 1168 | 1168 | public function getIdentFromLastHour($ident) |
| 1169 | 1169 | { |
| 1170 | 1170 | global $globalDBdriver, $globalTimezone; |
@@ -1180,11 +1180,11 @@ discard block |
||
| 1180 | 1180 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 1181 | 1181 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
| 1182 | 1182 | $query_data = array(':ident' => $ident); |
| 1183 | - } |
|
| 1183 | + } |
|
| 1184 | 1184 | |
| 1185 | 1185 | $sth = $this->db->prepare($query); |
| 1186 | 1186 | $sth->execute($query_data); |
| 1187 | - $ident_result=''; |
|
| 1187 | + $ident_result=''; |
|
| 1188 | 1188 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 1189 | 1189 | { |
| 1190 | 1190 | $ident_result = $row['ident']; |
@@ -1195,11 +1195,11 @@ discard block |
||
| 1195 | 1195 | |
| 1196 | 1196 | |
| 1197 | 1197 | /** |
| 1198 | - * Gets the aircraft data from the last 20 seconds |
|
| 1199 | - * |
|
| 1200 | - * @return Array the marine data |
|
| 1201 | - * |
|
| 1202 | - */ |
|
| 1198 | + * Gets the aircraft data from the last 20 seconds |
|
| 1199 | + * |
|
| 1200 | + * @return Array the marine data |
|
| 1201 | + * |
|
| 1202 | + */ |
|
| 1203 | 1203 | public function getRealTimeData($q = '') |
| 1204 | 1204 | { |
| 1205 | 1205 | global $globalDBdriver; |
@@ -1237,11 +1237,11 @@ discard block |
||
| 1237 | 1237 | |
| 1238 | 1238 | |
| 1239 | 1239 | /** |
| 1240 | - * Gets all number of flight over countries |
|
| 1241 | - * |
|
| 1242 | - * @return Array the airline country list |
|
| 1243 | - * |
|
| 1244 | - */ |
|
| 1240 | + * Gets all number of flight over countries |
|
| 1241 | + * |
|
| 1242 | + * @return Array the airline country list |
|
| 1243 | + * |
|
| 1244 | + */ |
|
| 1245 | 1245 | |
| 1246 | 1246 | public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
| 1247 | 1247 | { |
@@ -1314,11 +1314,11 @@ discard block |
||
| 1314 | 1314 | |
| 1315 | 1315 | |
| 1316 | 1316 | /** |
| 1317 | - * Gets all callsigns that have flown over |
|
| 1318 | - * |
|
| 1319 | - * @return Array the callsign list |
|
| 1320 | - * |
|
| 1321 | - */ |
|
| 1317 | + * Gets all callsigns that have flown over |
|
| 1318 | + * |
|
| 1319 | + * @return Array the callsign list |
|
| 1320 | + * |
|
| 1321 | + */ |
|
| 1322 | 1322 | public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
| 1323 | 1323 | { |
| 1324 | 1324 | global $globalDBdriver; |
@@ -1385,11 +1385,11 @@ discard block |
||
| 1385 | 1385 | |
| 1386 | 1386 | |
| 1387 | 1387 | /** |
| 1388 | - * Counts all dates |
|
| 1389 | - * |
|
| 1390 | - * @return Array the date list |
|
| 1391 | - * |
|
| 1392 | - */ |
|
| 1388 | + * Counts all dates |
|
| 1389 | + * |
|
| 1390 | + * @return Array the date list |
|
| 1391 | + * |
|
| 1392 | + */ |
|
| 1393 | 1393 | public function countAllDates($filters = array()) |
| 1394 | 1394 | { |
| 1395 | 1395 | global $globalTimezone, $globalDBdriver; |
@@ -1435,11 +1435,11 @@ discard block |
||
| 1435 | 1435 | |
| 1436 | 1436 | |
| 1437 | 1437 | /** |
| 1438 | - * Counts all dates during the last 7 days |
|
| 1439 | - * |
|
| 1440 | - * @return Array the date list |
|
| 1441 | - * |
|
| 1442 | - */ |
|
| 1438 | + * Counts all dates during the last 7 days |
|
| 1439 | + * |
|
| 1440 | + * @return Array the date list |
|
| 1441 | + * |
|
| 1442 | + */ |
|
| 1443 | 1443 | public function countAllDatesLast7Days($filters = array()) |
| 1444 | 1444 | { |
| 1445 | 1445 | global $globalTimezone, $globalDBdriver; |
@@ -1461,7 +1461,7 @@ discard block |
||
| 1461 | 1461 | $query .= " GROUP BY date_name |
| 1462 | 1462 | ORDER BY date_name ASC"; |
| 1463 | 1463 | $query_data = array(':offset' => $offset); |
| 1464 | - } |
|
| 1464 | + } |
|
| 1465 | 1465 | |
| 1466 | 1466 | $sth = $this->db->prepare($query); |
| 1467 | 1467 | $sth->execute($query_data); |
@@ -1481,11 +1481,11 @@ discard block |
||
| 1481 | 1481 | } |
| 1482 | 1482 | |
| 1483 | 1483 | /** |
| 1484 | - * Counts all dates during the last month |
|
| 1485 | - * |
|
| 1486 | - * @return Array the date list |
|
| 1487 | - * |
|
| 1488 | - */ |
|
| 1484 | + * Counts all dates during the last month |
|
| 1485 | + * |
|
| 1486 | + * @return Array the date list |
|
| 1487 | + * |
|
| 1488 | + */ |
|
| 1489 | 1489 | public function countAllDatesLastMonth($filters = array()) |
| 1490 | 1490 | { |
| 1491 | 1491 | global $globalTimezone, $globalDBdriver; |
@@ -1507,7 +1507,7 @@ discard block |
||
| 1507 | 1507 | $query .= " GROUP BY date_name |
| 1508 | 1508 | ORDER BY date_name ASC"; |
| 1509 | 1509 | $query_data = array(':offset' => $offset); |
| 1510 | - } |
|
| 1510 | + } |
|
| 1511 | 1511 | |
| 1512 | 1512 | $sth = $this->db->prepare($query); |
| 1513 | 1513 | $sth->execute($query_data); |
@@ -1529,11 +1529,11 @@ discard block |
||
| 1529 | 1529 | |
| 1530 | 1530 | |
| 1531 | 1531 | /** |
| 1532 | - * Counts all month |
|
| 1533 | - * |
|
| 1534 | - * @return Array the month list |
|
| 1535 | - * |
|
| 1536 | - */ |
|
| 1532 | + * Counts all month |
|
| 1533 | + * |
|
| 1534 | + * @return Array the month list |
|
| 1535 | + * |
|
| 1536 | + */ |
|
| 1537 | 1537 | public function countAllMonths($filters = array()) |
| 1538 | 1538 | { |
| 1539 | 1539 | global $globalTimezone, $globalDBdriver; |
@@ -1578,11 +1578,11 @@ discard block |
||
| 1578 | 1578 | |
| 1579 | 1579 | |
| 1580 | 1580 | /** |
| 1581 | - * Counts all dates during the last year |
|
| 1582 | - * |
|
| 1583 | - * @return Array the date list |
|
| 1584 | - * |
|
| 1585 | - */ |
|
| 1581 | + * Counts all dates during the last year |
|
| 1582 | + * |
|
| 1583 | + * @return Array the date list |
|
| 1584 | + * |
|
| 1585 | + */ |
|
| 1586 | 1586 | public function countAllMonthsLastYear($filters) |
| 1587 | 1587 | { |
| 1588 | 1588 | global $globalTimezone, $globalDBdriver; |
@@ -1604,7 +1604,7 @@ discard block |
||
| 1604 | 1604 | $query .= " GROUP BY year_name, month_name |
| 1605 | 1605 | ORDER BY year_name, month_name ASC"; |
| 1606 | 1606 | $query_data = array(':offset' => $offset); |
| 1607 | - } |
|
| 1607 | + } |
|
| 1608 | 1608 | |
| 1609 | 1609 | $sth = $this->db->prepare($query); |
| 1610 | 1610 | $sth->execute($query_data); |
@@ -1627,11 +1627,11 @@ discard block |
||
| 1627 | 1627 | |
| 1628 | 1628 | |
| 1629 | 1629 | /** |
| 1630 | - * Counts all hours |
|
| 1631 | - * |
|
| 1632 | - * @return Array the hour list |
|
| 1633 | - * |
|
| 1634 | - */ |
|
| 1630 | + * Counts all hours |
|
| 1631 | + * |
|
| 1632 | + * @return Array the hour list |
|
| 1633 | + * |
|
| 1634 | + */ |
|
| 1635 | 1635 | public function countAllHours($orderby,$filters = array()) |
| 1636 | 1636 | { |
| 1637 | 1637 | global $globalTimezone, $globalDBdriver; |
@@ -1694,11 +1694,11 @@ discard block |
||
| 1694 | 1694 | |
| 1695 | 1695 | |
| 1696 | 1696 | /** |
| 1697 | - * Counts all hours by date |
|
| 1698 | - * |
|
| 1699 | - * @return Array the hour list |
|
| 1700 | - * |
|
| 1701 | - */ |
|
| 1697 | + * Counts all hours by date |
|
| 1698 | + * |
|
| 1699 | + * @return Array the hour list |
|
| 1700 | + * |
|
| 1701 | + */ |
|
| 1702 | 1702 | public function countAllHoursByDate($date, $filters = array()) |
| 1703 | 1703 | { |
| 1704 | 1704 | global $globalTimezone, $globalDBdriver; |
@@ -1742,11 +1742,11 @@ discard block |
||
| 1742 | 1742 | |
| 1743 | 1743 | |
| 1744 | 1744 | /** |
| 1745 | - * Counts all hours by a ident/callsign |
|
| 1746 | - * |
|
| 1747 | - * @return Array the hour list |
|
| 1748 | - * |
|
| 1749 | - */ |
|
| 1745 | + * Counts all hours by a ident/callsign |
|
| 1746 | + * |
|
| 1747 | + * @return Array the hour list |
|
| 1748 | + * |
|
| 1749 | + */ |
|
| 1750 | 1750 | public function countAllHoursByIdent($ident, $filters = array()) |
| 1751 | 1751 | { |
| 1752 | 1752 | global $globalTimezone, $globalDBdriver; |
@@ -1791,11 +1791,11 @@ discard block |
||
| 1791 | 1791 | |
| 1792 | 1792 | |
| 1793 | 1793 | /** |
| 1794 | - * Counts all vessels |
|
| 1795 | - * |
|
| 1796 | - * @return Integer the number of vessels |
|
| 1797 | - * |
|
| 1798 | - */ |
|
| 1794 | + * Counts all vessels |
|
| 1795 | + * |
|
| 1796 | + * @return Integer the number of vessels |
|
| 1797 | + * |
|
| 1798 | + */ |
|
| 1799 | 1799 | public function countOverallMarine($filters = array(),$year = '',$month = '') |
| 1800 | 1800 | { |
| 1801 | 1801 | global $globalDBdriver; |
@@ -1830,11 +1830,11 @@ discard block |
||
| 1830 | 1830 | } |
| 1831 | 1831 | |
| 1832 | 1832 | /** |
| 1833 | - * Counts all vessel type |
|
| 1834 | - * |
|
| 1835 | - * @return Integer the number of vessels |
|
| 1836 | - * |
|
| 1837 | - */ |
|
| 1833 | + * Counts all vessel type |
|
| 1834 | + * |
|
| 1835 | + * @return Integer the number of vessels |
|
| 1836 | + * |
|
| 1837 | + */ |
|
| 1838 | 1838 | public function countOverallMarineTypes($filters = array(),$year = '',$month = '') |
| 1839 | 1839 | { |
| 1840 | 1840 | global $globalDBdriver; |
@@ -1869,11 +1869,11 @@ discard block |
||
| 1869 | 1869 | |
| 1870 | 1870 | |
| 1871 | 1871 | /** |
| 1872 | - * Counts all hours of today |
|
| 1873 | - * |
|
| 1874 | - * @return Array the hour list |
|
| 1875 | - * |
|
| 1876 | - */ |
|
| 1872 | + * Counts all hours of today |
|
| 1873 | + * |
|
| 1874 | + * @return Array the hour list |
|
| 1875 | + * |
|
| 1876 | + */ |
|
| 1877 | 1877 | public function countAllHoursFromToday($filters = array()) |
| 1878 | 1878 | { |
| 1879 | 1879 | global $globalTimezone, $globalDBdriver; |
@@ -1913,12 +1913,12 @@ discard block |
||
| 1913 | 1913 | } |
| 1914 | 1914 | |
| 1915 | 1915 | |
| 1916 | - /** |
|
| 1917 | - * Gets the Barrie Spotter ID based on the FlightAware ID |
|
| 1918 | - * |
|
| 1919 | - * @return Integer the Barrie Spotter ID |
|
| 1916 | + /** |
|
| 1917 | + * Gets the Barrie Spotter ID based on the FlightAware ID |
|
| 1918 | + * |
|
| 1919 | + * @return Integer the Barrie Spotter ID |
|
| 1920 | 1920 | q * |
| 1921 | - */ |
|
| 1921 | + */ |
|
| 1922 | 1922 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
| 1923 | 1923 | { |
| 1924 | 1924 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
@@ -1939,13 +1939,13 @@ discard block |
||
| 1939 | 1939 | |
| 1940 | 1940 | |
| 1941 | 1941 | /** |
| 1942 | - * Parses a date string |
|
| 1943 | - * |
|
| 1944 | - * @param String $dateString the date string |
|
| 1945 | - * @param String $timezone the timezone of a user |
|
| 1946 | - * @return Array the time information |
|
| 1947 | - * |
|
| 1948 | - */ |
|
| 1942 | + * Parses a date string |
|
| 1943 | + * |
|
| 1944 | + * @param String $dateString the date string |
|
| 1945 | + * @param String $timezone the timezone of a user |
|
| 1946 | + * @return Array the time information |
|
| 1947 | + * |
|
| 1948 | + */ |
|
| 1949 | 1949 | public function parseDateString($dateString, $timezone = '') |
| 1950 | 1950 | { |
| 1951 | 1951 | $time_array = array(); |
@@ -1978,12 +1978,12 @@ discard block |
||
| 1978 | 1978 | } |
| 1979 | 1979 | |
| 1980 | 1980 | /** |
| 1981 | - * Parses the direction degrees to working |
|
| 1982 | - * |
|
| 1983 | - * @param Float $direction the direction in degrees |
|
| 1984 | - * @return Array the direction information |
|
| 1985 | - * |
|
| 1986 | - */ |
|
| 1981 | + * Parses the direction degrees to working |
|
| 1982 | + * |
|
| 1983 | + * @param Float $direction the direction in degrees |
|
| 1984 | + * @return Array the direction information |
|
| 1985 | + * |
|
| 1986 | + */ |
|
| 1987 | 1987 | public function parseDirection($direction = 0) |
| 1988 | 1988 | { |
| 1989 | 1989 | if ($direction == '') $direction = 0; |
@@ -2062,12 +2062,12 @@ discard block |
||
| 2062 | 2062 | |
| 2063 | 2063 | |
| 2064 | 2064 | /** |
| 2065 | - * Gets Country from latitude/longitude |
|
| 2066 | - * |
|
| 2067 | - * @param Float $latitude latitute of the flight |
|
| 2068 | - * @param Float $longitude longitute of the flight |
|
| 2069 | - * @return String the countrie |
|
| 2070 | - */ |
|
| 2065 | + * Gets Country from latitude/longitude |
|
| 2066 | + * |
|
| 2067 | + * @param Float $latitude latitute of the flight |
|
| 2068 | + * @param Float $longitude longitute of the flight |
|
| 2069 | + * @return String the countrie |
|
| 2070 | + */ |
|
| 2071 | 2071 | public function getCountryFromLatitudeLongitude($latitude,$longitude) |
| 2072 | 2072 | { |
| 2073 | 2073 | global $globalDBdriver, $globalDebug; |
@@ -2104,11 +2104,11 @@ discard block |
||
| 2104 | 2104 | } |
| 2105 | 2105 | |
| 2106 | 2106 | /** |
| 2107 | - * Gets Country from iso2 |
|
| 2108 | - * |
|
| 2109 | - * @param String $iso2 ISO2 country code |
|
| 2110 | - * @return String the countrie |
|
| 2111 | - */ |
|
| 2107 | + * Gets Country from iso2 |
|
| 2108 | + * |
|
| 2109 | + * @param String $iso2 ISO2 country code |
|
| 2110 | + * @return String the countrie |
|
| 2111 | + */ |
|
| 2112 | 2112 | public function getCountryFromISO2($iso2) |
| 2113 | 2113 | { |
| 2114 | 2114 | global $globalDBdriver, $globalDebug; |
@@ -2137,12 +2137,12 @@ discard block |
||
| 2137 | 2137 | |
| 2138 | 2138 | |
| 2139 | 2139 | /** |
| 2140 | - * Gets the short url from bit.ly |
|
| 2141 | - * |
|
| 2142 | - * @param String $url the full url |
|
| 2143 | - * @return String the bit.ly url |
|
| 2144 | - * |
|
| 2145 | - */ |
|
| 2140 | + * Gets the short url from bit.ly |
|
| 2141 | + * |
|
| 2142 | + * @param String $url the full url |
|
| 2143 | + * @return String the bit.ly url |
|
| 2144 | + * |
|
| 2145 | + */ |
|
| 2146 | 2146 | public function getBitlyURL($url) |
| 2147 | 2147 | { |
| 2148 | 2148 | global $globalBitlyAccessToken; |
@@ -2169,11 +2169,11 @@ discard block |
||
| 2169 | 2169 | |
| 2170 | 2170 | |
| 2171 | 2171 | /** |
| 2172 | - * Gets all vessels types that have flown over |
|
| 2173 | - * |
|
| 2174 | - * @return Array the vessel type list |
|
| 2175 | - * |
|
| 2176 | - */ |
|
| 2172 | + * Gets all vessels types that have flown over |
|
| 2173 | + * |
|
| 2174 | + * @return Array the vessel type list |
|
| 2175 | + * |
|
| 2176 | + */ |
|
| 2177 | 2177 | public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
| 2178 | 2178 | { |
| 2179 | 2179 | global $globalDBdriver; |
@@ -2239,11 +2239,11 @@ discard block |
||
| 2239 | 2239 | } |
| 2240 | 2240 | |
| 2241 | 2241 | /** |
| 2242 | - * Gets all the tracker information |
|
| 2243 | - * |
|
| 2244 | - * @return Array the tracker information |
|
| 2245 | - * |
|
| 2246 | - */ |
|
| 2242 | + * Gets all the tracker information |
|
| 2243 | + * |
|
| 2244 | + * @return Array the tracker information |
|
| 2245 | + * |
|
| 2246 | + */ |
|
| 2247 | 2247 | public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array()) |
| 2248 | 2248 | { |
| 2249 | 2249 | global $globalTimezone, $globalDBdriver; |
@@ -2372,11 +2372,11 @@ discard block |
||
| 2372 | 2372 | } |
| 2373 | 2373 | |
| 2374 | 2374 | /** |
| 2375 | - * Check marine by id |
|
| 2376 | - * |
|
| 2377 | - * @return String the ident |
|
| 2378 | - * |
|
| 2379 | - */ |
|
| 2375 | + * Check marine by id |
|
| 2376 | + * |
|
| 2377 | + * @return String the ident |
|
| 2378 | + * |
|
| 2379 | + */ |
|
| 2380 | 2380 | public function checkId($id) |
| 2381 | 2381 | { |
| 2382 | 2382 | global $globalDBdriver, $globalTimezone; |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | require_once(dirname(__FILE__).'/class.Image.php'); |
| 3 | 3 | $global_marine_query = "SELECT marine_output.* FROM marine_output"; |
| 4 | 4 | |
| 5 | -class Marine{ |
|
| 5 | +class Marine { |
|
| 6 | 6 | public $db; |
| 7 | 7 | |
| 8 | 8 | public function __construct($dbc = null) { |
@@ -17,33 +17,33 @@ discard block |
||
| 17 | 17 | * @return Array the SQL part |
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 20 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 22 | 22 | $filters = array(); |
| 23 | 23 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 24 | 24 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 25 | 25 | $filters = $globalStatsFilters[$globalFilterName]; |
| 26 | 26 | } else { |
| 27 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 27 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 28 | 28 | } |
| 29 | 29 | } |
| 30 | 30 | if (isset($filter[0]['source'])) { |
| 31 | - $filters = array_merge($filters,$filter); |
|
| 31 | + $filters = array_merge($filters, $filter); |
|
| 32 | 32 | } |
| 33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 33 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 34 | 34 | $filter_query_join = ''; |
| 35 | 35 | $filter_query_where = ''; |
| 36 | - foreach($filters as $flt) { |
|
| 36 | + foreach ($filters as $flt) { |
|
| 37 | 37 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 38 | 38 | if (isset($flt['source'])) { |
| 39 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 39 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 40 | 40 | } else { |
| 41 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 41 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 46 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 46 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 47 | 47 | } |
| 48 | 48 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 49 | 49 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 82 | 82 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 83 | 83 | if ($filter_query_where != '') { |
| 84 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 84 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 85 | 85 | } |
| 86 | 86 | $filter_query = $filter_query_join.$filter_query_where; |
| 87 | 87 | return $filter_query; |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * @return Array the spotter information |
| 97 | 97 | * |
| 98 | 98 | */ |
| 99 | - public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
|
| 99 | + public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false) |
|
| 100 | 100 | { |
| 101 | 101 | date_default_timezone_set('UTC'); |
| 102 | 102 | if (!is_string($query)) |
@@ -116,13 +116,13 @@ discard block |
||
| 116 | 116 | $sth = $this->db->prepare($query.$limitQuery); |
| 117 | 117 | $sth->execute($params); |
| 118 | 118 | } catch (PDOException $e) { |
| 119 | - printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); |
|
| 119 | + printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery); |
|
| 120 | 120 | exit(); |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | $num_rows = 0; |
| 124 | 124 | $spotter_array = array(); |
| 125 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 125 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 126 | 126 | { |
| 127 | 127 | $num_rows++; |
| 128 | 128 | $temp_array = array(); |
@@ -164,10 +164,10 @@ discard block |
||
| 164 | 164 | } |
| 165 | 165 | if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
| 166 | 166 | |
| 167 | - if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
|
| 167 | + if (isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
|
| 168 | 168 | { |
| 169 | 169 | $Image = new Image($this->db); |
| 170 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
| 170 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']); |
|
| 171 | 171 | else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
| 172 | 172 | unset($Image); |
| 173 | 173 | if (count($image_array) > 0) { |
@@ -203,17 +203,17 @@ discard block |
||
| 203 | 203 | { |
| 204 | 204 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
| 205 | 205 | } else { |
| 206 | - $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
|
| 206 | + $temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC")); |
|
| 207 | 207 | } |
| 208 | 208 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
| 209 | - $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
|
| 210 | - $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
|
| 209 | + $temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC")); |
|
| 210 | + $temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC")); |
|
| 211 | 211 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
| 212 | 212 | if (isset($row['last_seen']) && $row['last_seen'] != '') { |
| 213 | 213 | if (strtotime($row['last_seen']) > strtotime($row['date'])) { |
| 214 | 214 | $temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']); |
| 215 | - $temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC")); |
|
| 216 | - $temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC")); |
|
| 215 | + $temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC")); |
|
| 216 | + $temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC")); |
|
| 217 | 217 | $temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC"); |
| 218 | 218 | } |
| 219 | 219 | } |
@@ -246,8 +246,8 @@ discard block |
||
| 246 | 246 | if ($limit != "") |
| 247 | 247 | { |
| 248 | 248 | $limit_array = explode(",", $limit); |
| 249 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 250 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 249 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 250 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 251 | 251 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 252 | 252 | { |
| 253 | 253 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -261,8 +261,8 @@ discard block |
||
| 261 | 261 | } else { |
| 262 | 262 | $orderby_query = " ORDER BY marine_output.date DESC"; |
| 263 | 263 | } |
| 264 | - $query = $global_marine_query.$filter_query." ".$orderby_query; |
|
| 265 | - $spotter_array = $this->getDataFromDB($query, array(),$limit_query,true); |
|
| 264 | + $query = $global_marine_query.$filter_query." ".$orderby_query; |
|
| 265 | + $spotter_array = $this->getDataFromDB($query, array(), $limit_query, true); |
|
| 266 | 266 | return $spotter_array; |
| 267 | 267 | } |
| 268 | 268 | |
@@ -280,8 +280,8 @@ discard block |
||
| 280 | 280 | if ($id == '') return array(); |
| 281 | 281 | $additional_query = "marine_output.fammarine_id = :id"; |
| 282 | 282 | $query_values = array(':id' => $id); |
| 283 | - $query = $global_marine_query." WHERE ".$additional_query." "; |
|
| 284 | - $spotter_array = $this->getDataFromDB($query,$query_values); |
|
| 283 | + $query = $global_marine_query." WHERE ".$additional_query." "; |
|
| 284 | + $spotter_array = $this->getDataFromDB($query, $query_values); |
|
| 285 | 285 | return $spotter_array; |
| 286 | 286 | } |
| 287 | 287 | |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | $query_values = array(); |
| 301 | 301 | $limit_query = ''; |
| 302 | 302 | $additional_query = ''; |
| 303 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 303 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 304 | 304 | if ($ident != "") |
| 305 | 305 | { |
| 306 | 306 | if (!is_string($ident)) |
@@ -316,8 +316,8 @@ discard block |
||
| 316 | 316 | { |
| 317 | 317 | $limit_array = explode(",", $limit); |
| 318 | 318 | |
| 319 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 320 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 319 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 320 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 321 | 321 | |
| 322 | 322 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 323 | 323 | { |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | $query_values = array(); |
| 357 | 357 | $limit_query = ''; |
| 358 | 358 | $additional_query = ''; |
| 359 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 359 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 360 | 360 | if (!is_string($type)) |
| 361 | 361 | { |
| 362 | 362 | return false; |
@@ -369,8 +369,8 @@ discard block |
||
| 369 | 369 | { |
| 370 | 370 | $limit_array = explode(",", $limit); |
| 371 | 371 | |
| 372 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 373 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 372 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 373 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 374 | 374 | |
| 375 | 375 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 376 | 376 | { |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | return $spotter_array; |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - public function getMarineDataByDate($date = '', $limit = '', $sort = '',$filter = array()) |
|
| 397 | + public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array()) |
|
| 398 | 398 | { |
| 399 | 399 | global $global_marine_query, $globalTimezone, $globalDBdriver; |
| 400 | 400 | |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | $limit_query = ''; |
| 403 | 403 | $additional_query = ''; |
| 404 | 404 | |
| 405 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 405 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 406 | 406 | |
| 407 | 407 | if ($date != "") |
| 408 | 408 | { |
@@ -428,8 +428,8 @@ discard block |
||
| 428 | 428 | { |
| 429 | 429 | $limit_array = explode(",", $limit); |
| 430 | 430 | |
| 431 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 432 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 431 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 432 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 433 | 433 | |
| 434 | 434 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 435 | 435 | { |
@@ -464,8 +464,8 @@ discard block |
||
| 464 | 464 | $query_values = array(); |
| 465 | 465 | $limit_query = ''; |
| 466 | 466 | $additional_query = ''; |
| 467 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 468 | - $captain = filter_var($captain,FILTER_SANITIZE_STRING); |
|
| 467 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 468 | + $captain = filter_var($captain, FILTER_SANITIZE_STRING); |
|
| 469 | 469 | if ($captain != "") |
| 470 | 470 | { |
| 471 | 471 | $additional_query = " AND (marine_output.captain_name = :captain OR marine_output.captain_id = :captain)"; |
@@ -474,8 +474,8 @@ discard block |
||
| 474 | 474 | if ($limit != "") |
| 475 | 475 | { |
| 476 | 476 | $limit_array = explode(",", $limit); |
| 477 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 478 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 477 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 478 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 479 | 479 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 480 | 480 | { |
| 481 | 481 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -507,8 +507,8 @@ discard block |
||
| 507 | 507 | $query_values = array(); |
| 508 | 508 | $limit_query = ''; |
| 509 | 509 | $additional_query = ''; |
| 510 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 511 | - $race = filter_var($race,FILTER_SANITIZE_STRING); |
|
| 510 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 511 | + $race = filter_var($race, FILTER_SANITIZE_STRING); |
|
| 512 | 512 | if ($race != "") |
| 513 | 513 | { |
| 514 | 514 | $additional_query = " AND (marine_output.race_name = :race OR marine_output.race_id = :race)"; |
@@ -517,8 +517,8 @@ discard block |
||
| 517 | 517 | if ($limit != "") |
| 518 | 518 | { |
| 519 | 519 | $limit_array = explode(",", $limit); |
| 520 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 521 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 520 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 521 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 522 | 522 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 523 | 523 | { |
| 524 | 524 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -543,14 +543,14 @@ discard block |
||
| 543 | 543 | * @return String Duration of all races |
| 544 | 544 | * |
| 545 | 545 | */ |
| 546 | - public function countRacesByCaptain($captain,$filters = array()) |
|
| 546 | + public function countRacesByCaptain($captain, $filters = array()) |
|
| 547 | 547 | { |
| 548 | - $captain = filter_var($captain,FILTER_SANITIZE_STRING); |
|
| 549 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 550 | - $query = "SELECT COUNT(*) AS nb |
|
| 548 | + $captain = filter_var($captain, FILTER_SANITIZE_STRING); |
|
| 549 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 550 | + $query = "SELECT COUNT(*) AS nb |
|
| 551 | 551 | FROM marine_output".$filter_query." (marine_output.captain_name = :captain OR marine_output.captain_id = :captain)"; |
| 552 | 552 | $query_values = array(); |
| 553 | - $query_values = array_merge($query_values,array(':captain' => $captain)); |
|
| 553 | + $query_values = array_merge($query_values, array(':captain' => $captain)); |
|
| 554 | 554 | $sth = $this->db->prepare($query); |
| 555 | 555 | $sth->execute($query_values); |
| 556 | 556 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -563,14 +563,14 @@ discard block |
||
| 563 | 563 | * @return String Duration of all races |
| 564 | 564 | * |
| 565 | 565 | */ |
| 566 | - public function countCaptainsByRace($race,$filters = array()) |
|
| 566 | + public function countCaptainsByRace($race, $filters = array()) |
|
| 567 | 567 | { |
| 568 | - $race = filter_var($race,FILTER_SANITIZE_STRING); |
|
| 569 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 570 | - $query = "SELECT COUNT(*) AS nb |
|
| 568 | + $race = filter_var($race, FILTER_SANITIZE_STRING); |
|
| 569 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 570 | + $query = "SELECT COUNT(*) AS nb |
|
| 571 | 571 | FROM marine_output".$filter_query." (marine_output.race_name = :race OR marine_output.race_id = :race)"; |
| 572 | 572 | $query_values = array(); |
| 573 | - $query_values = array_merge($query_values,array(':race' => $race)); |
|
| 573 | + $query_values = array_merge($query_values, array(':race' => $race)); |
|
| 574 | 574 | $sth = $this->db->prepare($query); |
| 575 | 575 | $sth->execute($query_values); |
| 576 | 576 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -583,44 +583,44 @@ discard block |
||
| 583 | 583 | * @return Array the boat list |
| 584 | 584 | * |
| 585 | 585 | */ |
| 586 | - public function countAllBoatTypesByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '') |
|
| 586 | + public function countAllBoatTypesByCaptain($captain, $filters = array(), $year = '', $month = '', $day = '') |
|
| 587 | 587 | { |
| 588 | 588 | global $globalDBdriver; |
| 589 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 590 | - $captain = filter_var($captain,FILTER_SANITIZE_STRING); |
|
| 591 | - $query = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count |
|
| 589 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 590 | + $captain = filter_var($captain, FILTER_SANITIZE_STRING); |
|
| 591 | + $query = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count |
|
| 592 | 592 | FROM marine_output".$filter_query." (marine_output.captain_id = :captain OR marine_output.captain_name = :captain)"; |
| 593 | 593 | $query_values = array(); |
| 594 | 594 | if ($year != '') { |
| 595 | 595 | if ($globalDBdriver == 'mysql') { |
| 596 | 596 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 597 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 597 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 598 | 598 | } else { |
| 599 | 599 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 600 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 600 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 601 | 601 | } |
| 602 | 602 | } |
| 603 | 603 | if ($month != '') { |
| 604 | 604 | if ($globalDBdriver == 'mysql') { |
| 605 | 605 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 606 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 606 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 607 | 607 | } else { |
| 608 | 608 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 609 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 609 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 610 | 610 | } |
| 611 | 611 | } |
| 612 | 612 | if ($day != '') { |
| 613 | 613 | if ($globalDBdriver == 'mysql') { |
| 614 | 614 | $query .= " AND DAY(marine_output.date) = :day"; |
| 615 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 615 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 616 | 616 | } else { |
| 617 | 617 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 618 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 618 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 619 | 619 | } |
| 620 | 620 | } |
| 621 | 621 | $query .= " GROUP BY marine_output.type |
| 622 | 622 | ORDER BY type_count DESC"; |
| 623 | - $query_values = array_merge($query_values,array(':captain' => $captain)); |
|
| 623 | + $query_values = array_merge($query_values, array(':captain' => $captain)); |
|
| 624 | 624 | $sth = $this->db->prepare($query); |
| 625 | 625 | $sth->execute($query_values); |
| 626 | 626 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -632,44 +632,44 @@ discard block |
||
| 632 | 632 | * @return Array the boat list |
| 633 | 633 | * |
| 634 | 634 | */ |
| 635 | - public function countAllBoatTypesByRace($race,$filters = array(),$year = '',$month = '',$day = '') |
|
| 635 | + public function countAllBoatTypesByRace($race, $filters = array(), $year = '', $month = '', $day = '') |
|
| 636 | 636 | { |
| 637 | 637 | global $globalDBdriver; |
| 638 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 639 | - $race = filter_var($race,FILTER_SANITIZE_STRING); |
|
| 640 | - $query = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count |
|
| 638 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 639 | + $race = filter_var($race, FILTER_SANITIZE_STRING); |
|
| 640 | + $query = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count |
|
| 641 | 641 | FROM marine_output".$filter_query." (marine_output.race_id = :race OR marine_output.race_name = :race)"; |
| 642 | 642 | $query_values = array(); |
| 643 | 643 | if ($year != '') { |
| 644 | 644 | if ($globalDBdriver == 'mysql') { |
| 645 | 645 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 646 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 646 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 647 | 647 | } else { |
| 648 | 648 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 649 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 649 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 650 | 650 | } |
| 651 | 651 | } |
| 652 | 652 | if ($month != '') { |
| 653 | 653 | if ($globalDBdriver == 'mysql') { |
| 654 | 654 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 655 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 655 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 656 | 656 | } else { |
| 657 | 657 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 658 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 658 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 659 | 659 | } |
| 660 | 660 | } |
| 661 | 661 | if ($day != '') { |
| 662 | 662 | if ($globalDBdriver == 'mysql') { |
| 663 | 663 | $query .= " AND DAY(marine_output.date) = :day"; |
| 664 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 664 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 665 | 665 | } else { |
| 666 | 666 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 667 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 667 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 668 | 668 | } |
| 669 | 669 | } |
| 670 | 670 | $query .= " GROUP BY marine_output.type |
| 671 | 671 | ORDER BY type_count DESC"; |
| 672 | - $query_values = array_merge($query_values,array(':race' => $race)); |
|
| 672 | + $query_values = array_merge($query_values, array(':race' => $race)); |
|
| 673 | 673 | $sth = $this->db->prepare($query); |
| 674 | 674 | $sth->execute($query_values); |
| 675 | 675 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -681,47 +681,47 @@ discard block |
||
| 681 | 681 | * @return String Duration of all race |
| 682 | 682 | * |
| 683 | 683 | */ |
| 684 | - public function getRaceDurationByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '') |
|
| 684 | + public function getRaceDurationByCaptain($captain, $filters = array(), $year = '', $month = '', $day = '') |
|
| 685 | 685 | { |
| 686 | 686 | global $globalDBdriver; |
| 687 | - $captain = filter_var($captain,FILTER_SANITIZE_STRING); |
|
| 688 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 689 | - $query = "SELECT SUM(last_seen - date) AS duration |
|
| 687 | + $captain = filter_var($captain, FILTER_SANITIZE_STRING); |
|
| 688 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 689 | + $query = "SELECT SUM(last_seen - date) AS duration |
|
| 690 | 690 | FROM marine_output".$filter_query." (marine_output.captain_name = :captain OR marine_output.captain_id = :captain) |
| 691 | 691 | AND last_seen > date"; |
| 692 | 692 | $query_values = array(); |
| 693 | 693 | if ($year != '') { |
| 694 | 694 | if ($globalDBdriver == 'mysql') { |
| 695 | 695 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 696 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 696 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 697 | 697 | } else { |
| 698 | 698 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 699 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 699 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 700 | 700 | } |
| 701 | 701 | } |
| 702 | 702 | if ($month != '') { |
| 703 | 703 | if ($globalDBdriver == 'mysql') { |
| 704 | 704 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 705 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 705 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 706 | 706 | } else { |
| 707 | 707 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 708 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 708 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 709 | 709 | } |
| 710 | 710 | } |
| 711 | 711 | if ($day != '') { |
| 712 | 712 | if ($globalDBdriver == 'mysql') { |
| 713 | 713 | $query .= " AND DAY(marine_output.date) = :day"; |
| 714 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 714 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 715 | 715 | } else { |
| 716 | 716 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 717 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 717 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 718 | 718 | } |
| 719 | 719 | } |
| 720 | - $query_values = array_merge($query_values,array(':captain' => $captain)); |
|
| 720 | + $query_values = array_merge($query_values, array(':captain' => $captain)); |
|
| 721 | 721 | $sth = $this->db->prepare($query); |
| 722 | 722 | $sth->execute($query_values); |
| 723 | 723 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 724 | - if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']); |
|
| 724 | + if (is_int($result[0]['duration'])) return gmdate('H:i:s', $result[0]['duration']); |
|
| 725 | 725 | else return $result[0]['duration']; |
| 726 | 726 | } |
| 727 | 727 | |
@@ -733,8 +733,8 @@ discard block |
||
| 733 | 733 | */ |
| 734 | 734 | public function getAllCaptainNames($filters = array()) |
| 735 | 735 | { |
| 736 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 737 | - $query = "SELECT DISTINCT marine_output.captain_name, marine_output.captain_id |
|
| 736 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 737 | + $query = "SELECT DISTINCT marine_output.captain_name, marine_output.captain_id |
|
| 738 | 738 | FROM marine_output".$filter_query." marine_output.captain_name <> '' |
| 739 | 739 | ORDER BY marine_output.captain_name ASC"; |
| 740 | 740 | |
@@ -751,8 +751,8 @@ discard block |
||
| 751 | 751 | */ |
| 752 | 752 | public function getAllRaceNames($filters = array()) |
| 753 | 753 | { |
| 754 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 755 | - $query = "SELECT DISTINCT marine_output.race_name, marine_output.race_id |
|
| 754 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 755 | + $query = "SELECT DISTINCT marine_output.race_name, marine_output.race_id |
|
| 756 | 756 | FROM marine_output".$filter_query." marine_output.race_name <> '' |
| 757 | 757 | ORDER BY marine_output.race_name ASC"; |
| 758 | 758 | |
@@ -768,11 +768,11 @@ discard block |
||
| 768 | 768 | * @return Array list of source name |
| 769 | 769 | * |
| 770 | 770 | */ |
| 771 | - public function getAllSourceName($type = '',$filters = array()) |
|
| 771 | + public function getAllSourceName($type = '', $filters = array()) |
|
| 772 | 772 | { |
| 773 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 773 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 774 | 774 | $query_values = array(); |
| 775 | - $query = "SELECT DISTINCT marine_output.source_name |
|
| 775 | + $query = "SELECT DISTINCT marine_output.source_name |
|
| 776 | 776 | FROM marine_output".$filter_query." marine_output.source_name <> ''"; |
| 777 | 777 | if ($type != '') { |
| 778 | 778 | $query_values = array(':type' => $type); |
@@ -787,7 +787,7 @@ discard block |
||
| 787 | 787 | $source_array = array(); |
| 788 | 788 | $temp_array = array(); |
| 789 | 789 | |
| 790 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 790 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 791 | 791 | { |
| 792 | 792 | $temp_array['source_name'] = $row['source_name']; |
| 793 | 793 | $source_array[] = $temp_array; |
@@ -804,8 +804,8 @@ discard block |
||
| 804 | 804 | */ |
| 805 | 805 | public function getAllIdents($filters = array()) |
| 806 | 806 | { |
| 807 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 808 | - $query = "SELECT DISTINCT marine_output.ident |
|
| 807 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 808 | + $query = "SELECT DISTINCT marine_output.ident |
|
| 809 | 809 | FROM marine_output".$filter_query." marine_output.ident <> '' |
| 810 | 810 | ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0"; |
| 811 | 811 | |
@@ -815,7 +815,7 @@ discard block |
||
| 815 | 815 | $ident_array = array(); |
| 816 | 816 | $temp_array = array(); |
| 817 | 817 | |
| 818 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 818 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 819 | 819 | { |
| 820 | 820 | $temp_array['ident'] = $row['ident']; |
| 821 | 821 | $ident_array[] = $temp_array; |
@@ -832,7 +832,7 @@ discard block |
||
| 832 | 832 | */ |
| 833 | 833 | public function getIdentity($mmsi) |
| 834 | 834 | { |
| 835 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
| 835 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
| 836 | 836 | $query = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1"; |
| 837 | 837 | $sth = $this->db->prepare($query); |
| 838 | 838 | $sth->execute(array(':mmsi' => $mmsi)); |
@@ -845,23 +845,23 @@ discard block |
||
| 845 | 845 | * Add identity |
| 846 | 846 | * |
| 847 | 847 | */ |
| 848 | - public function addIdentity($mmsi,$imo,$ident,$callsign,$type) |
|
| 848 | + public function addIdentity($mmsi, $imo, $ident, $callsign, $type) |
|
| 849 | 849 | { |
| 850 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
| 850 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
| 851 | 851 | if ($mmsi != '') { |
| 852 | - $imo = filter_var($imo,FILTER_SANITIZE_NUMBER_INT); |
|
| 853 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 854 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 855 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
| 852 | + $imo = filter_var($imo, FILTER_SANITIZE_NUMBER_INT); |
|
| 853 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 854 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 855 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
| 856 | 856 | $identinfo = $this->getIdentity($mmsi); |
| 857 | 857 | if (empty($identinfo)) { |
| 858 | - $query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)"; |
|
| 858 | + $query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)"; |
|
| 859 | 859 | $sth = $this->db->prepare($query); |
| 860 | - $sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':call_sign' => $callsign,':ship_name' => $ident,':type' => $type)); |
|
| 860 | + $sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':call_sign' => $callsign, ':ship_name' => $ident, ':type' => $type)); |
|
| 861 | 861 | } elseif ($ident != '' && $identinfo['ship_name'] != $ident) { |
| 862 | - $query = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi"; |
|
| 862 | + $query = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi"; |
|
| 863 | 863 | $sth = $this->db->prepare($query); |
| 864 | - $sth->execute(array(':mmsi' => $mmsi,':ship_name' => $ident,':type' => $type)); |
|
| 864 | + $sth->execute(array(':mmsi' => $mmsi, ':ship_name' => $ident, ':type' => $type)); |
|
| 865 | 865 | } |
| 866 | 866 | } |
| 867 | 867 | } |
@@ -882,12 +882,12 @@ discard block |
||
| 882 | 882 | } else $offset = '+00:00'; |
| 883 | 883 | |
| 884 | 884 | if ($globalDBdriver == 'mysql') { |
| 885 | - $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
| 885 | + $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
| 886 | 886 | FROM marine_output |
| 887 | 887 | WHERE marine_output.date <> '' |
| 888 | 888 | ORDER BY marine_output.date ASC LIMIT 0,100"; |
| 889 | 889 | } else { |
| 890 | - $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
| 890 | + $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
| 891 | 891 | FROM marine_output |
| 892 | 892 | WHERE marine_output.date <> '' |
| 893 | 893 | ORDER BY marine_output.date ASC LIMIT 0,100"; |
@@ -899,7 +899,7 @@ discard block |
||
| 899 | 899 | $date_array = array(); |
| 900 | 900 | $temp_array = array(); |
| 901 | 901 | |
| 902 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 902 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 903 | 903 | { |
| 904 | 904 | $temp_array['date'] = $row['date']; |
| 905 | 905 | |
@@ -917,10 +917,10 @@ discard block |
||
| 917 | 917 | * @return String success or false |
| 918 | 918 | * |
| 919 | 919 | */ |
| 920 | - public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
|
| 920 | + public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL) |
|
| 921 | 921 | { |
| 922 | 922 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
| 923 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
| 923 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident); |
|
| 924 | 924 | try { |
| 925 | 925 | $sth = $this->db->prepare($query); |
| 926 | 926 | $sth->execute($query_values); |
@@ -938,10 +938,10 @@ discard block |
||
| 938 | 938 | * @return String success or false |
| 939 | 939 | * |
| 940 | 940 | */ |
| 941 | - public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL) |
|
| 941 | + public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '', $fromsource = NULL) |
|
| 942 | 942 | { |
| 943 | 943 | $query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id'; |
| 944 | - $query_values = array(':fammarine_id' => $fammarine_id,':arrival_code' => $arrival_code); |
|
| 944 | + $query_values = array(':fammarine_id' => $fammarine_id, ':arrival_code' => $arrival_code); |
|
| 945 | 945 | try { |
| 946 | 946 | $sth = $this->db->prepare($query); |
| 947 | 947 | $sth->execute($query_values); |
@@ -960,11 +960,11 @@ discard block |
||
| 960 | 960 | * @return String success or false |
| 961 | 961 | * |
| 962 | 962 | */ |
| 963 | - public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') |
|
| 963 | + public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '') |
|
| 964 | 964 | { |
| 965 | 965 | |
| 966 | 966 | $query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; |
| 967 | - $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
| 967 | + $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id); |
|
| 968 | 968 | |
| 969 | 969 | try { |
| 970 | 970 | $sth = $this->db->prepare($query); |
@@ -984,13 +984,13 @@ discard block |
||
| 984 | 984 | * @return String success or false |
| 985 | 985 | * |
| 986 | 986 | */ |
| 987 | - public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '',$distance = NULL,$race_rank = NULL, $race_time = NULL, $status = '') |
|
| 987 | + public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '', $distance = NULL, $race_rank = NULL, $race_time = NULL, $status = '') |
|
| 988 | 988 | { |
| 989 | 989 | $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, status = :status WHERE fammarine_id = :fammarine_id'; |
| 990 | 990 | if ($latitude == '') $latitude = NULL; |
| 991 | 991 | if ($longitude == '') $longitude = NULL; |
| 992 | 992 | $groundspeed = round($groundspeed); |
| 993 | - $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,':status' => $status); |
|
| 993 | + $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, ':status' => $status); |
|
| 994 | 994 | try { |
| 995 | 995 | $sth = $this->db->prepare($query); |
| 996 | 996 | $sth->execute($query_values); |
@@ -1028,7 +1028,7 @@ discard block |
||
| 1028 | 1028 | * @param String $verticalrate vertival rate of flight |
| 1029 | 1029 | * @return String success or false |
| 1030 | 1030 | */ |
| 1031 | - 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 = '') |
|
| 1031 | + 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 = '') |
|
| 1032 | 1032 | { |
| 1033 | 1033 | global $globalURL, $globalMarineImageFetch; |
| 1034 | 1034 | |
@@ -1100,33 +1100,33 @@ discard block |
||
| 1100 | 1100 | $date = date("Y-m-d H:i:s", time()); |
| 1101 | 1101 | } |
| 1102 | 1102 | |
| 1103 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
| 1104 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 1105 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1106 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1107 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 1108 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1109 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 1110 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
| 1111 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
| 1112 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
| 1113 | - $type_id = filter_var($typeid,FILTER_SANITIZE_NUMBER_INT); |
|
| 1114 | - $status_id = filter_var($statusid,FILTER_SANITIZE_NUMBER_INT); |
|
| 1115 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 1116 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 1117 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
| 1118 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
| 1119 | - $captain_id = filter_var($captain_id,FILTER_SANITIZE_STRING); |
|
| 1120 | - $captain_name = filter_var($captain_name,FILTER_SANITIZE_STRING); |
|
| 1121 | - $race_id = filter_var($race_id,FILTER_SANITIZE_STRING); |
|
| 1122 | - $race_name = filter_var($race_name,FILTER_SANITIZE_STRING); |
|
| 1123 | - $race_rank = filter_var($race_rank,FILTER_SANITIZE_NUMBER_INT); |
|
| 1124 | - $race_time = filter_var($race_time,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1103 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
| 1104 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 1105 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1106 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1107 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 1108 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1109 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 1110 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
| 1111 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
| 1112 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
| 1113 | + $type_id = filter_var($typeid, FILTER_SANITIZE_NUMBER_INT); |
|
| 1114 | + $status_id = filter_var($statusid, FILTER_SANITIZE_NUMBER_INT); |
|
| 1115 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 1116 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 1117 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
| 1118 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
| 1119 | + $captain_id = filter_var($captain_id, FILTER_SANITIZE_STRING); |
|
| 1120 | + $captain_name = filter_var($captain_name, FILTER_SANITIZE_STRING); |
|
| 1121 | + $race_id = filter_var($race_id, FILTER_SANITIZE_STRING); |
|
| 1122 | + $race_name = filter_var($race_name, FILTER_SANITIZE_STRING); |
|
| 1123 | + $race_rank = filter_var($race_rank, FILTER_SANITIZE_NUMBER_INT); |
|
| 1124 | + $race_time = filter_var($race_time, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1125 | 1125 | if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) { |
| 1126 | 1126 | $Image = new Image($this->db); |
| 1127 | - $image_array = $Image->getMarineImage($mmsi,$imo,$ident); |
|
| 1127 | + $image_array = $Image->getMarineImage($mmsi, $imo, $ident); |
|
| 1128 | 1128 | if (!isset($image_array[0]['mmsi'])) { |
| 1129 | - $Image->addMarineImage($mmsi,$imo,$ident); |
|
| 1129 | + $Image->addMarineImage($mmsi, $imo, $ident); |
|
| 1130 | 1130 | } |
| 1131 | 1131 | unset($Image); |
| 1132 | 1132 | } |
@@ -1142,10 +1142,10 @@ discard block |
||
| 1142 | 1142 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
| 1143 | 1143 | //if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
| 1144 | 1144 | if ($arrival_date == '') $arrival_date = NULL; |
| 1145 | - $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, type_id, status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name, distance, race_rank,race_time) |
|
| 1145 | + $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, type_id, status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name, distance, race_rank,race_time) |
|
| 1146 | 1146 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:type_id,:status,:status_id,:imo,:arrival_port_name,:arrival_port_date,:captain_id,:captain_name,:race_id,:race_name, :distance, :race_rank,:race_time)"; |
| 1147 | 1147 | |
| 1148 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':mmsi' => $mmsi,':type' => $type,':type_id' => $type_id,':status' => $status,':status_id' => $status_id,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date,':captain_id' => $captain_id,':captain_name' => $captain_name,':race_id' => $race_id,':race_name' => $race_name,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time); |
|
| 1148 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':mmsi' => $mmsi, ':type' => $type, ':type_id' => $type_id, ':status' => $status, ':status_id' => $status_id, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date, ':captain_id' => $captain_id, ':captain_name' => $captain_name, ':race_id' => $race_id, ':race_name' => $race_name, ':distance' => $distance, ':race_rank' => $race_rank, ':race_time' => $race_time); |
|
| 1149 | 1149 | try { |
| 1150 | 1150 | $sth = $this->db->prepare($query); |
| 1151 | 1151 | $sth->execute($query_values); |
@@ -1169,13 +1169,13 @@ discard block |
||
| 1169 | 1169 | { |
| 1170 | 1170 | global $globalDBdriver, $globalTimezone; |
| 1171 | 1171 | if ($globalDBdriver == 'mysql') { |
| 1172 | - $query = "SELECT marine_output.ident FROM marine_output |
|
| 1172 | + $query = "SELECT marine_output.ident FROM marine_output |
|
| 1173 | 1173 | WHERE marine_output.ident = :ident |
| 1174 | 1174 | AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 1175 | 1175 | AND marine_output.date < UTC_TIMESTAMP()"; |
| 1176 | 1176 | $query_data = array(':ident' => $ident); |
| 1177 | 1177 | } else { |
| 1178 | - $query = "SELECT marine_output.ident FROM marine_output |
|
| 1178 | + $query = "SELECT marine_output.ident FROM marine_output |
|
| 1179 | 1179 | WHERE marine_output.ident = :ident |
| 1180 | 1180 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 1181 | 1181 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
@@ -1184,8 +1184,8 @@ discard block |
||
| 1184 | 1184 | |
| 1185 | 1185 | $sth = $this->db->prepare($query); |
| 1186 | 1186 | $sth->execute($query_data); |
| 1187 | - $ident_result=''; |
|
| 1188 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1187 | + $ident_result = ''; |
|
| 1188 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1189 | 1189 | { |
| 1190 | 1190 | $ident_result = $row['ident']; |
| 1191 | 1191 | } |
@@ -1211,8 +1211,8 @@ discard block |
||
| 1211 | 1211 | return false; |
| 1212 | 1212 | } else { |
| 1213 | 1213 | $q_array = explode(" ", $q); |
| 1214 | - foreach ($q_array as $q_item){ |
|
| 1215 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
| 1214 | + foreach ($q_array as $q_item) { |
|
| 1215 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
| 1216 | 1216 | $additional_query .= " AND ("; |
| 1217 | 1217 | $additional_query .= "(marine_output.ident like '%".$q_item."%')"; |
| 1218 | 1218 | $additional_query .= ")"; |
@@ -1220,11 +1220,11 @@ discard block |
||
| 1220 | 1220 | } |
| 1221 | 1221 | } |
| 1222 | 1222 | if ($globalDBdriver == 'mysql') { |
| 1223 | - $query = "SELECT marine_output.* FROM marine_output |
|
| 1223 | + $query = "SELECT marine_output.* FROM marine_output |
|
| 1224 | 1224 | WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
| 1225 | 1225 | AND marine_output.date < UTC_TIMESTAMP()"; |
| 1226 | 1226 | } else { |
| 1227 | - $query = "SELECT marine_output.* FROM marine_output |
|
| 1227 | + $query = "SELECT marine_output.* FROM marine_output |
|
| 1228 | 1228 | WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
| 1229 | 1229 | AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
| 1230 | 1230 | } |
@@ -1243,16 +1243,16 @@ discard block |
||
| 1243 | 1243 | * |
| 1244 | 1244 | */ |
| 1245 | 1245 | |
| 1246 | - public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
| 1246 | + public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
| 1247 | 1247 | { |
| 1248 | 1248 | global $globalDBdriver, $globalArchive; |
| 1249 | 1249 | //$filter_query = $this->getFilter($filters,true,true); |
| 1250 | - $Connection= new Connection($this->db); |
|
| 1250 | + $Connection = new Connection($this->db); |
|
| 1251 | 1251 | if (!$Connection->tableExists('countries')) return array(); |
| 1252 | 1252 | require_once('class.SpotterLive.php'); |
| 1253 | 1253 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
| 1254 | 1254 | $MarineLive = new MarineLive($this->db); |
| 1255 | - $filter_query = $MarineLive->getFilter($filters,true,true); |
|
| 1255 | + $filter_query = $MarineLive->getFilter($filters, true, true); |
|
| 1256 | 1256 | $filter_query .= " over_country IS NOT NULL AND over_country <> ''"; |
| 1257 | 1257 | if ($olderthanmonths > 0) { |
| 1258 | 1258 | if ($globalDBdriver == 'mysql') { |
@@ -1272,7 +1272,7 @@ discard block |
||
| 1272 | 1272 | } else { |
| 1273 | 1273 | require_once(dirname(__FILE__)."/class.MarineArchive.php"); |
| 1274 | 1274 | $MarineArchive = new MarineArchive($this->db); |
| 1275 | - $filter_query = $MarineArchive->getFilter($filters,true,true); |
|
| 1275 | + $filter_query = $MarineArchive->getFilter($filters, true, true); |
|
| 1276 | 1276 | $filter_query .= " over_country <> ''"; |
| 1277 | 1277 | if ($olderthanmonths > 0) { |
| 1278 | 1278 | if ($globalDBdriver == 'mysql') { |
@@ -1300,7 +1300,7 @@ discard block |
||
| 1300 | 1300 | $flight_array = array(); |
| 1301 | 1301 | $temp_array = array(); |
| 1302 | 1302 | |
| 1303 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1303 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1304 | 1304 | { |
| 1305 | 1305 | $temp_array['marine_count'] = $row['nb']; |
| 1306 | 1306 | $temp_array['marine_country'] = $row['name']; |
@@ -1319,11 +1319,11 @@ discard block |
||
| 1319 | 1319 | * @return Array the callsign list |
| 1320 | 1320 | * |
| 1321 | 1321 | */ |
| 1322 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
| 1322 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 1323 | 1323 | { |
| 1324 | 1324 | global $globalDBdriver; |
| 1325 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1326 | - $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
| 1325 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1326 | + $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
| 1327 | 1327 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
| 1328 | 1328 | if ($olderthanmonths > 0) { |
| 1329 | 1329 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -1337,28 +1337,28 @@ discard block |
||
| 1337 | 1337 | if ($year != '') { |
| 1338 | 1338 | if ($globalDBdriver == 'mysql') { |
| 1339 | 1339 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 1340 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1340 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1341 | 1341 | } else { |
| 1342 | 1342 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 1343 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1343 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1344 | 1344 | } |
| 1345 | 1345 | } |
| 1346 | 1346 | if ($month != '') { |
| 1347 | 1347 | if ($globalDBdriver == 'mysql') { |
| 1348 | 1348 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 1349 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1349 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1350 | 1350 | } else { |
| 1351 | 1351 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 1352 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1352 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1353 | 1353 | } |
| 1354 | 1354 | } |
| 1355 | 1355 | if ($day != '') { |
| 1356 | 1356 | if ($globalDBdriver == 'mysql') { |
| 1357 | 1357 | $query .= " AND DAY(marine_output.date) = :day"; |
| 1358 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 1358 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 1359 | 1359 | } else { |
| 1360 | 1360 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 1361 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 1361 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 1362 | 1362 | } |
| 1363 | 1363 | } |
| 1364 | 1364 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
@@ -1370,7 +1370,7 @@ discard block |
||
| 1370 | 1370 | $callsign_array = array(); |
| 1371 | 1371 | $temp_array = array(); |
| 1372 | 1372 | |
| 1373 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1373 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1374 | 1374 | { |
| 1375 | 1375 | $temp_array['callsign_icao'] = $row['ident']; |
| 1376 | 1376 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -1422,7 +1422,7 @@ discard block |
||
| 1422 | 1422 | $date_array = array(); |
| 1423 | 1423 | $temp_array = array(); |
| 1424 | 1424 | |
| 1425 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1425 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1426 | 1426 | { |
| 1427 | 1427 | $temp_array['date_name'] = $row['date_name']; |
| 1428 | 1428 | $temp_array['date_count'] = $row['date_count']; |
@@ -1448,7 +1448,7 @@ discard block |
||
| 1448 | 1448 | $datetime = new DateTime(); |
| 1449 | 1449 | $offset = $datetime->format('P'); |
| 1450 | 1450 | } else $offset = '+00:00'; |
| 1451 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1451 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1452 | 1452 | if ($globalDBdriver == 'mysql') { |
| 1453 | 1453 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
| 1454 | 1454 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -1469,7 +1469,7 @@ discard block |
||
| 1469 | 1469 | $date_array = array(); |
| 1470 | 1470 | $temp_array = array(); |
| 1471 | 1471 | |
| 1472 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1472 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1473 | 1473 | { |
| 1474 | 1474 | $temp_array['date_name'] = $row['date_name']; |
| 1475 | 1475 | $temp_array['date_count'] = $row['date_count']; |
@@ -1494,7 +1494,7 @@ discard block |
||
| 1494 | 1494 | $datetime = new DateTime(); |
| 1495 | 1495 | $offset = $datetime->format('P'); |
| 1496 | 1496 | } else $offset = '+00:00'; |
| 1497 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1497 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1498 | 1498 | if ($globalDBdriver == 'mysql') { |
| 1499 | 1499 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
| 1500 | 1500 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -1515,7 +1515,7 @@ discard block |
||
| 1515 | 1515 | $date_array = array(); |
| 1516 | 1516 | $temp_array = array(); |
| 1517 | 1517 | |
| 1518 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1518 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1519 | 1519 | { |
| 1520 | 1520 | $temp_array['date_name'] = $row['date_name']; |
| 1521 | 1521 | $temp_array['date_count'] = $row['date_count']; |
@@ -1562,7 +1562,7 @@ discard block |
||
| 1562 | 1562 | $date_array = array(); |
| 1563 | 1563 | $temp_array = array(); |
| 1564 | 1564 | |
| 1565 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1565 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1566 | 1566 | { |
| 1567 | 1567 | $temp_array['month_name'] = $row['month_name']; |
| 1568 | 1568 | $temp_array['year_name'] = $row['year_name']; |
@@ -1591,7 +1591,7 @@ discard block |
||
| 1591 | 1591 | $datetime = new DateTime(); |
| 1592 | 1592 | $offset = $datetime->format('P'); |
| 1593 | 1593 | } else $offset = '+00:00'; |
| 1594 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1594 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1595 | 1595 | if ($globalDBdriver == 'mysql') { |
| 1596 | 1596 | $query = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
| 1597 | 1597 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -1612,7 +1612,7 @@ discard block |
||
| 1612 | 1612 | $date_array = array(); |
| 1613 | 1613 | $temp_array = array(); |
| 1614 | 1614 | |
| 1615 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1615 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1616 | 1616 | { |
| 1617 | 1617 | $temp_array['year_name'] = $row['year_name']; |
| 1618 | 1618 | $temp_array['month_name'] = $row['month_name']; |
@@ -1632,7 +1632,7 @@ discard block |
||
| 1632 | 1632 | * @return Array the hour list |
| 1633 | 1633 | * |
| 1634 | 1634 | */ |
| 1635 | - public function countAllHours($orderby,$filters = array()) |
|
| 1635 | + public function countAllHours($orderby, $filters = array()) |
|
| 1636 | 1636 | { |
| 1637 | 1637 | global $globalTimezone, $globalDBdriver; |
| 1638 | 1638 | if ($globalTimezone != '') { |
@@ -1680,7 +1680,7 @@ discard block |
||
| 1680 | 1680 | $hour_array = array(); |
| 1681 | 1681 | $temp_array = array(); |
| 1682 | 1682 | |
| 1683 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1683 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1684 | 1684 | { |
| 1685 | 1685 | $temp_array['hour_name'] = $row['hour_name']; |
| 1686 | 1686 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1702,8 +1702,8 @@ discard block |
||
| 1702 | 1702 | public function countAllHoursByDate($date, $filters = array()) |
| 1703 | 1703 | { |
| 1704 | 1704 | global $globalTimezone, $globalDBdriver; |
| 1705 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1706 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
| 1705 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1706 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
| 1707 | 1707 | if ($globalTimezone != '') { |
| 1708 | 1708 | date_default_timezone_set($globalTimezone); |
| 1709 | 1709 | $datetime = new DateTime($date); |
@@ -1711,12 +1711,12 @@ discard block |
||
| 1711 | 1711 | } else $offset = '+00:00'; |
| 1712 | 1712 | |
| 1713 | 1713 | if ($globalDBdriver == 'mysql') { |
| 1714 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1714 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1715 | 1715 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date |
| 1716 | 1716 | GROUP BY hour_name |
| 1717 | 1717 | ORDER BY hour_name ASC"; |
| 1718 | 1718 | } else { |
| 1719 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1719 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1720 | 1720 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
| 1721 | 1721 | GROUP BY hour_name |
| 1722 | 1722 | ORDER BY hour_name ASC"; |
@@ -1728,7 +1728,7 @@ discard block |
||
| 1728 | 1728 | $hour_array = array(); |
| 1729 | 1729 | $temp_array = array(); |
| 1730 | 1730 | |
| 1731 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1731 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1732 | 1732 | { |
| 1733 | 1733 | $temp_array['hour_name'] = $row['hour_name']; |
| 1734 | 1734 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1750,8 +1750,8 @@ discard block |
||
| 1750 | 1750 | public function countAllHoursByIdent($ident, $filters = array()) |
| 1751 | 1751 | { |
| 1752 | 1752 | global $globalTimezone, $globalDBdriver; |
| 1753 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1754 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 1753 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1754 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 1755 | 1755 | if ($globalTimezone != '') { |
| 1756 | 1756 | date_default_timezone_set($globalTimezone); |
| 1757 | 1757 | $datetime = new DateTime(); |
@@ -1759,12 +1759,12 @@ discard block |
||
| 1759 | 1759 | } else $offset = '+00:00'; |
| 1760 | 1760 | |
| 1761 | 1761 | if ($globalDBdriver == 'mysql') { |
| 1762 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1762 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1763 | 1763 | FROM marine_output".$filter_query." marine_output.ident = :ident |
| 1764 | 1764 | GROUP BY hour_name |
| 1765 | 1765 | ORDER BY hour_name ASC"; |
| 1766 | 1766 | } else { |
| 1767 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1767 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1768 | 1768 | FROM marine_output".$filter_query." marine_output.ident = :ident |
| 1769 | 1769 | GROUP BY hour_name |
| 1770 | 1770 | ORDER BY hour_name ASC"; |
@@ -1772,12 +1772,12 @@ discard block |
||
| 1772 | 1772 | |
| 1773 | 1773 | |
| 1774 | 1774 | $sth = $this->db->prepare($query); |
| 1775 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
| 1775 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
| 1776 | 1776 | |
| 1777 | 1777 | $hour_array = array(); |
| 1778 | 1778 | $temp_array = array(); |
| 1779 | 1779 | |
| 1780 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1780 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1781 | 1781 | { |
| 1782 | 1782 | $temp_array['hour_name'] = $row['hour_name']; |
| 1783 | 1783 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1796,33 +1796,33 @@ discard block |
||
| 1796 | 1796 | * @return Integer the number of vessels |
| 1797 | 1797 | * |
| 1798 | 1798 | */ |
| 1799 | - public function countOverallMarine($filters = array(),$year = '',$month = '') |
|
| 1799 | + public function countOverallMarine($filters = array(), $year = '', $month = '') |
|
| 1800 | 1800 | { |
| 1801 | 1801 | global $globalDBdriver; |
| 1802 | 1802 | //$queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; |
| 1803 | - $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
| 1803 | + $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
| 1804 | 1804 | $query_values = array(); |
| 1805 | 1805 | $query = ''; |
| 1806 | 1806 | if ($year != '') { |
| 1807 | 1807 | if ($globalDBdriver == 'mysql') { |
| 1808 | 1808 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 1809 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1809 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1810 | 1810 | } else { |
| 1811 | 1811 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 1812 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1812 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1813 | 1813 | } |
| 1814 | 1814 | } |
| 1815 | 1815 | if ($month != '') { |
| 1816 | 1816 | if ($globalDBdriver == 'mysql') { |
| 1817 | 1817 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 1818 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1818 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1819 | 1819 | } else { |
| 1820 | 1820 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 1821 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1821 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1822 | 1822 | } |
| 1823 | 1823 | } |
| 1824 | 1824 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
| 1825 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1825 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
| 1826 | 1826 | |
| 1827 | 1827 | $sth = $this->db->prepare($queryi); |
| 1828 | 1828 | $sth->execute($query_values); |
@@ -1835,32 +1835,32 @@ discard block |
||
| 1835 | 1835 | * @return Integer the number of vessels |
| 1836 | 1836 | * |
| 1837 | 1837 | */ |
| 1838 | - public function countOverallMarineTypes($filters = array(),$year = '',$month = '') |
|
| 1838 | + public function countOverallMarineTypes($filters = array(), $year = '', $month = '') |
|
| 1839 | 1839 | { |
| 1840 | 1840 | global $globalDBdriver; |
| 1841 | - $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
| 1841 | + $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
| 1842 | 1842 | $query_values = array(); |
| 1843 | 1843 | $query = ''; |
| 1844 | 1844 | if ($year != '') { |
| 1845 | 1845 | if ($globalDBdriver == 'mysql') { |
| 1846 | 1846 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 1847 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1847 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1848 | 1848 | } else { |
| 1849 | 1849 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 1850 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1850 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1851 | 1851 | } |
| 1852 | 1852 | } |
| 1853 | 1853 | if ($month != '') { |
| 1854 | 1854 | if ($globalDBdriver == 'mysql') { |
| 1855 | 1855 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 1856 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1856 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1857 | 1857 | } else { |
| 1858 | 1858 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 1859 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1859 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1860 | 1860 | } |
| 1861 | 1861 | } |
| 1862 | 1862 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
| 1863 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1863 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
| 1864 | 1864 | |
| 1865 | 1865 | $sth = $this->db->prepare($queryi); |
| 1866 | 1866 | $sth->execute($query_values); |
@@ -1877,7 +1877,7 @@ discard block |
||
| 1877 | 1877 | public function countAllHoursFromToday($filters = array()) |
| 1878 | 1878 | { |
| 1879 | 1879 | global $globalTimezone, $globalDBdriver; |
| 1880 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1880 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1881 | 1881 | if ($globalTimezone != '') { |
| 1882 | 1882 | date_default_timezone_set($globalTimezone); |
| 1883 | 1883 | $datetime = new DateTime(); |
@@ -1885,12 +1885,12 @@ discard block |
||
| 1885 | 1885 | } else $offset = '+00:00'; |
| 1886 | 1886 | |
| 1887 | 1887 | if ($globalDBdriver == 'mysql') { |
| 1888 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1888 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1889 | 1889 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE() |
| 1890 | 1890 | GROUP BY hour_name |
| 1891 | 1891 | ORDER BY hour_name ASC"; |
| 1892 | 1892 | } else { |
| 1893 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1893 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1894 | 1894 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
| 1895 | 1895 | GROUP BY hour_name |
| 1896 | 1896 | ORDER BY hour_name ASC"; |
@@ -1902,7 +1902,7 @@ discard block |
||
| 1902 | 1902 | $hour_array = array(); |
| 1903 | 1903 | $temp_array = array(); |
| 1904 | 1904 | |
| 1905 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1905 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1906 | 1906 | { |
| 1907 | 1907 | $temp_array['hour_name'] = $row['hour_name']; |
| 1908 | 1908 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1921,9 +1921,9 @@ discard block |
||
| 1921 | 1921 | */ |
| 1922 | 1922 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
| 1923 | 1923 | { |
| 1924 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
| 1924 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
| 1925 | 1925 | |
| 1926 | - $query = "SELECT marine_output.marine_id |
|
| 1926 | + $query = "SELECT marine_output.marine_id |
|
| 1927 | 1927 | FROM marine_output |
| 1928 | 1928 | WHERE marine_output.fammarine_id = '".$fammarine_id."'"; |
| 1929 | 1929 | |
@@ -1931,7 +1931,7 @@ discard block |
||
| 1931 | 1931 | $sth = $this->db->prepare($query); |
| 1932 | 1932 | $sth->execute(); |
| 1933 | 1933 | |
| 1934 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1934 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1935 | 1935 | { |
| 1936 | 1936 | return $row['marine_id']; |
| 1937 | 1937 | } |
@@ -1956,23 +1956,23 @@ discard block |
||
| 1956 | 1956 | } |
| 1957 | 1957 | |
| 1958 | 1958 | $current_date = date("Y-m-d H:i:s"); |
| 1959 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
| 1959 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
| 1960 | 1960 | |
| 1961 | 1961 | $diff = abs(strtotime($current_date) - strtotime($date)); |
| 1962 | 1962 | |
| 1963 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
| 1963 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
| 1964 | 1964 | $years = $time_array['years']; |
| 1965 | 1965 | |
| 1966 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
| 1966 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
| 1967 | 1967 | $months = $time_array['months']; |
| 1968 | 1968 | |
| 1969 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
| 1969 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
| 1970 | 1970 | $days = $time_array['days']; |
| 1971 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
| 1971 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
| 1972 | 1972 | $hours = $time_array['hours']; |
| 1973 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
| 1973 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
| 1974 | 1974 | $minutes = $time_array['minutes']; |
| 1975 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
| 1975 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
| 1976 | 1976 | |
| 1977 | 1977 | return $time_array; |
| 1978 | 1978 | } |
@@ -1995,63 +1995,63 @@ discard block |
||
| 1995 | 1995 | $temp_array['direction_degree'] = $direction; |
| 1996 | 1996 | $temp_array['direction_shortname'] = "N"; |
| 1997 | 1997 | $temp_array['direction_fullname'] = "North"; |
| 1998 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
| 1998 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
| 1999 | 1999 | $temp_array['direction_degree'] = $direction; |
| 2000 | 2000 | $temp_array['direction_shortname'] = "NNE"; |
| 2001 | 2001 | $temp_array['direction_fullname'] = "North-Northeast"; |
| 2002 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
| 2002 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
| 2003 | 2003 | $temp_array['direction_degree'] = $direction; |
| 2004 | 2004 | $temp_array['direction_shortname'] = "NE"; |
| 2005 | 2005 | $temp_array['direction_fullname'] = "Northeast"; |
| 2006 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
| 2006 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
| 2007 | 2007 | $temp_array['direction_degree'] = $direction; |
| 2008 | 2008 | $temp_array['direction_shortname'] = "ENE"; |
| 2009 | 2009 | $temp_array['direction_fullname'] = "East-Northeast"; |
| 2010 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
| 2010 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
| 2011 | 2011 | $temp_array['direction_degree'] = $direction; |
| 2012 | 2012 | $temp_array['direction_shortname'] = "E"; |
| 2013 | 2013 | $temp_array['direction_fullname'] = "East"; |
| 2014 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
| 2014 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
| 2015 | 2015 | $temp_array['direction_degree'] = $direction; |
| 2016 | 2016 | $temp_array['direction_shortname'] = "ESE"; |
| 2017 | 2017 | $temp_array['direction_fullname'] = "East-Southeast"; |
| 2018 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
| 2018 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
| 2019 | 2019 | $temp_array['direction_degree'] = $direction; |
| 2020 | 2020 | $temp_array['direction_shortname'] = "SE"; |
| 2021 | 2021 | $temp_array['direction_fullname'] = "Southeast"; |
| 2022 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
| 2022 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
| 2023 | 2023 | $temp_array['direction_degree'] = $direction; |
| 2024 | 2024 | $temp_array['direction_shortname'] = "SSE"; |
| 2025 | 2025 | $temp_array['direction_fullname'] = "South-Southeast"; |
| 2026 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
| 2026 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
| 2027 | 2027 | $temp_array['direction_degree'] = $direction; |
| 2028 | 2028 | $temp_array['direction_shortname'] = "S"; |
| 2029 | 2029 | $temp_array['direction_fullname'] = "South"; |
| 2030 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
| 2030 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
| 2031 | 2031 | $temp_array['direction_degree'] = $direction; |
| 2032 | 2032 | $temp_array['direction_shortname'] = "SSW"; |
| 2033 | 2033 | $temp_array['direction_fullname'] = "South-Southwest"; |
| 2034 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
| 2034 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
| 2035 | 2035 | $temp_array['direction_degree'] = $direction; |
| 2036 | 2036 | $temp_array['direction_shortname'] = "SW"; |
| 2037 | 2037 | $temp_array['direction_fullname'] = "Southwest"; |
| 2038 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
| 2038 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
| 2039 | 2039 | $temp_array['direction_degree'] = $direction; |
| 2040 | 2040 | $temp_array['direction_shortname'] = "WSW"; |
| 2041 | 2041 | $temp_array['direction_fullname'] = "West-Southwest"; |
| 2042 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
| 2042 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
| 2043 | 2043 | $temp_array['direction_degree'] = $direction; |
| 2044 | 2044 | $temp_array['direction_shortname'] = "W"; |
| 2045 | 2045 | $temp_array['direction_fullname'] = "West"; |
| 2046 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
| 2046 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
| 2047 | 2047 | $temp_array['direction_degree'] = $direction; |
| 2048 | 2048 | $temp_array['direction_shortname'] = "WNW"; |
| 2049 | 2049 | $temp_array['direction_fullname'] = "West-Northwest"; |
| 2050 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
| 2050 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
| 2051 | 2051 | $temp_array['direction_degree'] = $direction; |
| 2052 | 2052 | $temp_array['direction_shortname'] = "NW"; |
| 2053 | 2053 | $temp_array['direction_fullname'] = "Northwest"; |
| 2054 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
| 2054 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
| 2055 | 2055 | $temp_array['direction_degree'] = $direction; |
| 2056 | 2056 | $temp_array['direction_shortname'] = "NNW"; |
| 2057 | 2057 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -2068,11 +2068,11 @@ discard block |
||
| 2068 | 2068 | * @param Float $longitude longitute of the flight |
| 2069 | 2069 | * @return String the countrie |
| 2070 | 2070 | */ |
| 2071 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
| 2071 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
| 2072 | 2072 | { |
| 2073 | 2073 | global $globalDBdriver, $globalDebug; |
| 2074 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 2075 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 2074 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 2075 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 2076 | 2076 | |
| 2077 | 2077 | $Connection = new Connection($this->db); |
| 2078 | 2078 | if (!$Connection->tableExists('countries')) return ''; |
@@ -2112,7 +2112,7 @@ discard block |
||
| 2112 | 2112 | public function getCountryFromISO2($iso2) |
| 2113 | 2113 | { |
| 2114 | 2114 | global $globalDBdriver, $globalDebug; |
| 2115 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
| 2115 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
| 2116 | 2116 | |
| 2117 | 2117 | $Connection = new Connection($this->db); |
| 2118 | 2118 | if (!$Connection->tableExists('countries')) return ''; |
@@ -2160,7 +2160,7 @@ discard block |
||
| 2160 | 2160 | |
| 2161 | 2161 | $bitly_data = json_decode($bitly_data); |
| 2162 | 2162 | $bitly_url = ''; |
| 2163 | - if ($bitly_data->status_txt = "OK"){ |
|
| 2163 | + if ($bitly_data->status_txt = "OK") { |
|
| 2164 | 2164 | $bitly_url = $bitly_data->data->url; |
| 2165 | 2165 | } |
| 2166 | 2166 | |
@@ -2174,11 +2174,11 @@ discard block |
||
| 2174 | 2174 | * @return Array the vessel type list |
| 2175 | 2175 | * |
| 2176 | 2176 | */ |
| 2177 | - public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
|
| 2177 | + public function countAllMarineTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 2178 | 2178 | { |
| 2179 | 2179 | global $globalDBdriver; |
| 2180 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 2181 | - $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id |
|
| 2180 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 2181 | + $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id |
|
| 2182 | 2182 | FROM marine_output ".$filter_query." marine_output.type <> '' AND marine_output.type_id IS NOT NULL"; |
| 2183 | 2183 | if ($olderthanmonths > 0) { |
| 2184 | 2184 | if ($globalDBdriver == 'mysql') { |
@@ -2198,28 +2198,28 @@ discard block |
||
| 2198 | 2198 | if ($year != '') { |
| 2199 | 2199 | if ($globalDBdriver == 'mysql') { |
| 2200 | 2200 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 2201 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 2201 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 2202 | 2202 | } else { |
| 2203 | 2203 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 2204 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 2204 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 2205 | 2205 | } |
| 2206 | 2206 | } |
| 2207 | 2207 | if ($month != '') { |
| 2208 | 2208 | if ($globalDBdriver == 'mysql') { |
| 2209 | 2209 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 2210 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 2210 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 2211 | 2211 | } else { |
| 2212 | 2212 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 2213 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 2213 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 2214 | 2214 | } |
| 2215 | 2215 | } |
| 2216 | 2216 | if ($day != '') { |
| 2217 | 2217 | if ($globalDBdriver == 'mysql') { |
| 2218 | 2218 | $query .= " AND DAY(marine_output.date) = :day"; |
| 2219 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 2219 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 2220 | 2220 | } else { |
| 2221 | 2221 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 2222 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 2222 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 2223 | 2223 | } |
| 2224 | 2224 | } |
| 2225 | 2225 | $query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC"; |
@@ -2228,7 +2228,7 @@ discard block |
||
| 2228 | 2228 | $sth->execute($query_values); |
| 2229 | 2229 | $marine_array = array(); |
| 2230 | 2230 | $temp_array = array(); |
| 2231 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2231 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2232 | 2232 | { |
| 2233 | 2233 | $temp_array['marine_type'] = $row['marine_type']; |
| 2234 | 2234 | $temp_array['marine_type_id'] = $row['marine_type_id']; |
@@ -2244,13 +2244,13 @@ discard block |
||
| 2244 | 2244 | * @return Array the tracker information |
| 2245 | 2245 | * |
| 2246 | 2246 | */ |
| 2247 | - public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array()) |
|
| 2247 | + public function searchMarineData($q = '', $callsign = '', $mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
| 2248 | 2248 | { |
| 2249 | 2249 | global $globalTimezone, $globalDBdriver; |
| 2250 | 2250 | date_default_timezone_set('UTC'); |
| 2251 | 2251 | $query_values = array(); |
| 2252 | 2252 | $additional_query = ''; |
| 2253 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 2253 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 2254 | 2254 | if ($q != "") |
| 2255 | 2255 | { |
| 2256 | 2256 | if (!is_string($q)) |
@@ -2258,8 +2258,8 @@ discard block |
||
| 2258 | 2258 | return false; |
| 2259 | 2259 | } else { |
| 2260 | 2260 | $q_array = explode(" ", $q); |
| 2261 | - foreach ($q_array as $q_item){ |
|
| 2262 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
| 2261 | + foreach ($q_array as $q_item) { |
|
| 2262 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
| 2263 | 2263 | $additional_query .= " AND ("; |
| 2264 | 2264 | if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
| 2265 | 2265 | if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
@@ -2271,42 +2271,42 @@ discard block |
||
| 2271 | 2271 | } |
| 2272 | 2272 | if ($callsign != "") |
| 2273 | 2273 | { |
| 2274 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 2274 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 2275 | 2275 | if (!is_string($callsign)) |
| 2276 | 2276 | { |
| 2277 | 2277 | return false; |
| 2278 | 2278 | } else { |
| 2279 | 2279 | $additional_query .= " AND marine_output.ident = :callsign"; |
| 2280 | - $query_values = array_merge($query_values,array(':callsign' => $callsign)); |
|
| 2280 | + $query_values = array_merge($query_values, array(':callsign' => $callsign)); |
|
| 2281 | 2281 | } |
| 2282 | 2282 | } |
| 2283 | 2283 | if ($mmsi != "") |
| 2284 | 2284 | { |
| 2285 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
| 2285 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
| 2286 | 2286 | if (!is_numeric($mmsi)) |
| 2287 | 2287 | { |
| 2288 | 2288 | return false; |
| 2289 | 2289 | } else { |
| 2290 | 2290 | $additional_query .= " AND marine_output.mmsi = :mmsi"; |
| 2291 | - $query_values = array_merge($query_values,array(':mmsi' => $mmsi)); |
|
| 2291 | + $query_values = array_merge($query_values, array(':mmsi' => $mmsi)); |
|
| 2292 | 2292 | } |
| 2293 | 2293 | } |
| 2294 | 2294 | if ($imo != "") |
| 2295 | 2295 | { |
| 2296 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 2296 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 2297 | 2297 | if (!is_numeric($imo)) |
| 2298 | 2298 | { |
| 2299 | 2299 | return false; |
| 2300 | 2300 | } else { |
| 2301 | 2301 | $additional_query .= " AND marine_output.imo = :imo"; |
| 2302 | - $query_values = array_merge($query_values,array(':imo' => $imo)); |
|
| 2302 | + $query_values = array_merge($query_values, array(':imo' => $imo)); |
|
| 2303 | 2303 | } |
| 2304 | 2304 | } |
| 2305 | 2305 | if ($date_posted != "") |
| 2306 | 2306 | { |
| 2307 | 2307 | $date_array = explode(",", $date_posted); |
| 2308 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 2309 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 2308 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
| 2309 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
| 2310 | 2310 | if ($globalTimezone != '') { |
| 2311 | 2311 | date_default_timezone_set($globalTimezone); |
| 2312 | 2312 | $datetime = new DateTime(); |
@@ -2333,8 +2333,8 @@ discard block |
||
| 2333 | 2333 | if ($limit != "") |
| 2334 | 2334 | { |
| 2335 | 2335 | $limit_array = explode(",", $limit); |
| 2336 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 2337 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 2336 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 2337 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 2338 | 2338 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 2339 | 2339 | { |
| 2340 | 2340 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -2352,22 +2352,22 @@ discard block |
||
| 2352 | 2352 | } |
| 2353 | 2353 | } |
| 2354 | 2354 | if ($origLat != "" && $origLon != "" && $dist != "") { |
| 2355 | - $dist = number_format($dist*0.621371,2,'.',''); // convert km to mile |
|
| 2355 | + $dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile |
|
| 2356 | 2356 | if ($globalDBdriver == 'mysql') { |
| 2357 | - $query="SELECT marine_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2))) as distance |
|
| 2357 | + $query = "SELECT marine_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2))) as distance |
|
| 2358 | 2358 | FROM marine_archive,marine_output".$filter_query." marine_output.fammarine_id = marine_archive.fammarine_id AND marine_output.ident <> '' ".$additional_query."AND marine_archive.longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and marine_archive.latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 2359 | 2359 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2)))) < $dist".$orderby_query; |
| 2360 | 2360 | } else { |
| 2361 | - $query="SELECT marine_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 2361 | + $query = "SELECT marine_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 2362 | 2362 | FROM marine_archive,marine_output".$filter_query." marine_output.fammarine_id = marine_archive.fammarine_id AND marine_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 2363 | 2363 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query.$orderby_query; |
| 2364 | 2364 | } |
| 2365 | 2365 | } else { |
| 2366 | - $query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' |
|
| 2366 | + $query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' |
|
| 2367 | 2367 | ".$additional_query." |
| 2368 | 2368 | ".$orderby_query; |
| 2369 | 2369 | } |
| 2370 | - $marine_array = $this->getDataFromDB($query, $query_values,$limit_query); |
|
| 2370 | + $marine_array = $this->getDataFromDB($query, $query_values, $limit_query); |
|
| 2371 | 2371 | return $marine_array; |
| 2372 | 2372 | } |
| 2373 | 2373 | |
@@ -2380,12 +2380,12 @@ discard block |
||
| 2380 | 2380 | public function checkId($id) |
| 2381 | 2381 | { |
| 2382 | 2382 | global $globalDBdriver, $globalTimezone; |
| 2383 | - $query = 'SELECT marine_output.ident, marine_output.fammarine_id FROM marine_output WHERE marine_output.fammarine_id = :id'; |
|
| 2383 | + $query = 'SELECT marine_output.ident, marine_output.fammarine_id FROM marine_output WHERE marine_output.fammarine_id = :id'; |
|
| 2384 | 2384 | $query_data = array(':id' => $id); |
| 2385 | 2385 | $sth = $this->db->prepare($query); |
| 2386 | 2386 | $sth->execute($query_data); |
| 2387 | - $ident_result=''; |
|
| 2388 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2387 | + $ident_result = ''; |
|
| 2388 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2389 | 2389 | { |
| 2390 | 2390 | $ident_result = $row['fammarine_id']; |
| 2391 | 2391 | } |
@@ -2394,7 +2394,7 @@ discard block |
||
| 2394 | 2394 | |
| 2395 | 2395 | public function getOrderBy() |
| 2396 | 2396 | { |
| 2397 | - $orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY marine_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY marine_output.type DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure port - ASC", "sql" => "ORDER BY marine_output.departure_port_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC")); |
|
| 2397 | + $orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY marine_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY marine_output.type DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure port - ASC", "sql" => "ORDER BY marine_output.departure_port_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC")); |
|
| 2398 | 2398 | |
| 2399 | 2399 | return $orderby; |
| 2400 | 2400 | |
@@ -8,7 +8,9 @@ discard block |
||
| 8 | 8 | public function __construct($dbc = null) { |
| 9 | 9 | $Connection = new Connection($dbc); |
| 10 | 10 | $this->db = $Connection->db(); |
| 11 | - if ($this->db === null) die('Error: No DB connection. (Marine)'); |
|
| 11 | + if ($this->db === null) { |
|
| 12 | + die('Error: No DB connection. (Marine)'); |
|
| 13 | + } |
|
| 12 | 14 | } |
| 13 | 15 | |
| 14 | 16 | /** |
@@ -30,7 +32,9 @@ discard block |
||
| 30 | 32 | if (isset($filter[0]['source'])) { |
| 31 | 33 | $filters = array_merge($filters,$filter); |
| 32 | 34 | } |
| 33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 35 | + if (is_array($globalFilter)) { |
|
| 36 | + $filter = array_merge($filter,$globalFilter); |
|
| 37 | + } |
|
| 34 | 38 | $filter_query_join = ''; |
| 35 | 39 | $filter_query_where = ''; |
| 36 | 40 | foreach($filters as $flt) { |
@@ -78,8 +82,11 @@ discard block |
||
| 78 | 82 | $filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
| 79 | 83 | } |
| 80 | 84 | } |
| 81 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 82 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 85 | + if ($filter_query_where == '' && $where) { |
|
| 86 | + $filter_query_where = ' WHERE'; |
|
| 87 | + } elseif ($filter_query_where != '' && $and) { |
|
| 88 | + $filter_query_where .= ' AND'; |
|
| 89 | + } |
|
| 83 | 90 | if ($filter_query_where != '') { |
| 84 | 91 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 85 | 92 | } |
@@ -133,42 +140,84 @@ discard block |
||
| 133 | 140 | $temp_array['spotter_id'] = $row['spotter_archive_id']; |
| 134 | 141 | } elseif (isset($row['spotter_archive_output_id'])) { |
| 135 | 142 | $temp_array['spotter_id'] = $row['spotter_archive_output_id']; |
| 136 | - */} |
|
| 137 | - elseif (isset($row['marineid'])) { |
|
| 143 | + */} elseif (isset($row['marineid'])) { |
|
| 138 | 144 | $temp_array['marine_id'] = $row['marineid']; |
| 139 | 145 | } else { |
| 140 | 146 | $temp_array['marine_id'] = ''; |
| 141 | 147 | } |
| 142 | - if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
| 143 | - if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi']; |
|
| 144 | - if (isset($row['type'])) $temp_array['type'] = $row['type']; |
|
| 145 | - if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id']; |
|
| 146 | - if (isset($row['status'])) $temp_array['status'] = $row['status']; |
|
| 147 | - if (isset($row['status_id'])) $temp_array['status_id'] = $row['status_id']; |
|
| 148 | - if (isset($row['captain_id'])) $temp_array['captain_id'] = $row['captain_id']; |
|
| 149 | - if (isset($row['captain_name'])) $temp_array['captain_name'] = $row['captain_name']; |
|
| 150 | - if (isset($row['race_id'])) $temp_array['race_id'] = $row['race_id']; |
|
| 151 | - if (isset($row['race_name'])) $temp_array['race_name'] = $row['race_name']; |
|
| 152 | - if (isset($row['race_time']) && isset($row['status']) && $row['status'] != 'Racing' && $row['race_time'] > 0) $temp_array['race_time'] = $row['race_time']; |
|
| 153 | - if (isset($row['race_rank'])) $temp_array['race_rank'] = $row['race_rank']; |
|
| 154 | - if (isset($row['ident'])) $temp_array['ident'] = $row['ident']; |
|
| 155 | - if (isset($row['arrival_port_name'])) $temp_array['arrival_port_name'] = $row['arrival_port_name']; |
|
| 156 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
| 157 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
| 158 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
| 159 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
| 148 | + if (isset($row['fammarine_id'])) { |
|
| 149 | + $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
| 150 | + } |
|
| 151 | + if (isset($row['mmsi'])) { |
|
| 152 | + $temp_array['mmsi'] = $row['mmsi']; |
|
| 153 | + } |
|
| 154 | + if (isset($row['type'])) { |
|
| 155 | + $temp_array['type'] = $row['type']; |
|
| 156 | + } |
|
| 157 | + if (isset($row['type_id'])) { |
|
| 158 | + $temp_array['type_id'] = $row['type_id']; |
|
| 159 | + } |
|
| 160 | + if (isset($row['status'])) { |
|
| 161 | + $temp_array['status'] = $row['status']; |
|
| 162 | + } |
|
| 163 | + if (isset($row['status_id'])) { |
|
| 164 | + $temp_array['status_id'] = $row['status_id']; |
|
| 165 | + } |
|
| 166 | + if (isset($row['captain_id'])) { |
|
| 167 | + $temp_array['captain_id'] = $row['captain_id']; |
|
| 168 | + } |
|
| 169 | + if (isset($row['captain_name'])) { |
|
| 170 | + $temp_array['captain_name'] = $row['captain_name']; |
|
| 171 | + } |
|
| 172 | + if (isset($row['race_id'])) { |
|
| 173 | + $temp_array['race_id'] = $row['race_id']; |
|
| 174 | + } |
|
| 175 | + if (isset($row['race_name'])) { |
|
| 176 | + $temp_array['race_name'] = $row['race_name']; |
|
| 177 | + } |
|
| 178 | + if (isset($row['race_time']) && isset($row['status']) && $row['status'] != 'Racing' && $row['race_time'] > 0) { |
|
| 179 | + $temp_array['race_time'] = $row['race_time']; |
|
| 180 | + } |
|
| 181 | + if (isset($row['race_rank'])) { |
|
| 182 | + $temp_array['race_rank'] = $row['race_rank']; |
|
| 183 | + } |
|
| 184 | + if (isset($row['ident'])) { |
|
| 185 | + $temp_array['ident'] = $row['ident']; |
|
| 186 | + } |
|
| 187 | + if (isset($row['arrival_port_name'])) { |
|
| 188 | + $temp_array['arrival_port_name'] = $row['arrival_port_name']; |
|
| 189 | + } |
|
| 190 | + if (isset($row['latitude'])) { |
|
| 191 | + $temp_array['latitude'] = $row['latitude']; |
|
| 192 | + } |
|
| 193 | + if (isset($row['longitude'])) { |
|
| 194 | + $temp_array['longitude'] = $row['longitude']; |
|
| 195 | + } |
|
| 196 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
| 197 | + $temp_array['distance'] = $row['distance']; |
|
| 198 | + } |
|
| 199 | + if (isset($row['format_source'])) { |
|
| 200 | + $temp_array['format_source'] = $row['format_source']; |
|
| 201 | + } |
|
| 160 | 202 | if (isset($row['heading'])) { |
| 161 | 203 | $temp_array['heading'] = $row['heading']; |
| 162 | 204 | $heading_direction = $this->parseDirection($row['heading']); |
| 163 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
| 205 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
| 206 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
| 207 | + } |
|
| 208 | + } |
|
| 209 | + if (isset($row['ground_speed'])) { |
|
| 210 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
| 164 | 211 | } |
| 165 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
| 166 | 212 | |
| 167 | 213 | if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
| 168 | 214 | { |
| 169 | 215 | $Image = new Image($this->db); |
| 170 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
| 171 | - else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
| 216 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') { |
|
| 217 | + $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
| 218 | + } else { |
|
| 219 | + $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
| 220 | + } |
|
| 172 | 221 | unset($Image); |
| 173 | 222 | if (count($image_array) > 0) { |
| 174 | 223 | $temp_array['image'] = $image_array[0]['image']; |
@@ -220,13 +269,21 @@ discard block |
||
| 220 | 269 | } |
| 221 | 270 | |
| 222 | 271 | $fromsource = NULL; |
| 223 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
| 224 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
| 225 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
| 272 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
| 273 | + $temp_array['source_name'] = $row['source_name']; |
|
| 274 | + } |
|
| 275 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
| 276 | + $temp_array['over_country'] = $row['over_country']; |
|
| 277 | + } |
|
| 278 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
| 279 | + $temp_array['distance'] = $row['distance']; |
|
| 280 | + } |
|
| 226 | 281 | $temp_array['query_number_rows'] = $num_rows; |
| 227 | 282 | $spotter_array[] = $temp_array; |
| 228 | 283 | } |
| 229 | - if ($num_rows == 0) return array(); |
|
| 284 | + if ($num_rows == 0) { |
|
| 285 | + return array(); |
|
| 286 | + } |
|
| 230 | 287 | $spotter_array[0]['query_number_rows'] = $num_rows; |
| 231 | 288 | return $spotter_array; |
| 232 | 289 | } |
@@ -252,8 +309,12 @@ discard block |
||
| 252 | 309 | { |
| 253 | 310 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 254 | 311 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 255 | - } else $limit_query = ""; |
|
| 256 | - } else $limit_query = ""; |
|
| 312 | + } else { |
|
| 313 | + $limit_query = ""; |
|
| 314 | + } |
|
| 315 | + } else { |
|
| 316 | + $limit_query = ""; |
|
| 317 | + } |
|
| 257 | 318 | if ($sort != "") |
| 258 | 319 | { |
| 259 | 320 | $search_orderby_array = $this->getOrderBy(); |
@@ -277,7 +338,9 @@ discard block |
||
| 277 | 338 | global $global_marine_query; |
| 278 | 339 | |
| 279 | 340 | date_default_timezone_set('UTC'); |
| 280 | - if ($id == '') return array(); |
|
| 341 | + if ($id == '') { |
|
| 342 | + return array(); |
|
| 343 | + } |
|
| 281 | 344 | $additional_query = "marine_output.fammarine_id = :id"; |
| 282 | 345 | $query_values = array(':id' => $id); |
| 283 | 346 | $query = $global_marine_query." WHERE ".$additional_query." "; |
@@ -721,8 +784,11 @@ discard block |
||
| 721 | 784 | $sth = $this->db->prepare($query); |
| 722 | 785 | $sth->execute($query_values); |
| 723 | 786 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 724 | - if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']); |
|
| 725 | - else return $result[0]['duration']; |
|
| 787 | + if (is_int($result[0]['duration'])) { |
|
| 788 | + return gmdate('H:i:s',$result[0]['duration']); |
|
| 789 | + } else { |
|
| 790 | + return $result[0]['duration']; |
|
| 791 | + } |
|
| 726 | 792 | } |
| 727 | 793 | |
| 728 | 794 | /** |
@@ -781,8 +847,11 @@ discard block |
||
| 781 | 847 | $query .= " ORDER BY marine_output.source_name ASC"; |
| 782 | 848 | |
| 783 | 849 | $sth = $this->db->prepare($query); |
| 784 | - if (!empty($query_values)) $sth->execute($query_values); |
|
| 785 | - else $sth->execute(); |
|
| 850 | + if (!empty($query_values)) { |
|
| 851 | + $sth->execute($query_values); |
|
| 852 | + } else { |
|
| 853 | + $sth->execute(); |
|
| 854 | + } |
|
| 786 | 855 | |
| 787 | 856 | $source_array = array(); |
| 788 | 857 | $temp_array = array(); |
@@ -837,8 +906,11 @@ discard block |
||
| 837 | 906 | $sth = $this->db->prepare($query); |
| 838 | 907 | $sth->execute(array(':mmsi' => $mmsi)); |
| 839 | 908 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 840 | - if (isset($result[0])) return $result[0]; |
|
| 841 | - else return array(); |
|
| 909 | + if (isset($result[0])) { |
|
| 910 | + return $result[0]; |
|
| 911 | + } else { |
|
| 912 | + return array(); |
|
| 913 | + } |
|
| 842 | 914 | } |
| 843 | 915 | |
| 844 | 916 | /** |
@@ -879,7 +951,9 @@ discard block |
||
| 879 | 951 | date_default_timezone_set($globalTimezone); |
| 880 | 952 | $datetime = new DateTime(); |
| 881 | 953 | $offset = $datetime->format('P'); |
| 882 | - } else $offset = '+00:00'; |
|
| 954 | + } else { |
|
| 955 | + $offset = '+00:00'; |
|
| 956 | + } |
|
| 883 | 957 | |
| 884 | 958 | if ($globalDBdriver == 'mysql') { |
| 885 | 959 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
@@ -987,8 +1061,12 @@ discard block |
||
| 987 | 1061 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '',$distance = NULL,$race_rank = NULL, $race_time = NULL, $status = '') |
| 988 | 1062 | { |
| 989 | 1063 | $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, status = :status WHERE fammarine_id = :fammarine_id'; |
| 990 | - if ($latitude == '') $latitude = NULL; |
|
| 991 | - if ($longitude == '') $longitude = NULL; |
|
| 1064 | + if ($latitude == '') { |
|
| 1065 | + $latitude = NULL; |
|
| 1066 | + } |
|
| 1067 | + if ($longitude == '') { |
|
| 1068 | + $longitude = NULL; |
|
| 1069 | + } |
|
| 992 | 1070 | $groundspeed = round($groundspeed); |
| 993 | 1071 | $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,':status' => $status); |
| 994 | 1072 | try { |
@@ -1134,14 +1212,28 @@ discard block |
||
| 1134 | 1212 | $latitude = 0; |
| 1135 | 1213 | $longitude = 0; |
| 1136 | 1214 | } |
| 1137 | - if ($type_id == '') $type_id = NULL; |
|
| 1138 | - if ($status_id == '') $status_id = NULL; |
|
| 1139 | - if ($distance == '') $distance = NULL; |
|
| 1140 | - if ($race_rank == '') $race_rank = NULL; |
|
| 1141 | - if ($race_time == '') $race_time = NULL; |
|
| 1142 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 1215 | + if ($type_id == '') { |
|
| 1216 | + $type_id = NULL; |
|
| 1217 | + } |
|
| 1218 | + if ($status_id == '') { |
|
| 1219 | + $status_id = NULL; |
|
| 1220 | + } |
|
| 1221 | + if ($distance == '') { |
|
| 1222 | + $distance = NULL; |
|
| 1223 | + } |
|
| 1224 | + if ($race_rank == '') { |
|
| 1225 | + $race_rank = NULL; |
|
| 1226 | + } |
|
| 1227 | + if ($race_time == '') { |
|
| 1228 | + $race_time = NULL; |
|
| 1229 | + } |
|
| 1230 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
| 1231 | + $heading = 0; |
|
| 1232 | + } |
|
| 1143 | 1233 | //if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
| 1144 | - if ($arrival_date == '') $arrival_date = NULL; |
|
| 1234 | + if ($arrival_date == '') { |
|
| 1235 | + $arrival_date = NULL; |
|
| 1236 | + } |
|
| 1145 | 1237 | $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, type_id, status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name, distance, race_rank,race_time) |
| 1146 | 1238 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:type_id,:status,:status_id,:imo,:arrival_port_name,:arrival_port_date,:captain_id,:captain_name,:race_id,:race_name, :distance, :race_rank,:race_time)"; |
| 1147 | 1239 | |
@@ -1248,7 +1340,9 @@ discard block |
||
| 1248 | 1340 | global $globalDBdriver, $globalArchive; |
| 1249 | 1341 | //$filter_query = $this->getFilter($filters,true,true); |
| 1250 | 1342 | $Connection= new Connection($this->db); |
| 1251 | - if (!$Connection->tableExists('countries')) return array(); |
|
| 1343 | + if (!$Connection->tableExists('countries')) { |
|
| 1344 | + return array(); |
|
| 1345 | + } |
|
| 1252 | 1346 | require_once('class.SpotterLive.php'); |
| 1253 | 1347 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
| 1254 | 1348 | $MarineLive = new MarineLive($this->db); |
@@ -1292,7 +1386,9 @@ discard block |
||
| 1292 | 1386 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT fammarine_id,over_country FROM marine_archive".$filter_query.") l ON c.iso2 = l.over_country "; |
| 1293 | 1387 | } |
| 1294 | 1388 | $query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; |
| 1295 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 1389 | + if ($limit) { |
|
| 1390 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 1391 | + } |
|
| 1296 | 1392 | |
| 1297 | 1393 | $sth = $this->db->prepare($query); |
| 1298 | 1394 | $sth->execute(); |
@@ -1326,12 +1422,18 @@ discard block |
||
| 1326 | 1422 | $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
| 1327 | 1423 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
| 1328 | 1424 | if ($olderthanmonths > 0) { |
| 1329 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
| 1330 | - else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 1425 | + if ($globalDBdriver == 'mysql') { |
|
| 1426 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
| 1427 | + } else { |
|
| 1428 | + $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 1429 | + } |
|
| 1331 | 1430 | } |
| 1332 | 1431 | if ($sincedate != '') { |
| 1333 | - if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'"; |
|
| 1334 | - else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
| 1432 | + if ($globalDBdriver == 'mysql') { |
|
| 1433 | + $query .= " AND marine_output.date > '".$sincedate."'"; |
|
| 1434 | + } else { |
|
| 1435 | + $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
| 1436 | + } |
|
| 1335 | 1437 | } |
| 1336 | 1438 | $query_values = array(); |
| 1337 | 1439 | if ($year != '') { |
@@ -1362,7 +1464,9 @@ discard block |
||
| 1362 | 1464 | } |
| 1363 | 1465 | } |
| 1364 | 1466 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
| 1365 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 1467 | + if ($limit) { |
|
| 1468 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 1469 | + } |
|
| 1366 | 1470 | |
| 1367 | 1471 | $sth = $this->db->prepare($query); |
| 1368 | 1472 | $sth->execute($query_values); |
@@ -1397,7 +1501,9 @@ discard block |
||
| 1397 | 1501 | date_default_timezone_set($globalTimezone); |
| 1398 | 1502 | $datetime = new DateTime(); |
| 1399 | 1503 | $offset = $datetime->format('P'); |
| 1400 | - } else $offset = '+00:00'; |
|
| 1504 | + } else { |
|
| 1505 | + $offset = '+00:00'; |
|
| 1506 | + } |
|
| 1401 | 1507 | |
| 1402 | 1508 | if ($globalDBdriver == 'mysql') { |
| 1403 | 1509 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1447,7 +1553,9 @@ discard block |
||
| 1447 | 1553 | date_default_timezone_set($globalTimezone); |
| 1448 | 1554 | $datetime = new DateTime(); |
| 1449 | 1555 | $offset = $datetime->format('P'); |
| 1450 | - } else $offset = '+00:00'; |
|
| 1556 | + } else { |
|
| 1557 | + $offset = '+00:00'; |
|
| 1558 | + } |
|
| 1451 | 1559 | $filter_query = $this->getFilter($filters,true,true); |
| 1452 | 1560 | if ($globalDBdriver == 'mysql') { |
| 1453 | 1561 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1493,7 +1601,9 @@ discard block |
||
| 1493 | 1601 | date_default_timezone_set($globalTimezone); |
| 1494 | 1602 | $datetime = new DateTime(); |
| 1495 | 1603 | $offset = $datetime->format('P'); |
| 1496 | - } else $offset = '+00:00'; |
|
| 1604 | + } else { |
|
| 1605 | + $offset = '+00:00'; |
|
| 1606 | + } |
|
| 1497 | 1607 | $filter_query = $this->getFilter($filters,true,true); |
| 1498 | 1608 | if ($globalDBdriver == 'mysql') { |
| 1499 | 1609 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1541,7 +1651,9 @@ discard block |
||
| 1541 | 1651 | date_default_timezone_set($globalTimezone); |
| 1542 | 1652 | $datetime = new DateTime(); |
| 1543 | 1653 | $offset = $datetime->format('P'); |
| 1544 | - } else $offset = '+00:00'; |
|
| 1654 | + } else { |
|
| 1655 | + $offset = '+00:00'; |
|
| 1656 | + } |
|
| 1545 | 1657 | |
| 1546 | 1658 | if ($globalDBdriver == 'mysql') { |
| 1547 | 1659 | $query = "SELECT YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
@@ -1590,7 +1702,9 @@ discard block |
||
| 1590 | 1702 | date_default_timezone_set($globalTimezone); |
| 1591 | 1703 | $datetime = new DateTime(); |
| 1592 | 1704 | $offset = $datetime->format('P'); |
| 1593 | - } else $offset = '+00:00'; |
|
| 1705 | + } else { |
|
| 1706 | + $offset = '+00:00'; |
|
| 1707 | + } |
|
| 1594 | 1708 | $filter_query = $this->getFilter($filters,true,true); |
| 1595 | 1709 | if ($globalDBdriver == 'mysql') { |
| 1596 | 1710 | $query = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
@@ -1639,7 +1753,9 @@ discard block |
||
| 1639 | 1753 | date_default_timezone_set($globalTimezone); |
| 1640 | 1754 | $datetime = new DateTime(); |
| 1641 | 1755 | $offset = $datetime->format('P'); |
| 1642 | - } else $offset = '+00:00'; |
|
| 1756 | + } else { |
|
| 1757 | + $offset = '+00:00'; |
|
| 1758 | + } |
|
| 1643 | 1759 | |
| 1644 | 1760 | $orderby_sql = ''; |
| 1645 | 1761 | if ($orderby == "hour") |
@@ -1708,7 +1824,9 @@ discard block |
||
| 1708 | 1824 | date_default_timezone_set($globalTimezone); |
| 1709 | 1825 | $datetime = new DateTime($date); |
| 1710 | 1826 | $offset = $datetime->format('P'); |
| 1711 | - } else $offset = '+00:00'; |
|
| 1827 | + } else { |
|
| 1828 | + $offset = '+00:00'; |
|
| 1829 | + } |
|
| 1712 | 1830 | |
| 1713 | 1831 | if ($globalDBdriver == 'mysql') { |
| 1714 | 1832 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1756,7 +1874,9 @@ discard block |
||
| 1756 | 1874 | date_default_timezone_set($globalTimezone); |
| 1757 | 1875 | $datetime = new DateTime(); |
| 1758 | 1876 | $offset = $datetime->format('P'); |
| 1759 | - } else $offset = '+00:00'; |
|
| 1877 | + } else { |
|
| 1878 | + $offset = '+00:00'; |
|
| 1879 | + } |
|
| 1760 | 1880 | |
| 1761 | 1881 | if ($globalDBdriver == 'mysql') { |
| 1762 | 1882 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1821,8 +1941,11 @@ discard block |
||
| 1821 | 1941 | $query_values = array_merge($query_values,array(':month' => $month)); |
| 1822 | 1942 | } |
| 1823 | 1943 | } |
| 1824 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
| 1825 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1944 | + if (empty($query_values)) { |
|
| 1945 | + $queryi .= $this->getFilter($filters); |
|
| 1946 | + } else { |
|
| 1947 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1948 | + } |
|
| 1826 | 1949 | |
| 1827 | 1950 | $sth = $this->db->prepare($queryi); |
| 1828 | 1951 | $sth->execute($query_values); |
@@ -1859,8 +1982,11 @@ discard block |
||
| 1859 | 1982 | $query_values = array_merge($query_values,array(':month' => $month)); |
| 1860 | 1983 | } |
| 1861 | 1984 | } |
| 1862 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
| 1863 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1985 | + if (empty($query_values)) { |
|
| 1986 | + $queryi .= $this->getFilter($filters); |
|
| 1987 | + } else { |
|
| 1988 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1989 | + } |
|
| 1864 | 1990 | |
| 1865 | 1991 | $sth = $this->db->prepare($queryi); |
| 1866 | 1992 | $sth->execute($query_values); |
@@ -1882,7 +2008,9 @@ discard block |
||
| 1882 | 2008 | date_default_timezone_set($globalTimezone); |
| 1883 | 2009 | $datetime = new DateTime(); |
| 1884 | 2010 | $offset = $datetime->format('P'); |
| 1885 | - } else $offset = '+00:00'; |
|
| 2011 | + } else { |
|
| 2012 | + $offset = '+00:00'; |
|
| 2013 | + } |
|
| 1886 | 2014 | |
| 1887 | 2015 | if ($globalDBdriver == 'mysql') { |
| 1888 | 2016 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1986,7 +2114,9 @@ discard block |
||
| 1986 | 2114 | */ |
| 1987 | 2115 | public function parseDirection($direction = 0) |
| 1988 | 2116 | { |
| 1989 | - if ($direction == '') $direction = 0; |
|
| 2117 | + if ($direction == '') { |
|
| 2118 | + $direction = 0; |
|
| 2119 | + } |
|
| 1990 | 2120 | $direction_array = array(); |
| 1991 | 2121 | $temp_array = array(); |
| 1992 | 2122 | |
@@ -2075,7 +2205,9 @@ discard block |
||
| 2075 | 2205 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 2076 | 2206 | |
| 2077 | 2207 | $Connection = new Connection($this->db); |
| 2078 | - if (!$Connection->tableExists('countries')) return ''; |
|
| 2208 | + if (!$Connection->tableExists('countries')) { |
|
| 2209 | + return ''; |
|
| 2210 | + } |
|
| 2079 | 2211 | |
| 2080 | 2212 | try { |
| 2081 | 2213 | /* |
@@ -2095,9 +2227,13 @@ discard block |
||
| 2095 | 2227 | $sth->closeCursor(); |
| 2096 | 2228 | if (count($row) > 0) { |
| 2097 | 2229 | return $row; |
| 2098 | - } else return ''; |
|
| 2230 | + } else { |
|
| 2231 | + return ''; |
|
| 2232 | + } |
|
| 2099 | 2233 | } catch (PDOException $e) { |
| 2100 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
| 2234 | + if (isset($globalDebug) && $globalDebug) { |
|
| 2235 | + echo 'Error : '.$e->getMessage()."\n"; |
|
| 2236 | + } |
|
| 2101 | 2237 | return ''; |
| 2102 | 2238 | } |
| 2103 | 2239 | |
@@ -2115,7 +2251,9 @@ discard block |
||
| 2115 | 2251 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
| 2116 | 2252 | |
| 2117 | 2253 | $Connection = new Connection($this->db); |
| 2118 | - if (!$Connection->tableExists('countries')) return ''; |
|
| 2254 | + if (!$Connection->tableExists('countries')) { |
|
| 2255 | + return ''; |
|
| 2256 | + } |
|
| 2119 | 2257 | |
| 2120 | 2258 | try { |
| 2121 | 2259 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -2127,9 +2265,13 @@ discard block |
||
| 2127 | 2265 | $sth->closeCursor(); |
| 2128 | 2266 | if (count($row) > 0) { |
| 2129 | 2267 | return $row; |
| 2130 | - } else return ''; |
|
| 2268 | + } else { |
|
| 2269 | + return ''; |
|
| 2270 | + } |
|
| 2131 | 2271 | } catch (PDOException $e) { |
| 2132 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
| 2272 | + if (isset($globalDebug) && $globalDebug) { |
|
| 2273 | + echo 'Error : '.$e->getMessage()."\n"; |
|
| 2274 | + } |
|
| 2133 | 2275 | return ''; |
| 2134 | 2276 | } |
| 2135 | 2277 | |
@@ -2147,7 +2289,9 @@ discard block |
||
| 2147 | 2289 | { |
| 2148 | 2290 | global $globalBitlyAccessToken; |
| 2149 | 2291 | |
| 2150 | - if ($globalBitlyAccessToken == '') return $url; |
|
| 2292 | + if ($globalBitlyAccessToken == '') { |
|
| 2293 | + return $url; |
|
| 2294 | + } |
|
| 2151 | 2295 | |
| 2152 | 2296 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
| 2153 | 2297 | |
@@ -2223,7 +2367,9 @@ discard block |
||
| 2223 | 2367 | } |
| 2224 | 2368 | } |
| 2225 | 2369 | $query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC"; |
| 2226 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 2370 | + if ($limit) { |
|
| 2371 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 2372 | + } |
|
| 2227 | 2373 | $sth = $this->db->prepare($query); |
| 2228 | 2374 | $sth->execute($query_values); |
| 2229 | 2375 | $marine_array = array(); |
@@ -2261,9 +2407,15 @@ discard block |
||
| 2261 | 2407 | foreach ($q_array as $q_item){ |
| 2262 | 2408 | $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
| 2263 | 2409 | $additional_query .= " AND ("; |
| 2264 | - if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
|
| 2265 | - if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
|
| 2266 | - if (is_int($q_item)) $additional_query .= "(marine_output.imo = '".$q_item."') OR "; |
|
| 2410 | + if (is_int($q_item)) { |
|
| 2411 | + $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
|
| 2412 | + } |
|
| 2413 | + if (is_int($q_item)) { |
|
| 2414 | + $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
|
| 2415 | + } |
|
| 2416 | + if (is_int($q_item)) { |
|
| 2417 | + $additional_query .= "(marine_output.imo = '".$q_item."') OR "; |
|
| 2418 | + } |
|
| 2267 | 2419 | $additional_query .= "(marine_output.ident like '%".$q_item."%') OR "; |
| 2268 | 2420 | $additional_query .= ")"; |
| 2269 | 2421 | } |
@@ -2311,7 +2463,9 @@ discard block |
||
| 2311 | 2463 | date_default_timezone_set($globalTimezone); |
| 2312 | 2464 | $datetime = new DateTime(); |
| 2313 | 2465 | $offset = $datetime->format('P'); |
| 2314 | - } else $offset = '+00:00'; |
|
| 2466 | + } else { |
|
| 2467 | + $offset = '+00:00'; |
|
| 2468 | + } |
|
| 2315 | 2469 | if ($date_array[1] != "") |
| 2316 | 2470 | { |
| 2317 | 2471 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
@@ -2338,8 +2492,12 @@ discard block |
||
| 2338 | 2492 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 2339 | 2493 | { |
| 2340 | 2494 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 2341 | - } else $limit_query = ""; |
|
| 2342 | - } else $limit_query = ""; |
|
| 2495 | + } else { |
|
| 2496 | + $limit_query = ""; |
|
| 2497 | + } |
|
| 2498 | + } else { |
|
| 2499 | + $limit_query = ""; |
|
| 2500 | + } |
|
| 2343 | 2501 | if ($sort != "") |
| 2344 | 2502 | { |
| 2345 | 2503 | $search_orderby_array = $this->getOrderBy(); |
@@ -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,75 +46,75 @@ 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 | - if (isset($globalVM) && $globalVM) { |
|
| 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 | + if (isset($globalVM) && $globalVM) { |
|
| 63 | 63 | if ($this->all_tracked[$key]['status'] == 'Racing') { |
| 64 | - $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[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status']); |
|
| 65 | - } else { |
|
| 66 | - $finaldatetime = date('Y-m-d H:i:s',strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time']); |
|
| 67 | - $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'],$finaldatetime,$this->all_tracked[$id]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status']); |
|
| 68 | - } |
|
| 69 | - } else { |
|
| 64 | + $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[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status']); |
|
| 65 | + } else { |
|
| 66 | + $finaldatetime = date('Y-m-d H:i:s',strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time']); |
|
| 67 | + $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'],$finaldatetime,$this->all_tracked[$id]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status']); |
|
| 68 | + } |
|
| 69 | + } else { |
|
| 70 | 70 | $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[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status']); |
| 71 | - } |
|
| 71 | + } |
|
| 72 | 72 | } |
| 73 | - } |
|
| 73 | + } |
|
| 74 | + } |
|
| 74 | 75 | } |
| 75 | - } |
|
| 76 | 76 | |
| 77 | - public function del() { |
|
| 77 | + public function del() { |
|
| 78 | 78 | global $globalDebug, $globalNoDB, $globalNoImport; |
| 79 | 79 | // Delete old infos |
| 80 | 80 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
| 81 | 81 | foreach ($this->all_tracked as $key => $flight) { |
| 82 | - if (isset($flight['lastupdate'])) { |
|
| 83 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
| 84 | - if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
| 85 | - if (isset($this->all_tracked[$key]['id'])) { |
|
| 86 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 87 | - /* |
|
| 82 | + if (isset($flight['lastupdate'])) { |
|
| 83 | + if ($flight['lastupdate'] < (time()-3000)) { |
|
| 84 | + if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
| 85 | + if (isset($this->all_tracked[$key]['id'])) { |
|
| 86 | + if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 87 | + /* |
|
| 88 | 88 | $MarineLive = new MarineLive(); |
| 89 | 89 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
| 90 | 90 | $MarineLive->db = null; |
| 91 | 91 | */ |
| 92 | - //$real_arrival = $this->arrival($key); |
|
| 93 | - $Marine = new Marine($this->db); |
|
| 94 | - if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
| 92 | + //$real_arrival = $this->arrival($key); |
|
| 93 | + $Marine = new Marine($this->db); |
|
| 94 | + if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
| 95 | 95 | if (isset($globalVM) && $globalVM) { |
| 96 | - if ($this->all_tracked[$key]['status'] == 'Racing') { |
|
| 96 | + if ($this->all_tracked[$key]['status'] == 'Racing') { |
|
| 97 | 97 | $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[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status']); |
| 98 | - } else { |
|
| 98 | + } else { |
|
| 99 | 99 | $finaldatetime = date('Y-m-d H:i:s',strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time']); |
| 100 | 100 | $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'],$finaldatetime,$this->all_tracked[$id]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status']); |
| 101 | - } |
|
| 101 | + } |
|
| 102 | 102 | } else { |
| 103 | 103 | $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[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status']); |
| 104 | 104 | } |
| 105 | 105 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 106 | - } |
|
| 107 | - // Put in archive |
|
| 106 | + } |
|
| 107 | + // Put in archive |
|
| 108 | 108 | // $Marine->db = null; |
| 109 | 109 | } |
| 110 | - } |
|
| 111 | - unset($this->all_tracked[$key]); |
|
| 112 | - } |
|
| 113 | - } |
|
| 114 | - } |
|
| 115 | - } |
|
| 110 | + } |
|
| 111 | + unset($this->all_tracked[$key]); |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - public function add($line) { |
|
| 117 | + public function add($line) { |
|
| 118 | 118 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine, $globalLiveInterval, $globalVM; |
| 119 | 119 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
| 120 | 120 | date_default_timezone_set('UTC'); |
@@ -123,106 +123,106 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | // SBS format is CSV format |
| 125 | 125 | if(is_array($line) && (isset($line['mmsi']) || isset($line['id']))) { |
| 126 | - //print_r($line); |
|
| 127 | - if (isset($line['mmsi']) || isset($line['id'])) { |
|
| 126 | + //print_r($line); |
|
| 127 | + if (isset($line['mmsi']) || isset($line['id'])) { |
|
| 128 | 128 | |
| 129 | 129 | |
| 130 | 130 | // Increment message number |
| 131 | 131 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
| 132 | - $current_date = date('Y-m-d'); |
|
| 133 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
| 134 | - else $source = ''; |
|
| 135 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 136 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
| 137 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
| 138 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
| 139 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 132 | + $current_date = date('Y-m-d'); |
|
| 133 | + if (isset($line['source_name'])) $source = $line['source_name']; |
|
| 134 | + else $source = ''; |
|
| 135 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 136 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
| 137 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
| 138 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
| 139 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | |
| 143 | 143 | $Common = new Common(); |
| 144 | 144 | $AIS = new AIS(); |
| 145 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
| 146 | - else $id = trim($line['id']); |
|
| 145 | + if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
| 146 | + else $id = trim($line['id']); |
|
| 147 | 147 | |
| 148 | 148 | if (!isset($this->all_tracked[$id])) { |
| 149 | - $this->all_tracked[$id] = array(); |
|
| 150 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
| 151 | - $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,'race_rank' => NULL,'race_time' => NULL,'race_begin' => date('Y-m-d H:i:s'))); |
|
| 152 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
| 153 | - if (!isset($line['id'])) { |
|
| 149 | + $this->all_tracked[$id] = array(); |
|
| 150 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
| 151 | + $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,'race_rank' => NULL,'race_time' => NULL,'race_begin' => date('Y-m-d H:i:s'))); |
|
| 152 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
| 153 | + if (!isset($line['id'])) { |
|
| 154 | 154 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 155 | 155 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
| 156 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 157 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
| 156 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 157 | + if ($globalAllTracked !== FALSE) $dataFound = true; |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
| 161 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
| 162 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 161 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
| 162 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 163 | 163 | $Marine = new Marine($this->db); |
| 164 | 164 | $identity = $Marine->getIdentity($line['mmsi']); |
| 165 | 165 | if (!empty($identity)) { |
| 166 | - $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
| 167 | - $this->all_tracked[$id]['type'] = $identity['type']; |
|
| 168 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type']))); |
|
| 166 | + $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
| 167 | + $this->all_tracked[$id]['type'] = $identity['type']; |
|
| 168 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type']))); |
|
| 169 | 169 | } |
| 170 | 170 | //print_r($identity); |
| 171 | 171 | unset($Marine); |
| 172 | 172 | //$dataFound = true; |
| 173 | - } |
|
| 173 | + } |
|
| 174 | 174 | } |
| 175 | 175 | if (isset($line['type_id'])) { |
| 176 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
| 177 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
| 176 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
| 177 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
| 178 | 178 | } |
| 179 | 179 | if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') { |
| 180 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
| 181 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type']))); |
|
| 180 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
| 181 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type']))); |
|
| 182 | 182 | } elseif (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] != '') { |
| 183 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
| 183 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
| 184 | 184 | } |
| 185 | 185 | if (isset($line['status']) && $line['status'] != '') { |
| 186 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
| 186 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
| 187 | 187 | } |
| 188 | 188 | if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) { |
| 189 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
| 190 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
| 189 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
| 190 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
| 191 | 191 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 192 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 192 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 193 | 193 | $Marine = new Marine($this->db); |
| 194 | 194 | $Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']); |
| 195 | 195 | unset($Marine); |
| 196 | - } |
|
| 196 | + } |
|
| 197 | + } |
|
| 197 | 198 | } |
| 198 | - } |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | |
| 202 | 202 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
| 203 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
| 203 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
| 204 | 204 | } |
| 205 | 205 | if (isset($line['imo']) && $line['imo'] != '') { |
| 206 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
| 206 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
| 207 | 207 | } |
| 208 | 208 | if (isset($line['callsign']) && $line['callsign'] != '') { |
| 209 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
| 209 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
| 210 | 210 | } |
| 211 | 211 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
| 212 | - if (!isset($this->all_tracked[$id]['arrival_code'])) { |
|
| 212 | + if (!isset($this->all_tracked[$id]['arrival_code'])) { |
|
| 213 | 213 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
| 214 | 214 | if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
| 215 | 215 | if ($this->all_tracked[$id]['addedMarine'] != 0) { |
| 216 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
| 216 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
| 217 | 217 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 218 | - $Marine = new Marine($this->db); |
|
| 219 | - $fromsource = NULL; |
|
| 220 | - $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource); |
|
| 221 | - $Marine->db = null; |
|
| 218 | + $Marine = new Marine($this->db); |
|
| 219 | + $fromsource = NULL; |
|
| 220 | + $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource); |
|
| 221 | + $Marine->db = null; |
|
| 222 | + } |
|
| 222 | 223 | } |
| 223 | - } |
|
| 224 | 224 | } |
| 225 | - } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) { |
|
| 225 | + } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) { |
|
| 226 | 226 | $this->all_tracked[$id]['arrival_code'] = $line['arrival_code']; |
| 227 | 227 | if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
| 228 | 228 | if (!isset($line['id'])) { |
@@ -230,50 +230,50 @@ discard block |
||
| 230 | 230 | $this->all_tracked[$id]['forcenew'] = 1; |
| 231 | 231 | $this->all_tracked[$id]['addedMarine'] = 0; |
| 232 | 232 | } |
| 233 | - } |
|
| 233 | + } |
|
| 234 | 234 | } |
| 235 | 235 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
| 236 | - if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
| 236 | + if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
| 237 | 237 | } |
| 238 | 238 | if (isset($line['captain_id']) && $line['captain_id'] != '') { |
| 239 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id'])); |
|
| 239 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id'])); |
|
| 240 | 240 | } |
| 241 | 241 | if (isset($line['captain_name']) && $line['captain_name'] != '') { |
| 242 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name'])); |
|
| 242 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name'])); |
|
| 243 | 243 | } |
| 244 | 244 | if (isset($line['race_id']) && $line['race_id'] != '') { |
| 245 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id'])); |
|
| 245 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id'])); |
|
| 246 | 246 | } |
| 247 | 247 | if (isset($line['race_name']) && $line['race_name'] != '') { |
| 248 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name'])); |
|
| 248 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name'])); |
|
| 249 | 249 | } |
| 250 | 250 | if (isset($line['race_rank']) && $line['race_rank'] != '') { |
| 251 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_rank' => $line['race_rank'])); |
|
| 251 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_rank' => $line['race_rank'])); |
|
| 252 | 252 | } |
| 253 | 253 | if (isset($line['race_time']) && $line['race_time'] != '') { |
| 254 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_time' => $line['race_time'])); |
|
| 254 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_time' => $line['race_time'])); |
|
| 255 | 255 | } |
| 256 | 256 | if (isset($line['race_begin']) && $line['race_begin'] != '') { |
| 257 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_begin' => $line['race_begin'])); |
|
| 257 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_begin' => $line['race_begin'])); |
|
| 258 | 258 | } |
| 259 | 259 | if (isset($line['distance']) && $line['distance'] != '') { |
| 260 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('distance' => $line['distance'])); |
|
| 260 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('distance' => $line['distance'])); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | //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'])) { |
| 264 | 264 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
| 265 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
| 265 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
| 266 | 266 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 267 | - $timeelapsed = microtime(true); |
|
| 268 | - $Marine = new Marine($this->db); |
|
| 269 | - $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']); |
|
| 270 | - $Marine->db = null; |
|
| 267 | + $timeelapsed = microtime(true); |
|
| 268 | + $Marine = new Marine($this->db); |
|
| 269 | + $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']); |
|
| 270 | + $Marine->db = null; |
|
| 271 | + } |
|
| 271 | 272 | } |
| 272 | - } |
|
| 273 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
| 274 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
| 273 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
| 274 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
| 275 | 275 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 276 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 276 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 277 | 277 | $timeelapsed = microtime(true); |
| 278 | 278 | $Marine = new Marine($this->db); |
| 279 | 279 | $fromsource = NULL; |
@@ -281,20 +281,20 @@ discard block |
||
| 281 | 281 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 282 | 282 | $Marine->db = null; |
| 283 | 283 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 284 | - } |
|
| 284 | + } |
|
| 285 | + } |
|
| 285 | 286 | } |
| 286 | - } |
|
| 287 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 287 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
| 291 | - if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
| 291 | + if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
| 292 | 292 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
| 293 | - } else { |
|
| 293 | + } else { |
|
| 294 | 294 | 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"; |
| 295 | 295 | 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"; |
| 296 | 296 | return ''; |
| 297 | - } |
|
| 297 | + } |
|
| 298 | 298 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
| 299 | 299 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
| 300 | 300 | return ''; |
@@ -311,33 +311,33 @@ discard block |
||
| 311 | 311 | |
| 312 | 312 | |
| 313 | 313 | if (isset($line['speed'])) { |
| 314 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'],2))); |
|
| 315 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
| 314 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'],2))); |
|
| 315 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
| 316 | 316 | } 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'])) { |
| 317 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
| 318 | - if ($distance > 1000 && $distance < 10000) { |
|
| 317 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
| 318 | + if ($distance > 1000 && $distance < 10000) { |
|
| 319 | 319 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
| 320 | 320 | $speed = $speed*3.6; |
| 321 | 321 | if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2))); |
| 322 | 322 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
| 323 | - } |
|
| 323 | + } |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
| 327 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 328 | - else unset($timediff); |
|
| 329 | - if ($this->tmd > 5 || |
|
| 330 | - !isset($timediff) || |
|
| 331 | - $timediff > $globalLiveInterval || |
|
| 332 | - ( |
|
| 333 | - $timediff > 30 && |
|
| 334 | - isset($this->all_tracked[$id]['latitude']) && |
|
| 335 | - isset($this->all_tracked[$id]['longitude']) && |
|
| 336 | - $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')) |
|
| 337 | - ) |
|
| 338 | - ) { |
|
| 326 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
| 327 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 328 | + else unset($timediff); |
|
| 329 | + if ($this->tmd > 5 || |
|
| 330 | + !isset($timediff) || |
|
| 331 | + $timediff > $globalLiveInterval || |
|
| 332 | + ( |
|
| 333 | + $timediff > 30 && |
|
| 334 | + isset($this->all_tracked[$id]['latitude']) && |
|
| 335 | + isset($this->all_tracked[$id]['longitude']) && |
|
| 336 | + $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')) |
|
| 337 | + ) |
|
| 338 | + ) { |
|
| 339 | 339 | 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'])) { |
| 340 | - 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'])) { |
|
| 340 | + 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'])) { |
|
| 341 | 341 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 342 | 342 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 343 | 343 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -345,213 +345,213 @@ discard block |
||
| 345 | 345 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
| 346 | 346 | $timeelapsed = microtime(true); |
| 347 | 347 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 348 | - $Marine = new Marine($this->db); |
|
| 349 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
| 350 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 351 | - $Marine->db = null; |
|
| 352 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 348 | + $Marine = new Marine($this->db); |
|
| 349 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
| 350 | + if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 351 | + $Marine->db = null; |
|
| 352 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 353 | 353 | } |
| 354 | 354 | $this->tmd = 0; |
| 355 | 355 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
| 356 | - } |
|
| 356 | + } |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 360 | 360 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 361 | 361 | 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') { |
| 362 | - $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
| 363 | - $dataFound = true; |
|
| 364 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 362 | + $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
| 363 | + $dataFound = true; |
|
| 364 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 365 | 365 | } |
| 366 | 366 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
| 367 | 367 | } |
| 368 | 368 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 369 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 369 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 370 | 370 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 371 | 371 | 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') { |
| 372 | - $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
| 373 | - $dataFound = true; |
|
| 374 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 372 | + $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
| 373 | + $dataFound = true; |
|
| 374 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 375 | 375 | } |
| 376 | 376 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | - } else if ($globalDebug && $timediff > 20) { |
|
| 379 | + } else if ($globalDebug && $timediff > 20) { |
|
| 380 | 380 | $this->tmd = $this->tmd + 1; |
| 381 | 381 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
| 382 | 382 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
| 383 | 383 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
| 384 | 384 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
| 385 | - } |
|
| 385 | + } |
|
| 386 | 386 | } |
| 387 | 387 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 388 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 389 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
| 388 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 389 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
| 390 | 390 | } |
| 391 | 391 | if (isset($line['format_source']) && $line['format_source'] != '') { |
| 392 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
| 392 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
| 393 | 393 | } |
| 394 | 394 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 395 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
| 395 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
| 396 | 396 | } |
| 397 | 397 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
| 398 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
| 398 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | if (isset($line['heading']) && $line['heading'] != '') { |
| 402 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 403 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
| 404 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
| 405 | - //$dataFound = true; |
|
| 402 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 403 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
| 404 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
| 405 | + //$dataFound = true; |
|
| 406 | 406 | } 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']) { |
| 407 | - $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']); |
|
| 408 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
| 409 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 410 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 407 | + $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']); |
|
| 408 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
| 409 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 410 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 411 | 411 | } |
| 412 | 412 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
| 413 | 413 | |
| 414 | 414 | |
| 415 | 415 | |
| 416 | 416 | if ($dataFound === true && (isset($this->all_tracked[$id]['mmsi']) || isset($this->all_tracked[$id]['id']))) { |
| 417 | - $this->all_tracked[$id]['lastupdate'] = time(); |
|
| 418 | - if ($this->all_tracked[$id]['addedMarine'] == 0 || (isset($globalVM) && $globalVM)) { |
|
| 419 | - 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'])) { |
|
| 420 | - if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
| 417 | + $this->all_tracked[$id]['lastupdate'] = time(); |
|
| 418 | + if ($this->all_tracked[$id]['addedMarine'] == 0 || (isset($globalVM) && $globalVM)) { |
|
| 419 | + 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'])) { |
|
| 420 | + if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
| 421 | 421 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 422 | - if ($globalDebug) echo "Check if vessel is already in DB..."; |
|
| 423 | - $timeelapsed = microtime(true); |
|
| 424 | - $MarineLive = new MarineLive($this->db); |
|
| 425 | - if (isset($line['id']) && isset($globalVM) && $globalVM) { |
|
| 422 | + if ($globalDebug) echo "Check if vessel is already in DB..."; |
|
| 423 | + $timeelapsed = microtime(true); |
|
| 424 | + $MarineLive = new MarineLive($this->db); |
|
| 425 | + if (isset($line['id']) && isset($globalVM) && $globalVM) { |
|
| 426 | 426 | $Marine = new Marine($this->db); |
| 427 | 427 | $recent_ident = $Marine->checkId($line['id']); |
| 428 | 428 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 429 | 429 | $Marine->db=null; |
| 430 | - } elseif (isset($line['id'])) { |
|
| 430 | + } elseif (isset($line['id'])) { |
|
| 431 | 431 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
| 432 | 432 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 433 | - } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
| 433 | + } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
| 434 | 434 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
| 435 | 435 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 436 | - } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
| 436 | + } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
| 437 | 437 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
| 438 | 438 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 439 | - } else $recent_ident = ''; |
|
| 440 | - $MarineLive->db=null; |
|
| 441 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 442 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 439 | + } else $recent_ident = ''; |
|
| 440 | + $MarineLive->db=null; |
|
| 441 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 442 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 443 | 443 | } else $recent_ident = ''; |
| 444 | - } else { |
|
| 444 | + } else { |
|
| 445 | 445 | $recent_ident = ''; |
| 446 | 446 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
| 447 | - } |
|
| 448 | - //if there was no vessel with the same callsign within the last hour and go post it into the archive |
|
| 449 | - if($recent_ident == "" && (($this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') || (isset($globalVM) && $globalVM))) |
|
| 450 | - { |
|
| 447 | + } |
|
| 448 | + //if there was no vessel with the same callsign within the last hour and go post it into the archive |
|
| 449 | + if($recent_ident == "" && (($this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') || (isset($globalVM) && $globalVM))) |
|
| 450 | + { |
|
| 451 | 451 | if ($globalDebug) { |
| 452 | 452 | if ($this->all_tracked[$id]['mmsi'] == '') echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
| 453 | 453 | else echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
| 454 | 454 | } |
| 455 | 455 | //adds the spotter data for the archive |
| 456 | - $highlight = ''; |
|
| 457 | - 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'))); |
|
| 458 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
| 456 | + $highlight = ''; |
|
| 457 | + 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'))); |
|
| 458 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
| 459 | 459 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 460 | - $timeelapsed = microtime(true); |
|
| 461 | - $Marine = new Marine($this->db); |
|
| 462 | - if (isset($globalVM) && $globalVM) { |
|
| 460 | + $timeelapsed = microtime(true); |
|
| 461 | + $Marine = new Marine($this->db); |
|
| 462 | + if (isset($globalVM) && $globalVM) { |
|
| 463 | 463 | $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]['race_begin'], $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']); |
| 464 | - } else { |
|
| 464 | + } else { |
|
| 465 | 465 | $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']); |
| 466 | - } |
|
| 467 | - $Marine->db = null; |
|
| 468 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 469 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 466 | + } |
|
| 467 | + $Marine->db = null; |
|
| 468 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 469 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 470 | + } |
|
| 470 | 471 | } |
| 471 | - } |
|
| 472 | - if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
|
| 472 | + if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
|
| 473 | 473 | // Add source stat in DB |
| 474 | 474 | $Stats = new Stats($this->db); |
| 475 | 475 | if (!empty($this->stats)) { |
| 476 | - if ($globalDebug) echo 'Add source stats : '; |
|
| 477 | - foreach($this->stats as $date => $data) { |
|
| 476 | + if ($globalDebug) echo 'Add source stats : '; |
|
| 477 | + foreach($this->stats as $date => $data) { |
|
| 478 | 478 | foreach($data as $source => $sourced) { |
| 479 | - //print_r($sourced); |
|
| 480 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
| 481 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
| 482 | - if (isset($sourced['msg'])) { |
|
| 483 | - if (time() - $sourced['msg']['date'] > 10) { |
|
| 484 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
| 485 | - echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
| 486 | - unset($this->stats[$date][$source]['msg']); |
|
| 487 | - } |
|
| 488 | - } |
|
| 489 | - } |
|
| 490 | - if ($date != date('Y-m-d')) { |
|
| 491 | - unset($this->stats[$date]); |
|
| 492 | - } |
|
| 493 | - } |
|
| 494 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 479 | + //print_r($sourced); |
|
| 480 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
| 481 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
| 482 | + if (isset($sourced['msg'])) { |
|
| 483 | + if (time() - $sourced['msg']['date'] > 10) { |
|
| 484 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
| 485 | + echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
| 486 | + unset($this->stats[$date][$source]['msg']); |
|
| 487 | + } |
|
| 488 | + } |
|
| 489 | + } |
|
| 490 | + if ($date != date('Y-m-d')) { |
|
| 491 | + unset($this->stats[$date]); |
|
| 492 | + } |
|
| 493 | + } |
|
| 494 | + if ($globalDebug) echo 'Done'."\n"; |
|
| 495 | 495 | } |
| 496 | 496 | $Stats->db = null; |
| 497 | - } |
|
| 497 | + } |
|
| 498 | 498 | |
| 499 | - $this->del(); |
|
| 499 | + $this->del(); |
|
| 500 | 500 | //$ignoreImport = false; |
| 501 | 501 | $this->all_tracked[$id]['addedMarine'] = 1; |
| 502 | 502 | //print_r($this->all_tracked[$id]); |
| 503 | 503 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 504 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
| 505 | - //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
| 506 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 504 | + if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
| 505 | + //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
| 506 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 507 | 507 | $MarineLive = new MarineLive($this->db); |
| 508 | 508 | $MarineLive->deleteLiveMarineData(); |
| 509 | 509 | $MarineLive->db=null; |
| 510 | 510 | if ($globalDebug) echo " Done\n"; |
| 511 | - } |
|
| 512 | - $this->last_delete = time(); |
|
| 511 | + } |
|
| 512 | + $this->last_delete = time(); |
|
| 513 | 513 | } |
| 514 | - } elseif ($recent_ident != '') { |
|
| 514 | + } elseif ($recent_ident != '') { |
|
| 515 | 515 | $this->all_tracked[$id]['id'] = $recent_ident; |
| 516 | 516 | $this->all_tracked[$id]['addedMarine'] = 1; |
| 517 | 517 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 518 | - if ((isset($globalDaemon) && !$globalDaemon) || (isset($globalVM) && $globalVM)) { |
|
| 518 | + if ((isset($globalDaemon) && !$globalDaemon) || (isset($globalVM) && $globalVM)) { |
|
| 519 | 519 | $Marine = new Marine($this->db); |
| 520 | 520 | if (isset($globalVM) && $globalVM) { |
| 521 | - if ($this->all_tracked[$id]['status'] == 'Racing') { |
|
| 521 | + if ($this->all_tracked[$id]['status'] == 'Racing') { |
|
| 522 | 522 | $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'],$this->all_tracked[$id]['status']); |
| 523 | - } else { |
|
| 523 | + } else { |
|
| 524 | 524 | $finaldatetime = date('Y-m-d H:i:s',strtotime($this->all_tracked[$id]['race_begin'])+$this->all_tracked[$id]['race_time']); |
| 525 | 525 | $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'],$finaldatetime,$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status']); |
| 526 | - } |
|
| 526 | + } |
|
| 527 | 527 | } else { |
| 528 | - $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'],$this->all_tracked[$id]['status']); |
|
| 528 | + $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'],$this->all_tracked[$id]['status']); |
|
| 529 | 529 | } |
| 530 | 530 | $Marine->db = null; |
| 531 | - } |
|
| 531 | + } |
|
| 532 | 532 | } |
| 533 | 533 | |
| 534 | - } |
|
| 534 | + } |
|
| 535 | + } |
|
| 535 | 536 | } |
| 536 | - } |
|
| 537 | - //adds the spotter LIVE data |
|
| 538 | - if ($globalDebug) { |
|
| 537 | + //adds the spotter LIVE data |
|
| 538 | + if ($globalDebug) { |
|
| 539 | 539 | 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"; |
| 540 | - } |
|
| 541 | - $ignoreImport = false; |
|
| 542 | - if ((isset($globalVM) && $globalVM) && $this->all_tracked[$id]['status'] != 'Racing') $ignoreImport = true; |
|
| 543 | - if (!$ignoreImport) { |
|
| 540 | + } |
|
| 541 | + $ignoreImport = false; |
|
| 542 | + if ((isset($globalVM) && $globalVM) && $this->all_tracked[$id]['status'] != 'Racing') $ignoreImport = true; |
|
| 543 | + if (!$ignoreImport) { |
|
| 544 | 544 | 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'])) { |
| 545 | 545 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
| 546 | 546 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 547 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 547 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 548 | 548 | $timeelapsed = microtime(true); |
| 549 | 549 | $MarineLive = new MarineLive($this->db); |
| 550 | 550 | $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']); |
| 551 | 551 | $MarineLive->db = null; |
| 552 | 552 | if ($globalDebug) echo $result."\n"; |
| 553 | 553 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 554 | - } |
|
| 554 | + } |
|
| 555 | 555 | } |
| 556 | 556 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
| 557 | 557 | $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']); |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | if ($stats_heading == 16) $stats_heading = 0; |
| 587 | 587 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 588 | 588 | for ($i=0;$i<=15;$i++) { |
| 589 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
| 589 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
| 590 | 590 | } |
| 591 | 591 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
| 592 | 592 | } else { |
@@ -599,11 +599,11 @@ discard block |
||
| 599 | 599 | //var_dump($this->stats); |
| 600 | 600 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
| 601 | 601 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 602 | - end($this->stats[$current_date][$source]['hist']); |
|
| 603 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
| 602 | + end($this->stats[$current_date][$source]['hist']); |
|
| 603 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
| 604 | 604 | } else $mini = 0; |
| 605 | 605 | for ($i=$mini;$i<=$distance;$i+=10) { |
| 606 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
| 606 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
| 607 | 607 | } |
| 608 | 608 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
| 609 | 609 | } else { |
@@ -619,24 +619,24 @@ discard block |
||
| 619 | 619 | |
| 620 | 620 | |
| 621 | 621 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 622 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 622 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 623 | 623 | if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
| 624 | 624 | $MarineLive = new MarineLive($this->db); |
| 625 | 625 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
| 626 | 626 | $MarineLive->db = null; |
| 627 | 627 | //MarineLive->deleteLiveMarineData(); |
| 628 | 628 | if ($globalDebug) echo " Done\n"; |
| 629 | - } |
|
| 630 | - $this->last_delete_hourly = time(); |
|
| 629 | + } |
|
| 630 | + $this->last_delete_hourly = time(); |
|
| 631 | 631 | } |
| 632 | 632 | |
| 633 | - } |
|
| 634 | - //$ignoreImport = false; |
|
| 633 | + } |
|
| 634 | + //$ignoreImport = false; |
|
| 635 | 635 | } |
| 636 | 636 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 637 | 637 | if ($send) return $this->all_tracked[$id]; |
| 638 | - } |
|
| 638 | + } |
|
| 639 | + } |
|
| 639 | 640 | } |
| 640 | - } |
|
| 641 | 641 | } |
| 642 | 642 | ?> |
@@ -61,13 +61,13 @@ discard block |
||
| 61 | 61 | $Marine = new Marine($this->db); |
| 62 | 62 | if (isset($globalVM) && $globalVM) { |
| 63 | 63 | if ($this->all_tracked[$key]['status'] == 'Racing') { |
| 64 | - $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[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status']); |
|
| 64 | + $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[$key]['race_rank'], $this->all_tracked[$key]['race_time'], $this->all_tracked[$key]['status']); |
|
| 65 | 65 | } else { |
| 66 | - $finaldatetime = date('Y-m-d H:i:s',strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time']); |
|
| 67 | - $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'],$finaldatetime,$this->all_tracked[$id]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status']); |
|
| 66 | + $finaldatetime = date('Y-m-d H:i:s', strtotime($this->all_tracked[$key]['race_begin']) + $this->all_tracked[$key]['race_time']); |
|
| 67 | + $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'], $finaldatetime, $this->all_tracked[$id]['distance'], $this->all_tracked[$key]['race_rank'], $this->all_tracked[$key]['race_time'], $this->all_tracked[$key]['status']); |
|
| 68 | 68 | } |
| 69 | 69 | } else { |
| 70 | - $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[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status']); |
|
| 70 | + $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[$key]['race_rank'], $this->all_tracked[$key]['race_time'], $this->all_tracked[$key]['status']); |
|
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | } |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
| 81 | 81 | foreach ($this->all_tracked as $key => $flight) { |
| 82 | 82 | if (isset($flight['lastupdate'])) { |
| 83 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
| 83 | + if ($flight['lastupdate'] < (time() - 3000)) { |
|
| 84 | 84 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
| 85 | 85 | if (isset($this->all_tracked[$key]['id'])) { |
| 86 | 86 | if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
@@ -94,13 +94,13 @@ discard block |
||
| 94 | 94 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
| 95 | 95 | if (isset($globalVM) && $globalVM) { |
| 96 | 96 | if ($this->all_tracked[$key]['status'] == 'Racing') { |
| 97 | - $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[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status']); |
|
| 97 | + $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[$key]['race_rank'], $this->all_tracked[$key]['race_time'], $this->all_tracked[$key]['status']); |
|
| 98 | 98 | } else { |
| 99 | - $finaldatetime = date('Y-m-d H:i:s',strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time']); |
|
| 100 | - $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'],$finaldatetime,$this->all_tracked[$id]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status']); |
|
| 99 | + $finaldatetime = date('Y-m-d H:i:s', strtotime($this->all_tracked[$key]['race_begin']) + $this->all_tracked[$key]['race_time']); |
|
| 100 | + $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'], $finaldatetime, $this->all_tracked[$id]['distance'], $this->all_tracked[$key]['race_rank'], $this->all_tracked[$key]['race_time'], $this->all_tracked[$key]['status']); |
|
| 101 | 101 | } |
| 102 | 102 | } else { |
| 103 | - $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[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status']); |
|
| 103 | + $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[$key]['distance'], $this->all_tracked[$key]['race_rank'], $this->all_tracked[$key]['race_time'], $this->all_tracked[$key]['status']); |
|
| 104 | 104 | } |
| 105 | 105 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 106 | 106 | } |
@@ -115,14 +115,14 @@ discard block |
||
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | public function add($line) { |
| 118 | - global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine, $globalLiveInterval, $globalVM; |
|
| 118 | + global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS, $APRSMarine, $globalLiveInterval, $globalVM; |
|
| 119 | 119 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
| 120 | 120 | date_default_timezone_set('UTC'); |
| 121 | 121 | $dataFound = false; |
| 122 | 122 | $send = false; |
| 123 | 123 | |
| 124 | 124 | // SBS format is CSV format |
| 125 | - if(is_array($line) && (isset($line['mmsi']) || isset($line['id']))) { |
|
| 125 | + if (is_array($line) && (isset($line['mmsi']) || isset($line['id']))) { |
|
| 126 | 126 | //print_r($line); |
| 127 | 127 | if (isset($line['mmsi']) || isset($line['id'])) { |
| 128 | 128 | |
@@ -147,25 +147,25 @@ discard block |
||
| 147 | 147 | |
| 148 | 148 | if (!isset($this->all_tracked[$id])) { |
| 149 | 149 | $this->all_tracked[$id] = array(); |
| 150 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
| 151 | - $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,'race_rank' => NULL,'race_time' => NULL,'race_begin' => date('Y-m-d H:i:s'))); |
|
| 152 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
| 150 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedMarine' => 0)); |
|
| 151 | + $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, 'race_rank' => NULL, 'race_time' => NULL, 'race_begin' => date('Y-m-d H:i:s'))); |
|
| 152 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time())); |
|
| 153 | 153 | if (!isset($line['id'])) { |
| 154 | 154 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 155 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 156 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 155 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
| 156 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id'])); |
|
| 157 | 157 | if ($globalAllTracked !== FALSE) $dataFound = true; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
| 161 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
| 161 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi' => $line['mmsi'])); |
|
| 162 | 162 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 163 | 163 | $Marine = new Marine($this->db); |
| 164 | 164 | $identity = $Marine->getIdentity($line['mmsi']); |
| 165 | 165 | if (!empty($identity)) { |
| 166 | 166 | $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
| 167 | 167 | $this->all_tracked[$id]['type'] = $identity['type']; |
| 168 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type']))); |
|
| 168 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('typeid' => $AIS->getShipTypeID($identity['type']))); |
|
| 169 | 169 | } |
| 170 | 170 | //print_r($identity); |
| 171 | 171 | unset($Marine); |
@@ -173,25 +173,25 @@ discard block |
||
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | if (isset($line['type_id'])) { |
| 176 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
| 177 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
| 176 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $AIS->getShipType($line['type_id']))); |
|
| 177 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('typeid' => $line['type_id'])); |
|
| 178 | 178 | } |
| 179 | 179 | if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') { |
| 180 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
| 181 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type']))); |
|
| 180 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type'])); |
|
| 181 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('typeid' => $AIS->getShipTypeID($line['type']))); |
|
| 182 | 182 | } elseif (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] != '') { |
| 183 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
| 183 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type'])); |
|
| 184 | 184 | } |
| 185 | 185 | if (isset($line['status']) && $line['status'] != '') { |
| 186 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
| 186 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status' => $line['status'])); |
|
| 187 | 187 | } |
| 188 | 188 | if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) { |
| 189 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
| 189 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status_id' => $line['status_id'])); |
|
| 190 | 190 | if ($this->all_tracked[$id]['addedMarine'] == 1) { |
| 191 | 191 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 192 | 192 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 193 | 193 | $Marine = new Marine($this->db); |
| 194 | - $Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']); |
|
| 194 | + $Marine->updateStatusMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['status']); |
|
| 195 | 195 | unset($Marine); |
| 196 | 196 | } |
| 197 | 197 | } |
@@ -200,24 +200,24 @@ discard block |
||
| 200 | 200 | |
| 201 | 201 | |
| 202 | 202 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
| 203 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
| 203 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi_type' => $line['mmsi_type'])); |
|
| 204 | 204 | } |
| 205 | 205 | if (isset($line['imo']) && $line['imo'] != '') { |
| 206 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
| 206 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('imo' => $line['imo'])); |
|
| 207 | 207 | } |
| 208 | 208 | if (isset($line['callsign']) && $line['callsign'] != '') { |
| 209 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
| 209 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('callsign' => $line['callsign'])); |
|
| 210 | 210 | } |
| 211 | 211 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
| 212 | 212 | if (!isset($this->all_tracked[$id]['arrival_code'])) { |
| 213 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
| 213 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_code' => $line['arrival_code'])); |
|
| 214 | 214 | if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
| 215 | 215 | if ($this->all_tracked[$id]['addedMarine'] != 0) { |
| 216 | 216 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 217 | 217 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 218 | 218 | $Marine = new Marine($this->db); |
| 219 | 219 | $fromsource = NULL; |
| 220 | - $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource); |
|
| 220 | + $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['arrival_code'], $fromsource); |
|
| 221 | 221 | $Marine->db = null; |
| 222 | 222 | } |
| 223 | 223 | } |
@@ -233,31 +233,31 @@ discard block |
||
| 233 | 233 | } |
| 234 | 234 | } |
| 235 | 235 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
| 236 | - if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
| 236 | + if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_date' => $line['arrival_date'])); |
|
| 237 | 237 | } |
| 238 | 238 | if (isset($line['captain_id']) && $line['captain_id'] != '') { |
| 239 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id'])); |
|
| 239 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('captain_id' => $line['captain_id'])); |
|
| 240 | 240 | } |
| 241 | 241 | if (isset($line['captain_name']) && $line['captain_name'] != '') { |
| 242 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name'])); |
|
| 242 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('captain_name' => $line['captain_name'])); |
|
| 243 | 243 | } |
| 244 | 244 | if (isset($line['race_id']) && $line['race_id'] != '') { |
| 245 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id'])); |
|
| 245 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_id' => $line['race_id'])); |
|
| 246 | 246 | } |
| 247 | 247 | if (isset($line['race_name']) && $line['race_name'] != '') { |
| 248 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name'])); |
|
| 248 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_name' => $line['race_name'])); |
|
| 249 | 249 | } |
| 250 | 250 | if (isset($line['race_rank']) && $line['race_rank'] != '') { |
| 251 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_rank' => $line['race_rank'])); |
|
| 251 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_rank' => $line['race_rank'])); |
|
| 252 | 252 | } |
| 253 | 253 | if (isset($line['race_time']) && $line['race_time'] != '') { |
| 254 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_time' => $line['race_time'])); |
|
| 254 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_time' => $line['race_time'])); |
|
| 255 | 255 | } |
| 256 | 256 | if (isset($line['race_begin']) && $line['race_begin'] != '') { |
| 257 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_begin' => $line['race_begin'])); |
|
| 257 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_begin' => $line['race_begin'])); |
|
| 258 | 258 | } |
| 259 | 259 | if (isset($line['distance']) && $line['distance'] != '') { |
| 260 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('distance' => $line['distance'])); |
|
| 260 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('distance' => $line['distance'])); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | //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'])) { |
@@ -266,44 +266,44 @@ discard block |
||
| 266 | 266 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 267 | 267 | $timeelapsed = microtime(true); |
| 268 | 268 | $Marine = new Marine($this->db); |
| 269 | - $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']); |
|
| 269 | + $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']); |
|
| 270 | 270 | $Marine->db = null; |
| 271 | 271 | } |
| 272 | 272 | } |
| 273 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
| 273 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident']))); |
|
| 274 | 274 | if ($this->all_tracked[$id]['addedMarine'] == 1) { |
| 275 | 275 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 276 | 276 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 277 | 277 | $timeelapsed = microtime(true); |
| 278 | 278 | $Marine = new Marine($this->db); |
| 279 | 279 | $fromsource = NULL; |
| 280 | - $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
| 280 | + $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource); |
|
| 281 | 281 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 282 | 282 | $Marine->db = null; |
| 283 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 283 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 284 | 284 | } |
| 285 | 285 | } |
| 286 | 286 | } |
| 287 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 287 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'])); |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
|
| 290 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 30*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
| 291 | 291 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
| 292 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
|
| 292 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime'])); |
|
| 293 | 293 | } else { |
| 294 | 294 | 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"; |
| 295 | 295 | 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"; |
| 296 | 296 | return ''; |
| 297 | 297 | } |
| 298 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
|
| 298 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time() - 30*60) { |
|
| 299 | 299 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
| 300 | 300 | return ''; |
| 301 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) { |
|
| 301 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time() + 20*60) { |
|
| 302 | 302 | if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
| 303 | 303 | return ''; |
| 304 | 304 | } elseif (!isset($line['datetime'])) { |
| 305 | 305 | date_default_timezone_set('UTC'); |
| 306 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 306 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
| 307 | 307 | } else { |
| 308 | 308 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n"; |
| 309 | 309 | return ''; |
@@ -311,20 +311,20 @@ discard block |
||
| 311 | 311 | |
| 312 | 312 | |
| 313 | 313 | if (isset($line['speed'])) { |
| 314 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'],2))); |
|
| 315 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
| 314 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed'], 2))); |
|
| 315 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true)); |
|
| 316 | 316 | } 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'])) { |
| 317 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
| 317 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm'); |
|
| 318 | 318 | if ($distance > 1000 && $distance < 10000) { |
| 319 | 319 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
| 320 | 320 | $speed = $speed*3.6; |
| 321 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2))); |
|
| 321 | + if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed, 2))); |
|
| 322 | 322 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
| 323 | 323 | } |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
| 327 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 327 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']); |
|
| 328 | 328 | else unset($timediff); |
| 329 | 329 | if ($this->tmd > 5 || |
| 330 | 330 | !isset($timediff) || |
@@ -333,11 +333,11 @@ discard block |
||
| 333 | 333 | $timediff > 30 && |
| 334 | 334 | isset($this->all_tracked[$id]['latitude']) && |
| 335 | 335 | isset($this->all_tracked[$id]['longitude']) && |
| 336 | - $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')) |
|
| 336 | + $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')) |
|
| 337 | 337 | ) |
| 338 | 338 | ) { |
| 339 | 339 | 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'])) { |
| 340 | - 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'])) { |
|
| 340 | + 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'])) { |
|
| 341 | 341 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 342 | 342 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 343 | 343 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -346,10 +346,10 @@ discard block |
||
| 346 | 346 | $timeelapsed = microtime(true); |
| 347 | 347 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 348 | 348 | $Marine = new Marine($this->db); |
| 349 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
| 349 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
| 350 | 350 | if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
| 351 | 351 | $Marine->db = null; |
| 352 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 352 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 353 | 353 | } |
| 354 | 354 | $this->tmd = 0; |
| 355 | 355 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
@@ -358,55 +358,55 @@ discard block |
||
| 358 | 358 | |
| 359 | 359 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 360 | 360 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 361 | - 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') { |
|
| 361 | + 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') { |
|
| 362 | 362 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
| 363 | 363 | $dataFound = true; |
| 364 | 364 | $this->all_tracked[$id]['time_last_coord'] = time(); |
| 365 | 365 | } |
| 366 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
|
| 366 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude'])); |
|
| 367 | 367 | } |
| 368 | 368 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 369 | 369 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
| 370 | 370 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 371 | - 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') { |
|
| 371 | + 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') { |
|
| 372 | 372 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
| 373 | 373 | $dataFound = true; |
| 374 | 374 | $this->all_tracked[$id]['time_last_coord'] = time(); |
| 375 | 375 | } |
| 376 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
|
| 376 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude'])); |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | } else if ($globalDebug && $timediff > 20) { |
| 380 | 380 | $this->tmd = $this->tmd + 1; |
| 381 | 381 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
| 382 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
|
| 383 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
| 382 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -"; |
|
| 383 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
| 384 | 384 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
| 385 | 385 | } |
| 386 | 386 | } |
| 387 | 387 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 388 | 388 | if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
| 389 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
| 389 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update'])); |
|
| 390 | 390 | } |
| 391 | 391 | if (isset($line['format_source']) && $line['format_source'] != '') { |
| 392 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
| 392 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source'])); |
|
| 393 | 393 | } |
| 394 | 394 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 395 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
| 395 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name'])); |
|
| 396 | 396 | } |
| 397 | 397 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
| 398 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
| 398 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true)); |
|
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | if (isset($line['heading']) && $line['heading'] != '') { |
| 402 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 403 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
| 404 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
| 402 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 403 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading']))); |
|
| 404 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true)); |
|
| 405 | 405 | //$dataFound = true; |
| 406 | 406 | } 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']) { |
| 407 | - $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']); |
|
| 408 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
| 409 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 407 | + $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']); |
|
| 408 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading))); |
|
| 409 | + if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 410 | 410 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
| 411 | 411 | } |
| 412 | 412 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | if ($dataFound === true && (isset($this->all_tracked[$id]['mmsi']) || isset($this->all_tracked[$id]['id']))) { |
| 417 | 417 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 418 | 418 | if ($this->all_tracked[$id]['addedMarine'] == 0 || (isset($globalVM) && $globalVM)) { |
| 419 | - 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'])) { |
|
| 419 | + 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'])) { |
|
| 420 | 420 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
| 421 | 421 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 422 | 422 | if ($globalDebug) echo "Check if vessel is already in DB..."; |
@@ -425,28 +425,28 @@ discard block |
||
| 425 | 425 | if (isset($line['id']) && isset($globalVM) && $globalVM) { |
| 426 | 426 | $Marine = new Marine($this->db); |
| 427 | 427 | $recent_ident = $Marine->checkId($line['id']); |
| 428 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 429 | - $Marine->db=null; |
|
| 428 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkId : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 429 | + $Marine->db = null; |
|
| 430 | 430 | } elseif (isset($line['id'])) { |
| 431 | 431 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
| 432 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 432 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 433 | 433 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
| 434 | 434 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
| 435 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 435 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 436 | 436 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
| 437 | 437 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
| 438 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 438 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 439 | 439 | } else $recent_ident = ''; |
| 440 | - $MarineLive->db=null; |
|
| 440 | + $MarineLive->db = null; |
|
| 441 | 441 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
| 442 | 442 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
| 443 | 443 | } else $recent_ident = ''; |
| 444 | 444 | } else { |
| 445 | 445 | $recent_ident = ''; |
| 446 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
|
| 446 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0)); |
|
| 447 | 447 | } |
| 448 | 448 | //if there was no vessel with the same callsign within the last hour and go post it into the archive |
| 449 | - if($recent_ident == "" && (($this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') || (isset($globalVM) && $globalVM))) |
|
| 449 | + if ($recent_ident == "" && (($this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') || (isset($globalVM) && $globalVM))) |
|
| 450 | 450 | { |
| 451 | 451 | if ($globalDebug) { |
| 452 | 452 | if ($this->all_tracked[$id]['mmsi'] == '') echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
@@ -454,19 +454,19 @@ discard block |
||
| 454 | 454 | } |
| 455 | 455 | //adds the spotter data for the archive |
| 456 | 456 | $highlight = ''; |
| 457 | - 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'))); |
|
| 457 | + 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'))); |
|
| 458 | 458 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 459 | 459 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 460 | 460 | $timeelapsed = microtime(true); |
| 461 | 461 | $Marine = new Marine($this->db); |
| 462 | 462 | if (isset($globalVM) && $globalVM) { |
| 463 | - $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]['race_begin'], $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']); |
|
| 463 | + $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]['race_begin'], $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']); |
|
| 464 | 464 | } else { |
| 465 | - $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']); |
|
| 465 | + $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']); |
|
| 466 | 466 | } |
| 467 | 467 | $Marine->db = null; |
| 468 | 468 | if ($globalDebug && isset($result)) echo $result."\n"; |
| 469 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 469 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 470 | 470 | } |
| 471 | 471 | } |
| 472 | 472 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
@@ -474,15 +474,15 @@ discard block |
||
| 474 | 474 | $Stats = new Stats($this->db); |
| 475 | 475 | if (!empty($this->stats)) { |
| 476 | 476 | if ($globalDebug) echo 'Add source stats : '; |
| 477 | - foreach($this->stats as $date => $data) { |
|
| 478 | - foreach($data as $source => $sourced) { |
|
| 477 | + foreach ($this->stats as $date => $data) { |
|
| 478 | + foreach ($data as $source => $sourced) { |
|
| 479 | 479 | //print_r($sourced); |
| 480 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
| 481 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
| 480 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar_marine', $date); |
|
| 481 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist_marine', $date); |
|
| 482 | 482 | if (isset($sourced['msg'])) { |
| 483 | 483 | if (time() - $sourced['msg']['date'] > 10) { |
| 484 | 484 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
| 485 | - echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
| 485 | + echo $Stats->addStatSource($nbmsg, $source, 'msg_marine', $date); |
|
| 486 | 486 | unset($this->stats[$date][$source]['msg']); |
| 487 | 487 | } |
| 488 | 488 | } |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 507 | 507 | $MarineLive = new MarineLive($this->db); |
| 508 | 508 | $MarineLive->deleteLiveMarineData(); |
| 509 | - $MarineLive->db=null; |
|
| 509 | + $MarineLive->db = null; |
|
| 510 | 510 | if ($globalDebug) echo " Done\n"; |
| 511 | 511 | } |
| 512 | 512 | $this->last_delete = time(); |
@@ -519,13 +519,13 @@ discard block |
||
| 519 | 519 | $Marine = new Marine($this->db); |
| 520 | 520 | if (isset($globalVM) && $globalVM) { |
| 521 | 521 | if ($this->all_tracked[$id]['status'] == 'Racing') { |
| 522 | - $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'],$this->all_tracked[$id]['status']); |
|
| 522 | + $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'], $this->all_tracked[$id]['status']); |
|
| 523 | 523 | } else { |
| 524 | - $finaldatetime = date('Y-m-d H:i:s',strtotime($this->all_tracked[$id]['race_begin'])+$this->all_tracked[$id]['race_time']); |
|
| 525 | - $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'],$finaldatetime,$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status']); |
|
| 524 | + $finaldatetime = date('Y-m-d H:i:s', strtotime($this->all_tracked[$id]['race_begin']) + $this->all_tracked[$id]['race_time']); |
|
| 525 | + $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'], $finaldatetime, $this->all_tracked[$id]['distance'], $this->all_tracked[$id]['race_rank'], $this->all_tracked[$id]['race_time'], $this->all_tracked[$id]['status']); |
|
| 526 | 526 | } |
| 527 | 527 | } else { |
| 528 | - $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'],$this->all_tracked[$id]['status']); |
|
| 528 | + $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'], $this->all_tracked[$id]['status']); |
|
| 529 | 529 | } |
| 530 | 530 | $Marine->db = null; |
| 531 | 531 | } |
@@ -541,20 +541,20 @@ discard block |
||
| 541 | 541 | $ignoreImport = false; |
| 542 | 542 | if ((isset($globalVM) && $globalVM) && $this->all_tracked[$id]['status'] != 'Racing') $ignoreImport = true; |
| 543 | 543 | if (!$ignoreImport) { |
| 544 | - 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'])) { |
|
| 544 | + 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'])) { |
|
| 545 | 545 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
| 546 | 546 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 547 | 547 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 548 | 548 | $timeelapsed = microtime(true); |
| 549 | 549 | $MarineLive = new MarineLive($this->db); |
| 550 | - $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']); |
|
| 550 | + $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']); |
|
| 551 | 551 | $MarineLive->db = null; |
| 552 | 552 | if ($globalDebug) echo $result."\n"; |
| 553 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 553 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 554 | 554 | } |
| 555 | 555 | } |
| 556 | 556 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
| 557 | - $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']); |
|
| 557 | + $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']); |
|
| 558 | 558 | } |
| 559 | 559 | $this->all_tracked[$id]['putinarchive'] = false; |
| 560 | 560 | |
@@ -573,19 +573,19 @@ discard block |
||
| 573 | 573 | $latitude = $globalCenterLatitude; |
| 574 | 574 | $longitude = $globalCenterLongitude; |
| 575 | 575 | } |
| 576 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
| 576 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
| 577 | 577 | } else { |
| 578 | 578 | $latitude = $this->source_location[$source]['latitude']; |
| 579 | 579 | $longitude = $this->source_location[$source]['longitude']; |
| 580 | 580 | } |
| 581 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
| 581 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
| 582 | 582 | //$stats_heading = $stats_heading%22.5; |
| 583 | 583 | $stats_heading = round($stats_heading/22.5); |
| 584 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
| 584 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
| 585 | 585 | $current_date = date('Y-m-d'); |
| 586 | 586 | if ($stats_heading == 16) $stats_heading = 0; |
| 587 | 587 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 588 | - for ($i=0;$i<=15;$i++) { |
|
| 588 | + for ($i = 0; $i <= 15; $i++) { |
|
| 589 | 589 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
| 590 | 590 | } |
| 591 | 591 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -600,9 +600,9 @@ discard block |
||
| 600 | 600 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
| 601 | 601 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 602 | 602 | end($this->stats[$current_date][$source]['hist']); |
| 603 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
| 603 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
| 604 | 604 | } else $mini = 0; |
| 605 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
| 605 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
| 606 | 606 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
| 607 | 607 | } |
| 608 | 608 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -614,7 +614,7 @@ discard block |
||
| 614 | 614 | |
| 615 | 615 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 616 | 616 | if ($this->all_tracked[$id]['putinarchive']) $send = true; |
| 617 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 617 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
| 618 | 618 | //$this->del(); |
| 619 | 619 | |
| 620 | 620 | |
@@ -54,7 +54,9 @@ discard block |
||
| 54 | 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"; |
|
| 57 | + if ($globalDebug) { |
|
| 58 | + echo "Update last seen tracked data...\n"; |
|
| 59 | + } |
|
| 58 | 60 | foreach ($this->all_tracked as $key => $flight) { |
| 59 | 61 | if (isset($this->all_tracked[$key]['id'])) { |
| 60 | 62 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
@@ -77,13 +79,17 @@ discard block |
||
| 77 | 79 | public function del() { |
| 78 | 80 | global $globalDebug, $globalNoDB, $globalNoImport; |
| 79 | 81 | // Delete old infos |
| 80 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
| 82 | + if ($globalDebug) { |
|
| 83 | + echo 'Delete old values and update latest data...'."\n"; |
|
| 84 | + } |
|
| 81 | 85 | foreach ($this->all_tracked as $key => $flight) { |
| 82 | 86 | if (isset($flight['lastupdate'])) { |
| 83 | 87 | if ($flight['lastupdate'] < (time()-3000)) { |
| 84 | 88 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
| 85 | 89 | if (isset($this->all_tracked[$key]['id'])) { |
| 86 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 90 | + if ($globalDebug) { |
|
| 91 | + echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 92 | + } |
|
| 87 | 93 | /* |
| 88 | 94 | $MarineLive = new MarineLive(); |
| 89 | 95 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
@@ -102,7 +108,9 @@ discard block |
||
| 102 | 108 | } else { |
| 103 | 109 | $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[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status']); |
| 104 | 110 | } |
| 105 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 111 | + if ($globalDebug && $result != 'success') { |
|
| 112 | + echo '!!! ERROR : '.$result."\n"; |
|
| 113 | + } |
|
| 106 | 114 | } |
| 107 | 115 | // Put in archive |
| 108 | 116 | // $Marine->db = null; |
@@ -116,7 +124,9 @@ discard block |
||
| 116 | 124 | |
| 117 | 125 | public function add($line) { |
| 118 | 126 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine, $globalLiveInterval, $globalVM; |
| 119 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
| 127 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
| 128 | + $globalCoordMinChange = '0.02'; |
|
| 129 | + } |
|
| 120 | 130 | date_default_timezone_set('UTC'); |
| 121 | 131 | $dataFound = false; |
| 122 | 132 | $send = false; |
@@ -130,20 +140,30 @@ discard block |
||
| 130 | 140 | // Increment message number |
| 131 | 141 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
| 132 | 142 | $current_date = date('Y-m-d'); |
| 133 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
| 134 | - else $source = ''; |
|
| 135 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 143 | + if (isset($line['source_name'])) { |
|
| 144 | + $source = $line['source_name']; |
|
| 145 | + } else { |
|
| 146 | + $source = ''; |
|
| 147 | + } |
|
| 148 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
| 149 | + $source = $line['format_source']; |
|
| 150 | + } |
|
| 136 | 151 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
| 137 | 152 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
| 138 | 153 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
| 139 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 154 | + } else { |
|
| 155 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 156 | + } |
|
| 140 | 157 | } |
| 141 | 158 | |
| 142 | 159 | |
| 143 | 160 | $Common = new Common(); |
| 144 | 161 | $AIS = new AIS(); |
| 145 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
| 146 | - else $id = trim($line['id']); |
|
| 162 | + if (!isset($line['id'])) { |
|
| 163 | + $id = trim($line['mmsi']); |
|
| 164 | + } else { |
|
| 165 | + $id = trim($line['id']); |
|
| 166 | + } |
|
| 147 | 167 | |
| 148 | 168 | if (!isset($this->all_tracked[$id])) { |
| 149 | 169 | $this->all_tracked[$id] = array(); |
@@ -151,10 +171,16 @@ discard block |
||
| 151 | 171 | $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,'race_rank' => NULL,'race_time' => NULL,'race_begin' => date('Y-m-d H:i:s'))); |
| 152 | 172 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
| 153 | 173 | if (!isset($line['id'])) { |
| 154 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 174 | + if (!isset($globalDaemon)) { |
|
| 175 | + $globalDaemon = TRUE; |
|
| 176 | + } |
|
| 155 | 177 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
| 156 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 157 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
| 178 | + } else { |
|
| 179 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 180 | + } |
|
| 181 | + if ($globalAllTracked !== FALSE) { |
|
| 182 | + $dataFound = true; |
|
| 183 | + } |
|
| 158 | 184 | } |
| 159 | 185 | |
| 160 | 186 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
@@ -211,7 +237,9 @@ discard block |
||
| 211 | 237 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
| 212 | 238 | if (!isset($this->all_tracked[$id]['arrival_code'])) { |
| 213 | 239 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
| 214 | - if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
| 240 | + if ($globalDebug) { |
|
| 241 | + echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
| 242 | + } |
|
| 215 | 243 | if ($this->all_tracked[$id]['addedMarine'] != 0) { |
| 216 | 244 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 217 | 245 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -224,7 +252,9 @@ discard block |
||
| 224 | 252 | } |
| 225 | 253 | } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) { |
| 226 | 254 | $this->all_tracked[$id]['arrival_code'] = $line['arrival_code']; |
| 227 | - if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
| 255 | + if ($globalDebug) { |
|
| 256 | + echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
| 257 | + } |
|
| 228 | 258 | if (!isset($line['id'])) { |
| 229 | 259 | $this->all_tracked[$id]['id'] = $id.'-'.date('YmdHi'); |
| 230 | 260 | $this->all_tracked[$id]['forcenew'] = 1; |
@@ -233,7 +263,9 @@ discard block |
||
| 233 | 263 | } |
| 234 | 264 | } |
| 235 | 265 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
| 236 | - if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
| 266 | + if (strtotime($line['arrival_date']) > time()) { |
|
| 267 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
| 268 | + } |
|
| 237 | 269 | } |
| 238 | 270 | if (isset($line['captain_id']) && $line['captain_id'] != '') { |
| 239 | 271 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id'])); |
@@ -278,34 +310,49 @@ discard block |
||
| 278 | 310 | $Marine = new Marine($this->db); |
| 279 | 311 | $fromsource = NULL; |
| 280 | 312 | $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
| 281 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 313 | + if ($globalDebug && $result != 'success') { |
|
| 314 | + echo '!!! ERROR : '.$result."\n"; |
|
| 315 | + } |
|
| 282 | 316 | $Marine->db = null; |
| 283 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 317 | + if ($globalDebugTimeElapsed) { |
|
| 318 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 319 | + } |
|
| 284 | 320 | } |
| 285 | 321 | } |
| 286 | 322 | } |
| 287 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 323 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
| 324 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 325 | + } |
|
| 288 | 326 | } |
| 289 | 327 | |
| 290 | 328 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
| 291 | 329 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
| 292 | 330 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
| 293 | 331 | } else { |
| 294 | - 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"; |
|
| 295 | - 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"; |
|
| 332 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
| 333 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
| 334 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
| 335 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 336 | + } |
|
| 296 | 337 | return ''; |
| 297 | 338 | } |
| 298 | 339 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
| 299 | - if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
| 340 | + if ($globalDebug) { |
|
| 341 | + echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
| 342 | + } |
|
| 300 | 343 | return ''; |
| 301 | 344 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) { |
| 302 | - if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
| 345 | + if ($globalDebug) { |
|
| 346 | + echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
| 347 | + } |
|
| 303 | 348 | return ''; |
| 304 | 349 | } elseif (!isset($line['datetime'])) { |
| 305 | 350 | date_default_timezone_set('UTC'); |
| 306 | 351 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
| 307 | 352 | } else { |
| 308 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n"; |
|
| 353 | + if ($globalDebug) { |
|
| 354 | + echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n"; |
|
| 355 | + } |
|
| 309 | 356 | return ''; |
| 310 | 357 | } |
| 311 | 358 | |
@@ -318,14 +365,21 @@ discard block |
||
| 318 | 365 | if ($distance > 1000 && $distance < 10000) { |
| 319 | 366 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
| 320 | 367 | $speed = $speed*3.6; |
| 321 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2))); |
|
| 322 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
| 368 | + if ($speed < 1000) { |
|
| 369 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2))); |
|
| 370 | + } |
|
| 371 | + if ($globalDebug) { |
|
| 372 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
| 373 | + } |
|
| 323 | 374 | } |
| 324 | 375 | } |
| 325 | 376 | |
| 326 | 377 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
| 327 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 328 | - else unset($timediff); |
|
| 378 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
| 379 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 380 | + } else { |
|
| 381 | + unset($timediff); |
|
| 382 | + } |
|
| 329 | 383 | if ($this->tmd > 5 || |
| 330 | 384 | !isset($timediff) || |
| 331 | 385 | $timediff > $globalLiveInterval || |
@@ -342,22 +396,32 @@ discard block |
||
| 342 | 396 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 343 | 397 | $this->all_tracked[$id]['putinarchive'] = true; |
| 344 | 398 | |
| 345 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 399 | + if ($globalDebug) { |
|
| 400 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 401 | + } |
|
| 346 | 402 | $timeelapsed = microtime(true); |
| 347 | 403 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 348 | 404 | $Marine = new Marine($this->db); |
| 349 | 405 | $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
| 350 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 406 | + if (!empty($all_country)) { |
|
| 407 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 408 | + } |
|
| 351 | 409 | $Marine->db = null; |
| 352 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 410 | + if ($globalDebugTimeElapsed) { |
|
| 411 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 412 | + } |
|
| 353 | 413 | } |
| 354 | 414 | $this->tmd = 0; |
| 355 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
| 415 | + if ($globalDebug) { |
|
| 416 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
| 417 | + } |
|
| 356 | 418 | } |
| 357 | 419 | } |
| 358 | 420 | |
| 359 | 421 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 360 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
| 422 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
| 423 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
| 424 | + } |
|
| 361 | 425 | 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') { |
| 362 | 426 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
| 363 | 427 | $dataFound = true; |
@@ -366,8 +430,12 @@ discard block |
||
| 366 | 430 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
| 367 | 431 | } |
| 368 | 432 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 369 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 370 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
| 433 | + if ($line['longitude'] > 180) { |
|
| 434 | + $line['longitude'] = $line['longitude'] - 360; |
|
| 435 | + } |
|
| 436 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
| 437 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
| 438 | + } |
|
| 371 | 439 | 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') { |
| 372 | 440 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
| 373 | 441 | $dataFound = true; |
@@ -385,7 +453,9 @@ discard block |
||
| 385 | 453 | } |
| 386 | 454 | } |
| 387 | 455 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 388 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 456 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
| 457 | + $dataFound = true; |
|
| 458 | + } |
|
| 389 | 459 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
| 390 | 460 | } |
| 391 | 461 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -399,15 +469,21 @@ discard block |
||
| 399 | 469 | } |
| 400 | 470 | |
| 401 | 471 | if (isset($line['heading']) && $line['heading'] != '') { |
| 402 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 472 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
| 473 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 474 | + } |
|
| 403 | 475 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
| 404 | 476 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
| 405 | 477 | //$dataFound = true; |
| 406 | 478 | } 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']) { |
| 407 | 479 | $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']); |
| 408 | 480 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
| 409 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 410 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 481 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
| 482 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 483 | + } |
|
| 484 | + if ($globalDebug) { |
|
| 485 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 486 | + } |
|
| 411 | 487 | } |
| 412 | 488 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
| 413 | 489 | |
@@ -419,28 +495,45 @@ discard block |
||
| 419 | 495 | 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'])) { |
| 420 | 496 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
| 421 | 497 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 422 | - if ($globalDebug) echo "Check if vessel is already in DB..."; |
|
| 498 | + if ($globalDebug) { |
|
| 499 | + echo "Check if vessel is already in DB..."; |
|
| 500 | + } |
|
| 423 | 501 | $timeelapsed = microtime(true); |
| 424 | 502 | $MarineLive = new MarineLive($this->db); |
| 425 | 503 | if (isset($line['id']) && isset($globalVM) && $globalVM) { |
| 426 | 504 | $Marine = new Marine($this->db); |
| 427 | 505 | $recent_ident = $Marine->checkId($line['id']); |
| 428 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 506 | + if ($globalDebugTimeElapsed) { |
|
| 507 | + echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 508 | + } |
|
| 429 | 509 | $Marine->db=null; |
| 430 | 510 | } elseif (isset($line['id'])) { |
| 431 | 511 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
| 432 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 512 | + if ($globalDebugTimeElapsed) { |
|
| 513 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 514 | + } |
|
| 433 | 515 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
| 434 | 516 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
| 435 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 517 | + if ($globalDebugTimeElapsed) { |
|
| 518 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 519 | + } |
|
| 436 | 520 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
| 437 | 521 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
| 438 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 439 | - } else $recent_ident = ''; |
|
| 522 | + if ($globalDebugTimeElapsed) { |
|
| 523 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 524 | + } |
|
| 525 | + } else { |
|
| 526 | + $recent_ident = ''; |
|
| 527 | + } |
|
| 440 | 528 | $MarineLive->db=null; |
| 441 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 442 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 443 | - } else $recent_ident = ''; |
|
| 529 | + if ($globalDebug && $recent_ident == '') { |
|
| 530 | + echo " Not in DB.\n"; |
|
| 531 | + } elseif ($globalDebug && $recent_ident != '') { |
|
| 532 | + echo " Already in DB.\n"; |
|
| 533 | + } |
|
| 534 | + } else { |
|
| 535 | + $recent_ident = ''; |
|
| 536 | + } |
|
| 444 | 537 | } else { |
| 445 | 538 | $recent_ident = ''; |
| 446 | 539 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -449,12 +542,17 @@ discard block |
||
| 449 | 542 | if($recent_ident == "" && (($this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') || (isset($globalVM) && $globalVM))) |
| 450 | 543 | { |
| 451 | 544 | if ($globalDebug) { |
| 452 | - if ($this->all_tracked[$id]['mmsi'] == '') echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
| 453 | - else echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
| 545 | + if ($this->all_tracked[$id]['mmsi'] == '') { |
|
| 546 | + echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
| 547 | + } else { |
|
| 548 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
| 549 | + } |
|
| 454 | 550 | } |
| 455 | 551 | //adds the spotter data for the archive |
| 456 | 552 | $highlight = ''; |
| 457 | - 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'))); |
|
| 553 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
| 554 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
| 555 | + } |
|
| 458 | 556 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 459 | 557 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 460 | 558 | $timeelapsed = microtime(true); |
@@ -465,20 +563,30 @@ discard block |
||
| 465 | 563 | $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']); |
| 466 | 564 | } |
| 467 | 565 | $Marine->db = null; |
| 468 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 469 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 566 | + if ($globalDebug && isset($result)) { |
|
| 567 | + echo $result."\n"; |
|
| 568 | + } |
|
| 569 | + if ($globalDebugTimeElapsed) { |
|
| 570 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 571 | + } |
|
| 470 | 572 | } |
| 471 | 573 | } |
| 472 | 574 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
| 473 | 575 | // Add source stat in DB |
| 474 | 576 | $Stats = new Stats($this->db); |
| 475 | 577 | if (!empty($this->stats)) { |
| 476 | - if ($globalDebug) echo 'Add source stats : '; |
|
| 578 | + if ($globalDebug) { |
|
| 579 | + echo 'Add source stats : '; |
|
| 580 | + } |
|
| 477 | 581 | foreach($this->stats as $date => $data) { |
| 478 | 582 | foreach($data as $source => $sourced) { |
| 479 | 583 | //print_r($sourced); |
| 480 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
| 481 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
| 584 | + if (isset($sourced['polar'])) { |
|
| 585 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
| 586 | + } |
|
| 587 | + if (isset($sourced['hist'])) { |
|
| 588 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
| 589 | + } |
|
| 482 | 590 | if (isset($sourced['msg'])) { |
| 483 | 591 | if (time() - $sourced['msg']['date'] > 10) { |
| 484 | 592 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -491,7 +599,9 @@ discard block |
||
| 491 | 599 | unset($this->stats[$date]); |
| 492 | 600 | } |
| 493 | 601 | } |
| 494 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 602 | + if ($globalDebug) { |
|
| 603 | + echo 'Done'."\n"; |
|
| 604 | + } |
|
| 495 | 605 | } |
| 496 | 606 | $Stats->db = null; |
| 497 | 607 | } |
@@ -501,13 +611,17 @@ discard block |
||
| 501 | 611 | $this->all_tracked[$id]['addedMarine'] = 1; |
| 502 | 612 | //print_r($this->all_tracked[$id]); |
| 503 | 613 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 504 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
| 614 | + if ($globalDebug) { |
|
| 615 | + echo "---- Deleting Live Marine data older than 9 hours..."; |
|
| 616 | + } |
|
| 505 | 617 | //MarineLive->deleteLiveMarineDataNotUpdated(); |
| 506 | 618 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 507 | 619 | $MarineLive = new MarineLive($this->db); |
| 508 | 620 | $MarineLive->deleteLiveMarineData(); |
| 509 | 621 | $MarineLive->db=null; |
| 510 | - if ($globalDebug) echo " Done\n"; |
|
| 622 | + if ($globalDebug) { |
|
| 623 | + echo " Done\n"; |
|
| 624 | + } |
|
| 511 | 625 | } |
| 512 | 626 | $this->last_delete = time(); |
| 513 | 627 | } |
@@ -539,18 +653,26 @@ discard block |
||
| 539 | 653 | 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"; |
| 540 | 654 | } |
| 541 | 655 | $ignoreImport = false; |
| 542 | - if ((isset($globalVM) && $globalVM) && $this->all_tracked[$id]['status'] != 'Racing') $ignoreImport = true; |
|
| 656 | + if ((isset($globalVM) && $globalVM) && $this->all_tracked[$id]['status'] != 'Racing') { |
|
| 657 | + $ignoreImport = true; |
|
| 658 | + } |
|
| 543 | 659 | if (!$ignoreImport) { |
| 544 | 660 | 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'])) { |
| 545 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
| 661 | + if ($globalDebug) { |
|
| 662 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
| 663 | + } |
|
| 546 | 664 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 547 | 665 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 548 | 666 | $timeelapsed = microtime(true); |
| 549 | 667 | $MarineLive = new MarineLive($this->db); |
| 550 | 668 | $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']); |
| 551 | 669 | $MarineLive->db = null; |
| 552 | - if ($globalDebug) echo $result."\n"; |
|
| 553 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 670 | + if ($globalDebug) { |
|
| 671 | + echo $result."\n"; |
|
| 672 | + } |
|
| 673 | + if ($globalDebugTimeElapsed) { |
|
| 674 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 675 | + } |
|
| 554 | 676 | } |
| 555 | 677 | } |
| 556 | 678 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
@@ -562,7 +684,9 @@ discard block |
||
| 562 | 684 | |
| 563 | 685 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
| 564 | 686 | $source = $this->all_tracked[$id]['source_name']; |
| 565 | - if ($source == '') $source = $this->all_tracked[$id]['format_source']; |
|
| 687 | + if ($source == '') { |
|
| 688 | + $source = $this->all_tracked[$id]['format_source']; |
|
| 689 | + } |
|
| 566 | 690 | if (!isset($this->source_location[$source])) { |
| 567 | 691 | $Location = new Source($this->db); |
| 568 | 692 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -583,7 +707,9 @@ discard block |
||
| 583 | 707 | $stats_heading = round($stats_heading/22.5); |
| 584 | 708 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
| 585 | 709 | $current_date = date('Y-m-d'); |
| 586 | - if ($stats_heading == 16) $stats_heading = 0; |
|
| 710 | + if ($stats_heading == 16) { |
|
| 711 | + $stats_heading = 0; |
|
| 712 | + } |
|
| 587 | 713 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 588 | 714 | for ($i=0;$i<=15;$i++) { |
| 589 | 715 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -601,7 +727,9 @@ discard block |
||
| 601 | 727 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 602 | 728 | end($this->stats[$current_date][$source]['hist']); |
| 603 | 729 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
| 604 | - } else $mini = 0; |
|
| 730 | + } else { |
|
| 731 | + $mini = 0; |
|
| 732 | + } |
|
| 605 | 733 | for ($i=$mini;$i<=$distance;$i+=10) { |
| 606 | 734 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
| 607 | 735 | } |
@@ -613,19 +741,27 @@ discard block |
||
| 613 | 741 | |
| 614 | 742 | |
| 615 | 743 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 616 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
| 617 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 744 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
| 745 | + $send = true; |
|
| 746 | + } |
|
| 747 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
| 748 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 749 | + } |
|
| 618 | 750 | //$this->del(); |
| 619 | 751 | |
| 620 | 752 | |
| 621 | 753 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 622 | 754 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 623 | - if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
| 755 | + if ($globalDebug) { |
|
| 756 | + echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
| 757 | + } |
|
| 624 | 758 | $MarineLive = new MarineLive($this->db); |
| 625 | 759 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
| 626 | 760 | $MarineLive->db = null; |
| 627 | 761 | //MarineLive->deleteLiveMarineData(); |
| 628 | - if ($globalDebug) echo " Done\n"; |
|
| 762 | + if ($globalDebug) { |
|
| 763 | + echo " Done\n"; |
|
| 764 | + } |
|
| 629 | 765 | } |
| 630 | 766 | $this->last_delete_hourly = time(); |
| 631 | 767 | } |
@@ -634,7 +770,9 @@ discard block |
||
| 634 | 770 | //$ignoreImport = false; |
| 635 | 771 | } |
| 636 | 772 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 637 | - if ($send) return $this->all_tracked[$id]; |
|
| 773 | + if ($send) { |
|
| 774 | + return $this->all_tracked[$id]; |
|
| 775 | + } |
|
| 638 | 776 | } |
| 639 | 777 | } |
| 640 | 778 | } |
@@ -50,20 +50,20 @@ discard block |
||
| 50 | 50 | die; |
| 51 | 51 | } |
| 52 | 52 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
| 53 | - $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
|
| 53 | + $globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port); |
|
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | |
| 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')); |
|
| 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 | 61 | $globalSources = array(); |
| 62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 62 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']); |
|
| 63 | 63 | else $globalSources[] = array('host' => $options['s']); |
| 64 | 64 | } elseif (isset($options['source'])) { |
| 65 | 65 | $globalSources = array(); |
| 66 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 66 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']); |
|
| 67 | 67 | else $globalSources[] = array('host' => $options['source']); |
| 68 | 68 | } |
| 69 | 69 | if (isset($options['aprsserverhost'])) { |
@@ -104,13 +104,13 @@ discard block |
||
| 104 | 104 | else $id_source = 1; |
| 105 | 105 | if (isset($globalServer) && $globalServer) { |
| 106 | 106 | if ($globalDebug) echo "Using Server Mode\n"; |
| 107 | - $SI=new SpotterServer(); |
|
| 107 | + $SI = new SpotterServer(); |
|
| 108 | 108 | /* |
| 109 | 109 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 110 | 110 | $SI = new adsb2aprs(); |
| 111 | 111 | $SI->connect(); |
| 112 | 112 | */ |
| 113 | -} else $SI=new SpotterImport($Connection->db); |
|
| 113 | +} else $SI = new SpotterImport($Connection->db); |
|
| 114 | 114 | |
| 115 | 115 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
| 116 | 116 | if (isset($globalMarine) && $globalMarine) { |
@@ -124,17 +124,17 @@ discard block |
||
| 124 | 124 | $MI = new MarineImport($Connection->db); |
| 125 | 125 | } |
| 126 | 126 | //$APRS=new APRS($Connection->db); |
| 127 | -$SBS=new SBS(); |
|
| 127 | +$SBS = new SBS(); |
|
| 128 | 128 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 129 | - $ACARS=new ACARS($Connection->db,true); |
|
| 130 | - $Source=new Source($Connection->db); |
|
| 129 | + $ACARS = new ACARS($Connection->db, true); |
|
| 130 | + $Source = new Source($Connection->db); |
|
| 131 | 131 | } |
| 132 | -$Common=new Common(); |
|
| 132 | +$Common = new Common(); |
|
| 133 | 133 | date_default_timezone_set('UTC'); |
| 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() { |
|
| 137 | + pcntl_signal(SIGINT, function() { |
|
| 138 | 138 | global $sockets; |
| 139 | 139 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
| 140 | 140 | die("Bye!\n"); |
@@ -150,40 +150,40 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | function connect_all($hosts) { |
| 152 | 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; |
|
| 153 | + global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context; |
|
| 154 | 154 | $reset++; |
| 155 | 155 | if ($globalDebug) echo 'Connect to all...'."\n"; |
| 156 | 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 | - if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
| 161 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 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 | 162 | //$formats[$id] = 'deltadbtxt'; |
| 163 | 163 | $globalSources[$id]['format'] = 'deltadbtxt'; |
| 164 | 164 | //$last_exec['deltadbtxt'] = 0; |
| 165 | 165 | if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
| 166 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 166 | + } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
| 167 | 167 | //$formats[$id] = 'vatsimtxt'; |
| 168 | 168 | $globalSources[$id]['format'] = 'vatsimtxt'; |
| 169 | 169 | //$last_exec['vatsimtxt'] = 0; |
| 170 | 170 | if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
| 171 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 171 | + } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
| 172 | 172 | //$formats[$id] = 'aircraftlistjson'; |
| 173 | 173 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
| 174 | 174 | //$last_exec['aircraftlistjson'] = 0; |
| 175 | 175 | if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
| 176 | - } else if (preg_match('/aircraft.json$/i',$host)) { |
|
| 176 | + } else if (preg_match('/aircraft.json$/i', $host)) { |
|
| 177 | 177 | //$formats[$id] = 'aircraftjson'; |
| 178 | 178 | $globalSources[$id]['format'] = 'aircraftjson'; |
| 179 | 179 | //$last_exec['aircraftlistjson'] = 0; |
| 180 | 180 | if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; |
| 181 | - } else if (preg_match('/aircraft$/i',$host)) { |
|
| 181 | + } else if (preg_match('/aircraft$/i', $host)) { |
|
| 182 | 182 | //$formats[$id] = 'planefinderclient'; |
| 183 | 183 | $globalSources[$id]['format'] = 'planefinderclient'; |
| 184 | 184 | //$last_exec['aircraftlistjson'] = 0; |
| 185 | 185 | if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; |
| 186 | - } else if (preg_match('/opensky/i',$host)) { |
|
| 186 | + } else if (preg_match('/opensky/i', $host)) { |
|
| 187 | 187 | //$formats[$id] = 'aircraftlistjson'; |
| 188 | 188 | $globalSources[$id]['format'] = 'opensky'; |
| 189 | 189 | //$last_exec['aircraftlistjson'] = 0; |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | exit(0); |
| 201 | 201 | } |
| 202 | 202 | */ |
| 203 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 203 | + } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
| 204 | 204 | //$formats[$id] = 'planeupdatefaa'; |
| 205 | 205 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
| 206 | 206 | //$last_exec['planeupdatefaa'] = 0; |
@@ -209,37 +209,37 @@ discard block |
||
| 209 | 209 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 210 | 210 | exit(0); |
| 211 | 211 | } |
| 212 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 212 | + } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
| 213 | 213 | //$formats[$id] = 'phpvmacars'; |
| 214 | 214 | $globalSources[$id]['format'] = 'phpvmacars'; |
| 215 | 215 | //$last_exec['phpvmacars'] = 0; |
| 216 | 216 | if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
| 217 | - } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
| 217 | + } else if (preg_match('/\/api\/v1\/acars\/data$/i', $host)) { |
|
| 218 | 218 | //$formats[$id] = 'phpvmacars'; |
| 219 | 219 | $globalSources[$id]['format'] = 'vaos'; |
| 220 | 220 | //$last_exec['phpvmacars'] = 0; |
| 221 | 221 | if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
| 222 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 222 | + } else if (preg_match('/VAM-json.php$/i', $host)) { |
|
| 223 | 223 | //$formats[$id] = 'phpvmacars'; |
| 224 | 224 | $globalSources[$id]['format'] = 'vam'; |
| 225 | 225 | if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
| 226 | - } else if (preg_match('/whazzup/i',$host)) { |
|
| 226 | + } else if (preg_match('/whazzup/i', $host)) { |
|
| 227 | 227 | //$formats[$id] = 'whazzup'; |
| 228 | 228 | $globalSources[$id]['format'] = 'whazzup'; |
| 229 | 229 | //$last_exec['whazzup'] = 0; |
| 230 | 230 | if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
| 231 | - } else if (preg_match('/blitzortung/i',$host)) { |
|
| 231 | + } else if (preg_match('/blitzortung/i', $host)) { |
|
| 232 | 232 | $globalSources[$id]['format'] = 'blitzortung'; |
| 233 | 233 | if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
| 234 | - } else if (preg_match('/airwhere/i',$host)) { |
|
| 234 | + } else if (preg_match('/airwhere/i', $host)) { |
|
| 235 | 235 | $globalSources[$id]['format'] = 'airwhere'; |
| 236 | 236 | if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
| 237 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
| 237 | + } else if (preg_match('/recentpireps/i', $host)) { |
|
| 238 | 238 | //$formats[$id] = 'pirepsjson'; |
| 239 | 239 | $globalSources[$id]['format'] = 'pirepsjson'; |
| 240 | 240 | //$last_exec['pirepsjson'] = 0; |
| 241 | 241 | if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
| 242 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 242 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
| 243 | 243 | //$formats[$id] = 'fr24json'; |
| 244 | 244 | $globalSources[$id]['format'] = 'fr24json'; |
| 245 | 245 | //$last_exec['fr24json'] = 0; |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 249 | 249 | exit(0); |
| 250 | 250 | } |
| 251 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
| 251 | + } else if (preg_match(':myshiptracking.com/:i', $host)) { |
|
| 252 | 252 | //$formats[$id] = 'fr24json'; |
| 253 | 253 | $globalSources[$id]['format'] = 'myshiptracking'; |
| 254 | 254 | //$last_exec['fr24json'] = 0; |
@@ -258,22 +258,22 @@ discard block |
||
| 258 | 258 | exit(0); |
| 259 | 259 | } |
| 260 | 260 | //} else if (preg_match('/10001/',$host)) { |
| 261 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 261 | + } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 262 | 262 | //$formats[$id] = 'tsv'; |
| 263 | 263 | $globalSources[$id]['format'] = 'tsv'; |
| 264 | 264 | if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
| 265 | 265 | } |
| 266 | - } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway')) { |
|
| 266 | + } elseif (filter_var($host, FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway')) { |
|
| 267 | 267 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
| 268 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
| 268 | + $idf = fopen($globalSources[$id]['host'], 'r', false, $context); |
|
| 269 | 269 | if ($idf !== false) { |
| 270 | 270 | $httpfeeds[$id] = $idf; |
| 271 | 271 | if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
| 272 | 272 | } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
| 273 | 273 | } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
| 274 | 274 | elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
| 275 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 276 | - $hostport = explode(':',$host); |
|
| 275 | + } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
| 276 | + $hostport = explode(':', $host); |
|
| 277 | 277 | if (isset($hostport[1])) { |
| 278 | 278 | $port = $hostport[1]; |
| 279 | 279 | $hostn = $hostport[0]; |
@@ -283,19 +283,19 @@ discard block |
||
| 283 | 283 | } |
| 284 | 284 | $Common = new Common(); |
| 285 | 285 | if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
| 286 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
| 286 | + $s = $Common->create_socket($hostn, $port, $errno, $errstr); |
|
| 287 | 287 | } else { |
| 288 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 288 | + $s = $Common->create_socket_udp($hostn, $port, $errno, $errstr); |
|
| 289 | 289 | } |
| 290 | 290 | if ($s) { |
| 291 | 291 | $sockets[$id] = $s; |
| 292 | 292 | if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
| 293 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
| 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 | 300 | } elseif ($port == '10001') { |
| 301 | 301 | //$formats[$id] = 'tsv'; |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
| 337 | 337 | else $timeout = 20; |
| 338 | 338 | $errno = ''; |
| 339 | -$errstr=''; |
|
| 339 | +$errstr = ''; |
|
| 340 | 340 | |
| 341 | 341 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 342 | 342 | /* Initiate connections to all the hosts simultaneously */ |
@@ -344,7 +344,7 @@ 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 | 349 | $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
| 350 | 350 | } |
@@ -374,16 +374,16 @@ discard block |
||
| 374 | 374 | |
| 375 | 375 | if ($use_aprs) { |
| 376 | 376 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 377 | - $APRS=new APRS(); |
|
| 377 | + $APRS = new APRS(); |
|
| 378 | 378 | $aprs_connect = 0; |
| 379 | 379 | $aprs_keep = 120; |
| 380 | 380 | $aprs_last_tx = time(); |
| 381 | 381 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
| 382 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 382 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
| 383 | 383 | if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
| 384 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 384 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
| 385 | 385 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
| 386 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 386 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 387 | 387 | if ($aprs_full) $aprs_filter = ''; |
| 388 | 388 | if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
| 389 | 389 | else $aprs_pass = '-1'; |
@@ -397,12 +397,12 @@ discard block |
||
| 397 | 397 | sleep(1); |
| 398 | 398 | if ($globalDebug) echo "SCAN MODE \n\n"; |
| 399 | 399 | if (!isset($globalCronEnd)) $globalCronEnd = 60; |
| 400 | -$endtime = time()+$globalCronEnd; |
|
| 400 | +$endtime = time() + $globalCronEnd; |
|
| 401 | 401 | $i = 1; |
| 402 | 402 | $tt = array(); |
| 403 | 403 | // Delete all ATC |
| 404 | 404 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
| 405 | - $ATC=new ATC($Connection->db); |
|
| 405 | + $ATC = new ATC($Connection->db); |
|
| 406 | 406 | } |
| 407 | 407 | if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 408 | 408 | $ATC->deleteAll(); |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | while ($i > 0) { |
| 413 | 413 | if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
| 414 | 414 | |
| 415 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 415 | + if (!$globalDaemon) $i = $endtime - time(); |
|
| 416 | 416 | // Delete old ATC |
| 417 | 417 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 418 | 418 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | } |
| 427 | 427 | if ($max < $globalMinFetch) { |
| 428 | 428 | if ($globalDebug) echo 'Sleeping...'."\n"; |
| 429 | - sleep($globalMinFetch-$max+2); |
|
| 429 | + sleep($globalMinFetch - $max + 2); |
|
| 430 | 430 | } |
| 431 | 431 | } |
| 432 | 432 | |
@@ -445,8 +445,8 @@ discard block |
||
| 445 | 445 | //$buffer = $Common->getData($hosts[$id]); |
| 446 | 446 | $buffer = $Common->getData($value['host']); |
| 447 | 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); |
|
| 448 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 449 | + $buffer = explode('\n', $buffer); |
|
| 450 | 450 | foreach ($buffer as $line) { |
| 451 | 451 | if ($line != '' && count($line) > 7) { |
| 452 | 452 | $line = explode(',', $line); |
@@ -479,11 +479,11 @@ discard block |
||
| 479 | 479 | ) |
| 480 | 480 | ) { |
| 481 | 481 | date_default_timezone_set('CET'); |
| 482 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
| 482 | + $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host'])); |
|
| 483 | 483 | date_default_timezone_set('UTC'); |
| 484 | 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); |
|
| 485 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 486 | + $buffer = explode('\n', $buffer); |
|
| 487 | 487 | foreach ($buffer as $line) { |
| 488 | 488 | if ($line != '') { |
| 489 | 489 | //echo "'".$line."'\n"; |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | $ais_data = $AIS->parse_line(trim($line)); |
| 492 | 492 | $data = array(); |
| 493 | 493 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
| 494 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 494 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9); |
|
| 495 | 495 | if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
| 496 | 496 | if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
| 497 | 497 | if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
@@ -503,7 +503,7 @@ discard block |
||
| 503 | 503 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
| 504 | 504 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
| 505 | 505 | if (isset($ais_data['timestamp'])) { |
| 506 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 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 | 508 | $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
| 509 | 509 | $add = true; |
@@ -526,21 +526,21 @@ discard block |
||
| 526 | 526 | $w = $e = null; |
| 527 | 527 | |
| 528 | 528 | if (isset($arr[$id])) { |
| 529 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
| 529 | + $nn = stream_select($arr, $w, $e, $timeout); |
|
| 530 | 530 | if ($nn > 0) { |
| 531 | 531 | foreach ($httpfeeds as $feed) { |
| 532 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
| 532 | + $buffer = stream_get_line($feed, 2000, "\n"); |
|
| 533 | 533 | if ($buffer === FALSE) { |
| 534 | 534 | connect_all($globalSources); |
| 535 | 535 | } |
| 536 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 537 | - $buffer = explode('\n',$buffer); |
|
| 536 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 537 | + $buffer = explode('\n', $buffer); |
|
| 538 | 538 | foreach ($buffer as $line) { |
| 539 | 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']; |
| 543 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 543 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9); |
|
| 544 | 544 | if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
| 545 | 545 | if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
| 546 | 546 | if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
@@ -552,9 +552,9 @@ discard block |
||
| 552 | 552 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
| 553 | 553 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
| 554 | 554 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
| 555 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 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 | 559 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 560 | 560 | } |
@@ -586,10 +586,10 @@ discard block |
||
| 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'); |
|
| 589 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
| 590 | 590 | if ($buffer != '') { |
| 591 | 591 | //echo $buffer; |
| 592 | - $all_data = json_decode($buffer,true); |
|
| 592 | + $all_data = json_decode($buffer, true); |
|
| 593 | 593 | //print_r($all_data); |
| 594 | 594 | if (isset($all_data[0]['DATA'])) { |
| 595 | 595 | foreach ($all_data[0]['DATA'] as $line) { |
@@ -598,7 +598,7 @@ discard block |
||
| 598 | 598 | $data['ident'] = $line['NAME']; |
| 599 | 599 | $data['mmsi'] = $line['MMSI']; |
| 600 | 600 | if (strlen($data['mmsi']) > 9) { |
| 601 | - $data['mmsi'] = substr($data['mmsi'],-9); |
|
| 601 | + $data['mmsi'] = substr($data['mmsi'], -9); |
|
| 602 | 602 | } |
| 603 | 603 | $data['speed'] = $line['SOG']; |
| 604 | 604 | $data['heading'] = $line['COG']; |
@@ -608,8 +608,8 @@ discard block |
||
| 608 | 608 | //$data['type_id'] = $line['TYPE']; |
| 609 | 609 | $data['imo'] = $line['IMO']; |
| 610 | 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']); |
|
| 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 | 613 | $data['format_source'] = 'myshiptracking'; |
| 614 | 614 | $data['id_source'] = $id_source; |
| 615 | 615 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -626,16 +626,16 @@ discard block |
||
| 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'])); |
|
| 629 | + $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host'])); |
|
| 630 | 630 | if ($buffer != '') { |
| 631 | - $all_data = json_decode($buffer,true); |
|
| 631 | + $all_data = json_decode($buffer, true); |
|
| 632 | 632 | if (isset($all_data[0]['mmsi'])) { |
| 633 | 633 | foreach ($all_data as $line) { |
| 634 | 634 | if ($line != '') { |
| 635 | 635 | $data = array(); |
| 636 | 636 | $data['ident'] = $line['shipname']; |
| 637 | 637 | $data['callsign'] = $line['callsign']; |
| 638 | - $data['mmsi'] = substr($line['mmsi'],-9); |
|
| 638 | + $data['mmsi'] = substr($line['mmsi'], -9); |
|
| 639 | 639 | $data['speed'] = $line['sog']; |
| 640 | 640 | if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
| 641 | 641 | $data['latitude'] = $line['latitude']; |
@@ -662,14 +662,14 @@ discard block |
||
| 662 | 662 | ) { |
| 663 | 663 | $buffer = $Common->getData($value['host']); |
| 664 | 664 | if ($buffer != '') { |
| 665 | - $all_data = json_decode($buffer,true); |
|
| 665 | + $all_data = json_decode($buffer, true); |
|
| 666 | 666 | if (isset($all_data['features'][0]['id'])) { |
| 667 | 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']; |
| 671 | 671 | if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
| 672 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
| 672 | + if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'], -9); |
|
| 673 | 673 | if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo']; |
| 674 | 674 | if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
| 675 | 675 | if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading']; |
@@ -696,31 +696,31 @@ discard block |
||
| 696 | 696 | ) |
| 697 | 697 | ) { |
| 698 | 698 | if ($globalDebug) echo 'download...'; |
| 699 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
| 699 | + $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter'); |
|
| 700 | 700 | if ($globalDebug) echo 'done !'."\n"; |
| 701 | 701 | // FIXME: Need more work |
| 702 | 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); |
|
| 703 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 704 | + $buffer = explode('\n', $buffer); |
|
| 705 | 705 | foreach ($buffer as $line) { |
| 706 | 706 | if ($line != '') { |
| 707 | 707 | $data = array(); |
| 708 | 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)); |
|
| 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 | 716 | //$data['course'] = substr($line,57,5); |
| 717 | - $data['heading'] = round(substr($line,63,3)); |
|
| 717 | + $data['heading'] = round(substr($line, 63, 3)); |
|
| 718 | 718 | //$data['draft'] = substr($line,67,4); |
| 719 | 719 | //$data['length'] = substr($line,72,3); |
| 720 | 720 | //$data['beam'] = substr($line,76,2); |
| 721 | - $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
| 721 | + $data['ident'] = trim(utf8_encode(substr($line, 78, 20))); |
|
| 722 | 722 | //$data['callsign'] = trim(substr($line,100,7); |
| 723 | - $data['arrival_code'] = substr($line,108,20); |
|
| 723 | + $data['arrival_code'] = substr($line, 108, 20); |
|
| 724 | 724 | //$data['etaDate'] = substr($line,129,5); |
| 725 | 725 | //$data['etaTime'] = substr($line,135,5); |
| 726 | 726 | $data['format_source'] = 'shipplotter'; |
@@ -740,21 +740,21 @@ discard block |
||
| 740 | 740 | ) |
| 741 | 741 | ) { |
| 742 | 742 | if ($globalDebug) echo '! Download... '; |
| 743 | - for ($i =0; $i <= 1; $i++) { |
|
| 743 | + for ($i = 0; $i <= 1; $i++) { |
|
| 744 | 744 | if ($globalDebug) echo 'Racetype: '.$i.' '; |
| 745 | 745 | $buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i); |
| 746 | 746 | if ($globalDebug) echo 'done'."\n"; |
| 747 | 747 | if ($buffer != '') { |
| 748 | - $all_data = json_decode($buffer,true); |
|
| 748 | + $all_data = json_decode($buffer, true); |
|
| 749 | 749 | if (isset($all_data['missions'])) { |
| 750 | 750 | foreach ($all_data['missions'] as $mission) { |
| 751 | 751 | $mission_user = $mission['usrname']; |
| 752 | - $mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$mission['mistitle']); |
|
| 753 | - if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) { |
|
| 752 | + $mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $mission['mistitle']); |
|
| 753 | + if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'], $globalFilter['sailway']['race']))) { |
|
| 754 | 754 | $bufferm = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']); |
| 755 | 755 | } else $bufferm = ''; |
| 756 | 756 | if ($bufferm != '') { |
| 757 | - $mission_data = json_decode($bufferm,true); |
|
| 757 | + $mission_data = json_decode($bufferm, true); |
|
| 758 | 758 | if (isset($mission_data['leaderboard'][0]['results'])) { |
| 759 | 759 | foreach ($mission_data['leaderboard'][0]['results'] as $sail) { |
| 760 | 760 | //print_r($sail); |
@@ -766,7 +766,7 @@ discard block |
||
| 766 | 766 | //$data['id'] = $sail['misnr'].'-'.$sail['usrnr'].'-'.$sail['ubtnr']; |
| 767 | 767 | $data['id'] = $sail['misnr'].'-'.$sail['usrnr']; |
| 768 | 768 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 769 | - $data['race_begin'] = date('Y-m-d H:i:s',strtotime($mission_data['leaderboard'][0]['misstart'])); |
|
| 769 | + $data['race_begin'] = date('Y-m-d H:i:s', strtotime($mission_data['leaderboard'][0]['misstart'])); |
|
| 770 | 770 | $data['last_update'] = date('Y-m-d H:i:s'); |
| 771 | 771 | $data['status'] = $sail['status']; |
| 772 | 772 | $data['type'] = $sail['btptype']; |
@@ -777,16 +777,16 @@ discard block |
||
| 777 | 777 | $data['longitude'] = $pos['longitude']; |
| 778 | 778 | } |
| 779 | 779 | if ($sail['status'] == 'Racing' && $sail['resultdescr'] != '-') { |
| 780 | - $resultdescr = explode(',',$sail['resultdescr']); |
|
| 780 | + $resultdescr = explode(',', $sail['resultdescr']); |
|
| 781 | 781 | if (count($resultdescr) > 2) { |
| 782 | - $data['speed'] = round(str_replace(array('Spd: ','kn.'),'',trim($resultdescr[2]))*1.852,2); |
|
| 783 | - $data['heading'] = str_replace(array('Hdg: ','°'),'',trim($resultdescr[1])); |
|
| 782 | + $data['speed'] = round(str_replace(array('Spd: ', 'kn.'), '', trim($resultdescr[2]))*1.852, 2); |
|
| 783 | + $data['heading'] = str_replace(array('Hdg: ', '°'), '', trim($resultdescr[1])); |
|
| 784 | 784 | if (isset($resultdescr[3])) { |
| 785 | - $data['distance'] = round(str_replace('nm.','',trim(explode(' ',$resultdescr[3])[1]))*1.852,3); |
|
| 785 | + $data['distance'] = round(str_replace('nm.', '', trim(explode(' ', $resultdescr[3])[1]))*1.852, 3); |
|
| 786 | 786 | } |
| 787 | 787 | } |
| 788 | 788 | } |
| 789 | - $data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$sail['ubtname'])); |
|
| 789 | + $data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $sail['ubtname'])); |
|
| 790 | 790 | $data['captain_id'] = $sail['usrnr']; |
| 791 | 791 | $data['captain_name'] = $sail['usrname']; |
| 792 | 792 | $data['race_id'] = $sail['misnr']; |
@@ -833,8 +833,8 @@ discard block |
||
| 833 | 833 | ) { |
| 834 | 834 | //$buffer = $Common->getData($hosts[$id]); |
| 835 | 835 | $buffer = $Common->getData($value['host']); |
| 836 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 837 | - $buffer = explode('\n',$buffer); |
|
| 836 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 837 | + $buffer = explode('\n', $buffer); |
|
| 838 | 838 | $reset = 0; |
| 839 | 839 | foreach ($buffer as $line) { |
| 840 | 840 | if ($line != '') { |
@@ -845,7 +845,7 @@ discard block |
||
| 845 | 845 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
| 846 | 846 | $data['pilot_id'] = $line[1]; |
| 847 | 847 | $data['pilot_name'] = $line[2]; |
| 848 | - $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
|
| 848 | + $data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT); |
|
| 849 | 849 | $data['ident'] = $line[0]; // ident |
| 850 | 850 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
| 851 | 851 | $data['speed'] = $line[8]; // speed |
@@ -861,7 +861,7 @@ discard block |
||
| 861 | 861 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
| 862 | 862 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
| 863 | 863 | $data['departure_airport_icao'] = $line[11]; |
| 864 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 864 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
| 865 | 865 | $data['arrival_airport_icao'] = $line[13]; |
| 866 | 866 | $data['frequency'] = $line[4]; |
| 867 | 867 | $data['type'] = $line[18]; |
@@ -870,7 +870,7 @@ discard block |
||
| 870 | 870 | $data['id_source'] = $id_source; |
| 871 | 871 | //$data['arrival_airport_time'] = ; |
| 872 | 872 | if ($line[9] != '') { |
| 873 | - $aircraft_data = explode('/',$line[9]); |
|
| 873 | + $aircraft_data = explode('/', $line[9]); |
|
| 874 | 874 | if (isset($aircraft_data[1])) { |
| 875 | 875 | $data['aircraft_icao'] = $aircraft_data[1]; |
| 876 | 876 | } |
@@ -885,9 +885,9 @@ discard block |
||
| 885 | 885 | if ($line[3] === 'PILOT') $SI->add($data); |
| 886 | 886 | elseif ($line[3] === 'ATC') { |
| 887 | 887 | //print_r($data); |
| 888 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
| 889 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
| 890 | - $typec = substr($data['ident'],-3); |
|
| 888 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
| 889 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
| 890 | + $typec = substr($data['ident'], -3); |
|
| 891 | 891 | if ($typec === 'APP') $data['type'] = 'Approach'; |
| 892 | 892 | elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
| 893 | 893 | elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
@@ -899,8 +899,8 @@ discard block |
||
| 899 | 899 | elseif ($data['type'] === '') $data['type'] = 'Observer'; |
| 900 | 900 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
| 901 | 901 | if (isset($ATC)) { |
| 902 | - if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
| 903 | - 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']); |
|
| 902 | + if (count($ATC->getByIdent($data['ident'], $data['format_source'])) > 0) echo $ATC->update($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']); |
|
| 903 | + 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']); |
|
| 904 | 904 | } |
| 905 | 905 | } |
| 906 | 906 | unset($data); |
@@ -916,24 +916,24 @@ discard block |
||
| 916 | 916 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 917 | 917 | ) |
| 918 | 918 | ) { |
| 919 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
| 919 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20'); |
|
| 920 | 920 | if ($buffer != '') { |
| 921 | 921 | $all_data = simplexml_load_string($buffer); |
| 922 | - foreach($all_data->children() as $childdata) { |
|
| 922 | + foreach ($all_data->children() as $childdata) { |
|
| 923 | 923 | $data = array(); |
| 924 | 924 | $line = $childdata; |
| 925 | 925 | //$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT); |
| 926 | - $data['id'] = date('Ymd').(int)$line['pktPilotID']; |
|
| 927 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
|
| 928 | - $data['latitude'] = (float)$line['pktLatitude']; |
|
| 929 | - $data['longitude'] = (float)$line['pktLongitude']; |
|
| 930 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
| 931 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
| 932 | - $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
|
| 926 | + $data['id'] = date('Ymd').(int) $line['pktPilotID']; |
|
| 927 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST')); |
|
| 928 | + $data['latitude'] = (float) $line['pktLatitude']; |
|
| 929 | + $data['longitude'] = (float) $line['pktLongitude']; |
|
| 930 | + if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack']; |
|
| 931 | + if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed']; |
|
| 932 | + $data['altitude'] = round((int) $line['pktAltitude']*3.28084); |
|
| 933 | 933 | $data['altitude_relative'] = 'AMSL'; |
| 934 | - $data['pilot_id'] = (int)$line['pktPilotID']; |
|
| 934 | + $data['pilot_id'] = (int) $line['pktPilotID']; |
|
| 935 | 935 | $data['aircraft_icao'] = 'PARAGLIDER'; |
| 936 | - $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
| 936 | + $pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
| 937 | 937 | if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
| 938 | 938 | $data['format_source'] = $value['format']; |
| 939 | 939 | $SI->add($data); |
@@ -941,22 +941,22 @@ discard block |
||
| 941 | 941 | } |
| 942 | 942 | } |
| 943 | 943 | $Source->deleteOldLocationByType('gs'); |
| 944 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
| 944 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20'); |
|
| 945 | 945 | if ($buffer != '') { |
| 946 | 946 | $all_data = simplexml_load_string($buffer); |
| 947 | - foreach($all_data->children() as $childdata) { |
|
| 947 | + foreach ($all_data->children() as $childdata) { |
|
| 948 | 948 | $data = array(); |
| 949 | 949 | $line = $childdata; |
| 950 | - $data['id'] = (int)$line['gsID']; |
|
| 951 | - $data['latitude'] = (float)$line['gsLatitude']; |
|
| 952 | - $data['longitude'] = (float)$line['gsLongitude']; |
|
| 953 | - $data['altitude'] = round((int)$line['gsHeight']*3.28084); |
|
| 950 | + $data['id'] = (int) $line['gsID']; |
|
| 951 | + $data['latitude'] = (float) $line['gsLatitude']; |
|
| 952 | + $data['longitude'] = (float) $line['gsLongitude']; |
|
| 953 | + $data['altitude'] = round((int) $line['gsHeight']*3.28084); |
|
| 954 | 954 | $data['altitude_relative'] = 'AMSL'; |
| 955 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST')); |
|
| 955 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST')); |
|
| 956 | 956 | if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) { |
| 957 | - $Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
| 957 | + $Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
| 958 | 958 | } else { |
| 959 | - $Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
| 959 | + $Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
| 960 | 960 | } |
| 961 | 961 | unset($data); |
| 962 | 962 | } |
@@ -974,9 +974,9 @@ discard block |
||
| 974 | 974 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 975 | 975 | ) |
| 976 | 976 | ) { |
| 977 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 977 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
| 978 | 978 | if ($buffer != '') { |
| 979 | - $all_data = json_decode($buffer,true); |
|
| 979 | + $all_data = json_decode($buffer, true); |
|
| 980 | 980 | if (isset($all_data['acList'])) { |
| 981 | 981 | $reset = 0; |
| 982 | 982 | foreach ($all_data['acList'] as $line) { |
@@ -992,7 +992,7 @@ discard block |
||
| 992 | 992 | if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
| 993 | 993 | $data['emergency'] = ''; // emergency |
| 994 | 994 | if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
| 995 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 995 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
| 996 | 996 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 997 | 997 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 998 | 998 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
@@ -1017,7 +1017,7 @@ discard block |
||
| 1017 | 1017 | $data['verticalrate'] = $line['vrt']; // verticale rate |
| 1018 | 1018 | $data['squawk'] = $line['squawk']; // squawk |
| 1019 | 1019 | $data['emergency'] = ''; // emergency |
| 1020 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1020 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
| 1021 | 1021 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 1022 | 1022 | $data['format_source'] = 'aircraftlistjson'; |
| 1023 | 1023 | $data['id_source'] = $id_source; |
@@ -1038,7 +1038,7 @@ discard block |
||
| 1038 | 1038 | ) |
| 1039 | 1039 | ) { |
| 1040 | 1040 | $buffer = $Common->getData($value['host']); |
| 1041 | - $all_data = json_decode($buffer,true); |
|
| 1041 | + $all_data = json_decode($buffer, true); |
|
| 1042 | 1042 | if (isset($all_data['planes'])) { |
| 1043 | 1043 | $reset = 0; |
| 1044 | 1044 | foreach ($all_data['planes'] as $key => $line) { |
@@ -1055,12 +1055,12 @@ discard block |
||
| 1055 | 1055 | $data['emergency'] = ''; // emergency |
| 1056 | 1056 | $data['registration'] = $line[2]; |
| 1057 | 1057 | $data['aircraft_icao'] = $line[0]; |
| 1058 | - $deparr = explode('-',$line[1]); |
|
| 1058 | + $deparr = explode('-', $line[1]); |
|
| 1059 | 1059 | if (count($deparr) === 2) { |
| 1060 | 1060 | $data['departure_airport_icao'] = $deparr[0]; |
| 1061 | 1061 | $data['arrival_airport_icao'] = $deparr[1]; |
| 1062 | 1062 | } |
| 1063 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 1063 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
| 1064 | 1064 | $data['format_source'] = 'planeupdatefaa'; |
| 1065 | 1065 | $data['id_source'] = $id_source; |
| 1066 | 1066 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -1078,7 +1078,7 @@ discard block |
||
| 1078 | 1078 | ) |
| 1079 | 1079 | ) { |
| 1080 | 1080 | $buffer = $Common->getData($value['host']); |
| 1081 | - $all_data = json_decode($buffer,true); |
|
| 1081 | + $all_data = json_decode($buffer, true); |
|
| 1082 | 1082 | if (isset($all_data['states'])) { |
| 1083 | 1083 | $reset = 0; |
| 1084 | 1084 | foreach ($all_data['states'] as $key => $line) { |
@@ -1095,7 +1095,7 @@ discard block |
||
| 1095 | 1095 | //$data['emergency'] = ''; // emergency |
| 1096 | 1096 | //$data['registration'] = $line[2]; |
| 1097 | 1097 | //$data['aircraft_icao'] = $line[0]; |
| 1098 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 1098 | + $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
| 1099 | 1099 | $data['format_source'] = 'opensky'; |
| 1100 | 1100 | $data['id_source'] = $id_source; |
| 1101 | 1101 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -1112,8 +1112,8 @@ discard block |
||
| 1112 | 1112 | ) |
| 1113 | 1113 | ) { |
| 1114 | 1114 | $buffer = $Common->getData($value['host']); |
| 1115 | - $all_data = json_decode($buffer,true); |
|
| 1116 | - if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) { |
|
| 1115 | + $all_data = json_decode($buffer, true); |
|
| 1116 | + if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time() - 1800) { |
|
| 1117 | 1117 | $reset = 0; |
| 1118 | 1118 | foreach ($all_data['aircraft'] as $key => $line) { |
| 1119 | 1119 | $data = array(); |
@@ -1151,7 +1151,7 @@ discard block |
||
| 1151 | 1151 | ) |
| 1152 | 1152 | ) { |
| 1153 | 1153 | $buffer = $Common->getData($value['host']); |
| 1154 | - $all_data = json_decode($buffer,true); |
|
| 1154 | + $all_data = json_decode($buffer, true); |
|
| 1155 | 1155 | if (isset($all_data['aircraft'])) { |
| 1156 | 1156 | $reset = 0; |
| 1157 | 1157 | foreach ($all_data['aircraft'] as $key => $line) { |
@@ -1168,7 +1168,7 @@ discard block |
||
| 1168 | 1168 | //$data['emergency'] = ''; // emergency |
| 1169 | 1169 | if (isset($line['reg'])) $data['registration'] = $line['reg']; |
| 1170 | 1170 | if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
| 1171 | - $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
|
| 1171 | + $data['datetime'] = date('Y-m-d H:i:s', $line['pos_update_time']); |
|
| 1172 | 1172 | $data['format_source'] = 'planefinderclient'; |
| 1173 | 1173 | $data['id_source'] = $id_source; |
| 1174 | 1174 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -1187,7 +1187,7 @@ discard block |
||
| 1187 | 1187 | ) { |
| 1188 | 1188 | //$buffer = $Common->getData($hosts[$id]); |
| 1189 | 1189 | $buffer = $Common->getData($value['host']); |
| 1190 | - $all_data = json_decode($buffer,true); |
|
| 1190 | + $all_data = json_decode($buffer, true); |
|
| 1191 | 1191 | if (!empty($all_data)) $reset = 0; |
| 1192 | 1192 | foreach ($all_data as $key => $line) { |
| 1193 | 1193 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
@@ -1225,11 +1225,11 @@ discard block |
||
| 1225 | 1225 | ) |
| 1226 | 1226 | ) { |
| 1227 | 1227 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
| 1228 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 1228 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
| 1229 | 1229 | //echo $buffer; |
| 1230 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 1231 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 1232 | - $all_data = json_decode($buffer,true); |
|
| 1230 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
| 1231 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
| 1232 | + $all_data = json_decode($buffer, true); |
|
| 1233 | 1233 | if (json_last_error() != JSON_ERROR_NONE) { |
| 1234 | 1234 | die(json_last_error_msg()); |
| 1235 | 1235 | } |
@@ -1252,7 +1252,7 @@ discard block |
||
| 1252 | 1252 | //$data['departure_airport_iata'] = $line[11]; |
| 1253 | 1253 | //$data['arrival_airport_iata'] = $line[12]; |
| 1254 | 1254 | //$data['emergency'] = ''; // emergency |
| 1255 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
| 1255 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
| 1256 | 1256 | $data['format_source'] = 'radarvirtueljson'; |
| 1257 | 1257 | $data['id_source'] = $id_source; |
| 1258 | 1258 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -1273,14 +1273,14 @@ discard block |
||
| 1273 | 1273 | ) { |
| 1274 | 1274 | //$buffer = $Common->getData($hosts[$id]); |
| 1275 | 1275 | $buffer = $Common->getData($value['host'].'?'.time()); |
| 1276 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
| 1276 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
| 1277 | 1277 | |
| 1278 | 1278 | if (isset($all_data['pireps'])) { |
| 1279 | 1279 | $reset = 0; |
| 1280 | 1280 | foreach ($all_data['pireps'] as $line) { |
| 1281 | 1281 | $data = array(); |
| 1282 | 1282 | $data['id'] = $line['id']; |
| 1283 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 1283 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
| 1284 | 1284 | $data['ident'] = $line['callsign']; // ident |
| 1285 | 1285 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
| 1286 | 1286 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -1310,9 +1310,9 @@ discard block |
||
| 1310 | 1310 | $SI->add($data); |
| 1311 | 1311 | // print_r($data); |
| 1312 | 1312 | } elseif ($line['icon'] === 'ct') { |
| 1313 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
| 1314 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
| 1315 | - $typec = substr($data['ident'],-3); |
|
| 1313 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
| 1314 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
| 1315 | + $typec = substr($data['ident'], -3); |
|
| 1316 | 1316 | $data['type'] = ''; |
| 1317 | 1317 | if ($typec === 'APP') $data['type'] = 'Approach'; |
| 1318 | 1318 | elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
@@ -1323,7 +1323,7 @@ discard block |
||
| 1323 | 1323 | elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
| 1324 | 1324 | elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 1325 | 1325 | else $data['type'] = 'Observer'; |
| 1326 | - 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']); |
|
| 1326 | + 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']); |
|
| 1327 | 1327 | } |
| 1328 | 1328 | unset($data); |
| 1329 | 1329 | } |
@@ -1340,14 +1340,14 @@ discard block |
||
| 1340 | 1340 | //$buffer = $Common->getData($hosts[$id]); |
| 1341 | 1341 | if ($globalDebug) echo 'Get Data...'."\n"; |
| 1342 | 1342 | $buffer = $Common->getData($value['host']); |
| 1343 | - $all_data = json_decode($buffer,true); |
|
| 1343 | + $all_data = json_decode($buffer, true); |
|
| 1344 | 1344 | if ($buffer != '' && is_array($all_data)) { |
| 1345 | 1345 | $reset = 0; |
| 1346 | 1346 | foreach ($all_data as $line) { |
| 1347 | 1347 | $data = array(); |
| 1348 | 1348 | //$data['id'] = $line['id']; // id not usable |
| 1349 | 1349 | if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
| 1350 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1350 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
| 1351 | 1351 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
| 1352 | 1352 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
| 1353 | 1353 | $data['ident'] = $line['flightnum']; // ident |
@@ -1362,7 +1362,7 @@ discard block |
||
| 1362 | 1362 | //$data['datetime'] = $line['lastupdate']; |
| 1363 | 1363 | //$data['last_update'] = $line['lastupdate']; |
| 1364 | 1364 | if (isset($value['timezone'])) { |
| 1365 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
| 1365 | + $datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone'])); |
|
| 1366 | 1366 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
| 1367 | 1367 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1368 | 1368 | } else $data['datetime'] = date('Y-m-d H:i:s'); |
@@ -1378,14 +1378,14 @@ discard block |
||
| 1378 | 1378 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
| 1379 | 1379 | if (isset($line['aircraftname'])) { |
| 1380 | 1380 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 1381 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
| 1382 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
| 1381 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
| 1382 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
| 1383 | 1383 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
| 1384 | 1384 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
| 1385 | 1385 | else { |
| 1386 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 1387 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1388 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1386 | + $aircraft_data = explode(' ', $line['aircraftname']); |
|
| 1387 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]); |
|
| 1388 | + else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']); |
|
| 1389 | 1389 | } |
| 1390 | 1390 | } |
| 1391 | 1391 | if (isset($line['route'])) $data['waypoints'] = $line['route']; |
@@ -1410,7 +1410,7 @@ discard block |
||
| 1410 | 1410 | //$buffer = $Common->getData($hosts[$id]); |
| 1411 | 1411 | if ($globalDebug) echo 'Get Data...'."\n"; |
| 1412 | 1412 | $buffer = $Common->getData($value['host']); |
| 1413 | - $all_data = json_decode($buffer,true); |
|
| 1413 | + $all_data = json_decode($buffer, true); |
|
| 1414 | 1414 | if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
| 1415 | 1415 | $reset = 0; |
| 1416 | 1416 | foreach ($all_data['ACARSData'] as $line) { |
@@ -1421,7 +1421,7 @@ discard block |
||
| 1421 | 1421 | //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
| 1422 | 1422 | if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
| 1423 | 1423 | if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
| 1424 | - $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
| 1424 | + $data['ident'] = str_replace(' ', '', $line['bid']['flightnum']); // ident |
|
| 1425 | 1425 | if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
| 1426 | 1426 | $data['altitude'] = $line['altitude']; // altitude |
| 1427 | 1427 | $data['speed'] = $line['groundspeed']; // speed |
@@ -1432,7 +1432,7 @@ discard block |
||
| 1432 | 1432 | //$data['squawk'] = ''; // squawk |
| 1433 | 1433 | //$data['emergency'] = ''; // emergency |
| 1434 | 1434 | if (isset($value['timezone'])) { |
| 1435 | - $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
| 1435 | + $datetime = new DateTime($line['updated_at'], new DateTimeZone($value['timezone'])); |
|
| 1436 | 1436 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
| 1437 | 1437 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1438 | 1438 | } else $data['datetime'] = date('Y-m-d H:i:s'); |
@@ -1468,14 +1468,14 @@ discard block |
||
| 1468 | 1468 | //$buffer = $Common->getData($hosts[$id]); |
| 1469 | 1469 | if ($globalDebug) echo 'Get Data...'."\n"; |
| 1470 | 1470 | $buffer = $Common->getData($value['host']); |
| 1471 | - $all_data = json_decode($buffer,true); |
|
| 1471 | + $all_data = json_decode($buffer, true); |
|
| 1472 | 1472 | if ($buffer != '' && is_array($all_data)) { |
| 1473 | 1473 | $reset = 0; |
| 1474 | 1474 | foreach ($all_data as $line) { |
| 1475 | 1475 | $data = array(); |
| 1476 | 1476 | //$data['id'] = $line['id']; // id not usable |
| 1477 | 1477 | $data['id'] = trim($line['flight_id']); |
| 1478 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1478 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
| 1479 | 1479 | $data['pilot_name'] = $line['pilot_name']; |
| 1480 | 1480 | $data['pilot_id'] = $line['pilot_id']; |
| 1481 | 1481 | $data['ident'] = trim($line['callsign']); // ident |
@@ -1519,24 +1519,24 @@ discard block |
||
| 1519 | 1519 | //$buffer = $Common->getData($hosts[$id]); |
| 1520 | 1520 | if ($globalDebug) echo 'Get Data...'."\n"; |
| 1521 | 1521 | $buffer = $Common->getData($value['host']); |
| 1522 | - $all_data = json_decode($buffer,true); |
|
| 1522 | + $all_data = json_decode($buffer, true); |
|
| 1523 | 1523 | if ($buffer != '') { |
| 1524 | 1524 | $Source->deleteLocationBySource('blitzortung'); |
| 1525 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 1526 | - $buffer = explode('\n',$buffer); |
|
| 1525 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 1526 | + $buffer = explode('\n', $buffer); |
|
| 1527 | 1527 | foreach ($buffer as $buffer_line) { |
| 1528 | - $line = json_decode($buffer_line,true); |
|
| 1528 | + $line = json_decode($buffer_line, true); |
|
| 1529 | 1529 | if (isset($line['time'])) { |
| 1530 | 1530 | $data = array(); |
| 1531 | 1531 | $data['altitude'] = $line['alt']; // altitude |
| 1532 | 1532 | $data['latitude'] = $line['lat']; // lat |
| 1533 | 1533 | $data['longitude'] = $line['lon']; // long |
| 1534 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10)); |
|
| 1534 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10)); |
|
| 1535 | 1535 | $data['id_source'] = $id_source; |
| 1536 | 1536 | $data['format_source'] = 'blitzortung'; |
| 1537 | 1537 | $SI->add($data); |
| 1538 | 1538 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
| 1539 | - $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
|
| 1539 | + $Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']); |
|
| 1540 | 1540 | unset($data); |
| 1541 | 1541 | } |
| 1542 | 1542 | } |
@@ -1559,11 +1559,11 @@ discard block |
||
| 1559 | 1559 | //$value = $formats[$nb]; |
| 1560 | 1560 | $format = $globalSources[$nb]['format']; |
| 1561 | 1561 | if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
| 1562 | - $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
|
| 1562 | + $buffer = @socket_read($r, 6000, PHP_NORMAL_READ); |
|
| 1563 | 1563 | } elseif ($format === 'vrstcp') { |
| 1564 | 1564 | $buffer = @socket_read($r, 6000); |
| 1565 | 1565 | } else { |
| 1566 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
| 1566 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
| 1567 | 1567 | } |
| 1568 | 1568 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
| 1569 | 1569 | //echo $buffer."\n"; |
@@ -1573,8 +1573,8 @@ discard block |
||
| 1573 | 1573 | //$SI::del(); |
| 1574 | 1574 | if ($buffer !== FALSE) { |
| 1575 | 1575 | if ($format === 'vrstcp') { |
| 1576 | - $buffer = explode('},{',$buffer); |
|
| 1577 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 1576 | + $buffer = explode('},{', $buffer); |
|
| 1577 | + } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
| 1578 | 1578 | } |
| 1579 | 1579 | // SBS format is CSV format |
| 1580 | 1580 | if ($buffer !== FALSE && $buffer !== '') { |
@@ -1598,7 +1598,7 @@ discard block |
||
| 1598 | 1598 | $ais_data = $AIS->parse_line(trim($buffer)); |
| 1599 | 1599 | $data = array(); |
| 1600 | 1600 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
| 1601 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 1601 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9); |
|
| 1602 | 1602 | if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
| 1603 | 1603 | if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
| 1604 | 1604 | if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
@@ -1609,13 +1609,13 @@ discard block |
||
| 1609 | 1609 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
| 1610 | 1610 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
| 1611 | 1611 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
| 1612 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1612 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
| 1613 | 1613 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1614 | 1614 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
| 1615 | 1615 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
| 1616 | 1616 | |
| 1617 | 1617 | if (isset($ais_data['timestamp'])) { |
| 1618 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 1618 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
| 1619 | 1619 | } else { |
| 1620 | 1620 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1621 | 1621 | } |
@@ -1626,10 +1626,10 @@ discard block |
||
| 1626 | 1626 | } elseif ($format === 'flightgearsp') { |
| 1627 | 1627 | //echo $buffer."\n"; |
| 1628 | 1628 | if (strlen($buffer) > 5) { |
| 1629 | - $line = explode(',',$buffer); |
|
| 1629 | + $line = explode(',', $buffer); |
|
| 1630 | 1630 | $data = array(); |
| 1631 | 1631 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
| 1632 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
| 1632 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
| 1633 | 1633 | $data['ident'] = $line[6]; |
| 1634 | 1634 | $data['aircraft_name'] = $line[7]; |
| 1635 | 1635 | $data['longitude'] = $line[1]; |
@@ -1646,16 +1646,16 @@ discard block |
||
| 1646 | 1646 | } elseif ($format === 'acars') { |
| 1647 | 1647 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
| 1648 | 1648 | $ACARS->add(trim($buffer)); |
| 1649 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1649 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
| 1650 | 1650 | $ACARS->deleteLiveAcarsData(); |
| 1651 | 1651 | } elseif ($format === 'flightgearmp') { |
| 1652 | - if (substr($buffer,0,1) != '#') { |
|
| 1652 | + if (substr($buffer, 0, 1) != '#') { |
|
| 1653 | 1653 | $data = array(); |
| 1654 | 1654 | //echo $buffer."\n"; |
| 1655 | - $line = explode(' ',$buffer); |
|
| 1655 | + $line = explode(' ', $buffer); |
|
| 1656 | 1656 | if (count($line) === 11) { |
| 1657 | - $userserver = explode('@',$line[0]); |
|
| 1658 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 1657 | + $userserver = explode('@', $line[0]); |
|
| 1658 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
| 1659 | 1659 | $data['ident'] = $userserver[0]; |
| 1660 | 1660 | $data['registration'] = $userserver[0]; |
| 1661 | 1661 | $data['latitude'] = $line[4]; |
@@ -1663,8 +1663,8 @@ discard block |
||
| 1663 | 1663 | $data['altitude'] = $line[6]; |
| 1664 | 1664 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1665 | 1665 | $aircraft_type = $line[10]; |
| 1666 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 1667 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 1666 | + $aircraft_type = preg_split(':/:', $aircraft_type); |
|
| 1667 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
| 1668 | 1668 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1669 | 1669 | if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1670 | 1670 | } |
@@ -1673,8 +1673,8 @@ discard block |
||
| 1673 | 1673 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
| 1674 | 1674 | die; |
| 1675 | 1675 | } elseif ($format === 'vrstcp') { |
| 1676 | - foreach($buffer as $all_data) { |
|
| 1677 | - $line = json_decode('{'.$all_data.'}',true); |
|
| 1676 | + foreach ($buffer as $all_data) { |
|
| 1677 | + $line = json_decode('{'.$all_data.'}', true); |
|
| 1678 | 1678 | $data = array(); |
| 1679 | 1679 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
| 1680 | 1680 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -1700,16 +1700,16 @@ discard block |
||
| 1700 | 1700 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
| 1701 | 1701 | unset($data); |
| 1702 | 1702 | } |
| 1703 | - } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
|
| 1703 | + } elseif ($format === 'tsv' || substr($buffer, 0, 4) === 'clock') { |
|
| 1704 | 1704 | $line = explode("\t", $buffer); |
| 1705 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
| 1705 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
| 1706 | 1706 | $key = $line[$k]; |
| 1707 | - $lined[$key] = $line[$k+1]; |
|
| 1707 | + $lined[$key] = $line[$k + 1]; |
|
| 1708 | 1708 | } |
| 1709 | 1709 | if (count($lined) > 3) { |
| 1710 | 1710 | $data['hex'] = $lined['hexid']; |
| 1711 | 1711 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
| 1712 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 1712 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
| 1713 | 1713 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
| 1714 | 1714 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
| 1715 | 1715 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -1728,23 +1728,23 @@ discard block |
||
| 1728 | 1728 | } else $error = true; |
| 1729 | 1729 | } elseif ($format === 'aprs' && $use_aprs) { |
| 1730 | 1730 | if ($aprs_connect === 0) { |
| 1731 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
| 1731 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
| 1732 | 1732 | $aprs_connect = 1; |
| 1733 | 1733 | } |
| 1734 | 1734 | |
| 1735 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 1735 | + if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
| 1736 | 1736 | $aprs_last_tx = time(); |
| 1737 | 1737 | $data_aprs = "# Keep alive"; |
| 1738 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
| 1738 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
| 1739 | 1739 | } |
| 1740 | 1740 | |
| 1741 | 1741 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
| 1742 | 1742 | //echo 'APRS data : '.$buffer."\n"; |
| 1743 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
| 1744 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
| 1743 | + $buffer = str_replace('APRS <- ', '', $buffer); |
|
| 1744 | + $buffer = str_replace('APRS -> ', '', $buffer); |
|
| 1745 | 1745 | //echo $buffer."\n"; |
| 1746 | 1746 | date_default_timezone_set('UTC'); |
| 1747 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 1747 | + if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { |
|
| 1748 | 1748 | $line = $APRS->parse($buffer); |
| 1749 | 1749 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
| 1750 | 1750 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
@@ -1759,7 +1759,7 @@ discard block |
||
| 1759 | 1759 | if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
| 1760 | 1760 | if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
| 1761 | 1761 | if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
| 1762 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1762 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
| 1763 | 1763 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 1764 | 1764 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 1765 | 1765 | if (isset($line['ident'])) $data['ident'] = $line['ident']; |
@@ -1847,29 +1847,29 @@ discard block |
||
| 1847 | 1847 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
| 1848 | 1848 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
| 1849 | 1849 | $Source->deleteOldLocationByType('gs'); |
| 1850 | - if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
|
| 1851 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
| 1850 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) { |
|
| 1851 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
| 1852 | 1852 | } else { |
| 1853 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
| 1853 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
| 1854 | 1854 | } |
| 1855 | 1855 | } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
| 1856 | 1856 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 1857 | 1857 | if ($globalDebug) echo '# Weather Station added'."\n"; |
| 1858 | 1858 | $Source->deleteOldLocationByType('wx'); |
| 1859 | 1859 | $weather_data = json_encode($line); |
| 1860 | - if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
|
| 1861 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
|
| 1860 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) { |
|
| 1861 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); |
|
| 1862 | 1862 | } else { |
| 1863 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
|
| 1863 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); |
|
| 1864 | 1864 | } |
| 1865 | 1865 | } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
| 1866 | 1866 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 1867 | 1867 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
| 1868 | 1868 | $Source->deleteOldLocationByType('lightning'); |
| 1869 | - if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
|
| 1870 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
|
| 1869 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) { |
|
| 1870 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); |
|
| 1871 | 1871 | } else { |
| 1872 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
|
| 1872 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); |
|
| 1873 | 1873 | } |
| 1874 | 1874 | } elseif ($globalDebug) { |
| 1875 | 1875 | echo '/!\ Not added: '.$buffer."\n"; |
@@ -1878,7 +1878,7 @@ discard block |
||
| 1878 | 1878 | unset($data); |
| 1879 | 1879 | } |
| 1880 | 1880 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
| 1881 | - $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
|
| 1881 | + $Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']); |
|
| 1882 | 1882 | } |
| 1883 | 1883 | /* |
| 1884 | 1884 | elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] === 'Car' || $line['symbol'] === 'Ambulance' || $line['symbol'] === 'Van' || $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || $line['symbol'] === 'Motorcycle')) { |
@@ -1887,7 +1887,7 @@ discard block |
||
| 1887 | 1887 | */ |
| 1888 | 1888 | //elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
| 1889 | 1889 | elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
| 1890 | - if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
|
| 1890 | + if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) { |
|
| 1891 | 1891 | $Source->deleteOldLocationByType('lightning'); |
| 1892 | 1892 | $Source->deleteOldLocationByType('wx'); |
| 1893 | 1893 | $globalSources[$nb]['last_weather_clean'] = time(); |
@@ -1973,7 +1973,7 @@ discard block |
||
| 1973 | 1973 | connect_all($sourceee); |
| 1974 | 1974 | $sourceee = array(); |
| 1975 | 1975 | //connect_all($globalSources); |
| 1976 | - $tt[$format]=0; |
|
| 1976 | + $tt[$format] = 0; |
|
| 1977 | 1977 | break; |
| 1978 | 1978 | } |
| 1979 | 1979 | //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
@@ -1983,14 +1983,14 @@ discard block |
||
| 1983 | 1983 | } else { |
| 1984 | 1984 | $error = socket_strerror(socket_last_error()); |
| 1985 | 1985 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 1986 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 1986 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
| 1987 | 1987 | if (isset($globalDebug)) echo "Restarting...\n"; |
| 1988 | 1988 | // Restart the script if possible |
| 1989 | 1989 | if (is_array($sockets)) { |
| 1990 | 1990 | if ($globalDebug) echo "Shutdown all sockets..."; |
| 1991 | 1991 | |
| 1992 | 1992 | foreach ($sockets as $sock) { |
| 1993 | - @socket_shutdown($sock,2); |
|
| 1993 | + @socket_shutdown($sock, 2); |
|
| 1994 | 1994 | @socket_close($sock); |
| 1995 | 1995 | } |
| 1996 | 1996 | |
@@ -14,13 +14,17 @@ discard block |
||
| 14 | 14 | require_once(dirname(__FILE__).'/../require/class.Source.php'); |
| 15 | 15 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
| 16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
| 17 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 17 | +if (isset($globalTracker) && $globalTracker) { |
|
| 18 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 19 | +} |
|
| 18 | 20 | if (isset($globalMarine) && $globalMarine) { |
| 19 | 21 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
| 20 | 22 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
| 21 | 23 | } |
| 22 | 24 | |
| 23 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
| 25 | +if (!isset($globalDebug)) { |
|
| 26 | + $globalDebug = FALSE; |
|
| 27 | +} |
|
| 24 | 28 | |
| 25 | 29 | // Check if schema is at latest version |
| 26 | 30 | $Connection = new Connection(); |
@@ -59,66 +63,107 @@ discard block |
||
| 59 | 63 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 60 | 64 | if (isset($options['s'])) { |
| 61 | 65 | $globalSources = array(); |
| 62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 63 | - else $globalSources[] = array('host' => $options['s']); |
|
| 64 | -} elseif (isset($options['source'])) { |
|
| 66 | + if (isset($options['format'])) { |
|
| 67 | + $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 68 | + } else { |
|
| 69 | + $globalSources[] = array('host' => $options['s']); |
|
| 70 | + } |
|
| 71 | + } elseif (isset($options['source'])) { |
|
| 65 | 72 | $globalSources = array(); |
| 66 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 67 | - else $globalSources[] = array('host' => $options['source']); |
|
| 68 | -} |
|
| 73 | + if (isset($options['format'])) { |
|
| 74 | + $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 75 | + } else { |
|
| 76 | + $globalSources[] = array('host' => $options['source']); |
|
| 77 | + } |
|
| 78 | + } |
|
| 69 | 79 | if (isset($options['aprsserverhost'])) { |
| 70 | 80 | $globalServerAPRS = TRUE; |
| 71 | 81 | $globalServerAPRShost = $options['aprsserverhost']; |
| 72 | 82 | } |
| 73 | -if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport']; |
|
| 74 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
|
| 75 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
|
| 76 | -if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; |
|
| 83 | +if (isset($options['aprsserverport'])) { |
|
| 84 | + $globalServerAPRSport = $options['aprsserverport']; |
|
| 85 | +} |
|
| 86 | +if (isset($options['aprsserverssid'])) { |
|
| 87 | + $globalServerAPRSssid = $options['aprsserverssid']; |
|
| 88 | +} |
|
| 89 | +if (isset($options['aprsserverpass'])) { |
|
| 90 | + $globalServerAPRSpass = $options['aprsserverpass']; |
|
| 91 | +} |
|
| 92 | +if (isset($options['noaprsserver'])) { |
|
| 93 | + $globalServerAPRS = FALSE; |
|
| 94 | +} |
|
| 77 | 95 | if (isset($options['enable-aircraft'])) { |
| 78 | - if ($globalDebug) echo 'Enable Aircraft mode'."\n"; |
|
| 96 | + if ($globalDebug) { |
|
| 97 | + echo 'Enable Aircraft mode'."\n"; |
|
| 98 | + } |
|
| 79 | 99 | $globalAircraft = TRUE; |
| 80 | 100 | } |
| 81 | 101 | if (isset($options['disable-aircraft'])) { |
| 82 | - if ($globalDebug) echo 'Disable Aircraft mode'."\n"; |
|
| 102 | + if ($globalDebug) { |
|
| 103 | + echo 'Disable Aircraft mode'."\n"; |
|
| 104 | + } |
|
| 83 | 105 | $globalAircraft = FALSE; |
| 84 | 106 | } |
| 85 | 107 | if (isset($options['enable-tracker'])) { |
| 86 | - if ($globalDebug) echo 'Enable Tracker mode'."\n"; |
|
| 108 | + if ($globalDebug) { |
|
| 109 | + echo 'Enable Tracker mode'."\n"; |
|
| 110 | + } |
|
| 87 | 111 | $globalTracker = TRUE; |
| 88 | 112 | } |
| 89 | 113 | if (isset($options['disable-tracker'])) { |
| 90 | - if ($globalDebug) echo 'Disable Tracker mode'."\n"; |
|
| 114 | + if ($globalDebug) { |
|
| 115 | + echo 'Disable Tracker mode'."\n"; |
|
| 116 | + } |
|
| 91 | 117 | $globalTracker = FALSE; |
| 92 | 118 | } |
| 93 | 119 | if (isset($options['enable-marine'])) { |
| 94 | - if ($globalDebug) echo 'Enable Marine mode'."\n"; |
|
| 120 | + if ($globalDebug) { |
|
| 121 | + echo 'Enable Marine mode'."\n"; |
|
| 122 | + } |
|
| 95 | 123 | $globalMarine = TRUE; |
| 96 | 124 | } |
| 97 | 125 | if (isset($options['disable-marine'])) { |
| 98 | - if ($globalDebug) echo 'Disable Marine mode'."\n"; |
|
| 126 | + if ($globalDebug) { |
|
| 127 | + echo 'Disable Marine mode'."\n"; |
|
| 128 | + } |
|
| 99 | 129 | $globalMarine = FALSE; |
| 100 | 130 | } |
| 101 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; |
|
| 102 | -if (isset($options['server'])) $globalServer = TRUE; |
|
| 103 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
| 104 | -else $id_source = 1; |
|
| 131 | +if (isset($options['nodaemon'])) { |
|
| 132 | + $globalDaemon = FALSE; |
|
| 133 | +} |
|
| 134 | +if (isset($options['server'])) { |
|
| 135 | + $globalServer = TRUE; |
|
| 136 | +} |
|
| 137 | +if (isset($options['idsource'])) { |
|
| 138 | + $id_source = $options['idsource']; |
|
| 139 | +} else { |
|
| 140 | + $id_source = 1; |
|
| 141 | +} |
|
| 105 | 142 | if (isset($globalServer) && $globalServer) { |
| 106 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 143 | + if ($globalDebug) { |
|
| 144 | + echo "Using Server Mode\n"; |
|
| 145 | + } |
|
| 107 | 146 | $SI=new SpotterServer(); |
| 108 | 147 | /* |
| 109 | 148 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 110 | 149 | $SI = new adsb2aprs(); |
| 111 | 150 | $SI->connect(); |
| 112 | 151 | */ |
| 113 | -} else $SI=new SpotterImport($Connection->db); |
|
| 152 | +} else { |
|
| 153 | + $SI=new SpotterImport($Connection->db); |
|
| 154 | +} |
|
| 114 | 155 | |
| 115 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 156 | +if (isset($globalTracker) && $globalTracker) { |
|
| 157 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 158 | +} |
|
| 116 | 159 | if (isset($globalMarine) && $globalMarine) { |
| 117 | 160 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
| 118 | 161 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
| 119 | 162 | } |
| 120 | 163 | |
| 121 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
| 164 | +if (isset($globalTracker) && $globalTracker) { |
|
| 165 | + $TI = new TrackerImport($Connection->db); |
|
| 166 | +} |
|
| 122 | 167 | if (isset($globalMarine) && $globalMarine) { |
| 123 | 168 | $AIS = new AIS(); |
| 124 | 169 | $MI = new MarineImport($Connection->db); |
@@ -143,7 +188,9 @@ discard block |
||
| 143 | 188 | } |
| 144 | 189 | |
| 145 | 190 | // let's try and connect |
| 146 | -if ($globalDebug) echo "Connecting...\n"; |
|
| 191 | +if ($globalDebug) { |
|
| 192 | + echo "Connecting...\n"; |
|
| 193 | +} |
|
| 147 | 194 | $use_aprs = false; |
| 148 | 195 | $aprs_full = false; |
| 149 | 196 | $reset = 0; |
@@ -152,7 +199,9 @@ discard block |
||
| 152 | 199 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
| 153 | 200 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
| 154 | 201 | $reset++; |
| 155 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 202 | + if ($globalDebug) { |
|
| 203 | + echo 'Connect to all...'."\n"; |
|
| 204 | + } |
|
| 156 | 205 | foreach ($hosts as $id => $value) { |
| 157 | 206 | $host = $value['host']; |
| 158 | 207 | $globalSources[$id]['last_exec'] = 0; |
@@ -162,32 +211,44 @@ discard block |
||
| 162 | 211 | //$formats[$id] = 'deltadbtxt'; |
| 163 | 212 | $globalSources[$id]['format'] = 'deltadbtxt'; |
| 164 | 213 | //$last_exec['deltadbtxt'] = 0; |
| 165 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 214 | + if ($globalDebug) { |
|
| 215 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
| 216 | + } |
|
| 166 | 217 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
| 167 | 218 | //$formats[$id] = 'vatsimtxt'; |
| 168 | 219 | $globalSources[$id]['format'] = 'vatsimtxt'; |
| 169 | 220 | //$last_exec['vatsimtxt'] = 0; |
| 170 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 221 | + if ($globalDebug) { |
|
| 222 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
| 223 | + } |
|
| 171 | 224 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
| 172 | 225 | //$formats[$id] = 'aircraftlistjson'; |
| 173 | 226 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
| 174 | 227 | //$last_exec['aircraftlistjson'] = 0; |
| 175 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 228 | + if ($globalDebug) { |
|
| 229 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 230 | + } |
|
| 176 | 231 | } else if (preg_match('/aircraft.json$/i',$host)) { |
| 177 | 232 | //$formats[$id] = 'aircraftjson'; |
| 178 | 233 | $globalSources[$id]['format'] = 'aircraftjson'; |
| 179 | 234 | //$last_exec['aircraftlistjson'] = 0; |
| 180 | - if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; |
|
| 235 | + if ($globalDebug) { |
|
| 236 | + echo "Connect to aircraft.json source (".$host.")...\n"; |
|
| 237 | + } |
|
| 181 | 238 | } else if (preg_match('/aircraft$/i',$host)) { |
| 182 | 239 | //$formats[$id] = 'planefinderclient'; |
| 183 | 240 | $globalSources[$id]['format'] = 'planefinderclient'; |
| 184 | 241 | //$last_exec['aircraftlistjson'] = 0; |
| 185 | - if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; |
|
| 242 | + if ($globalDebug) { |
|
| 243 | + echo "Connect to planefinderclient source (".$host.")...\n"; |
|
| 244 | + } |
|
| 186 | 245 | } else if (preg_match('/opensky/i',$host)) { |
| 187 | 246 | //$formats[$id] = 'aircraftlistjson'; |
| 188 | 247 | $globalSources[$id]['format'] = 'opensky'; |
| 189 | 248 | //$last_exec['aircraftlistjson'] = 0; |
| 190 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 249 | + if ($globalDebug) { |
|
| 250 | + echo "Connect to opensky source (".$host.")...\n"; |
|
| 251 | + } |
|
| 191 | 252 | /* |
| 192 | 253 | // Disabled for now, site change source format |
| 193 | 254 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
@@ -204,7 +265,9 @@ discard block |
||
| 204 | 265 | //$formats[$id] = 'planeupdatefaa'; |
| 205 | 266 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
| 206 | 267 | //$last_exec['planeupdatefaa'] = 0; |
| 207 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 268 | + if ($globalDebug) { |
|
| 269 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 270 | + } |
|
| 208 | 271 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 209 | 272 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 210 | 273 | exit(0); |
@@ -213,37 +276,53 @@ discard block |
||
| 213 | 276 | //$formats[$id] = 'phpvmacars'; |
| 214 | 277 | $globalSources[$id]['format'] = 'phpvmacars'; |
| 215 | 278 | //$last_exec['phpvmacars'] = 0; |
| 216 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 279 | + if ($globalDebug) { |
|
| 280 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 281 | + } |
|
| 217 | 282 | } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
| 218 | 283 | //$formats[$id] = 'phpvmacars'; |
| 219 | 284 | $globalSources[$id]['format'] = 'vaos'; |
| 220 | 285 | //$last_exec['phpvmacars'] = 0; |
| 221 | - if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
| 286 | + if ($globalDebug) { |
|
| 287 | + echo "Connect to vaos source (".$host.")...\n"; |
|
| 288 | + } |
|
| 222 | 289 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
| 223 | 290 | //$formats[$id] = 'phpvmacars'; |
| 224 | 291 | $globalSources[$id]['format'] = 'vam'; |
| 225 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 292 | + if ($globalDebug) { |
|
| 293 | + echo "Connect to Vam source (".$host.")...\n"; |
|
| 294 | + } |
|
| 226 | 295 | } else if (preg_match('/whazzup/i',$host)) { |
| 227 | 296 | //$formats[$id] = 'whazzup'; |
| 228 | 297 | $globalSources[$id]['format'] = 'whazzup'; |
| 229 | 298 | //$last_exec['whazzup'] = 0; |
| 230 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 299 | + if ($globalDebug) { |
|
| 300 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
| 301 | + } |
|
| 231 | 302 | } else if (preg_match('/blitzortung/i',$host)) { |
| 232 | 303 | $globalSources[$id]['format'] = 'blitzortung'; |
| 233 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
| 304 | + if ($globalDebug) { |
|
| 305 | + echo "Connect to blitzortung source (".$host.")...\n"; |
|
| 306 | + } |
|
| 234 | 307 | } else if (preg_match('/airwhere/i',$host)) { |
| 235 | 308 | $globalSources[$id]['format'] = 'airwhere'; |
| 236 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
| 309 | + if ($globalDebug) { |
|
| 310 | + echo "Connect to airwhere source (".$host.")...\n"; |
|
| 311 | + } |
|
| 237 | 312 | } else if (preg_match('/recentpireps/i',$host)) { |
| 238 | 313 | //$formats[$id] = 'pirepsjson'; |
| 239 | 314 | $globalSources[$id]['format'] = 'pirepsjson'; |
| 240 | 315 | //$last_exec['pirepsjson'] = 0; |
| 241 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 316 | + if ($globalDebug) { |
|
| 317 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 318 | + } |
|
| 242 | 319 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
| 243 | 320 | //$formats[$id] = 'fr24json'; |
| 244 | 321 | $globalSources[$id]['format'] = 'fr24json'; |
| 245 | 322 | //$last_exec['fr24json'] = 0; |
| 246 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 323 | + if ($globalDebug) { |
|
| 324 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
| 325 | + } |
|
| 247 | 326 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 248 | 327 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 249 | 328 | exit(0); |
@@ -252,7 +331,9 @@ discard block |
||
| 252 | 331 | //$formats[$id] = 'fr24json'; |
| 253 | 332 | $globalSources[$id]['format'] = 'myshiptracking'; |
| 254 | 333 | //$last_exec['fr24json'] = 0; |
| 255 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 334 | + if ($globalDebug) { |
|
| 335 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 336 | + } |
|
| 256 | 337 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 257 | 338 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 258 | 339 | exit(0); |
@@ -261,17 +342,26 @@ discard block |
||
| 261 | 342 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
| 262 | 343 | //$formats[$id] = 'tsv'; |
| 263 | 344 | $globalSources[$id]['format'] = 'tsv'; |
| 264 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 345 | + if ($globalDebug) { |
|
| 346 | + echo "Connect to tsv source (".$host.")...\n"; |
|
| 347 | + } |
|
| 265 | 348 | } |
| 266 | 349 | } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway')) { |
| 267 | 350 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
| 268 | 351 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
| 269 | 352 | if ($idf !== false) { |
| 270 | 353 | $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"; |
|
| 354 | + if ($globalDebug) { |
|
| 355 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 356 | + } |
|
| 357 | + } elseif ($globalDebug) { |
|
| 358 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 359 | + } |
|
| 360 | + } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') { |
|
| 361 | + echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
| 362 | + } elseif ($globalDebug) { |
|
| 363 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 364 | + } |
|
| 275 | 365 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
| 276 | 366 | $hostport = explode(':',$host); |
| 277 | 367 | if (isset($hostport[1])) { |
@@ -311,19 +401,27 @@ discard block |
||
| 311 | 401 | //$formats[$id] = 'beast'; |
| 312 | 402 | $globalSources[$id]['format'] = 'beast'; |
| 313 | 403 | //} else $formats[$id] = 'sbs'; |
| 314 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 404 | + } else { |
|
| 405 | + $globalSources[$id]['format'] = 'sbs'; |
|
| 406 | + } |
|
| 315 | 407 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
| 316 | 408 | } |
| 317 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 409 | + if ($globalDebug) { |
|
| 410 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 411 | + } |
|
| 318 | 412 | } else { |
| 319 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 413 | + if ($globalDebug) { |
|
| 414 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 415 | + } |
|
| 320 | 416 | sleep(10); |
| 321 | 417 | connect_all($hosts); |
| 322 | 418 | } |
| 323 | 419 | } |
| 324 | 420 | } |
| 325 | 421 | } |
| 326 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
| 422 | +if (!isset($globalMinFetch)) { |
|
| 423 | + $globalMinFetch = 15; |
|
| 424 | +} |
|
| 327 | 425 | |
| 328 | 426 | // Initialize all |
| 329 | 427 | $status = array(); |
@@ -332,13 +430,19 @@ discard block |
||
| 332 | 430 | $formats = array(); |
| 333 | 431 | $last_exec = array(); |
| 334 | 432 | $time = time(); |
| 335 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
| 336 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
| 337 | -else $timeout = 20; |
|
| 433 | +if (isset($globalSourcesTimeout)) { |
|
| 434 | + $timeout = $globalSourcesTimeOut; |
|
| 435 | +} else if (isset($globalSBS1TimeOut)) { |
|
| 436 | + $timeout = $globalSBS1TimeOut; |
|
| 437 | +} else { |
|
| 438 | + $timeout = 20; |
|
| 439 | +} |
|
| 338 | 440 | $errno = ''; |
| 339 | 441 | $errstr=''; |
| 340 | 442 | |
| 341 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 443 | +if (!isset($globalDaemon)) { |
|
| 444 | + $globalDaemon = TRUE; |
|
| 445 | +} |
|
| 342 | 446 | /* Initiate connections to all the hosts simultaneously */ |
| 343 | 447 | //connect_all($hosts); |
| 344 | 448 | //connect_all($globalSources); |
@@ -367,7 +471,9 @@ discard block |
||
| 367 | 471 | if (isset($source['format']) && $source['format'] == 'aprs') { |
| 368 | 472 | $aprs_connect = 0; |
| 369 | 473 | $use_aprs = true; |
| 370 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
| 474 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
| 475 | + $aprs_full = true; |
|
| 476 | + } |
|
| 371 | 477 | break; |
| 372 | 478 | } |
| 373 | 479 | } |
@@ -378,25 +484,46 @@ discard block |
||
| 378 | 484 | $aprs_connect = 0; |
| 379 | 485 | $aprs_keep = 120; |
| 380 | 486 | $aprs_last_tx = time(); |
| 381 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
| 382 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 383 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
| 384 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 385 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
| 386 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 387 | - if ($aprs_full) $aprs_filter = ''; |
|
| 388 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
| 389 | - else $aprs_pass = '-1'; |
|
| 487 | + if (isset($globalAPRSversion)) { |
|
| 488 | + $aprs_version = $globalAPRSversion; |
|
| 489 | + } else { |
|
| 490 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 491 | + } |
|
| 492 | + if (isset($globalAPRSssid)) { |
|
| 493 | + $aprs_ssid = $globalAPRSssid; |
|
| 494 | + } else { |
|
| 495 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 496 | + } |
|
| 497 | + if (isset($globalAPRSfilter)) { |
|
| 498 | + $aprs_filter = $globalAPRSfilter; |
|
| 499 | + } else { |
|
| 500 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 501 | + } |
|
| 502 | + if ($aprs_full) { |
|
| 503 | + $aprs_filter = ''; |
|
| 504 | + } |
|
| 505 | + if (isset($globalAPRSpass)) { |
|
| 506 | + $aprs_pass = $globalAPRSpass; |
|
| 507 | + } else { |
|
| 508 | + $aprs_pass = '-1'; |
|
| 509 | + } |
|
| 390 | 510 | |
| 391 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 392 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
| 393 | -} |
|
| 511 | + if ($aprs_filter != '') { |
|
| 512 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 513 | + } else { |
|
| 514 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
| 515 | + } |
|
| 516 | + } |
|
| 394 | 517 | |
| 395 | 518 | // connected - lets do some work |
| 396 | 519 | //if ($globalDebug) echo "Connected!\n"; |
| 397 | 520 | sleep(1); |
| 398 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
| 399 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
| 521 | +if ($globalDebug) { |
|
| 522 | + echo "SCAN MODE \n\n"; |
|
| 523 | +} |
|
| 524 | +if (!isset($globalCronEnd)) { |
|
| 525 | + $globalCronEnd = 60; |
|
| 526 | +} |
|
| 400 | 527 | $endtime = time()+$globalCronEnd; |
| 401 | 528 | $i = 1; |
| 402 | 529 | $tt = array(); |
@@ -410,22 +537,32 @@ discard block |
||
| 410 | 537 | |
| 411 | 538 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 412 | 539 | while ($i > 0) { |
| 413 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 540 | + if (function_exists('pcntl_fork')) { |
|
| 541 | + pcntl_signal_dispatch(); |
|
| 542 | + } |
|
| 414 | 543 | |
| 415 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 544 | + if (!$globalDaemon) { |
|
| 545 | + $i = $endtime-time(); |
|
| 546 | + } |
|
| 416 | 547 | // Delete old ATC |
| 417 | 548 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 418 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
| 549 | + if ($globalDebug) { |
|
| 550 | + echo 'Delete old ATC...'."\n"; |
|
| 551 | + } |
|
| 419 | 552 | $ATC->deleteOldATC(); |
| 420 | 553 | } |
| 421 | 554 | |
| 422 | 555 | if (count($last_exec) == count($globalSources)) { |
| 423 | 556 | $max = $globalMinFetch; |
| 424 | 557 | foreach ($last_exec as $last) { |
| 425 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 558 | + if ((time() - $last['last']) < $max) { |
|
| 559 | + $max = time() - $last['last']; |
|
| 560 | + } |
|
| 426 | 561 | } |
| 427 | 562 | if ($max < $globalMinFetch) { |
| 428 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 563 | + if ($globalDebug) { |
|
| 564 | + echo 'Sleeping...'."\n"; |
|
| 565 | + } |
|
| 429 | 566 | sleep($globalMinFetch-$max+2); |
| 430 | 567 | } |
| 431 | 568 | } |
@@ -435,7 +572,9 @@ discard block |
||
| 435 | 572 | foreach ($globalSources as $id => $value) { |
| 436 | 573 | date_default_timezone_set('UTC'); |
| 437 | 574 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
| 438 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
| 575 | + if (!isset($last_exec[$id]['last'])) { |
|
| 576 | + $last_exec[$id]['last'] = 0; |
|
| 577 | + } |
|
| 439 | 578 | if ($value['format'] === 'deltadbtxt' && |
| 440 | 579 | ( |
| 441 | 580 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
@@ -444,7 +583,9 @@ discard block |
||
| 444 | 583 | ) { |
| 445 | 584 | //$buffer = $Common->getData($hosts[$id]); |
| 446 | 585 | $buffer = $Common->getData($value['host']); |
| 447 | - if ($buffer != '') $reset = 0; |
|
| 586 | + if ($buffer != '') { |
|
| 587 | + $reset = 0; |
|
| 588 | + } |
|
| 448 | 589 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 449 | 590 | $buffer = explode('\n',$buffer); |
| 450 | 591 | foreach ($buffer as $line) { |
@@ -453,20 +594,41 @@ discard block |
||
| 453 | 594 | $data = array(); |
| 454 | 595 | $data['hex'] = $line[1]; // hex |
| 455 | 596 | $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 |
|
| 597 | + if (isset($line[3])) { |
|
| 598 | + $data['altitude'] = $line[3]; |
|
| 599 | + } |
|
| 600 | + // altitude |
|
| 601 | + if (isset($line[4])) { |
|
| 602 | + $data['speed'] = $line[4]; |
|
| 603 | + } |
|
| 604 | + // speed |
|
| 605 | + if (isset($line[5])) { |
|
| 606 | + $data['heading'] = $line[5]; |
|
| 607 | + } |
|
| 608 | + // heading |
|
| 609 | + if (isset($line[6])) { |
|
| 610 | + $data['latitude'] = $line[6]; |
|
| 611 | + } |
|
| 612 | + // lat |
|
| 613 | + if (isset($line[7])) { |
|
| 614 | + $data['longitude'] = $line[7]; |
|
| 615 | + } |
|
| 616 | + // long |
|
| 461 | 617 | $data['verticalrate'] = ''; // vertical rate |
| 462 | 618 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
| 463 | 619 | $data['emergency'] = ''; // emergency |
| 464 | 620 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 465 | 621 | $data['format_source'] = 'deltadbtxt'; |
| 466 | 622 | $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']; |
|
| 623 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 624 | + $data['source_name'] = $value['name']; |
|
| 625 | + } |
|
| 626 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 627 | + $data['noarchive'] = true; |
|
| 628 | + } |
|
| 629 | + if (isset($value['sourcestats'])) { |
|
| 630 | + $data['sourcestats'] = $value['sourcestats']; |
|
| 631 | + } |
|
| 470 | 632 | $SI->add($data); |
| 471 | 633 | unset($data); |
| 472 | 634 | } |
@@ -481,7 +643,9 @@ discard block |
||
| 481 | 643 | date_default_timezone_set('CET'); |
| 482 | 644 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
| 483 | 645 | date_default_timezone_set('UTC'); |
| 484 | - if ($buffer != '') $reset = 0; |
|
| 646 | + if ($buffer != '') { |
|
| 647 | + $reset = 0; |
|
| 648 | + } |
|
| 485 | 649 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 486 | 650 | $buffer = explode('\n',$buffer); |
| 487 | 651 | foreach ($buffer as $line) { |
@@ -490,18 +654,42 @@ discard block |
||
| 490 | 654 | $add = false; |
| 491 | 655 | $ais_data = $AIS->parse_line(trim($line)); |
| 492 | 656 | $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']; |
|
| 657 | + if (isset($ais_data['ident'])) { |
|
| 658 | + $data['ident'] = $ais_data['ident']; |
|
| 659 | + } |
|
| 660 | + if (isset($ais_data['mmsi'])) { |
|
| 661 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 662 | + } |
|
| 663 | + if (isset($ais_data['speed'])) { |
|
| 664 | + $data['speed'] = $ais_data['speed']; |
|
| 665 | + } |
|
| 666 | + if (isset($ais_data['heading'])) { |
|
| 667 | + $data['heading'] = $ais_data['heading']; |
|
| 668 | + } |
|
| 669 | + if (isset($ais_data['latitude'])) { |
|
| 670 | + $data['latitude'] = $ais_data['latitude']; |
|
| 671 | + } |
|
| 672 | + if (isset($ais_data['longitude'])) { |
|
| 673 | + $data['longitude'] = $ais_data['longitude']; |
|
| 674 | + } |
|
| 675 | + if (isset($ais_data['status'])) { |
|
| 676 | + $data['status'] = $ais_data['status']; |
|
| 677 | + } |
|
| 678 | + if (isset($ais_data['statusid'])) { |
|
| 679 | + $data['status_id'] = $ais_data['statusid']; |
|
| 680 | + } |
|
| 681 | + if (isset($ais_data['type'])) { |
|
| 682 | + $data['type'] = $ais_data['type']; |
|
| 683 | + } |
|
| 684 | + if (isset($ais_data['typeid'])) { |
|
| 685 | + $data['type_id'] = $ais_data['typeid']; |
|
| 686 | + } |
|
| 687 | + if (isset($ais_data['imo'])) { |
|
| 688 | + $data['imo'] = $ais_data['imo']; |
|
| 689 | + } |
|
| 690 | + if (isset($ais_data['callsign'])) { |
|
| 691 | + $data['callsign'] = $ais_data['callsign']; |
|
| 692 | + } |
|
| 505 | 693 | if (isset($ais_data['timestamp'])) { |
| 506 | 694 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 507 | 695 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -515,8 +703,12 @@ discard block |
||
| 515 | 703 | $data['format_source'] = 'aisnmeatxt'; |
| 516 | 704 | $data['id_source'] = $id_source; |
| 517 | 705 | //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); |
|
| 706 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 707 | + $data['noarchive'] = true; |
|
| 708 | + } |
|
| 709 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
| 710 | + $MI->add($data); |
|
| 711 | + } |
|
| 520 | 712 | unset($data); |
| 521 | 713 | } |
| 522 | 714 | } |
@@ -539,20 +731,48 @@ discard block |
||
| 539 | 731 | if ($line != '') { |
| 540 | 732 | $ais_data = $AIS->parse_line(trim($line)); |
| 541 | 733 | $data = array(); |
| 542 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 543 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 544 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 545 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 546 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 547 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 548 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 549 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 550 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 551 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
| 552 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 553 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 554 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 555 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 734 | + if (isset($ais_data['ident'])) { |
|
| 735 | + $data['ident'] = $ais_data['ident']; |
|
| 736 | + } |
|
| 737 | + if (isset($ais_data['mmsi'])) { |
|
| 738 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 739 | + } |
|
| 740 | + if (isset($ais_data['speed'])) { |
|
| 741 | + $data['speed'] = $ais_data['speed']; |
|
| 742 | + } |
|
| 743 | + if (isset($ais_data['heading'])) { |
|
| 744 | + $data['heading'] = $ais_data['heading']; |
|
| 745 | + } |
|
| 746 | + if (isset($ais_data['latitude'])) { |
|
| 747 | + $data['latitude'] = $ais_data['latitude']; |
|
| 748 | + } |
|
| 749 | + if (isset($ais_data['longitude'])) { |
|
| 750 | + $data['longitude'] = $ais_data['longitude']; |
|
| 751 | + } |
|
| 752 | + if (isset($ais_data['status'])) { |
|
| 753 | + $data['status'] = $ais_data['status']; |
|
| 754 | + } |
|
| 755 | + if (isset($ais_data['statusid'])) { |
|
| 756 | + $data['status_id'] = $ais_data['statusid']; |
|
| 757 | + } |
|
| 758 | + if (isset($ais_data['type'])) { |
|
| 759 | + $data['type'] = $ais_data['type']; |
|
| 760 | + } |
|
| 761 | + if (isset($ais_data['typeid'])) { |
|
| 762 | + $data['type_id'] = $ais_data['typeid']; |
|
| 763 | + } |
|
| 764 | + if (isset($ais_data['imo'])) { |
|
| 765 | + $data['imo'] = $ais_data['imo']; |
|
| 766 | + } |
|
| 767 | + if (isset($ais_data['callsign'])) { |
|
| 768 | + $data['callsign'] = $ais_data['callsign']; |
|
| 769 | + } |
|
| 770 | + if (isset($ais_data['destination'])) { |
|
| 771 | + $data['arrival_code'] = $ais_data['destination']; |
|
| 772 | + } |
|
| 773 | + if (isset($ais_data['eta_ts'])) { |
|
| 774 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 775 | + } |
|
| 556 | 776 | if (isset($ais_data['timestamp'])) { |
| 557 | 777 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 558 | 778 | } else { |
@@ -560,18 +780,27 @@ discard block |
||
| 560 | 780 | } |
| 561 | 781 | $data['format_source'] = 'aisnmeahttp'; |
| 562 | 782 | $data['id_source'] = $id_source; |
| 563 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 564 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 783 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 784 | + $data['noarchive'] = true; |
|
| 785 | + } |
|
| 786 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
| 787 | + $MI->add($data); |
|
| 788 | + } |
|
| 565 | 789 | unset($data); |
| 566 | 790 | } |
| 567 | 791 | } |
| 568 | 792 | } |
| 569 | 793 | } else { |
| 570 | 794 | $format = $value['format']; |
| 571 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 572 | - else $tt[$format] = 0; |
|
| 795 | + if (isset($tt[$format])) { |
|
| 796 | + $tt[$format]++; |
|
| 797 | + } else { |
|
| 798 | + $tt[$format] = 0; |
|
| 799 | + } |
|
| 573 | 800 | if ($tt[$format] > 30) { |
| 574 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
| 801 | + if ($globalDebug) { |
|
| 802 | + echo 'Reconnect...'."\n"; |
|
| 803 | + } |
|
| 575 | 804 | sleep(2); |
| 576 | 805 | //$sourceeen[] = $value; |
| 577 | 806 | //connect_all($sourceeen); |
@@ -607,12 +836,18 @@ discard block |
||
| 607 | 836 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
| 608 | 837 | //$data['type_id'] = $line['TYPE']; |
| 609 | 838 | $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'])); |
|
| 839 | + if ($line['DEST'] != '') { |
|
| 840 | + $data['arrival_code'] = $line['DEST']; |
|
| 841 | + } |
|
| 842 | + if ($line['ARV'] != '') { |
|
| 843 | + $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
| 844 | + } |
|
| 612 | 845 | $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
| 613 | 846 | $data['format_source'] = 'myshiptracking'; |
| 614 | 847 | $data['id_source'] = $id_source; |
| 615 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 848 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 849 | + $data['noarchive'] = true; |
|
| 850 | + } |
|
| 616 | 851 | $MI->add($data); |
| 617 | 852 | unset($data); |
| 618 | 853 | } |
@@ -637,7 +872,9 @@ discard block |
||
| 637 | 872 | $data['callsign'] = $line['callsign']; |
| 638 | 873 | $data['mmsi'] = substr($line['mmsi'],-9); |
| 639 | 874 | $data['speed'] = $line['sog']; |
| 640 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 875 | + if ($line['heading'] != '511') { |
|
| 876 | + $data['heading'] = $line['heading']; |
|
| 877 | + } |
|
| 641 | 878 | $data['latitude'] = $line['latitude']; |
| 642 | 879 | $data['longitude'] = $line['longitude']; |
| 643 | 880 | $data['type_id'] = $line['shiptype']; |
@@ -645,7 +882,9 @@ discard block |
||
| 645 | 882 | $data['datetime'] = $line['time']; |
| 646 | 883 | $data['format_source'] = 'boatbeaconapp'; |
| 647 | 884 | $data['id_source'] = $id_source; |
| 648 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 885 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 886 | + $data['noarchive'] = true; |
|
| 887 | + } |
|
| 649 | 888 | $MI->add($data); |
| 650 | 889 | unset($data); |
| 651 | 890 | } |
@@ -667,22 +906,44 @@ discard block |
||
| 667 | 906 | foreach ($all_data['features'] as $line) { |
| 668 | 907 | print_r($line); |
| 669 | 908 | $data = array(); |
| 670 | - if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
|
| 671 | - if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
|
| 672 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
| 673 | - if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo']; |
|
| 674 | - if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
|
| 675 | - if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading']; |
|
| 909 | + if (isset($line['properties']['name'])) { |
|
| 910 | + $data['ident'] = $line['properties']['name']; |
|
| 911 | + } |
|
| 912 | + if (isset($line['properties']['callsign'])) { |
|
| 913 | + $data['callsign'] = $line['properties']['callsign']; |
|
| 914 | + } |
|
| 915 | + if (isset($line['properties']['mmsi'])) { |
|
| 916 | + $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
| 917 | + } |
|
| 918 | + if (isset($line['properties']['imo'])) { |
|
| 919 | + $data['imo'] = $line['properties']['imo']; |
|
| 920 | + } |
|
| 921 | + if (isset($line['properties']['speed'])) { |
|
| 922 | + $data['speed'] = $line['properties']['speed']; |
|
| 923 | + } |
|
| 924 | + if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) { |
|
| 925 | + $data['heading'] = $line['properties']['heading']; |
|
| 926 | + } |
|
| 676 | 927 | $data['latitude'] = $line['geometry']['coordinates'][1]; |
| 677 | 928 | $data['longitude'] = $line['geometry']['coordinates'][0]; |
| 678 | - if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType']; |
|
| 679 | - if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination']; |
|
| 680 | - if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta']; |
|
| 929 | + if (isset($line['properties']['vesselType'])) { |
|
| 930 | + $data['type'] = $line['properties']['vesselType']; |
|
| 931 | + } |
|
| 932 | + if (isset($line['properties']['destination'])) { |
|
| 933 | + $data['arrival_code'] = $line['properties']['destination']; |
|
| 934 | + } |
|
| 935 | + if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') { |
|
| 936 | + $data['arrival_date'] = $line['properties']['eta']; |
|
| 937 | + } |
|
| 681 | 938 | $data['format_source'] = 'boatnerd'; |
| 682 | 939 | $data['id_source'] = $id_source; |
| 683 | 940 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 684 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 685 | - if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
|
| 941 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 942 | + $data['noarchive'] = true; |
|
| 943 | + } |
|
| 944 | + if ($line['properties']['vesselType'] != 'Navigation Aid') { |
|
| 945 | + $MI->add($data); |
|
| 946 | + } |
|
| 686 | 947 | unset($data); |
| 687 | 948 | } |
| 688 | 949 | } |
@@ -695,11 +956,17 @@ discard block |
||
| 695 | 956 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 696 | 957 | ) |
| 697 | 958 | ) { |
| 698 | - if ($globalDebug) echo 'download...'; |
|
| 959 | + if ($globalDebug) { |
|
| 960 | + echo 'download...'; |
|
| 961 | + } |
|
| 699 | 962 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
| 700 | - if ($globalDebug) echo 'done !'."\n"; |
|
| 963 | + if ($globalDebug) { |
|
| 964 | + echo 'done !'."\n"; |
|
| 965 | + } |
|
| 701 | 966 | // FIXME: Need more work |
| 702 | - if ($buffer != '') $reset = 0; |
|
| 967 | + if ($buffer != '') { |
|
| 968 | + $reset = 0; |
|
| 969 | + } |
|
| 703 | 970 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 704 | 971 | $buffer = explode('\n',$buffer); |
| 705 | 972 | foreach ($buffer as $line) { |
@@ -725,7 +992,9 @@ discard block |
||
| 725 | 992 | //$data['etaTime'] = substr($line,135,5); |
| 726 | 993 | $data['format_source'] = 'shipplotter'; |
| 727 | 994 | $data['id_source'] = $id_source; |
| 728 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 995 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 996 | + $data['noarchive'] = true; |
|
| 997 | + } |
|
| 729 | 998 | //print_r($data); |
| 730 | 999 | //echo 'Add...'."\n"; |
| 731 | 1000 | $MI->add($data); |
@@ -739,11 +1008,17 @@ discard block |
||
| 739 | 1008 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 740 | 1009 | ) |
| 741 | 1010 | ) { |
| 742 | - if ($globalDebug) echo '! Download... '; |
|
| 1011 | + if ($globalDebug) { |
|
| 1012 | + echo '! Download... '; |
|
| 1013 | + } |
|
| 743 | 1014 | for ($i =0; $i <= 1; $i++) { |
| 744 | - if ($globalDebug) echo 'Racetype: '.$i.' '; |
|
| 1015 | + if ($globalDebug) { |
|
| 1016 | + echo 'Racetype: '.$i.' '; |
|
| 1017 | + } |
|
| 745 | 1018 | $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"; |
|
| 1019 | + if ($globalDebug) { |
|
| 1020 | + echo 'done'."\n"; |
|
| 1021 | + } |
|
| 747 | 1022 | if ($buffer != '') { |
| 748 | 1023 | $all_data = json_decode($buffer,true); |
| 749 | 1024 | if (isset($all_data['missions'])) { |
@@ -752,7 +1027,9 @@ discard block |
||
| 752 | 1027 | $mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$mission['mistitle']); |
| 753 | 1028 | if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) { |
| 754 | 1029 | $bufferm = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']); |
| 755 | - } else $bufferm = ''; |
|
| 1030 | + } else { |
|
| 1031 | + $bufferm = ''; |
|
| 1032 | + } |
|
| 756 | 1033 | if ($bufferm != '') { |
| 757 | 1034 | $mission_data = json_decode($bufferm,true); |
| 758 | 1035 | if (isset($mission_data['leaderboard'][0]['results'])) { |
@@ -790,7 +1067,9 @@ discard block |
||
| 790 | 1067 | $data['captain_id'] = $sail['usrnr']; |
| 791 | 1068 | $data['captain_name'] = $sail['usrname']; |
| 792 | 1069 | $data['race_id'] = $sail['misnr']; |
| 793 | - if ($sail['rank'] != 'DNF') $data['race_rank'] = $sail['rank']; |
|
| 1070 | + if ($sail['rank'] != 'DNF') { |
|
| 1071 | + $data['race_rank'] = $sail['rank']; |
|
| 1072 | + } |
|
| 794 | 1073 | $data['race_time'] = $sail['racetime']; |
| 795 | 1074 | if ($mission_user != '') { |
| 796 | 1075 | $data['race_name'] = $mission_name.' ('.$mission_user.')'; |
@@ -800,7 +1079,9 @@ discard block |
||
| 800 | 1079 | //$data['callsign'] = trim(substr($line,100,7); |
| 801 | 1080 | $data['format_source'] = 'sailaway'; |
| 802 | 1081 | $data['id_source'] = $id_source; |
| 803 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1082 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1083 | + $data['noarchive'] = true; |
|
| 1084 | + } |
|
| 804 | 1085 | //print_r($data); |
| 805 | 1086 | //echo 'Add...'."\n"; |
| 806 | 1087 | $MI->add($data); |
@@ -841,16 +1122,28 @@ discard block |
||
| 841 | 1122 | $line = explode(':', $line); |
| 842 | 1123 | if (count($line) > 30 && $line[0] != 'callsign') { |
| 843 | 1124 | $data = array(); |
| 844 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 845 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 1125 | + if (isset($line[37]) && $line[37] != '') { |
|
| 1126 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 1127 | + } else { |
|
| 1128 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 1129 | + } |
|
| 846 | 1130 | $data['pilot_id'] = $line[1]; |
| 847 | 1131 | $data['pilot_name'] = $line[2]; |
| 848 | 1132 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
| 849 | 1133 | $data['ident'] = $line[0]; // ident |
| 850 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
| 1134 | + if ($line[7] != '' && $line[7] != 0) { |
|
| 1135 | + $data['altitude'] = $line[7]; |
|
| 1136 | + } |
|
| 1137 | + // altitude |
|
| 851 | 1138 | $data['speed'] = $line[8]; // speed |
| 852 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
| 853 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
| 1139 | + if (isset($line[45])) { |
|
| 1140 | + $data['heading'] = $line[45]; |
|
| 1141 | + } |
|
| 1142 | + // heading |
|
| 1143 | + elseif (isset($line[38])) { |
|
| 1144 | + $data['heading'] = $line[38]; |
|
| 1145 | + } |
|
| 1146 | + // heading |
|
| 854 | 1147 | $data['latitude'] = $line[5]; // lat |
| 855 | 1148 | $data['longitude'] = $line[6]; // long |
| 856 | 1149 | $data['verticalrate'] = ''; // vertical rate |
@@ -866,7 +1159,9 @@ discard block |
||
| 866 | 1159 | $data['frequency'] = $line[4]; |
| 867 | 1160 | $data['type'] = $line[18]; |
| 868 | 1161 | $data['range'] = $line[19]; |
| 869 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
| 1162 | + if (isset($line[35])) { |
|
| 1163 | + $data['info'] = $line[35]; |
|
| 1164 | + } |
|
| 870 | 1165 | $data['id_source'] = $id_source; |
| 871 | 1166 | //$data['arrival_airport_time'] = ; |
| 872 | 1167 | if ($line[9] != '') { |
@@ -880,27 +1175,47 @@ discard block |
||
| 880 | 1175 | elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 881 | 1176 | */ |
| 882 | 1177 | $data['format_source'] = $value['format']; |
| 883 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 884 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 885 | - if ($line[3] === 'PILOT') $SI->add($data); |
|
| 886 | - elseif ($line[3] === 'ATC') { |
|
| 1178 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1179 | + $data['noarchive'] = true; |
|
| 1180 | + } |
|
| 1181 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1182 | + $data['source_name'] = $value['name']; |
|
| 1183 | + } |
|
| 1184 | + if ($line[3] === 'PILOT') { |
|
| 1185 | + $SI->add($data); |
|
| 1186 | + } elseif ($line[3] === 'ATC') { |
|
| 887 | 1187 | //print_r($data); |
| 888 | 1188 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 889 | 1189 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 890 | 1190 | $typec = substr($data['ident'],-3); |
| 891 | - if ($typec === 'APP') $data['type'] = 'Approach'; |
|
| 892 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
| 893 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
|
| 894 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; |
|
| 895 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; |
|
| 896 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; |
|
| 897 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 898 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 899 | - elseif ($data['type'] === '') $data['type'] = 'Observer'; |
|
| 900 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
| 1191 | + if ($typec === 'APP') { |
|
| 1192 | + $data['type'] = 'Approach'; |
|
| 1193 | + } elseif ($typec === 'TWR') { |
|
| 1194 | + $data['type'] = 'Tower'; |
|
| 1195 | + } elseif ($typec === 'OBS') { |
|
| 1196 | + $data['type'] = 'Observer'; |
|
| 1197 | + } elseif ($typec === 'GND') { |
|
| 1198 | + $data['type'] = 'Ground'; |
|
| 1199 | + } elseif ($typec === 'DEL') { |
|
| 1200 | + $data['type'] = 'Delivery'; |
|
| 1201 | + } elseif ($typec === 'DEP') { |
|
| 1202 | + $data['type'] = 'Departure'; |
|
| 1203 | + } elseif ($typec === 'FSS') { |
|
| 1204 | + $data['type'] = 'Flight Service Station'; |
|
| 1205 | + } elseif ($typec === 'CTR') { |
|
| 1206 | + $data['type'] = 'Control Radar or Centre'; |
|
| 1207 | + } elseif ($data['type'] === '') { |
|
| 1208 | + $data['type'] = 'Observer'; |
|
| 1209 | + } |
|
| 1210 | + if (!isset($data['source_name'])) { |
|
| 1211 | + $data['source_name'] = ''; |
|
| 1212 | + } |
|
| 901 | 1213 | if (isset($ATC)) { |
| 902 | - if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
| 903 | - 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']); |
|
| 1214 | + if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) { |
|
| 1215 | + echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
| 1216 | + } else { |
|
| 1217 | + 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']); |
|
| 1218 | + } |
|
| 904 | 1219 | } |
| 905 | 1220 | } |
| 906 | 1221 | unset($data); |
@@ -927,14 +1242,20 @@ discard block |
||
| 927 | 1242 | $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
| 928 | 1243 | $data['latitude'] = (float)$line['pktLatitude']; |
| 929 | 1244 | $data['longitude'] = (float)$line['pktLongitude']; |
| 930 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
| 931 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
| 1245 | + if ((float)$line['pktTrack'] != 0) { |
|
| 1246 | + $data['heading'] = (float)$line['pktTrack']; |
|
| 1247 | + } |
|
| 1248 | + if ((int)$line['pktSpeed'] != 0) { |
|
| 1249 | + $data['speed'] = (int)$line['pktSpeed']; |
|
| 1250 | + } |
|
| 932 | 1251 | $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
| 933 | 1252 | $data['altitude_relative'] = 'AMSL'; |
| 934 | 1253 | $data['pilot_id'] = (int)$line['pktPilotID']; |
| 935 | 1254 | $data['aircraft_icao'] = 'PARAGLIDER'; |
| 936 | 1255 | $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
| 937 | - if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
|
| 1256 | + if (isset($pilot_data[4])) { |
|
| 1257 | + $data['pilot_name'] = $pilot_data[4]; |
|
| 1258 | + } |
|
| 938 | 1259 | $data['format_source'] = $value['format']; |
| 939 | 1260 | $SI->add($data); |
| 940 | 1261 | unset($data); |
@@ -982,25 +1303,59 @@ discard block |
||
| 982 | 1303 | foreach ($all_data['acList'] as $line) { |
| 983 | 1304 | $data = array(); |
| 984 | 1305 | $data['hex'] = $line['Icao']; // hex |
| 985 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 986 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 987 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 988 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 989 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 990 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 1306 | + if (isset($line['Call'])) { |
|
| 1307 | + $data['ident'] = $line['Call']; |
|
| 1308 | + } |
|
| 1309 | + // ident |
|
| 1310 | + if (isset($line['Alt'])) { |
|
| 1311 | + $data['altitude'] = $line['Alt']; |
|
| 1312 | + } |
|
| 1313 | + // altitude |
|
| 1314 | + if (isset($line['Spd'])) { |
|
| 1315 | + $data['speed'] = $line['Spd']; |
|
| 1316 | + } |
|
| 1317 | + // speed |
|
| 1318 | + if (isset($line['Trak'])) { |
|
| 1319 | + $data['heading'] = $line['Trak']; |
|
| 1320 | + } |
|
| 1321 | + // heading |
|
| 1322 | + if (isset($line['Lat'])) { |
|
| 1323 | + $data['latitude'] = $line['Lat']; |
|
| 1324 | + } |
|
| 1325 | + // lat |
|
| 1326 | + if (isset($line['Long'])) { |
|
| 1327 | + $data['longitude'] = $line['Long']; |
|
| 1328 | + } |
|
| 1329 | + // long |
|
| 991 | 1330 | //$data['verticalrate'] = $line['']; // verticale rate |
| 992 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 1331 | + if (isset($line['Sqk'])) { |
|
| 1332 | + $data['squawk'] = $line['Sqk']; |
|
| 1333 | + } |
|
| 1334 | + // squawk |
|
| 993 | 1335 | $data['emergency'] = ''; // emergency |
| 994 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 995 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 996 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1336 | + if (isset($line['Reg'])) { |
|
| 1337 | + $data['registration'] = $line['Reg']; |
|
| 1338 | + } |
|
| 1339 | + if (isset($line['PosTime'])) { |
|
| 1340 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1341 | + } else { |
|
| 1342 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1343 | + } |
|
| 997 | 1344 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 998 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 1345 | + if (isset($line['Type'])) { |
|
| 1346 | + $data['aircraft_icao'] = $line['Type']; |
|
| 1347 | + } |
|
| 999 | 1348 | $data['format_source'] = 'aircraftlistjson'; |
| 1000 | 1349 | $data['id_source'] = $id_source; |
| 1001 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1002 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1003 | - if (isset($data['latitude'])) $SI->add($data); |
|
| 1350 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1351 | + $data['source_name'] = $value['name']; |
|
| 1352 | + } |
|
| 1353 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1354 | + $data['noarchive'] = true; |
|
| 1355 | + } |
|
| 1356 | + if (isset($data['latitude'])) { |
|
| 1357 | + $SI->add($data); |
|
| 1358 | + } |
|
| 1004 | 1359 | unset($data); |
| 1005 | 1360 | } |
| 1006 | 1361 | } elseif (is_array($all_data)) { |
@@ -1017,17 +1372,26 @@ discard block |
||
| 1017 | 1372 | $data['verticalrate'] = $line['vrt']; // verticale rate |
| 1018 | 1373 | $data['squawk'] = $line['squawk']; // squawk |
| 1019 | 1374 | $data['emergency'] = ''; // emergency |
| 1020 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1021 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1375 | + if (isset($line['PosTime'])) { |
|
| 1376 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1377 | + } else { |
|
| 1378 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1379 | + } |
|
| 1022 | 1380 | $data['format_source'] = 'aircraftlistjson'; |
| 1023 | 1381 | $data['id_source'] = $id_source; |
| 1024 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1025 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1382 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1383 | + $data['noarchive'] = true; |
|
| 1384 | + } |
|
| 1385 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1386 | + $data['source_name'] = $value['name']; |
|
| 1387 | + } |
|
| 1026 | 1388 | $SI->add($data); |
| 1027 | 1389 | unset($data); |
| 1028 | 1390 | } |
| 1029 | 1391 | } |
| 1030 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
| 1392 | + } elseif ($globalDebug) { |
|
| 1393 | + echo 'No data'."\n"; |
|
| 1394 | + } |
|
| 1031 | 1395 | //$last_exec['aircraftlistjson'] = time(); |
| 1032 | 1396 | $last_exec[$id]['last'] = time(); |
| 1033 | 1397 | //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
@@ -1063,8 +1427,12 @@ discard block |
||
| 1063 | 1427 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
| 1064 | 1428 | $data['format_source'] = 'planeupdatefaa'; |
| 1065 | 1429 | $data['id_source'] = $id_source; |
| 1066 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1067 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1430 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1431 | + $data['noarchive'] = true; |
|
| 1432 | + } |
|
| 1433 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1434 | + $data['source_name'] = $value['name']; |
|
| 1435 | + } |
|
| 1068 | 1436 | $SI->add($data); |
| 1069 | 1437 | unset($data); |
| 1070 | 1438 | } |
@@ -1098,7 +1466,9 @@ discard block |
||
| 1098 | 1466 | $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
| 1099 | 1467 | $data['format_source'] = 'opensky'; |
| 1100 | 1468 | $data['id_source'] = $id_source; |
| 1101 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1469 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1470 | + $data['noarchive'] = true; |
|
| 1471 | + } |
|
| 1102 | 1472 | $SI->add($data); |
| 1103 | 1473 | unset($data); |
| 1104 | 1474 | } |
@@ -1118,15 +1488,42 @@ discard block |
||
| 1118 | 1488 | foreach ($all_data['aircraft'] as $key => $line) { |
| 1119 | 1489 | $data = array(); |
| 1120 | 1490 | // add support for ground vehicule with ~ in front of hex |
| 1121 | - if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
| 1122 | - if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
| 1123 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1124 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1125 | - if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
| 1126 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1127 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1128 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1129 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1491 | + if (isset($line['hex'])) { |
|
| 1492 | + $data['hex'] = $line['hex']; |
|
| 1493 | + } |
|
| 1494 | + // hex |
|
| 1495 | + if (isset($line['flight'])) { |
|
| 1496 | + $data['ident'] = trim($line['flight']); |
|
| 1497 | + } |
|
| 1498 | + // ident |
|
| 1499 | + if (isset($line['altitude'])) { |
|
| 1500 | + $data['altitude'] = $line['altitude']; |
|
| 1501 | + } |
|
| 1502 | + // altitude |
|
| 1503 | + if (isset($line['speed'])) { |
|
| 1504 | + $data['speed'] = $line['speed']; |
|
| 1505 | + } |
|
| 1506 | + // speed |
|
| 1507 | + if (isset($line['track'])) { |
|
| 1508 | + $data['heading'] = $line['track']; |
|
| 1509 | + } |
|
| 1510 | + // heading |
|
| 1511 | + if (isset($line['lat'])) { |
|
| 1512 | + $data['latitude'] = $line['lat']; |
|
| 1513 | + } |
|
| 1514 | + // lat |
|
| 1515 | + if (isset($line['lon'])) { |
|
| 1516 | + $data['longitude'] = $line['lon']; |
|
| 1517 | + } |
|
| 1518 | + // long |
|
| 1519 | + if (isset($line['vert_rate'])) { |
|
| 1520 | + $data['verticalrate'] = $line['vert_rate']; |
|
| 1521 | + } |
|
| 1522 | + // verticale rate |
|
| 1523 | + if (isset($line['squawk'])) { |
|
| 1524 | + $data['squawk'] = $line['squawk']; |
|
| 1525 | + } |
|
| 1526 | + // squawk |
|
| 1130 | 1527 | //$data['emergency'] = ''; // emergency |
| 1131 | 1528 | //$data['registration'] = $line[2]; |
| 1132 | 1529 | //$data['aircraft_icao'] = $line[0]; |
@@ -1134,10 +1531,17 @@ discard block |
||
| 1134 | 1531 | $data['format_source'] = 'aircraftjson'; |
| 1135 | 1532 | $data['id_source'] = $id_source; |
| 1136 | 1533 | if (isset($value['name']) && $value['name'] != '') { |
| 1137 | - if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
| 1138 | - else $data['source_name'] = $value['name']; |
|
| 1139 | - } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
| 1140 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1534 | + if (isset($line['mlat']) && !empty($line['mlat'])) { |
|
| 1535 | + $data['source_name'] = $value['name'].'_MLAT'; |
|
| 1536 | + } else { |
|
| 1537 | + $data['source_name'] = $value['name']; |
|
| 1538 | + } |
|
| 1539 | + } elseif (isset($line['mlat']) && !empty($line['mlat'])) { |
|
| 1540 | + $data['source_name'] = 'MLAT'; |
|
| 1541 | + } |
|
| 1542 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1543 | + $data['noarchive'] = true; |
|
| 1544 | + } |
|
| 1141 | 1545 | $SI->add($data); |
| 1142 | 1546 | unset($data); |
| 1143 | 1547 | } |
@@ -1157,22 +1561,54 @@ discard block |
||
| 1157 | 1561 | foreach ($all_data['aircraft'] as $key => $line) { |
| 1158 | 1562 | $data = array(); |
| 1159 | 1563 | $data['hex'] = $key; // hex |
| 1160 | - if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident |
|
| 1161 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1162 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1163 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1164 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1165 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1166 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1167 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1564 | + if (isset($line['callsign'])) { |
|
| 1565 | + $data['ident'] = trim($line['callsign']); |
|
| 1566 | + } |
|
| 1567 | + // ident |
|
| 1568 | + if (isset($line['altitude'])) { |
|
| 1569 | + $data['altitude'] = $line['altitude']; |
|
| 1570 | + } |
|
| 1571 | + // altitude |
|
| 1572 | + if (isset($line['speed'])) { |
|
| 1573 | + $data['speed'] = $line['speed']; |
|
| 1574 | + } |
|
| 1575 | + // speed |
|
| 1576 | + if (isset($line['heading'])) { |
|
| 1577 | + $data['heading'] = $line['heading']; |
|
| 1578 | + } |
|
| 1579 | + // heading |
|
| 1580 | + if (isset($line['lat'])) { |
|
| 1581 | + $data['latitude'] = $line['lat']; |
|
| 1582 | + } |
|
| 1583 | + // lat |
|
| 1584 | + if (isset($line['lon'])) { |
|
| 1585 | + $data['longitude'] = $line['lon']; |
|
| 1586 | + } |
|
| 1587 | + // long |
|
| 1588 | + if (isset($line['vert_rate'])) { |
|
| 1589 | + $data['verticalrate'] = $line['vert_rate']; |
|
| 1590 | + } |
|
| 1591 | + // verticale rate |
|
| 1592 | + if (isset($line['squawk'])) { |
|
| 1593 | + $data['squawk'] = $line['squawk']; |
|
| 1594 | + } |
|
| 1595 | + // squawk |
|
| 1168 | 1596 | //$data['emergency'] = ''; // emergency |
| 1169 | - if (isset($line['reg'])) $data['registration'] = $line['reg']; |
|
| 1170 | - if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
|
| 1597 | + if (isset($line['reg'])) { |
|
| 1598 | + $data['registration'] = $line['reg']; |
|
| 1599 | + } |
|
| 1600 | + if (isset($line['type'])) { |
|
| 1601 | + $data['aircraft_icao'] = $line['type']; |
|
| 1602 | + } |
|
| 1171 | 1603 | $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
| 1172 | 1604 | $data['format_source'] = 'planefinderclient'; |
| 1173 | 1605 | $data['id_source'] = $id_source; |
| 1174 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1175 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1606 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1607 | + $data['source_name'] = $value['name']; |
|
| 1608 | + } |
|
| 1609 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1610 | + $data['noarchive'] = true; |
|
| 1611 | + } |
|
| 1176 | 1612 | $SI->add($data); |
| 1177 | 1613 | unset($data); |
| 1178 | 1614 | } |
@@ -1188,7 +1624,9 @@ discard block |
||
| 1188 | 1624 | //$buffer = $Common->getData($hosts[$id]); |
| 1189 | 1625 | $buffer = $Common->getData($value['host']); |
| 1190 | 1626 | $all_data = json_decode($buffer,true); |
| 1191 | - if (!empty($all_data)) $reset = 0; |
|
| 1627 | + if (!empty($all_data)) { |
|
| 1628 | + $reset = 0; |
|
| 1629 | + } |
|
| 1192 | 1630 | foreach ($all_data as $key => $line) { |
| 1193 | 1631 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 1194 | 1632 | $data = array(); |
@@ -1209,8 +1647,12 @@ discard block |
||
| 1209 | 1647 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
| 1210 | 1648 | $data['format_source'] = 'fr24json'; |
| 1211 | 1649 | $data['id_source'] = $id_source; |
| 1212 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1213 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1650 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1651 | + $data['noarchive'] = true; |
|
| 1652 | + } |
|
| 1653 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1654 | + $data['source_name'] = $value['name']; |
|
| 1655 | + } |
|
| 1214 | 1656 | $SI->add($data); |
| 1215 | 1657 | unset($data); |
| 1216 | 1658 | } |
@@ -1239,24 +1681,42 @@ discard block |
||
| 1239 | 1681 | if (isset($line['inf'])) { |
| 1240 | 1682 | $data = array(); |
| 1241 | 1683 | $data['hex'] = $line['inf']['ia']; |
| 1242 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
| 1684 | + if (isset($line['inf']['cs'])) { |
|
| 1685 | + $data['ident'] = $line['inf']['cs']; |
|
| 1686 | + } |
|
| 1687 | + //$line[13] |
|
| 1243 | 1688 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
| 1244 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 1245 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 1689 | + if (isset($line['inf']['gs'])) { |
|
| 1690 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
| 1691 | + } |
|
| 1692 | + // speed |
|
| 1693 | + if (isset($line['inf']['tr'])) { |
|
| 1694 | + $data['heading'] = $line['inf']['tr']; |
|
| 1695 | + } |
|
| 1696 | + // heading |
|
| 1246 | 1697 | $data['latitude'] = $line['pt'][0]; // lat |
| 1247 | 1698 | $data['longitude'] = $line['pt'][1]; // long |
| 1248 | 1699 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
| 1249 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 1700 | + if (isset($line['inf']['sq'])) { |
|
| 1701 | + $data['squawk'] = $line['inf']['sq']; |
|
| 1702 | + } |
|
| 1703 | + // squawk |
|
| 1250 | 1704 | //$data['aircraft_icao'] = $line[8]; |
| 1251 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 1705 | + if (isset($line['inf']['rc'])) { |
|
| 1706 | + $data['registration'] = $line['inf']['rc']; |
|
| 1707 | + } |
|
| 1252 | 1708 | //$data['departure_airport_iata'] = $line[11]; |
| 1253 | 1709 | //$data['arrival_airport_iata'] = $line[12]; |
| 1254 | 1710 | //$data['emergency'] = ''; // emergency |
| 1255 | 1711 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 1256 | 1712 | $data['format_source'] = 'radarvirtueljson'; |
| 1257 | 1713 | $data['id_source'] = $id_source; |
| 1258 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1259 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1714 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1715 | + $data['noarchive'] = true; |
|
| 1716 | + } |
|
| 1717 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1718 | + $data['source_name'] = $value['name']; |
|
| 1719 | + } |
|
| 1260 | 1720 | $SI->add($data); |
| 1261 | 1721 | unset($data); |
| 1262 | 1722 | } |
@@ -1282,30 +1742,65 @@ discard block |
||
| 1282 | 1742 | $data['id'] = $line['id']; |
| 1283 | 1743 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
| 1284 | 1744 | $data['ident'] = $line['callsign']; // ident |
| 1285 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 1286 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 1287 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 1288 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 1289 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1290 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1745 | + if (isset($line['pilotid'])) { |
|
| 1746 | + $data['pilot_id'] = $line['pilotid']; |
|
| 1747 | + } |
|
| 1748 | + // pilot id |
|
| 1749 | + if (isset($line['name'])) { |
|
| 1750 | + $data['pilot_name'] = $line['name']; |
|
| 1751 | + } |
|
| 1752 | + // pilot name |
|
| 1753 | + if (isset($line['alt'])) { |
|
| 1754 | + $data['altitude'] = $line['alt']; |
|
| 1755 | + } |
|
| 1756 | + // altitude |
|
| 1757 | + if (isset($line['gs'])) { |
|
| 1758 | + $data['speed'] = $line['gs']; |
|
| 1759 | + } |
|
| 1760 | + // speed |
|
| 1761 | + if (isset($line['heading'])) { |
|
| 1762 | + $data['heading'] = $line['heading']; |
|
| 1763 | + } |
|
| 1764 | + // heading |
|
| 1765 | + if (isset($line['route'])) { |
|
| 1766 | + $data['waypoints'] = $line['route']; |
|
| 1767 | + } |
|
| 1768 | + // route |
|
| 1291 | 1769 | $data['latitude'] = $line['lat']; // lat |
| 1292 | 1770 | $data['longitude'] = $line['lon']; // long |
| 1293 | 1771 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
| 1294 | 1772 | //$data['squawk'] = $line['squawk']; // squawk |
| 1295 | 1773 | //$data['emergency'] = ''; // emergency |
| 1296 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 1297 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 1298 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1774 | + if (isset($line['depicao'])) { |
|
| 1775 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 1776 | + } |
|
| 1777 | + if (isset($line['deptime'])) { |
|
| 1778 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 1779 | + } |
|
| 1780 | + if (isset($line['arricao'])) { |
|
| 1781 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1782 | + } |
|
| 1299 | 1783 | //$data['arrival_airport_time'] = $line['arrtime']; |
| 1300 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 1301 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 1302 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 1303 | - else $data['info'] = ''; |
|
| 1784 | + if (isset($line['aircraft'])) { |
|
| 1785 | + $data['aircraft_icao'] = $line['aircraft']; |
|
| 1786 | + } |
|
| 1787 | + if (isset($line['transponder'])) { |
|
| 1788 | + $data['squawk'] = $line['transponder']; |
|
| 1789 | + } |
|
| 1790 | + if (isset($line['atis'])) { |
|
| 1791 | + $data['info'] = $line['atis']; |
|
| 1792 | + } else { |
|
| 1793 | + $data['info'] = ''; |
|
| 1794 | + } |
|
| 1304 | 1795 | $data['format_source'] = 'pireps'; |
| 1305 | 1796 | $data['id_source'] = $id_source; |
| 1306 | 1797 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1307 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1308 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1798 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1799 | + $data['noarchive'] = true; |
|
| 1800 | + } |
|
| 1801 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1802 | + $data['source_name'] = $value['name']; |
|
| 1803 | + } |
|
| 1309 | 1804 | if ($line['icon'] === 'plane') { |
| 1310 | 1805 | $SI->add($data); |
| 1311 | 1806 | // print_r($data); |
@@ -1314,16 +1809,28 @@ discard block |
||
| 1314 | 1809 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 1315 | 1810 | $typec = substr($data['ident'],-3); |
| 1316 | 1811 | $data['type'] = ''; |
| 1317 | - if ($typec === 'APP') $data['type'] = 'Approach'; |
|
| 1318 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
| 1319 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
|
| 1320 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; |
|
| 1321 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; |
|
| 1322 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; |
|
| 1323 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 1324 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 1325 | - else $data['type'] = 'Observer'; |
|
| 1326 | - 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']); |
|
| 1812 | + if ($typec === 'APP') { |
|
| 1813 | + $data['type'] = 'Approach'; |
|
| 1814 | + } elseif ($typec === 'TWR') { |
|
| 1815 | + $data['type'] = 'Tower'; |
|
| 1816 | + } elseif ($typec === 'OBS') { |
|
| 1817 | + $data['type'] = 'Observer'; |
|
| 1818 | + } elseif ($typec === 'GND') { |
|
| 1819 | + $data['type'] = 'Ground'; |
|
| 1820 | + } elseif ($typec === 'DEL') { |
|
| 1821 | + $data['type'] = 'Delivery'; |
|
| 1822 | + } elseif ($typec === 'DEP') { |
|
| 1823 | + $data['type'] = 'Departure'; |
|
| 1824 | + } elseif ($typec === 'FSS') { |
|
| 1825 | + $data['type'] = 'Flight Service Station'; |
|
| 1826 | + } elseif ($typec === 'CTR') { |
|
| 1827 | + $data['type'] = 'Control Radar or Centre'; |
|
| 1828 | + } else { |
|
| 1829 | + $data['type'] = 'Observer'; |
|
| 1830 | + } |
|
| 1831 | + if (isset($ATC)) { |
|
| 1832 | + 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']); |
|
| 1833 | + } |
|
| 1327 | 1834 | } |
| 1328 | 1835 | unset($data); |
| 1329 | 1836 | } |
@@ -1338,7 +1845,9 @@ discard block |
||
| 1338 | 1845 | ) |
| 1339 | 1846 | ) { |
| 1340 | 1847 | //$buffer = $Common->getData($hosts[$id]); |
| 1341 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1848 | + if ($globalDebug) { |
|
| 1849 | + echo 'Get Data...'."\n"; |
|
| 1850 | + } |
|
| 1342 | 1851 | $buffer = $Common->getData($value['host']); |
| 1343 | 1852 | $all_data = json_decode($buffer,true); |
| 1344 | 1853 | if ($buffer != '' && is_array($all_data)) { |
@@ -1346,10 +1855,16 @@ discard block |
||
| 1346 | 1855 | foreach ($all_data as $line) { |
| 1347 | 1856 | $data = array(); |
| 1348 | 1857 | //$data['id'] = $line['id']; // id not usable |
| 1349 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1858 | + if (isset($line['pilotid'])) { |
|
| 1859 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1860 | + } |
|
| 1350 | 1861 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
| 1351 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 1352 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 1862 | + if (isset($line['pilotname'])) { |
|
| 1863 | + $data['pilot_name'] = $line['pilotname']; |
|
| 1864 | + } |
|
| 1865 | + if (isset($line['pilotid'])) { |
|
| 1866 | + $data['pilot_id'] = $line['pilotid']; |
|
| 1867 | + } |
|
| 1353 | 1868 | $data['ident'] = $line['flightnum']; // ident |
| 1354 | 1869 | $data['altitude'] = $line['alt']; // altitude |
| 1355 | 1870 | $data['speed'] = $line['gs']; // speed |
@@ -1365,7 +1880,9 @@ discard block |
||
| 1365 | 1880 | $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
| 1366 | 1881 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
| 1367 | 1882 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1368 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1883 | + } else { |
|
| 1884 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1885 | + } |
|
| 1369 | 1886 | $data['departure_airport_icao'] = $line['depicao']; |
| 1370 | 1887 | $data['departure_airport_time'] = $line['deptime']; |
| 1371 | 1888 | $data['arrival_airport_icao'] = $line['arricao']; |
@@ -1373,29 +1890,47 @@ discard block |
||
| 1373 | 1890 | if (isset($line['registration'])) { |
| 1374 | 1891 | $data['registration'] = $line['registration']; |
| 1375 | 1892 | //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
| 1376 | - } else $data['registration'] = $line['aircraft']; |
|
| 1377 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1378 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1893 | + } else { |
|
| 1894 | + $data['registration'] = $line['aircraft']; |
|
| 1895 | + } |
|
| 1896 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1897 | + $data['noarchive'] = true; |
|
| 1898 | + } |
|
| 1899 | + if (isset($line['route'])) { |
|
| 1900 | + $data['waypoints'] = $line['route']; |
|
| 1901 | + } |
|
| 1902 | + // route |
|
| 1379 | 1903 | if (isset($line['aircraftname'])) { |
| 1380 | 1904 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 1381 | 1905 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 1382 | 1906 | $aircraft_data = explode('-',$line['aircraftname']); |
| 1383 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1384 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1385 | - else { |
|
| 1907 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { |
|
| 1908 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1909 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { |
|
| 1910 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1911 | + } else { |
|
| 1386 | 1912 | $aircraft_data = explode(' ',$line['aircraftname']); |
| 1387 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1388 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1913 | + if (isset($aircraft_data[1])) { |
|
| 1914 | + $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1915 | + } else { |
|
| 1916 | + $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1917 | + } |
|
| 1389 | 1918 | } |
| 1390 | 1919 | } |
| 1391 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 1920 | + if (isset($line['route'])) { |
|
| 1921 | + $data['waypoints'] = $line['route']; |
|
| 1922 | + } |
|
| 1392 | 1923 | $data['id_source'] = $id_source; |
| 1393 | 1924 | $data['format_source'] = 'phpvmacars'; |
| 1394 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1925 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1926 | + $data['source_name'] = $value['name']; |
|
| 1927 | + } |
|
| 1395 | 1928 | $SI->add($data); |
| 1396 | 1929 | unset($data); |
| 1397 | 1930 | } |
| 1398 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 1931 | + if ($globalDebug) { |
|
| 1932 | + echo 'No more data...'."\n"; |
|
| 1933 | + } |
|
| 1399 | 1934 | unset($buffer); |
| 1400 | 1935 | unset($all_data); |
| 1401 | 1936 | } |
@@ -1408,7 +1943,9 @@ discard block |
||
| 1408 | 1943 | ) |
| 1409 | 1944 | ) { |
| 1410 | 1945 | //$buffer = $Common->getData($hosts[$id]); |
| 1411 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1946 | + if ($globalDebug) { |
|
| 1947 | + echo 'Get Data...'."\n"; |
|
| 1948 | + } |
|
| 1412 | 1949 | $buffer = $Common->getData($value['host']); |
| 1413 | 1950 | $all_data = json_decode($buffer,true); |
| 1414 | 1951 | if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
@@ -1419,10 +1956,16 @@ discard block |
||
| 1419 | 1956 | //$data['id'] = $line['id']; // id not usable |
| 1420 | 1957 | $data['id'] = $line['id']; |
| 1421 | 1958 | //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
| 1422 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
| 1423 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
| 1959 | + if (isset($line['user']['username'])) { |
|
| 1960 | + $data['pilot_name'] = $line['user']['username']; |
|
| 1961 | + } |
|
| 1962 | + if (isset($line['user_id'])) { |
|
| 1963 | + $data['pilot_id'] = $line['user_id']; |
|
| 1964 | + } |
|
| 1424 | 1965 | $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
| 1425 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
| 1966 | + if (is_numeric($data['ident'])) { |
|
| 1967 | + $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
| 1968 | + } |
|
| 1426 | 1969 | $data['altitude'] = $line['altitude']; // altitude |
| 1427 | 1970 | $data['speed'] = $line['groundspeed']; // speed |
| 1428 | 1971 | $data['heading'] = $line['heading']; // heading |
@@ -1435,7 +1978,9 @@ discard block |
||
| 1435 | 1978 | $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
| 1436 | 1979 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
| 1437 | 1980 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1438 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1981 | + } else { |
|
| 1982 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1983 | + } |
|
| 1439 | 1984 | |
| 1440 | 1985 | $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
| 1441 | 1986 | $data['departure_airport_time'] = $line['bid']['deptime']; |
@@ -1443,17 +1988,26 @@ discard block |
||
| 1443 | 1988 | $data['arrival_airport_time'] = $line['bid']['arrtime']; |
| 1444 | 1989 | $data['registration'] = $line['bid']['aircraft']['registration']; |
| 1445 | 1990 | |
| 1446 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1447 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
| 1991 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1992 | + $data['noarchive'] = true; |
|
| 1993 | + } |
|
| 1994 | + if (isset($line['bid']['route']) && $line['bid']['route'] != '') { |
|
| 1995 | + $data['waypoints'] = $line['bid']['route']; |
|
| 1996 | + } |
|
| 1997 | + // route |
|
| 1448 | 1998 | $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
| 1449 | 1999 | |
| 1450 | 2000 | $data['id_source'] = $id_source; |
| 1451 | 2001 | $data['format_source'] = 'vaos'; |
| 1452 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 2002 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 2003 | + $data['source_name'] = $value['name']; |
|
| 2004 | + } |
|
| 1453 | 2005 | $SI->add($data); |
| 1454 | 2006 | unset($data); |
| 1455 | 2007 | } |
| 1456 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 2008 | + if ($globalDebug) { |
|
| 2009 | + echo 'No more data...'."\n"; |
|
| 2010 | + } |
|
| 1457 | 2011 | unset($buffer); |
| 1458 | 2012 | unset($all_data); |
| 1459 | 2013 | } |
@@ -1466,7 +2020,9 @@ discard block |
||
| 1466 | 2020 | ) |
| 1467 | 2021 | ) { |
| 1468 | 2022 | //$buffer = $Common->getData($hosts[$id]); |
| 1469 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 2023 | + if ($globalDebug) { |
|
| 2024 | + echo 'Get Data...'."\n"; |
|
| 2025 | + } |
|
| 1470 | 2026 | $buffer = $Common->getData($value['host']); |
| 1471 | 2027 | $all_data = json_decode($buffer,true); |
| 1472 | 2028 | if ($buffer != '' && is_array($all_data)) { |
@@ -1495,16 +2051,25 @@ discard block |
||
| 1495 | 2051 | $data['arrival_airport_icao'] = $line['arrival']; |
| 1496 | 2052 | //$data['arrival_airport_time'] = $line['arrival_time']; |
| 1497 | 2053 | //$data['registration'] = $line['aircraft']; |
| 1498 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 2054 | + if (isset($line['route'])) { |
|
| 2055 | + $data['waypoints'] = $line['route']; |
|
| 2056 | + } |
|
| 2057 | + // route |
|
| 1499 | 2058 | $data['aircraft_icao'] = $line['plane_type']; |
| 1500 | 2059 | $data['id_source'] = $id_source; |
| 1501 | 2060 | $data['format_source'] = 'vam'; |
| 1502 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1503 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 2061 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 2062 | + $data['noarchive'] = true; |
|
| 2063 | + } |
|
| 2064 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 2065 | + $data['source_name'] = $value['name']; |
|
| 2066 | + } |
|
| 1504 | 2067 | $SI->add($data); |
| 1505 | 2068 | unset($data); |
| 1506 | 2069 | } |
| 1507 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 2070 | + if ($globalDebug) { |
|
| 2071 | + echo 'No more data...'."\n"; |
|
| 2072 | + } |
|
| 1508 | 2073 | unset($buffer); |
| 1509 | 2074 | unset($all_data); |
| 1510 | 2075 | } |
@@ -1517,7 +2082,9 @@ discard block |
||
| 1517 | 2082 | ) |
| 1518 | 2083 | ) { |
| 1519 | 2084 | //$buffer = $Common->getData($hosts[$id]); |
| 1520 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 2085 | + if ($globalDebug) { |
|
| 2086 | + echo 'Get Data...'."\n"; |
|
| 2087 | + } |
|
| 1521 | 2088 | $buffer = $Common->getData($value['host']); |
| 1522 | 2089 | $all_data = json_decode($buffer,true); |
| 1523 | 2090 | if ($buffer != '') { |
@@ -1535,12 +2102,16 @@ discard block |
||
| 1535 | 2102 | $data['id_source'] = $id_source; |
| 1536 | 2103 | $data['format_source'] = 'blitzortung'; |
| 1537 | 2104 | $SI->add($data); |
| 1538 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
| 2105 | + if ($globalDebug) { |
|
| 2106 | + echo '☈ Lightning added'."\n"; |
|
| 2107 | + } |
|
| 1539 | 2108 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
| 1540 | 2109 | unset($data); |
| 1541 | 2110 | } |
| 1542 | 2111 | } |
| 1543 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 2112 | + if ($globalDebug) { |
|
| 2113 | + echo 'No more data...'."\n"; |
|
| 2114 | + } |
|
| 1544 | 2115 | unset($buffer); |
| 1545 | 2116 | } |
| 1546 | 2117 | $last_exec[$id]['last'] = time(); |
@@ -1552,7 +2123,9 @@ discard block |
||
| 1552 | 2123 | $write = NULL; |
| 1553 | 2124 | $e = NULL; |
| 1554 | 2125 | $n = socket_select($read, $write, $e, $timeout); |
| 1555 | - if ($e != NULL) var_dump($e); |
|
| 2126 | + if ($e != NULL) { |
|
| 2127 | + var_dump($e); |
|
| 2128 | + } |
|
| 1556 | 2129 | if ($n > 0) { |
| 1557 | 2130 | $reset = 0; |
| 1558 | 2131 | foreach ($read as $nb => $r) { |
@@ -1574,13 +2147,17 @@ discard block |
||
| 1574 | 2147 | if ($buffer !== FALSE) { |
| 1575 | 2148 | if ($format === 'vrstcp') { |
| 1576 | 2149 | $buffer = explode('},{',$buffer); |
| 1577 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 2150 | + } else { |
|
| 2151 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 2152 | + } |
|
| 1578 | 2153 | } |
| 1579 | 2154 | // SBS format is CSV format |
| 1580 | 2155 | if ($buffer !== FALSE && $buffer !== '') { |
| 1581 | 2156 | $tt[$format] = 0; |
| 1582 | 2157 | if ($format === 'acarssbs3') { |
| 1583 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 2158 | + if ($globalDebug) { |
|
| 2159 | + echo 'ACARS : '.$buffer."\n"; |
|
| 2160 | + } |
|
| 1584 | 2161 | $ACARS->add(trim($buffer)); |
| 1585 | 2162 | $ACARS->deleteLiveAcarsData(); |
| 1586 | 2163 | } elseif ($format === 'raw') { |
@@ -1589,30 +2166,70 @@ discard block |
||
| 1589 | 2166 | if (is_array($data)) { |
| 1590 | 2167 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1591 | 2168 | $data['format_source'] = 'raw'; |
| 1592 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1593 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1594 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1595 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 2169 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2170 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2171 | + } |
|
| 2172 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2173 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2174 | + } |
|
| 2175 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2176 | + $data['noarchive'] = true; |
|
| 2177 | + } |
|
| 2178 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2179 | + $SI->add($data); |
|
| 2180 | + } |
|
| 1596 | 2181 | } |
| 1597 | 2182 | } elseif ($format === 'ais') { |
| 1598 | 2183 | $ais_data = $AIS->parse_line(trim($buffer)); |
| 1599 | 2184 | $data = array(); |
| 1600 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1601 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 1602 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1603 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1604 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1605 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1606 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1607 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 1608 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1609 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1610 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1611 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1612 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1613 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1614 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1615 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2185 | + if (isset($ais_data['ident'])) { |
|
| 2186 | + $data['ident'] = $ais_data['ident']; |
|
| 2187 | + } |
|
| 2188 | + if (isset($ais_data['mmsi'])) { |
|
| 2189 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 2190 | + } |
|
| 2191 | + if (isset($ais_data['speed'])) { |
|
| 2192 | + $data['speed'] = $ais_data['speed']; |
|
| 2193 | + } |
|
| 2194 | + if (isset($ais_data['heading'])) { |
|
| 2195 | + $data['heading'] = $ais_data['heading']; |
|
| 2196 | + } |
|
| 2197 | + if (isset($ais_data['latitude'])) { |
|
| 2198 | + $data['latitude'] = $ais_data['latitude']; |
|
| 2199 | + } |
|
| 2200 | + if (isset($ais_data['longitude'])) { |
|
| 2201 | + $data['longitude'] = $ais_data['longitude']; |
|
| 2202 | + } |
|
| 2203 | + if (isset($ais_data['status'])) { |
|
| 2204 | + $data['status'] = $ais_data['status']; |
|
| 2205 | + } |
|
| 2206 | + if (isset($ais_data['statusid'])) { |
|
| 2207 | + $data['status_id'] = $ais_data['statusid']; |
|
| 2208 | + } |
|
| 2209 | + if (isset($ais_data['type'])) { |
|
| 2210 | + $data['type'] = $ais_data['type']; |
|
| 2211 | + } |
|
| 2212 | + if (isset($ais_data['imo'])) { |
|
| 2213 | + $data['imo'] = $ais_data['imo']; |
|
| 2214 | + } |
|
| 2215 | + if (isset($ais_data['callsign'])) { |
|
| 2216 | + $data['callsign'] = $ais_data['callsign']; |
|
| 2217 | + } |
|
| 2218 | + if (isset($ais_data['destination'])) { |
|
| 2219 | + $data['arrival_code'] = $ais_data['destination']; |
|
| 2220 | + } |
|
| 2221 | + if (isset($ais_data['eta_ts'])) { |
|
| 2222 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 2223 | + } |
|
| 2224 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2225 | + $data['noarchive'] = true; |
|
| 2226 | + } |
|
| 2227 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2228 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2229 | + } |
|
| 2230 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2231 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2232 | + } |
|
| 1616 | 2233 | |
| 1617 | 2234 | if (isset($ais_data['timestamp'])) { |
| 1618 | 2235 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1621,7 +2238,9 @@ discard block |
||
| 1621 | 2238 | } |
| 1622 | 2239 | $data['format_source'] = 'aisnmea'; |
| 1623 | 2240 | $data['id_source'] = $id_source; |
| 1624 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 2241 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
| 2242 | + $MI->add($data); |
|
| 2243 | + } |
|
| 1625 | 2244 | unset($data); |
| 1626 | 2245 | } elseif ($format === 'flightgearsp') { |
| 1627 | 2246 | //echo $buffer."\n"; |
@@ -1639,12 +2258,18 @@ discard block |
||
| 1639 | 2258 | $data['speed'] = round($line[5]*1.94384); |
| 1640 | 2259 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1641 | 2260 | $data['format_source'] = 'flightgearsp'; |
| 1642 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1643 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 2261 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2262 | + $data['noarchive'] = true; |
|
| 2263 | + } |
|
| 2264 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2265 | + $SI->add($data); |
|
| 2266 | + } |
|
| 1644 | 2267 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1645 | 2268 | } |
| 1646 | 2269 | } elseif ($format === 'acars') { |
| 1647 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 2270 | + if ($globalDebug) { |
|
| 2271 | + echo 'ACARS : '.$buffer."\n"; |
|
| 2272 | + } |
|
| 1648 | 2273 | $ACARS->add(trim($buffer)); |
| 1649 | 2274 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
| 1650 | 2275 | $ACARS->deleteLiveAcarsData(); |
@@ -1665,8 +2290,12 @@ discard block |
||
| 1665 | 2290 | $aircraft_type = $line[10]; |
| 1666 | 2291 | $aircraft_type = preg_split(':/:',$aircraft_type); |
| 1667 | 2292 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
| 1668 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1669 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 2293 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2294 | + $data['noarchive'] = true; |
|
| 2295 | + } |
|
| 2296 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2297 | + $SI->add($data); |
|
| 2298 | + } |
|
| 1670 | 2299 | } |
| 1671 | 2300 | } |
| 1672 | 2301 | } elseif ($format === 'beast') { |
@@ -1676,28 +2305,62 @@ discard block |
||
| 1676 | 2305 | foreach($buffer as $all_data) { |
| 1677 | 2306 | $line = json_decode('{'.$all_data.'}',true); |
| 1678 | 2307 | $data = array(); |
| 1679 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
| 1680 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 1681 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 1682 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 1683 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 1684 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 1685 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 2308 | + if (isset($line['Icao'])) { |
|
| 2309 | + $data['hex'] = $line['Icao']; |
|
| 2310 | + } |
|
| 2311 | + // hex |
|
| 2312 | + if (isset($line['Call'])) { |
|
| 2313 | + $data['ident'] = $line['Call']; |
|
| 2314 | + } |
|
| 2315 | + // ident |
|
| 2316 | + if (isset($line['Alt'])) { |
|
| 2317 | + $data['altitude'] = $line['Alt']; |
|
| 2318 | + } |
|
| 2319 | + // altitude |
|
| 2320 | + if (isset($line['Spd'])) { |
|
| 2321 | + $data['speed'] = $line['Spd']; |
|
| 2322 | + } |
|
| 2323 | + // speed |
|
| 2324 | + if (isset($line['Trak'])) { |
|
| 2325 | + $data['heading'] = $line['Trak']; |
|
| 2326 | + } |
|
| 2327 | + // heading |
|
| 2328 | + if (isset($line['Lat'])) { |
|
| 2329 | + $data['latitude'] = $line['Lat']; |
|
| 2330 | + } |
|
| 2331 | + // lat |
|
| 2332 | + if (isset($line['Long'])) { |
|
| 2333 | + $data['longitude'] = $line['Long']; |
|
| 2334 | + } |
|
| 2335 | + // long |
|
| 1686 | 2336 | //$data['verticalrate'] = $line['']; // verticale rate |
| 1687 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 2337 | + if (isset($line['Sqk'])) { |
|
| 2338 | + $data['squawk'] = $line['Sqk']; |
|
| 2339 | + } |
|
| 2340 | + // squawk |
|
| 1688 | 2341 | $data['emergency'] = ''; // emergency |
| 1689 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 2342 | + if (isset($line['Reg'])) { |
|
| 2343 | + $data['registration'] = $line['Reg']; |
|
| 2344 | + } |
|
| 1690 | 2345 | /* |
| 1691 | 2346 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
| 1692 | 2347 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 1693 | 2348 | */ |
| 1694 | 2349 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1695 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 2350 | + if (isset($line['Type'])) { |
|
| 2351 | + $data['aircraft_icao'] = $line['Type']; |
|
| 2352 | + } |
|
| 1696 | 2353 | $data['format_source'] = 'vrstcp'; |
| 1697 | 2354 | $data['id_source'] = $id_source; |
| 1698 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1699 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1700 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
| 2355 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2356 | + $data['noarchive'] = true; |
|
| 2357 | + } |
|
| 2358 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 2359 | + $data['source_name'] = $value['name']; |
|
| 2360 | + } |
|
| 2361 | + if (isset($data['latitude']) && isset($data['hex'])) { |
|
| 2362 | + $SI->add($data); |
|
| 2363 | + } |
|
| 1701 | 2364 | unset($data); |
| 1702 | 2365 | } |
| 1703 | 2366 | } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
@@ -1710,22 +2373,46 @@ discard block |
||
| 1710 | 2373 | $data['hex'] = $lined['hexid']; |
| 1711 | 2374 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
| 1712 | 2375 | $data['datetime'] = date('Y-m-d H:i:s');; |
| 1713 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1714 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1715 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1716 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1717 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1718 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1719 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 2376 | + if (isset($lined['ident'])) { |
|
| 2377 | + $data['ident'] = $lined['ident']; |
|
| 2378 | + } |
|
| 2379 | + if (isset($lined['lat'])) { |
|
| 2380 | + $data['latitude'] = $lined['lat']; |
|
| 2381 | + } |
|
| 2382 | + if (isset($lined['lon'])) { |
|
| 2383 | + $data['longitude'] = $lined['lon']; |
|
| 2384 | + } |
|
| 2385 | + if (isset($lined['speed'])) { |
|
| 2386 | + $data['speed'] = $lined['speed']; |
|
| 2387 | + } |
|
| 2388 | + if (isset($lined['squawk'])) { |
|
| 2389 | + $data['squawk'] = $lined['squawk']; |
|
| 2390 | + } |
|
| 2391 | + if (isset($lined['alt'])) { |
|
| 2392 | + $data['altitude'] = $lined['alt']; |
|
| 2393 | + } |
|
| 2394 | + if (isset($lined['heading'])) { |
|
| 2395 | + $data['heading'] = $lined['heading']; |
|
| 2396 | + } |
|
| 1720 | 2397 | $data['id_source'] = $id_source; |
| 1721 | 2398 | $data['format_source'] = 'tsv'; |
| 1722 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1723 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1724 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1725 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 2399 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2400 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2401 | + } |
|
| 2402 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2403 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2404 | + } |
|
| 2405 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2406 | + $data['noarchive'] = true; |
|
| 2407 | + } |
|
| 2408 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2409 | + $SI->add($data); |
|
| 2410 | + } |
|
| 1726 | 2411 | unset($lined); |
| 1727 | 2412 | unset($data); |
| 1728 | - } else $error = true; |
|
| 2413 | + } else { |
|
| 2414 | + $error = true; |
|
| 2415 | + } |
|
| 1729 | 2416 | } elseif ($format === 'aprs' && $use_aprs) { |
| 1730 | 2417 | if ($aprs_connect === 0) { |
| 1731 | 2418 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1751,47 +2438,96 @@ discard block |
||
| 1751 | 2438 | $aprs_last_tx = time(); |
| 1752 | 2439 | $data = array(); |
| 1753 | 2440 | //print_r($line); |
| 1754 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1755 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
| 1756 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
| 1757 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
| 1758 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
| 1759 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
| 1760 | - if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
| 1761 | - if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
| 1762 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1763 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2441 | + if (isset($line['address'])) { |
|
| 2442 | + $data['hex'] = $line['address']; |
|
| 2443 | + } |
|
| 2444 | + if (isset($line['mmsi'])) { |
|
| 2445 | + $data['mmsi'] = $line['mmsi']; |
|
| 2446 | + } |
|
| 2447 | + if (isset($line['imo'])) { |
|
| 2448 | + $data['imo'] = $line['imo']; |
|
| 2449 | + } |
|
| 2450 | + if (isset($line['squawk'])) { |
|
| 2451 | + $data['squawk'] = $line['squawk']; |
|
| 2452 | + } |
|
| 2453 | + if (isset($line['arrival_code'])) { |
|
| 2454 | + $data['arrival_code'] = $line['arrival_code']; |
|
| 2455 | + } |
|
| 2456 | + if (isset($line['arrival_date'])) { |
|
| 2457 | + $data['arrival_date'] = $line['arrival_date']; |
|
| 2458 | + } |
|
| 2459 | + if (isset($line['typeid'])) { |
|
| 2460 | + $data['type_id'] = $line['typeid']; |
|
| 2461 | + } |
|
| 2462 | + if (isset($line['statusid'])) { |
|
| 2463 | + $data['status_id'] = $line['statusid']; |
|
| 2464 | + } |
|
| 2465 | + if (isset($line['timestamp'])) { |
|
| 2466 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 2467 | + } else { |
|
| 2468 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2469 | + } |
|
| 1764 | 2470 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 1765 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 2471 | + if (isset($line['ident'])) { |
|
| 2472 | + $data['ident'] = $line['ident']; |
|
| 2473 | + } |
|
| 1766 | 2474 | $data['latitude'] = $line['latitude']; |
| 1767 | 2475 | $data['longitude'] = $line['longitude']; |
| 1768 | 2476 | //$data['verticalrate'] = $line[16]; |
| 1769 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 2477 | + if (isset($line['speed'])) { |
|
| 2478 | + $data['speed'] = $line['speed']; |
|
| 2479 | + } |
|
| 1770 | 2480 | //else $data['speed'] = 0; |
| 1771 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1772 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1773 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 2481 | + if (isset($line['altitude'])) { |
|
| 2482 | + $data['altitude'] = $line['altitude']; |
|
| 2483 | + } |
|
| 2484 | + if (isset($line['comment'])) { |
|
| 2485 | + $data['comment'] = $line['comment']; |
|
| 2486 | + } |
|
| 2487 | + if (isset($line['symbol'])) { |
|
| 2488 | + $data['type'] = $line['symbol']; |
|
| 2489 | + } |
|
| 1774 | 2490 | //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
| 1775 | 2491 | |
| 1776 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
| 2492 | + if (isset($line['heading']) && isset($line['format_source'])) { |
|
| 2493 | + $data['heading'] = $line['heading']; |
|
| 2494 | + } |
|
| 1777 | 2495 | //else echo 'No heading...'."\n"; |
| 1778 | 2496 | //else $data['heading'] = 0; |
| 1779 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 2497 | + if (isset($line['stealth'])) { |
|
| 2498 | + $data['aircraft_type'] = $line['stealth']; |
|
| 2499 | + } |
|
| 1780 | 2500 | //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
| 1781 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
| 1782 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
| 1783 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1784 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
| 2501 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) { |
|
| 2502 | + $data['noarchive'] = true; |
|
| 2503 | + } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) { |
|
| 2504 | + $data['noarchive'] = false; |
|
| 2505 | + } |
|
| 2506 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2507 | + $data['noarchive'] = true; |
|
| 2508 | + } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) { |
|
| 2509 | + $data['noarchive'] = false; |
|
| 2510 | + } |
|
| 1785 | 2511 | $data['id_source'] = $id_source; |
| 1786 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1787 | - else $data['format_source'] = 'aprs'; |
|
| 2512 | + if (isset($line['format_source'])) { |
|
| 2513 | + $data['format_source'] = $line['format_source']; |
|
| 2514 | + } else { |
|
| 2515 | + $data['format_source'] = 'aprs'; |
|
| 2516 | + } |
|
| 1788 | 2517 | $data['source_name'] = $line['source']; |
| 1789 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1790 | - else $data['source_type'] = 'flarm'; |
|
| 1791 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2518 | + if (isset($line['source_type'])) { |
|
| 2519 | + $data['source_type'] = $line['source_type']; |
|
| 2520 | + } else { |
|
| 2521 | + $data['source_type'] = 'flarm'; |
|
| 2522 | + } |
|
| 2523 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2524 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2525 | + } |
|
| 1792 | 2526 | $currentdate = date('Y-m-d H:i:s'); |
| 1793 | 2527 | $aprsdate = strtotime($data['datetime']); |
| 1794 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
| 2528 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') { |
|
| 2529 | + $data['altitude_relative'] = 'AMSL'; |
|
| 2530 | + } |
|
| 1795 | 2531 | // Accept data if time <= system time + 20s |
| 1796 | 2532 | //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'])))) { |
| 1797 | 2533 | if ( |
@@ -1803,7 +2539,9 @@ discard block |
||
| 1803 | 2539 | $send = $SI->add($data); |
| 1804 | 2540 | } elseif ($data['source_type'] === 'ais') { |
| 1805 | 2541 | $data['type'] = ''; |
| 1806 | - if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
|
| 2542 | + if (isset($globalMarine) && $globalMarine) { |
|
| 2543 | + $send = $MI->add($data); |
|
| 2544 | + } |
|
| 1807 | 2545 | } elseif (isset($line['stealth']) && $line['stealth'] != 0) { |
| 1808 | 2546 | echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
| 1809 | 2547 | } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
@@ -1811,8 +2549,12 @@ discard block |
||
| 1811 | 2549 | $line['symbol'] === 'Glider' || |
| 1812 | 2550 | $line['symbol'] === 'No. Plane' || |
| 1813 | 2551 | $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
| 1814 | - if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
| 1815 | - if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
| 2552 | + if ($line['symbol'] === 'Ballon') { |
|
| 2553 | + $data['aircraft_icao'] = 'BALL'; |
|
| 2554 | + } |
|
| 2555 | + if ($line['symbol'] === 'Glider') { |
|
| 2556 | + $data['aircraft_icao'] = 'PARAGLIDER'; |
|
| 2557 | + } |
|
| 1816 | 2558 | $send = $SI->add($data); |
| 1817 | 2559 | } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
| 1818 | 2560 | $line['symbol'] === 'Yacht (Sail)' || |
@@ -1843,9 +2585,13 @@ discard block |
||
| 1843 | 2585 | //} 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') { |
| 1844 | 2586 | // } 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') { |
| 1845 | 2587 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
| 1846 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
| 2588 | + if (isset($globalTracker) && $globalTracker) { |
|
| 2589 | + $send = $TI->add($data); |
|
| 2590 | + } |
|
| 1847 | 2591 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
| 1848 | - if (!isset($data['altitude'])) $data['altitude'] = 0; |
|
| 2592 | + if (!isset($data['altitude'])) { |
|
| 2593 | + $data['altitude'] = 0; |
|
| 2594 | + } |
|
| 1849 | 2595 | $Source->deleteOldLocationByType('gs'); |
| 1850 | 2596 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
| 1851 | 2597 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
@@ -1854,7 +2600,9 @@ discard block |
||
| 1854 | 2600 | } |
| 1855 | 2601 | } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
| 1856 | 2602 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 1857 | - if ($globalDebug) echo '# Weather Station added'."\n"; |
|
| 2603 | + if ($globalDebug) { |
|
| 2604 | + echo '# Weather Station added'."\n"; |
|
| 2605 | + } |
|
| 1858 | 2606 | $Source->deleteOldLocationByType('wx'); |
| 1859 | 2607 | $weather_data = json_encode($line); |
| 1860 | 2608 | if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
@@ -1864,7 +2612,9 @@ discard block |
||
| 1864 | 2612 | } |
| 1865 | 2613 | } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
| 1866 | 2614 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 1867 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
| 2615 | + if ($globalDebug) { |
|
| 2616 | + echo '☈ Lightning added'."\n"; |
|
| 2617 | + } |
|
| 1868 | 2618 | $Source->deleteOldLocationByType('lightning'); |
| 1869 | 2619 | if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
| 1870 | 2620 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
@@ -1876,8 +2626,7 @@ discard block |
||
| 1876 | 2626 | print_r($line); |
| 1877 | 2627 | } |
| 1878 | 2628 | unset($data); |
| 1879 | - } |
|
| 1880 | - elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
| 2629 | + } elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
| 1881 | 2630 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
| 1882 | 2631 | } |
| 1883 | 2632 | /* |
@@ -1886,7 +2635,9 @@ discard block |
||
| 1886 | 2635 | } |
| 1887 | 2636 | */ |
| 1888 | 2637 | //elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
| 1889 | - elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
|
| 2638 | + elseif ($line === true && $globalDebug) { |
|
| 2639 | + echo '!! Failed : '.$buffer."!!\n"; |
|
| 2640 | + } |
|
| 1890 | 2641 | if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
| 1891 | 2642 | $Source->deleteOldLocationByType('lightning'); |
| 1892 | 2643 | $Source->deleteOldLocationByType('wx'); |
@@ -1922,27 +2673,47 @@ discard block |
||
| 1922 | 2673 | $data['ground'] = $line[21]; |
| 1923 | 2674 | $data['emergency'] = $line[19]; |
| 1924 | 2675 | $data['format_source'] = 'sbs'; |
| 1925 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1926 | - elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT'; |
|
| 1927 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1928 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 2676 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2677 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2678 | + } elseif ($line[0] == 'MLAT') { |
|
| 2679 | + $data['source_name'] = 'MLAT'; |
|
| 2680 | + } |
|
| 2681 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2682 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2683 | + } |
|
| 2684 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2685 | + $data['noarchive'] = true; |
|
| 2686 | + } |
|
| 1929 | 2687 | $data['id_source'] = $id_source; |
| 1930 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1931 | - else $error = true; |
|
| 2688 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2689 | + $send = $SI->add($data); |
|
| 2690 | + } else { |
|
| 2691 | + $error = true; |
|
| 2692 | + } |
|
| 1932 | 2693 | unset($data); |
| 1933 | - } else $error = true; |
|
| 2694 | + } else { |
|
| 2695 | + $error = true; |
|
| 2696 | + } |
|
| 1934 | 2697 | if ($error) { |
| 1935 | 2698 | if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { |
| 1936 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
| 2699 | + if ($globalDebug) { |
|
| 2700 | + echo "Not a message. Ignoring... \n"; |
|
| 2701 | + } |
|
| 1937 | 2702 | } else { |
| 1938 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
| 2703 | + if ($globalDebug) { |
|
| 2704 | + echo "Wrong line format. Ignoring... \n"; |
|
| 2705 | + } |
|
| 1939 | 2706 | if ($globalDebug) { |
| 1940 | 2707 | echo $buffer; |
| 1941 | 2708 | //print_r($line); |
| 1942 | 2709 | } |
| 1943 | 2710 | //socket_close($r); |
| 1944 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
| 1945 | - if ($format === 'aprs') $aprs_connect = 0; |
|
| 2711 | + if ($globalDebug) { |
|
| 2712 | + echo "Reconnect after an error...\n"; |
|
| 2713 | + } |
|
| 2714 | + if ($format === 'aprs') { |
|
| 2715 | + $aprs_connect = 0; |
|
| 2716 | + } |
|
| 1946 | 2717 | $sourceer[$nb] = $globalSources[$nb]; |
| 1947 | 2718 | connect_all($sourceer); |
| 1948 | 2719 | $sourceer = array(); |
@@ -1950,10 +2721,14 @@ discard block |
||
| 1950 | 2721 | } |
| 1951 | 2722 | } |
| 1952 | 2723 | // Sleep for xxx microseconds |
| 1953 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
| 2724 | + if (isset($globalSBSSleep)) { |
|
| 2725 | + usleep($globalSBSSleep); |
|
| 2726 | + } |
|
| 1954 | 2727 | } else { |
| 1955 | 2728 | if ($format === 'flightgearmp') { |
| 1956 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 2729 | + if ($globalDebug) { |
|
| 2730 | + echo "Reconnect FlightGear MP..."; |
|
| 2731 | + } |
|
| 1957 | 2732 | //@socket_close($r); |
| 1958 | 2733 | sleep($globalMinFetch); |
| 1959 | 2734 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1962,10 +2737,15 @@ discard block |
||
| 1962 | 2737 | break; |
| 1963 | 2738 | |
| 1964 | 2739 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 1965 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 1966 | - else $tt[$format] = 0; |
|
| 2740 | + if (isset($tt[$format])) { |
|
| 2741 | + $tt[$format]++; |
|
| 2742 | + } else { |
|
| 2743 | + $tt[$format] = 0; |
|
| 2744 | + } |
|
| 1967 | 2745 | if ($tt[$format] > 30 || $buffer === FALSE) { |
| 1968 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
| 2746 | + if ($globalDebug) { |
|
| 2747 | + echo "ERROR : Reconnect ".$format."..."; |
|
| 2748 | + } |
|
| 1969 | 2749 | //@socket_close($r); |
| 1970 | 2750 | sleep(2); |
| 1971 | 2751 | $aprs_connect = 0; |
@@ -1983,11 +2763,17 @@ discard block |
||
| 1983 | 2763 | } else { |
| 1984 | 2764 | $error = socket_strerror(socket_last_error()); |
| 1985 | 2765 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 1986 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 1987 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
| 2766 | + if ($globalDebug) { |
|
| 2767 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 2768 | + } |
|
| 2769 | + if (isset($globalDebug)) { |
|
| 2770 | + echo "Restarting...\n"; |
|
| 2771 | + } |
|
| 1988 | 2772 | // Restart the script if possible |
| 1989 | 2773 | if (is_array($sockets)) { |
| 1990 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 2774 | + if ($globalDebug) { |
|
| 2775 | + echo "Shutdown all sockets..."; |
|
| 2776 | + } |
|
| 1991 | 2777 | |
| 1992 | 2778 | foreach ($sockets as $sock) { |
| 1993 | 2779 | @socket_shutdown($sock,2); |
@@ -1995,25 +2781,45 @@ discard block |
||
| 1995 | 2781 | } |
| 1996 | 2782 | |
| 1997 | 2783 | } |
| 1998 | - if ($globalDebug) echo "Waiting..."; |
|
| 2784 | + if ($globalDebug) { |
|
| 2785 | + echo "Waiting..."; |
|
| 2786 | + } |
|
| 1999 | 2787 | sleep(2); |
| 2000 | 2788 | $time = time(); |
| 2001 | 2789 | //connect_all($hosts); |
| 2002 | 2790 | $aprs_connect = 0; |
| 2003 | - if ($reset%5 === 0) sleep(20); |
|
| 2004 | - if ($reset%10 === 0) sleep(100); |
|
| 2005 | - if ($reset%20 === 0) sleep(200); |
|
| 2006 | - if ($reset > 100) exit('Too many attempts...'); |
|
| 2007 | - if ($globalDebug) echo "Restart all connections..."; |
|
| 2791 | + if ($reset%5 === 0) { |
|
| 2792 | + sleep(20); |
|
| 2793 | + } |
|
| 2794 | + if ($reset%10 === 0) { |
|
| 2795 | + sleep(100); |
|
| 2796 | + } |
|
| 2797 | + if ($reset%20 === 0) { |
|
| 2798 | + sleep(200); |
|
| 2799 | + } |
|
| 2800 | + if ($reset > 100) { |
|
| 2801 | + exit('Too many attempts...'); |
|
| 2802 | + } |
|
| 2803 | + if ($globalDebug) { |
|
| 2804 | + echo "Restart all connections..."; |
|
| 2805 | + } |
|
| 2008 | 2806 | connect_all($globalSources); |
| 2009 | 2807 | } |
| 2010 | 2808 | } |
| 2011 | 2809 | } |
| 2012 | 2810 | if ($globalDaemon === false) { |
| 2013 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
| 2014 | - if (isset($SI)) $SI->checkAll(); |
|
| 2015 | - if (isset($TI)) $TI->checkAll(); |
|
| 2016 | - if (isset($MI)) $MI->checkAll(); |
|
| 2811 | + if ($globalDebug) { |
|
| 2812 | + echo 'Check all...'."\n"; |
|
| 2813 | + } |
|
| 2814 | + if (isset($SI)) { |
|
| 2815 | + $SI->checkAll(); |
|
| 2816 | + } |
|
| 2817 | + if (isset($TI)) { |
|
| 2818 | + $TI->checkAll(); |
|
| 2819 | + } |
|
| 2820 | + if (isset($MI)) { |
|
| 2821 | + $MI->checkAll(); |
|
| 2822 | + } |
|
| 2017 | 2823 | } |
| 2018 | 2824 | } |
| 2019 | 2825 | } |
@@ -4,15 +4,15 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | require_once(dirname(__FILE__).'/require/class.Common.php'); |
| 6 | 6 | $Common = new Common(); |
| 7 | -$showRouteStop = $Common->multiKeyExists($spotter_array,'route_stop'); |
|
| 7 | +$showRouteStop = $Common->multiKeyExists($spotter_array, 'route_stop'); |
|
| 8 | 8 | if (isset($globalVM) && $globalVM) { |
| 9 | - $showDuration = $Common->multiKeyExists($spotter_array,'race_time'); |
|
| 10 | - if ($showDuration === false) $showDuration = $Common->multiKeyExists($spotter_array,'duration'); |
|
| 9 | + $showDuration = $Common->multiKeyExists($spotter_array, 'race_time'); |
|
| 10 | + if ($showDuration === false) $showDuration = $Common->multiKeyExists($spotter_array, 'duration'); |
|
| 11 | 11 | } else { |
| 12 | - $showDuration = $Common->multiKeyExists($spotter_array,'duration'); |
|
| 12 | + $showDuration = $Common->multiKeyExists($spotter_array, 'duration'); |
|
| 13 | 13 | } |
| 14 | 14 | if (isset($globalVM) && $globalVM) { |
| 15 | - $showDistance = $Common->multiKeyExists($spotter_array,'distance'); |
|
| 15 | + $showDistance = $Common->multiKeyExists($spotter_array, 'distance'); |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | } |
| 175 | 175 | print '<th class="more"></th>'; |
| 176 | 176 | print '</thead>'; |
| 177 | -} else if (strtolower($current_page) == "upcoming"){ |
|
| 177 | +} else if (strtolower($current_page) == "upcoming") { |
|
| 178 | 178 | print '<thead>'; |
| 179 | 179 | if (!isset($globalNoAirlines) || $globalNoAirlines === FALSE) { |
| 180 | 180 | if ($_GET['sort'] == "airline_name_asc") |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | } |
| 229 | 229 | */ |
| 230 | 230 | print '</thead>'; |
| 231 | -} else if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive"){ |
|
| 231 | +} else if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive") { |
|
| 232 | 232 | print '<thead>'; |
| 233 | 233 | print '<th class="aircraft_thumbnail"></th>'; |
| 234 | 234 | print '<th class="logo">'._("Airline").'</th>'; |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | print '</thead>'; |
| 266 | 266 | } else { |
| 267 | 267 | |
| 268 | - if ($hide_th_links === true){ |
|
| 268 | + if ($hide_th_links === true) { |
|
| 269 | 269 | print '<thead>'; |
| 270 | 270 | if ($type == 'marine' && isset($globalVM) && $globalVM) { |
| 271 | 271 | print '<th class="rank">'._("Rank").'</th>'; |
@@ -584,7 +584,7 @@ discard block |
||
| 584 | 584 | } |
| 585 | 585 | |
| 586 | 586 | print '<tbody>'."\n"; |
| 587 | -foreach($spotter_array as $spotter_item) |
|
| 587 | +foreach ($spotter_array as $spotter_item) |
|
| 588 | 588 | { |
| 589 | 589 | if (isset($globalTimezone)) |
| 590 | 590 | { |
@@ -619,13 +619,13 @@ discard block |
||
| 619 | 619 | $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id; |
| 620 | 620 | } |
| 621 | 621 | if (isset($spotter_item['airline_name'])) { |
| 622 | - print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
| 622 | + print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
| 623 | 623 | } else { |
| 624 | - print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '._("Not available").'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
| 624 | + print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '._("Not available").'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
| 625 | 625 | } |
| 626 | 626 | } else { |
| 627 | 627 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
| 628 | - $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
|
| 628 | + $image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']); |
|
| 629 | 629 | } else $image_thumbnail = $spotter_item['image_thumbnail']; |
| 630 | 630 | if (isset($spotter_item['airline_name'])) { |
| 631 | 631 | print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
@@ -651,7 +651,7 @@ discard block |
||
| 651 | 651 | { |
| 652 | 652 | print '<td class="aircraft_thumbnail">'."\n"; |
| 653 | 653 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
| 654 | - $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
|
| 654 | + $image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']); |
|
| 655 | 655 | } else $image_thumbnail = $spotter_item['image_thumbnail']; |
| 656 | 656 | if (isset($spotter_item['mmsi']) && $spotter_item['mmsi'] != '') { |
| 657 | 657 | print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
@@ -673,7 +673,7 @@ discard block |
||
| 673 | 673 | { |
| 674 | 674 | print '<td class="aircraft_thumbnail">'."\n"; |
| 675 | 675 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
| 676 | - $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
|
| 676 | + $image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']); |
|
| 677 | 677 | } else $image_thumbnail = $spotter_item['image_thumbnail']; |
| 678 | 678 | print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
| 679 | 679 | print '</td>'."\n"; |
@@ -717,7 +717,7 @@ discard block |
||
| 717 | 717 | print '</td>'."\n"; |
| 718 | 718 | } |
| 719 | 719 | } |
| 720 | - } 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"){ |
|
| 720 | + } 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") { |
|
| 721 | 721 | if ($type == 'aircraft') { |
| 722 | 722 | if (!isset($spotter_item['squawk']) || $spotter_item['squawk'] == 0) { |
| 723 | 723 | $spotter_item['squawk'] = '-'; |
@@ -734,17 +734,17 @@ discard block |
||
| 734 | 734 | $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id; |
| 735 | 735 | } |
| 736 | 736 | if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) { |
| 737 | - print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" 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:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
| 737 | + print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" 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:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
| 738 | 738 | } elseif (!isset($spotter_item['aircraft_name']) && isset($spotter_item['airline_name'])) { |
| 739 | - print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
| 739 | + print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
| 740 | 740 | } elseif (!isset($spotter_item['aircraft_name']) && !isset($spotter_item['airline_name'])) { |
| 741 | - print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" 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:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
| 741 | + print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" 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:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
| 742 | 742 | } else { |
| 743 | - print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
| 743 | + print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
|
| 744 | 744 | } |
| 745 | 745 | } else { |
| 746 | 746 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
| 747 | - $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
|
| 747 | + $image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']); |
|
| 748 | 748 | } else $image_thumbnail = $spotter_item['image_thumbnail']; |
| 749 | 749 | if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) { |
| 750 | 750 | print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$image_thumbnail.'" 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:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
@@ -784,7 +784,7 @@ discard block |
||
| 784 | 784 | { |
| 785 | 785 | print '<td class="aircraft_thumbnail">'."\n"; |
| 786 | 786 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
| 787 | - $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
|
| 787 | + $image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']); |
|
| 788 | 788 | } else $image_thumbnail = $spotter_item['image_thumbnail']; |
| 789 | 789 | if (isset($spotter_item['mmsi']) && $spotter_item['mmsi'] != '') { |
| 790 | 790 | print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
@@ -806,7 +806,7 @@ discard block |
||
| 806 | 806 | { |
| 807 | 807 | print '<td class="aircraft_thumbnail">'."\n"; |
| 808 | 808 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
| 809 | - $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
|
| 809 | + $image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']); |
|
| 810 | 810 | } else $image_thumbnail = $spotter_item['image_thumbnail']; |
| 811 | 811 | print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
| 812 | 812 | print '</td>'."\n"; |
@@ -915,7 +915,7 @@ discard block |
||
| 915 | 915 | print '</td>'."\n"; |
| 916 | 916 | } |
| 917 | 917 | // Aircraft type |
| 918 | - if(strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive"){ |
|
| 918 | + if (strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive") { |
|
| 919 | 919 | print '<td class="type">'."\n"; |
| 920 | 920 | if ($type == 'aircraft') { |
| 921 | 921 | if (!isset($spotter_item['aircraft_type']) && isset($spotter_item['aircraft_name'])) { |
@@ -924,7 +924,7 @@ discard block |
||
| 924 | 924 | //print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'._("Not available").'</a></span>'."\n"; |
| 925 | 925 | print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a></span>'."\n"; |
| 926 | 926 | } else { |
| 927 | - $aircraft_names = explode('/',$spotter_item['aircraft_name']); |
|
| 927 | + $aircraft_names = explode('/', $spotter_item['aircraft_name']); |
|
| 928 | 928 | if (count($aircraft_names) == 1) print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].'</a></span>'."\n"; |
| 929 | 929 | else print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'" title="'.$spotter_item['aircraft_name'].'">'.$spotter_item['aircraft_manufacturer'].' '.$aircraft_names[0].'</a></span>'."\n"; |
| 930 | 930 | } |
@@ -968,22 +968,22 @@ discard block |
||
| 968 | 968 | } |
| 969 | 969 | if (isset($spotter_item['departure_airport_time']) && isset($spotter_item['real_departure_airport_time'])) { |
| 970 | 970 | if ($spotter_item['departure_airport_time'] > 2460) { |
| 971 | - $departure_airport_time = date('H:m',$spotter_item['departure_airport_time']); |
|
| 972 | - } else $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2); |
|
| 971 | + $departure_airport_time = date('H:m', $spotter_item['departure_airport_time']); |
|
| 972 | + } else $departure_airport_time = substr($spotter_item['departure_airport_time'], 0, -2).':'.substr($spotter_item['departure_airport_time'], -2); |
|
| 973 | 973 | if ($spotter_item['real_departure_airport_time'] > 2460) { |
| 974 | - $real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']); |
|
| 974 | + $real_departure_airport_time = date('H:m', $spotter_item['real_departure_airport_time']); |
|
| 975 | 975 | } else $real_departure_airport_time = $spotter_item['real_departure_airport_time']; |
| 976 | 976 | print '<br /><span class="airport_time">'.$departure_airport_time.' ('.$real_departure_airport_time.')</span>'."\n"; |
| 977 | 977 | } elseif (isset($spotter_item['real_departure_airport_time']) && $spotter_item['real_departure_airport_time'] != 'NULL') { |
| 978 | 978 | if ($spotter_item['real_departure_airport_time'] > 2460) { |
| 979 | - $real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']); |
|
| 979 | + $real_departure_airport_time = date('H:m', $spotter_item['real_departure_airport_time']); |
|
| 980 | 980 | } else $real_departure_airport_time = $spotter_item['real_departure_airport_time']; |
| 981 | 981 | print '<br /><span class="airport_time">'.$real_departure_airport_time.'</span>'."\n"; |
| 982 | 982 | } elseif (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != 'NULL') { |
| 983 | 983 | if ($spotter_item['departure_airport_time'] > 2460) { |
| 984 | - $departure_airport_time = date('H:m',$spotter_item['departure_airport_time']); |
|
| 984 | + $departure_airport_time = date('H:m', $spotter_item['departure_airport_time']); |
|
| 985 | 985 | } else { |
| 986 | - $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2); |
|
| 986 | + $departure_airport_time = substr($spotter_item['departure_airport_time'], 0, -2).':'.substr($spotter_item['departure_airport_time'], -2); |
|
| 987 | 987 | } |
| 988 | 988 | print '<br /><span class="airport_time">'.$departure_airport_time.'</span>'."\n"; |
| 989 | 989 | } |
@@ -998,7 +998,7 @@ discard block |
||
| 998 | 998 | $latitude = $spotter_item['latitude']; |
| 999 | 999 | $longitude = $spotter_item['longitude']; |
| 1000 | 1000 | } |
| 1001 | - $distance = $Spotter->getAirportDistance($spotter_item['departure_airport'],$latitude,$longitude); |
|
| 1001 | + $distance = $Spotter->getAirportDistance($spotter_item['departure_airport'], $latitude, $longitude); |
|
| 1002 | 1002 | } else $distance = ''; |
| 1003 | 1003 | if ($distance != '') { |
| 1004 | 1004 | if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) { |
@@ -1041,20 +1041,20 @@ discard block |
||
| 1041 | 1041 | } |
| 1042 | 1042 | if (isset($spotter_item['arrival_airport_time']) && isset($spotter_item['real_arrival_airport_time'])) { |
| 1043 | 1043 | if ($spotter_item['arrival_airport_time'] > 2460) { |
| 1044 | - $arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']); |
|
| 1044 | + $arrival_airport_time = date('H:m', $spotter_item['arrival_airport_time']); |
|
| 1045 | 1045 | } else $arrival_airport_time = $spotter_item['arrival_airport_time']; |
| 1046 | 1046 | if ($spotter_item['real_arrival_airport_time'] > 2460) { |
| 1047 | - $real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']); |
|
| 1047 | + $real_arrival_airport_time = date('H:m', $spotter_item['real_arrival_airport_time']); |
|
| 1048 | 1048 | } else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time']; |
| 1049 | 1049 | print '<br /><span class="airport_time">'.$spotter_item['arrival_airport_time'].' ('.$spotter_item['real_arrival_airport_time'].')</span>'."\n"; |
| 1050 | 1050 | } elseif (isset($spotter_item['real_arrival_airport_time'])) { |
| 1051 | 1051 | if ($spotter_item['real_arrival_airport_time'] > 2460) { |
| 1052 | - $real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']); |
|
| 1052 | + $real_arrival_airport_time = date('H:m', $spotter_item['real_arrival_airport_time']); |
|
| 1053 | 1053 | } else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time']; |
| 1054 | 1054 | print '<br /><span class="airport_time">'.$real_arrival_airport_time.'</span>'."\n"; |
| 1055 | 1055 | } elseif (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != 'NULL') { |
| 1056 | 1056 | if ($spotter_item['arrival_airport_time'] > 2460) { |
| 1057 | - $arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']); |
|
| 1057 | + $arrival_airport_time = date('H:m', $spotter_item['arrival_airport_time']); |
|
| 1058 | 1058 | } else $arrival_airport_time = $spotter_item['arrival_airport_time']; |
| 1059 | 1059 | print '<br /><span class="airport_time">'.$arrival_airport_time.'</span>'."\n"; |
| 1060 | 1060 | } |
@@ -1067,7 +1067,7 @@ discard block |
||
| 1067 | 1067 | $latitude = $spotter_item['latitude']; |
| 1068 | 1068 | $longitude = $spotter_item['longitude']; |
| 1069 | 1069 | } |
| 1070 | - $distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'],$latitude,$longitude); |
|
| 1070 | + $distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'], $latitude, $longitude); |
|
| 1071 | 1071 | } else $distance = ''; |
| 1072 | 1072 | if ($distance != '') { |
| 1073 | 1073 | if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) { |
@@ -1129,19 +1129,19 @@ discard block |
||
| 1129 | 1129 | print '<span class="mobile">-</span>'."\n"; |
| 1130 | 1130 | } else { |
| 1131 | 1131 | if ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) { |
| 1132 | - print '<span class="nomobile">'.round($spotter_item['distance'],2).' km</span>'."\n"; |
|
| 1133 | - print '<span class="mobile">'.round($spotter_item['distance'],2).' km</span><br />'."\n"; |
|
| 1132 | + print '<span class="nomobile">'.round($spotter_item['distance'], 2).' km</span>'."\n"; |
|
| 1133 | + print '<span class="mobile">'.round($spotter_item['distance'], 2).' km</span><br />'."\n"; |
|
| 1134 | 1134 | } elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) { |
| 1135 | - print '<span class="nomobile">'.round($spotter_item['distance']*0.621371,2).' mi</span>'."\n"; |
|
| 1136 | - print '<span class="mobile">'.round($spotter_item['distance']*0.621371,2).' mi</span><br />'."\n"; |
|
| 1135 | + print '<span class="nomobile">'.round($spotter_item['distance']*0.621371, 2).' mi</span>'."\n"; |
|
| 1136 | + print '<span class="mobile">'.round($spotter_item['distance']*0.621371, 2).' mi</span><br />'."\n"; |
|
| 1137 | 1137 | } elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) { |
| 1138 | - print '<span class="nomobile">'.round($spotter_item['distance']*0.539957,2).' nm</span>'."\n"; |
|
| 1139 | - print '<span class="mobile">'.round($spotter_item['distance']*0.539957,2).' nm</span><br />'."\n"; |
|
| 1138 | + print '<span class="nomobile">'.round($spotter_item['distance']*0.539957, 2).' nm</span>'."\n"; |
|
| 1139 | + print '<span class="mobile">'.round($spotter_item['distance']*0.539957, 2).' nm</span><br />'."\n"; |
|
| 1140 | 1140 | } |
| 1141 | 1141 | } |
| 1142 | 1142 | print '</td>'."\n"; |
| 1143 | 1143 | } |
| 1144 | - if(strtolower($current_page) != "upcoming"){ |
|
| 1144 | + if (strtolower($current_page) != "upcoming") { |
|
| 1145 | 1145 | if ($type == 'aircraft') { |
| 1146 | 1146 | //if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) { |
| 1147 | 1147 | if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) { |
@@ -1186,14 +1186,14 @@ discard block |
||
| 1186 | 1186 | if (isset($spotter_item['distance'])) { |
| 1187 | 1187 | print '<td class="distance">'; |
| 1188 | 1188 | if ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) { |
| 1189 | - print '<span class="nomobile">'.round($spotter_item['distance'],2).' km</span>'."\n"; |
|
| 1190 | - print '<span class="mobile">'.round($spotter_item['distance'],2).' km</span><br />'."\n"; |
|
| 1189 | + print '<span class="nomobile">'.round($spotter_item['distance'], 2).' km</span>'."\n"; |
|
| 1190 | + print '<span class="mobile">'.round($spotter_item['distance'], 2).' km</span><br />'."\n"; |
|
| 1191 | 1191 | } elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) { |
| 1192 | - print '<span class="nomobile">'.round($spotter_item['distance']*0.621371,2).' mi</span>'."\n"; |
|
| 1193 | - print '<span class="mobile">'.round($spotter_item['distance']*0.621371,2).' mi</span><br />'."\n"; |
|
| 1192 | + print '<span class="nomobile">'.round($spotter_item['distance']*0.621371, 2).' mi</span>'."\n"; |
|
| 1193 | + print '<span class="mobile">'.round($spotter_item['distance']*0.621371, 2).' mi</span><br />'."\n"; |
|
| 1194 | 1194 | } elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) { |
| 1195 | - print '<span class="nomobile">'.round($spotter_item['distance']*0.539957,2).' nm</span>'."\n"; |
|
| 1196 | - print '<span class="mobile">'.round($spotter_item['distance']*0.539957,2).' nm</span><br />'."\n"; |
|
| 1195 | + print '<span class="nomobile">'.round($spotter_item['distance']*0.539957, 2).' nm</span>'."\n"; |
|
| 1196 | + print '<span class="mobile">'.round($spotter_item['distance']*0.539957, 2).' nm</span><br />'."\n"; |
|
| 1197 | 1197 | } |
| 1198 | 1198 | print '</td>'."\n"; |
| 1199 | 1199 | } else { |
@@ -1224,7 +1224,7 @@ discard block |
||
| 1224 | 1224 | |
| 1225 | 1225 | if ($showRouteStop) { |
| 1226 | 1226 | // Route stop |
| 1227 | - if(strtolower($current_page) != "upcoming"){ |
|
| 1227 | + if (strtolower($current_page) != "upcoming") { |
|
| 1228 | 1228 | print '<td class="route_stop">'."\n"; |
| 1229 | 1229 | if (!isset($spotter_item['route_stop']) || $spotter_item['route_stop'] == '' || $spotter_item['route_stop'] == 'NULL') { |
| 1230 | 1230 | print '<span class="nomobile">-</span>'."\n"; |
@@ -1247,19 +1247,19 @@ discard block |
||
| 1247 | 1247 | print '<td class="duration">'."\n"; |
| 1248 | 1248 | if (isset($spotter_item['race_time'])) { |
| 1249 | 1249 | if ($spotter_item['race_time'] > 86400) { |
| 1250 | - print '<span class="nomobile">'.gmdate("z\d. H\h. i\m. s\s.",$spotter_item['race_time']).'</span>'."\n"; |
|
| 1251 | - print '<span class="mobile">'.gmdate("z\d. H\h. i\m. s\s.",$spotter_item['race_time']).'</span>'."\n"; |
|
| 1250 | + print '<span class="nomobile">'.gmdate("z\d. H\h. i\m. s\s.", $spotter_item['race_time']).'</span>'."\n"; |
|
| 1251 | + print '<span class="mobile">'.gmdate("z\d. H\h. i\m. s\s.", $spotter_item['race_time']).'</span>'."\n"; |
|
| 1252 | 1252 | } else { |
| 1253 | - print '<span class="nomobile">'.gmdate("H\h. i\m. s\s.",$spotter_item['race_time']).'</span>'."\n"; |
|
| 1254 | - print '<span class="mobile">'.gmdate("H\h. i\m. s\s.",$spotter_item['race_time']).'</span>'."\n"; |
|
| 1253 | + print '<span class="nomobile">'.gmdate("H\h. i\m. s\s.", $spotter_item['race_time']).'</span>'."\n"; |
|
| 1254 | + print '<span class="mobile">'.gmdate("H\h. i\m. s\s.", $spotter_item['race_time']).'</span>'."\n"; |
|
| 1255 | 1255 | } |
| 1256 | 1256 | } elseif (isset($spotter_item['duration'])) { |
| 1257 | 1257 | if ($spotter_item['duration'] > 86400) { |
| 1258 | - print '<span class="nomobile">'.gmdate('z\d. H\h. i\m. s\s.',$spotter_item['duration']).'</span>'."\n"; |
|
| 1259 | - print '<span class="mobile">'.gmdate('z\d. H\h. i\m. s\s.',$spotter_item['duration']).'</span>'."\n"; |
|
| 1258 | + print '<span class="nomobile">'.gmdate('z\d. H\h. i\m. s\s.', $spotter_item['duration']).'</span>'."\n"; |
|
| 1259 | + print '<span class="mobile">'.gmdate('z\d. H\h. i\m. s\s.', $spotter_item['duration']).'</span>'."\n"; |
|
| 1260 | 1260 | } else { |
| 1261 | - print '<span class="nomobile">'.gmdate('H\h. i\m. s\s.',$spotter_item['duration']).'</span>'."\n"; |
|
| 1262 | - print '<span class="mobile">'.gmdate('H\h. i\m. s\s.',$spotter_item['duration']).'</span>'."\n"; |
|
| 1261 | + print '<span class="nomobile">'.gmdate('H\h. i\m. s\s.', $spotter_item['duration']).'</span>'."\n"; |
|
| 1262 | + print '<span class="mobile">'.gmdate('H\h. i\m. s\s.', $spotter_item['duration']).'</span>'."\n"; |
|
| 1263 | 1263 | } |
| 1264 | 1264 | } else { |
| 1265 | 1265 | print '<span class="nomobile">-</span>'."\n"; |
@@ -1267,11 +1267,11 @@ discard block |
||
| 1267 | 1267 | } |
| 1268 | 1268 | print '</td>'."\n"; |
| 1269 | 1269 | } else { |
| 1270 | - if(strtolower($current_page) != "upcoming"){ |
|
| 1270 | + if (strtolower($current_page) != "upcoming") { |
|
| 1271 | 1271 | print '<td class="duration">'."\n"; |
| 1272 | 1272 | if (isset($spotter_item['duration'])) { |
| 1273 | - print '<span class="nomobile">'.gmdate('H:i:s',$spotter_item['duration']).'</span>'."\n"; |
|
| 1274 | - print '<span class="mobile">'.gmdate('H:i:s',$spotter_item['duration']).'</span>'."\n"; |
|
| 1273 | + print '<span class="nomobile">'.gmdate('H:i:s', $spotter_item['duration']).'</span>'."\n"; |
|
| 1274 | + print '<span class="mobile">'.gmdate('H:i:s', $spotter_item['duration']).'</span>'."\n"; |
|
| 1275 | 1275 | } else { |
| 1276 | 1276 | print '<span class="nomobile">-</span>'."\n"; |
| 1277 | 1277 | print '<span class="mobile">-</span>'."\n"; |
@@ -1285,7 +1285,7 @@ discard block |
||
| 1285 | 1285 | if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive") { |
| 1286 | 1286 | if (isset($spotter_item['decode']) && $spotter_item['decode'] != '') { |
| 1287 | 1287 | print '<td class="message"><p>'."\n"; |
| 1288 | - print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']); |
|
| 1288 | + print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']); |
|
| 1289 | 1289 | print '</p><p class="decode">'; |
| 1290 | 1290 | $decode_array = json_decode($spotter_item['decode']); |
| 1291 | 1291 | foreach ($decode_array as $key => $value) { |
@@ -1295,7 +1295,7 @@ discard block |
||
| 1295 | 1295 | print '</td>'."\n"; |
| 1296 | 1296 | } else { |
| 1297 | 1297 | print '<td class="message">'."\n"; |
| 1298 | - print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']); |
|
| 1298 | + print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']); |
|
| 1299 | 1299 | print '</td>'."\n"; |
| 1300 | 1300 | } |
| 1301 | 1301 | } |
@@ -1320,7 +1320,7 @@ discard block |
||
| 1320 | 1320 | } |
| 1321 | 1321 | print '</td>'."\n"; |
| 1322 | 1322 | print '<td class="message">'."\n"; |
| 1323 | - print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']); |
|
| 1323 | + print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']); |
|
| 1324 | 1324 | print '</td>'."\n"; |
| 1325 | 1325 | } |
| 1326 | 1326 | if (strtolower($current_page) == "incident-latest" || strtolower($current_page) == "incident-detailed") { |
@@ -1346,7 +1346,7 @@ discard block |
||
| 1346 | 1346 | print '</td>'."\n"; |
| 1347 | 1347 | */ |
| 1348 | 1348 | print '<td class="message">'."\n"; |
| 1349 | - print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']); |
|
| 1349 | + print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']); |
|
| 1350 | 1350 | print '</td>'."\n"; |
| 1351 | 1351 | } |
| 1352 | 1352 | |
@@ -7,8 +7,10 @@ discard block |
||
| 7 | 7 | $showRouteStop = $Common->multiKeyExists($spotter_array,'route_stop'); |
| 8 | 8 | if (isset($globalVM) && $globalVM) { |
| 9 | 9 | $showDuration = $Common->multiKeyExists($spotter_array,'race_time'); |
| 10 | - if ($showDuration === false) $showDuration = $Common->multiKeyExists($spotter_array,'duration'); |
|
| 11 | -} else { |
|
| 10 | + if ($showDuration === false) { |
|
| 11 | + $showDuration = $Common->multiKeyExists($spotter_array,'duration'); |
|
| 12 | + } |
|
| 13 | + } else { |
|
| 12 | 14 | $showDuration = $Common->multiKeyExists($spotter_array,'duration'); |
| 13 | 15 | } |
| 14 | 16 | if (isset($globalVM) && $globalVM) { |
@@ -16,7 +18,9 @@ discard block |
||
| 16 | 18 | } |
| 17 | 19 | |
| 18 | 20 | |
| 19 | -if (!isset($type)) $type = 'aircraft'; |
|
| 21 | +if (!isset($type)) { |
|
| 22 | + $type = 'aircraft'; |
|
| 23 | +} |
|
| 20 | 24 | |
| 21 | 25 | if (!isset($_GET['sort'])) |
| 22 | 26 | { |
@@ -589,7 +593,9 @@ discard block |
||
| 589 | 593 | if (isset($globalTimezone)) |
| 590 | 594 | { |
| 591 | 595 | date_default_timezone_set($globalTimezone); |
| 592 | - } else date_default_timezone_set('UTC'); |
|
| 596 | + } else { |
|
| 597 | + date_default_timezone_set('UTC'); |
|
| 598 | + } |
|
| 593 | 599 | if ($showSpecial === true) |
| 594 | 600 | { |
| 595 | 601 | print '<tr class="special">'."\n"; |
@@ -604,7 +610,9 @@ discard block |
||
| 604 | 610 | print '<tr class="active">'; |
| 605 | 611 | } elseif (isset($spotter_item['spotted_registration'])) { |
| 606 | 612 | print '<tr class="info">'; |
| 607 | - } else print '<tr>'; |
|
| 613 | + } else { |
|
| 614 | + print '<tr>'; |
|
| 615 | + } |
|
| 608 | 616 | } |
| 609 | 617 | if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive" || strtolower($current_page) == "currently" || strtolower($current_page) == "accident-latest" || strtolower($current_page) == "incident-latest" || strtolower($current_page) == "accident-detailed" || strtolower($current_page) == "incident-detailed") { |
| 610 | 618 | if ($type == 'aircraft') { |
@@ -612,8 +620,9 @@ discard block |
||
| 612 | 620 | { |
| 613 | 621 | print '<td class="aircraft_thumbnail">'."\n"; |
| 614 | 622 | if ($spotter_item['image_source'] == 'planespotters') { |
| 615 | - if ($spotter_item['image_source_website'] != '') $image_src = $spotter_item['image_source_website']; |
|
| 616 | - else { |
|
| 623 | + if ($spotter_item['image_source_website'] != '') { |
|
| 624 | + $image_src = $spotter_item['image_source_website']; |
|
| 625 | + } else { |
|
| 617 | 626 | $planespotter_url_array = explode("_", $spotter_item['image']); |
| 618 | 627 | $planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]); |
| 619 | 628 | $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id; |
@@ -626,7 +635,9 @@ discard block |
||
| 626 | 635 | } else { |
| 627 | 636 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
| 628 | 637 | $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
| 629 | - } else $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 638 | + } else { |
|
| 639 | + $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 640 | + } |
|
| 630 | 641 | if (isset($spotter_item['airline_name'])) { |
| 631 | 642 | print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
| 632 | 643 | } else { |
@@ -652,7 +663,9 @@ discard block |
||
| 652 | 663 | print '<td class="aircraft_thumbnail">'."\n"; |
| 653 | 664 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
| 654 | 665 | $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
| 655 | - } else $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 666 | + } else { |
|
| 667 | + $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 668 | + } |
|
| 656 | 669 | if (isset($spotter_item['mmsi']) && $spotter_item['mmsi'] != '') { |
| 657 | 670 | print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
| 658 | 671 | } else { |
@@ -674,7 +687,9 @@ discard block |
||
| 674 | 687 | print '<td class="aircraft_thumbnail">'."\n"; |
| 675 | 688 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
| 676 | 689 | $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
| 677 | - } else $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 690 | + } else { |
|
| 691 | + $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 692 | + } |
|
| 678 | 693 | print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
| 679 | 694 | print '</td>'."\n"; |
| 680 | 695 | } else { |
@@ -727,8 +742,9 @@ discard block |
||
| 727 | 742 | print '<td class="aircraft_thumbnail">'."\n"; |
| 728 | 743 | //print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$spotter_item['image_thumbnail'].'" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>'; |
| 729 | 744 | if ($spotter_item['image_source'] == 'planespotters') { |
| 730 | - if ($spotter_item['image_source_website'] != '') $image_src = $spotter_item['image_source_website']; |
|
| 731 | - else { |
|
| 745 | + if ($spotter_item['image_source_website'] != '') { |
|
| 746 | + $image_src = $spotter_item['image_source_website']; |
|
| 747 | + } else { |
|
| 732 | 748 | $planespotter_url_array = explode("_", $spotter_array[0]['image']); |
| 733 | 749 | $planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]); |
| 734 | 750 | $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id; |
@@ -745,7 +761,9 @@ discard block |
||
| 745 | 761 | } else { |
| 746 | 762 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
| 747 | 763 | $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
| 748 | - } else $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 764 | + } else { |
|
| 765 | + $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 766 | + } |
|
| 749 | 767 | if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) { |
| 750 | 768 | print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$image_thumbnail.'" 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:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
| 751 | 769 | } elseif (!isset($spotter_item['aircraft_name']) && isset($spotter_item['airline_name'])) { |
@@ -785,7 +803,9 @@ discard block |
||
| 785 | 803 | print '<td class="aircraft_thumbnail">'."\n"; |
| 786 | 804 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
| 787 | 805 | $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
| 788 | - } else $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 806 | + } else { |
|
| 807 | + $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 808 | + } |
|
| 789 | 809 | if (isset($spotter_item['mmsi']) && $spotter_item['mmsi'] != '') { |
| 790 | 810 | print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
| 791 | 811 | } else { |
@@ -807,7 +827,9 @@ discard block |
||
| 807 | 827 | print '<td class="aircraft_thumbnail">'."\n"; |
| 808 | 828 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
| 809 | 829 | $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
| 810 | - } else $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 830 | + } else { |
|
| 831 | + $image_thumbnail = $spotter_item['image_thumbnail']; |
|
| 832 | + } |
|
| 811 | 833 | print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
| 812 | 834 | print '</td>'."\n"; |
| 813 | 835 | } else { |
@@ -925,8 +947,11 @@ discard block |
||
| 925 | 947 | print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a></span>'."\n"; |
| 926 | 948 | } else { |
| 927 | 949 | $aircraft_names = explode('/',$spotter_item['aircraft_name']); |
| 928 | - if (count($aircraft_names) == 1) print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].'</a></span>'."\n"; |
|
| 929 | - else print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'" title="'.$spotter_item['aircraft_name'].'">'.$spotter_item['aircraft_manufacturer'].' '.$aircraft_names[0].'</a></span>'."\n"; |
|
| 950 | + if (count($aircraft_names) == 1) { |
|
| 951 | + print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].'</a></span>'."\n"; |
|
| 952 | + } else { |
|
| 953 | + print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'" title="'.$spotter_item['aircraft_name'].'">'.$spotter_item['aircraft_manufacturer'].' '.$aircraft_names[0].'</a></span>'."\n"; |
|
| 954 | + } |
|
| 930 | 955 | } |
| 931 | 956 | print '<span class="mobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a></span>'."\n"; |
| 932 | 957 | } elseif ($type == 'marine') { |
@@ -969,15 +994,21 @@ discard block |
||
| 969 | 994 | if (isset($spotter_item['departure_airport_time']) && isset($spotter_item['real_departure_airport_time'])) { |
| 970 | 995 | if ($spotter_item['departure_airport_time'] > 2460) { |
| 971 | 996 | $departure_airport_time = date('H:m',$spotter_item['departure_airport_time']); |
| 972 | - } else $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2); |
|
| 997 | + } else { |
|
| 998 | + $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2); |
|
| 999 | + } |
|
| 973 | 1000 | if ($spotter_item['real_departure_airport_time'] > 2460) { |
| 974 | 1001 | $real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']); |
| 975 | - } else $real_departure_airport_time = $spotter_item['real_departure_airport_time']; |
|
| 1002 | + } else { |
|
| 1003 | + $real_departure_airport_time = $spotter_item['real_departure_airport_time']; |
|
| 1004 | + } |
|
| 976 | 1005 | print '<br /><span class="airport_time">'.$departure_airport_time.' ('.$real_departure_airport_time.')</span>'."\n"; |
| 977 | 1006 | } elseif (isset($spotter_item['real_departure_airport_time']) && $spotter_item['real_departure_airport_time'] != 'NULL') { |
| 978 | 1007 | if ($spotter_item['real_departure_airport_time'] > 2460) { |
| 979 | 1008 | $real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']); |
| 980 | - } else $real_departure_airport_time = $spotter_item['real_departure_airport_time']; |
|
| 1009 | + } else { |
|
| 1010 | + $real_departure_airport_time = $spotter_item['real_departure_airport_time']; |
|
| 1011 | + } |
|
| 981 | 1012 | print '<br /><span class="airport_time">'.$real_departure_airport_time.'</span>'."\n"; |
| 982 | 1013 | } elseif (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != 'NULL') { |
| 983 | 1014 | if ($spotter_item['departure_airport_time'] > 2460) { |
@@ -999,7 +1030,9 @@ discard block |
||
| 999 | 1030 | $longitude = $spotter_item['longitude']; |
| 1000 | 1031 | } |
| 1001 | 1032 | $distance = $Spotter->getAirportDistance($spotter_item['departure_airport'],$latitude,$longitude); |
| 1002 | - } else $distance = ''; |
|
| 1033 | + } else { |
|
| 1034 | + $distance = ''; |
|
| 1035 | + } |
|
| 1003 | 1036 | if ($distance != '') { |
| 1004 | 1037 | if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) { |
| 1005 | 1038 | echo '<br/><i>'.round($distance*0.539957).' nm</i>'; |
@@ -1026,7 +1059,9 @@ discard block |
||
| 1026 | 1059 | } else { |
| 1027 | 1060 | if (isset($spotter_item['real_arrival_airport']) && $spotter_item['real_arrival_airport'] != $spotter_item['arrival_airport']) { |
| 1028 | 1061 | print '<span class="nomobile">Scheduled : <a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'">'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].' ('.$spotter_item['arrival_airport'].')</a></span>'."\n"; |
| 1029 | - if (!isset($Spotter)) $Spotter = new Spotter(); |
|
| 1062 | + if (!isset($Spotter)) { |
|
| 1063 | + $Spotter = new Spotter(); |
|
| 1064 | + } |
|
| 1030 | 1065 | $arrival_airport_info = $Spotter->getAllAirportInfo($spotter_item['real_arrival_airport']); |
| 1031 | 1066 | print '<br /><span class="nomobile">'._("Real:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$arrival_airport_info[0]['city'].','.$arrival_airport_info[0]['country'].' ('.$spotter_item['real_arrival_airport'].')</a></span>'."\n"; |
| 1032 | 1067 | print '<span class="mobile">'._("Scheduled:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$spotter_item['real_arrival_airport'].'</a></span>'."\n"; |
@@ -1042,20 +1077,28 @@ discard block |
||
| 1042 | 1077 | if (isset($spotter_item['arrival_airport_time']) && isset($spotter_item['real_arrival_airport_time'])) { |
| 1043 | 1078 | if ($spotter_item['arrival_airport_time'] > 2460) { |
| 1044 | 1079 | $arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']); |
| 1045 | - } else $arrival_airport_time = $spotter_item['arrival_airport_time']; |
|
| 1080 | + } else { |
|
| 1081 | + $arrival_airport_time = $spotter_item['arrival_airport_time']; |
|
| 1082 | + } |
|
| 1046 | 1083 | if ($spotter_item['real_arrival_airport_time'] > 2460) { |
| 1047 | 1084 | $real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']); |
| 1048 | - } else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time']; |
|
| 1085 | + } else { |
|
| 1086 | + $real_arrival_airport_time = $spotter_item['real_arrival_airport_time']; |
|
| 1087 | + } |
|
| 1049 | 1088 | print '<br /><span class="airport_time">'.$spotter_item['arrival_airport_time'].' ('.$spotter_item['real_arrival_airport_time'].')</span>'."\n"; |
| 1050 | 1089 | } elseif (isset($spotter_item['real_arrival_airport_time'])) { |
| 1051 | 1090 | if ($spotter_item['real_arrival_airport_time'] > 2460) { |
| 1052 | 1091 | $real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']); |
| 1053 | - } else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time']; |
|
| 1092 | + } else { |
|
| 1093 | + $real_arrival_airport_time = $spotter_item['real_arrival_airport_time']; |
|
| 1094 | + } |
|
| 1054 | 1095 | print '<br /><span class="airport_time">'.$real_arrival_airport_time.'</span>'."\n"; |
| 1055 | 1096 | } elseif (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != 'NULL') { |
| 1056 | 1097 | if ($spotter_item['arrival_airport_time'] > 2460) { |
| 1057 | 1098 | $arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']); |
| 1058 | - } else $arrival_airport_time = $spotter_item['arrival_airport_time']; |
|
| 1099 | + } else { |
|
| 1100 | + $arrival_airport_time = $spotter_item['arrival_airport_time']; |
|
| 1101 | + } |
|
| 1059 | 1102 | print '<br /><span class="airport_time">'.$arrival_airport_time.'</span>'."\n"; |
| 1060 | 1103 | } |
| 1061 | 1104 | if (!isset($spotter_item['real_arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
@@ -1068,7 +1111,9 @@ discard block |
||
| 1068 | 1111 | $longitude = $spotter_item['longitude']; |
| 1069 | 1112 | } |
| 1070 | 1113 | $distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'],$latitude,$longitude); |
| 1071 | - } else $distance = ''; |
|
| 1114 | + } else { |
|
| 1115 | + $distance = ''; |
|
| 1116 | + } |
|
| 1072 | 1117 | if ($distance != '') { |
| 1073 | 1118 | if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) { |
| 1074 | 1119 | echo '<br/><i>'.round($distance*0.539957).' nm</i>'; |