@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | } |
14 | 14 | |
15 | 15 | /** |
16 | - * Get SQL query part for filter used |
|
17 | - * @param Array $filter the filter |
|
18 | - * @return Array the SQL part |
|
19 | - */ |
|
16 | + * Get SQL query part for filter used |
|
17 | + * @param Array $filter the filter |
|
18 | + * @return Array the SQL part |
|
19 | + */ |
|
20 | 20 | |
21 | 21 | public function getFilter($filter = array(),$where = false,$and = false) { |
22 | 22 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
@@ -80,14 +80,14 @@ discard block |
||
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
83 | - * Executes the SQL statements to get the spotter information |
|
84 | - * |
|
85 | - * @param String $query the SQL query |
|
86 | - * @param Array $params parameter of the query |
|
87 | - * @param String $limitQuery the limit query |
|
88 | - * @return Array the spotter information |
|
89 | - * |
|
90 | - */ |
|
83 | + * Executes the SQL statements to get the spotter information |
|
84 | + * |
|
85 | + * @param String $query the SQL query |
|
86 | + * @param Array $params parameter of the query |
|
87 | + * @param String $limitQuery the limit query |
|
88 | + * @return Array the spotter information |
|
89 | + * |
|
90 | + */ |
|
91 | 91 | public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
92 | 92 | { |
93 | 93 | date_default_timezone_set('UTC'); |
@@ -199,11 +199,11 @@ discard block |
||
199 | 199 | |
200 | 200 | |
201 | 201 | /** |
202 | - * Gets all the spotter information based on the latest data entry |
|
203 | - * |
|
204 | - * @return Array the spotter information |
|
205 | - * |
|
206 | - */ |
|
202 | + * Gets all the spotter information based on the latest data entry |
|
203 | + * |
|
204 | + * @return Array the spotter information |
|
205 | + * |
|
206 | + */ |
|
207 | 207 | public function getLatestMarineData($limit = '', $sort = '', $filter = array()) |
208 | 208 | { |
209 | 209 | global $global_query; |
@@ -261,11 +261,11 @@ discard block |
||
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
264 | - * Gets all the spotter information based on the callsign |
|
265 | - * |
|
266 | - * @return Array the spotter information |
|
267 | - * |
|
268 | - */ |
|
264 | + * Gets all the spotter information based on the callsign |
|
265 | + * |
|
266 | + * @return Array the spotter information |
|
267 | + * |
|
268 | + */ |
|
269 | 269 | public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array()) |
270 | 270 | { |
271 | 271 | global $global_query; |
@@ -376,12 +376,12 @@ discard block |
||
376 | 376 | |
377 | 377 | |
378 | 378 | /** |
379 | - * Gets all source name |
|
380 | - * |
|
381 | - * @param String type format of source |
|
382 | - * @return Array list of source name |
|
383 | - * |
|
384 | - */ |
|
379 | + * Gets all source name |
|
380 | + * |
|
381 | + * @param String type format of source |
|
382 | + * @return Array list of source name |
|
383 | + * |
|
384 | + */ |
|
385 | 385 | public function getAllSourceName($type = '',$filters = array()) |
386 | 386 | { |
387 | 387 | $filter_query = $this->getFilter($filters,true,true); |
@@ -411,11 +411,11 @@ discard block |
||
411 | 411 | |
412 | 412 | |
413 | 413 | /** |
414 | - * Gets a list of all idents/callsigns |
|
415 | - * |
|
416 | - * @return Array list of ident/callsign names |
|
417 | - * |
|
418 | - */ |
|
414 | + * Gets a list of all idents/callsigns |
|
415 | + * |
|
416 | + * @return Array list of ident/callsign names |
|
417 | + * |
|
418 | + */ |
|
419 | 419 | public function getAllIdents($filters = array()) |
420 | 420 | { |
421 | 421 | $filter_query = $this->getFilter($filters,true,true); |
@@ -439,11 +439,11 @@ discard block |
||
439 | 439 | } |
440 | 440 | |
441 | 441 | /** |
442 | - * Gets all info from a mmsi |
|
443 | - * |
|
444 | - * @return Array list of mmsi info |
|
445 | - * |
|
446 | - */ |
|
442 | + * Gets all info from a mmsi |
|
443 | + * |
|
444 | + * @return Array list of mmsi info |
|
445 | + * |
|
446 | + */ |
|
447 | 447 | public function getIdentity($mmsi) |
448 | 448 | { |
449 | 449 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
@@ -500,18 +500,18 @@ discard block |
||
500 | 500 | |
501 | 501 | |
502 | 502 | /** |
503 | - * Update ident tracker data |
|
504 | - * |
|
505 | - * @param String $fammarine_id the ID |
|
506 | - * @param String $ident the marine ident |
|
507 | - * @return String success or false |
|
508 | - * |
|
509 | - */ |
|
503 | + * Update ident tracker data |
|
504 | + * |
|
505 | + * @param String $fammarine_id the ID |
|
506 | + * @param String $ident the marine ident |
|
507 | + * @return String success or false |
|
508 | + * |
|
509 | + */ |
|
510 | 510 | public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
511 | 511 | { |
512 | 512 | |
513 | 513 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
514 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
514 | + $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
515 | 515 | |
516 | 516 | try { |
517 | 517 | $sth = $this->db->prepare($query); |
@@ -524,17 +524,17 @@ discard block |
||
524 | 524 | |
525 | 525 | } |
526 | 526 | /** |
527 | - * Update latest marine data |
|
528 | - * |
|
529 | - * @param String $fammarine_id the ID |
|
530 | - * @param String $ident the marine ident |
|
531 | - * @return String success or false |
|
532 | - * |
|
533 | - */ |
|
527 | + * Update latest marine data |
|
528 | + * |
|
529 | + * @param String $fammarine_id the ID |
|
530 | + * @param String $ident the marine ident |
|
531 | + * @return String success or false |
|
532 | + * |
|
533 | + */ |
|
534 | 534 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
535 | 535 | { |
536 | 536 | $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 WHERE fammarine_id = :fammarine_id'; |
537 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
537 | + $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
538 | 538 | |
539 | 539 | try { |
540 | 540 | $sth = $this->db->prepare($query); |
@@ -548,30 +548,30 @@ discard block |
||
548 | 548 | } |
549 | 549 | |
550 | 550 | /** |
551 | - * Adds a new spotter data |
|
552 | - * |
|
553 | - * @param String $fammarine_id the ID |
|
554 | - * @param String $ident the marine ident |
|
555 | - * @param String $departure_airport_icao the departure airport |
|
556 | - * @param String $arrival_airport_icao the arrival airport |
|
557 | - * @param String $latitude latitude of flight |
|
558 | - * @param String $longitude latitude of flight |
|
559 | - * @param String $waypoints waypoints of flight |
|
560 | - * @param String $heading heading of flight |
|
561 | - * @param String $groundspeed speed of flight |
|
562 | - * @param String $date date of flight |
|
563 | - * @param String $departure_airport_time departure time of flight |
|
564 | - * @param String $arrival_airport_time arrival time of flight |
|
565 | - * @param String $squawk squawk code of flight |
|
566 | - * @param String $route_stop route stop of flight |
|
567 | - * @param String $highlight highlight or not |
|
568 | - * @param String $ModeS ModesS code of flight |
|
569 | - * @param String $registration registration code of flight |
|
570 | - * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
571 | - * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
572 | - * @param String $verticalrate vertival rate of flight |
|
573 | - * @return String success or false |
|
574 | - */ |
|
551 | + * Adds a new spotter data |
|
552 | + * |
|
553 | + * @param String $fammarine_id the ID |
|
554 | + * @param String $ident the marine ident |
|
555 | + * @param String $departure_airport_icao the departure airport |
|
556 | + * @param String $arrival_airport_icao the arrival airport |
|
557 | + * @param String $latitude latitude of flight |
|
558 | + * @param String $longitude latitude of flight |
|
559 | + * @param String $waypoints waypoints of flight |
|
560 | + * @param String $heading heading of flight |
|
561 | + * @param String $groundspeed speed of flight |
|
562 | + * @param String $date date of flight |
|
563 | + * @param String $departure_airport_time departure time of flight |
|
564 | + * @param String $arrival_airport_time arrival time of flight |
|
565 | + * @param String $squawk squawk code of flight |
|
566 | + * @param String $route_stop route stop of flight |
|
567 | + * @param String $highlight highlight or not |
|
568 | + * @param String $ModeS ModesS code of flight |
|
569 | + * @param String $registration registration code of flight |
|
570 | + * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
571 | + * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
572 | + * @param String $verticalrate vertival rate of flight |
|
573 | + * @return String success or false |
|
574 | + */ |
|
575 | 575 | public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$format_source = '', $source_name = '') |
576 | 576 | { |
577 | 577 | global $globalURL; |
@@ -659,13 +659,13 @@ discard block |
||
659 | 659 | $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
660 | 660 | $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
661 | 661 | |
662 | - if ($latitude == '' && $longitude == '') { |
|
663 | - $latitude = 0; |
|
664 | - $longitude = 0; |
|
665 | - } |
|
666 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
667 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
668 | - if ($arrival_date == '') $arrival_date = NULL; |
|
662 | + if ($latitude == '' && $longitude == '') { |
|
663 | + $latitude = 0; |
|
664 | + $longitude = 0; |
|
665 | + } |
|
666 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
667 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
668 | + if ($arrival_date == '') $arrival_date = NULL; |
|
669 | 669 | $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) |
670 | 670 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
671 | 671 | |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | $sth->execute($query_values); |
677 | 677 | $this->db = null; |
678 | 678 | } catch (PDOException $e) { |
679 | - return "error : ".$e->getMessage(); |
|
679 | + return "error : ".$e->getMessage(); |
|
680 | 680 | } |
681 | 681 | |
682 | 682 | return "success"; |
@@ -685,11 +685,11 @@ discard block |
||
685 | 685 | |
686 | 686 | |
687 | 687 | /** |
688 | - * Gets the aircraft ident within the last hour |
|
689 | - * |
|
690 | - * @return String the ident |
|
691 | - * |
|
692 | - */ |
|
688 | + * Gets the aircraft ident within the last hour |
|
689 | + * |
|
690 | + * @return String the ident |
|
691 | + * |
|
692 | + */ |
|
693 | 693 | public function getIdentFromLastHour($ident) |
694 | 694 | { |
695 | 695 | global $globalDBdriver, $globalTimezone; |
@@ -705,11 +705,11 @@ discard block |
||
705 | 705 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
706 | 706 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
707 | 707 | $query_data = array(':ident' => $ident); |
708 | - } |
|
708 | + } |
|
709 | 709 | |
710 | 710 | $sth = $this->db->prepare($query); |
711 | 711 | $sth->execute($query_data); |
712 | - $ident_result=''; |
|
712 | + $ident_result=''; |
|
713 | 713 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
714 | 714 | { |
715 | 715 | $ident_result = $row['ident']; |
@@ -720,11 +720,11 @@ discard block |
||
720 | 720 | |
721 | 721 | |
722 | 722 | /** |
723 | - * Gets the aircraft data from the last 20 seconds |
|
724 | - * |
|
725 | - * @return Array the spotter data |
|
726 | - * |
|
727 | - */ |
|
723 | + * Gets the aircraft data from the last 20 seconds |
|
724 | + * |
|
725 | + * @return Array the spotter data |
|
726 | + * |
|
727 | + */ |
|
728 | 728 | public function getRealTimeData($q = '') |
729 | 729 | { |
730 | 730 | global $globalDBdriver; |
@@ -762,11 +762,11 @@ discard block |
||
762 | 762 | |
763 | 763 | |
764 | 764 | /** |
765 | - * Gets all number of flight over countries |
|
766 | - * |
|
767 | - * @return Array the airline country list |
|
768 | - * |
|
769 | - */ |
|
765 | + * Gets all number of flight over countries |
|
766 | + * |
|
767 | + * @return Array the airline country list |
|
768 | + * |
|
769 | + */ |
|
770 | 770 | /* |
771 | 771 | public function countAllTrackedOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
772 | 772 | { |
@@ -817,11 +817,11 @@ discard block |
||
817 | 817 | |
818 | 818 | |
819 | 819 | /** |
820 | - * Gets all callsigns that have flown over |
|
821 | - * |
|
822 | - * @return Array the callsign list |
|
823 | - * |
|
824 | - */ |
|
820 | + * Gets all callsigns that have flown over |
|
821 | + * |
|
822 | + * @return Array the callsign list |
|
823 | + * |
|
824 | + */ |
|
825 | 825 | public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
826 | 826 | { |
827 | 827 | global $globalDBdriver; |
@@ -888,11 +888,11 @@ discard block |
||
888 | 888 | |
889 | 889 | |
890 | 890 | /** |
891 | - * Counts all dates |
|
892 | - * |
|
893 | - * @return Array the date list |
|
894 | - * |
|
895 | - */ |
|
891 | + * Counts all dates |
|
892 | + * |
|
893 | + * @return Array the date list |
|
894 | + * |
|
895 | + */ |
|
896 | 896 | public function countAllDates($filters = array()) |
897 | 897 | { |
898 | 898 | global $globalTimezone, $globalDBdriver; |
@@ -938,11 +938,11 @@ discard block |
||
938 | 938 | |
939 | 939 | |
940 | 940 | /** |
941 | - * Counts all dates during the last 7 days |
|
942 | - * |
|
943 | - * @return Array the date list |
|
944 | - * |
|
945 | - */ |
|
941 | + * Counts all dates during the last 7 days |
|
942 | + * |
|
943 | + * @return Array the date list |
|
944 | + * |
|
945 | + */ |
|
946 | 946 | public function countAllDatesLast7Days($filters = array()) |
947 | 947 | { |
948 | 948 | global $globalTimezone, $globalDBdriver; |
@@ -964,7 +964,7 @@ discard block |
||
964 | 964 | $query .= " GROUP BY date_name |
965 | 965 | ORDER BY date_name ASC"; |
966 | 966 | $query_data = array(':offset' => $offset); |
967 | - } |
|
967 | + } |
|
968 | 968 | |
969 | 969 | $sth = $this->db->prepare($query); |
970 | 970 | $sth->execute($query_data); |
@@ -984,11 +984,11 @@ discard block |
||
984 | 984 | } |
985 | 985 | |
986 | 986 | /** |
987 | - * Counts all dates during the last month |
|
988 | - * |
|
989 | - * @return Array the date list |
|
990 | - * |
|
991 | - */ |
|
987 | + * Counts all dates during the last month |
|
988 | + * |
|
989 | + * @return Array the date list |
|
990 | + * |
|
991 | + */ |
|
992 | 992 | public function countAllDatesLastMonth($filters = array()) |
993 | 993 | { |
994 | 994 | global $globalTimezone, $globalDBdriver; |
@@ -1010,7 +1010,7 @@ discard block |
||
1010 | 1010 | $query .= " GROUP BY date_name |
1011 | 1011 | ORDER BY date_name ASC"; |
1012 | 1012 | $query_data = array(':offset' => $offset); |
1013 | - } |
|
1013 | + } |
|
1014 | 1014 | |
1015 | 1015 | $sth = $this->db->prepare($query); |
1016 | 1016 | $sth->execute($query_data); |
@@ -1032,11 +1032,11 @@ discard block |
||
1032 | 1032 | |
1033 | 1033 | |
1034 | 1034 | /** |
1035 | - * Counts all month |
|
1036 | - * |
|
1037 | - * @return Array the month list |
|
1038 | - * |
|
1039 | - */ |
|
1035 | + * Counts all month |
|
1036 | + * |
|
1037 | + * @return Array the month list |
|
1038 | + * |
|
1039 | + */ |
|
1040 | 1040 | public function countAllMonths($filters = array()) |
1041 | 1041 | { |
1042 | 1042 | global $globalTimezone, $globalDBdriver; |
@@ -1081,11 +1081,11 @@ discard block |
||
1081 | 1081 | |
1082 | 1082 | |
1083 | 1083 | /** |
1084 | - * Counts all dates during the last year |
|
1085 | - * |
|
1086 | - * @return Array the date list |
|
1087 | - * |
|
1088 | - */ |
|
1084 | + * Counts all dates during the last year |
|
1085 | + * |
|
1086 | + * @return Array the date list |
|
1087 | + * |
|
1088 | + */ |
|
1089 | 1089 | public function countAllMonthsLastYear($filters) |
1090 | 1090 | { |
1091 | 1091 | global $globalTimezone, $globalDBdriver; |
@@ -1107,7 +1107,7 @@ discard block |
||
1107 | 1107 | $query .= " GROUP BY year_name, month_name |
1108 | 1108 | ORDER BY year_name, month_name ASC"; |
1109 | 1109 | $query_data = array(':offset' => $offset); |
1110 | - } |
|
1110 | + } |
|
1111 | 1111 | |
1112 | 1112 | $sth = $this->db->prepare($query); |
1113 | 1113 | $sth->execute($query_data); |
@@ -1130,11 +1130,11 @@ discard block |
||
1130 | 1130 | |
1131 | 1131 | |
1132 | 1132 | /** |
1133 | - * Counts all hours |
|
1134 | - * |
|
1135 | - * @return Array the hour list |
|
1136 | - * |
|
1137 | - */ |
|
1133 | + * Counts all hours |
|
1134 | + * |
|
1135 | + * @return Array the hour list |
|
1136 | + * |
|
1137 | + */ |
|
1138 | 1138 | public function countAllHours($orderby,$filters = array()) |
1139 | 1139 | { |
1140 | 1140 | global $globalTimezone, $globalDBdriver; |
@@ -1197,11 +1197,11 @@ discard block |
||
1197 | 1197 | |
1198 | 1198 | |
1199 | 1199 | /** |
1200 | - * Counts all hours by date |
|
1201 | - * |
|
1202 | - * @return Array the hour list |
|
1203 | - * |
|
1204 | - */ |
|
1200 | + * Counts all hours by date |
|
1201 | + * |
|
1202 | + * @return Array the hour list |
|
1203 | + * |
|
1204 | + */ |
|
1205 | 1205 | public function countAllHoursByDate($date, $filters = array()) |
1206 | 1206 | { |
1207 | 1207 | global $globalTimezone, $globalDBdriver; |
@@ -1245,11 +1245,11 @@ discard block |
||
1245 | 1245 | |
1246 | 1246 | |
1247 | 1247 | /** |
1248 | - * Counts all hours by a ident/callsign |
|
1249 | - * |
|
1250 | - * @return Array the hour list |
|
1251 | - * |
|
1252 | - */ |
|
1248 | + * Counts all hours by a ident/callsign |
|
1249 | + * |
|
1250 | + * @return Array the hour list |
|
1251 | + * |
|
1252 | + */ |
|
1253 | 1253 | public function countAllHoursByIdent($ident, $filters = array()) |
1254 | 1254 | { |
1255 | 1255 | global $globalTimezone, $globalDBdriver; |
@@ -1294,11 +1294,11 @@ discard block |
||
1294 | 1294 | |
1295 | 1295 | |
1296 | 1296 | /** |
1297 | - * Counts all flights that have flown over |
|
1298 | - * |
|
1299 | - * @return Integer the number of flights |
|
1300 | - * |
|
1301 | - */ |
|
1297 | + * Counts all flights that have flown over |
|
1298 | + * |
|
1299 | + * @return Integer the number of flights |
|
1300 | + * |
|
1301 | + */ |
|
1302 | 1302 | public function countOverallTracked($filters = array(),$year = '',$month = '') |
1303 | 1303 | { |
1304 | 1304 | global $globalDBdriver; |
@@ -1333,11 +1333,11 @@ discard block |
||
1333 | 1333 | |
1334 | 1334 | |
1335 | 1335 | /** |
1336 | - * Counts all hours of today |
|
1337 | - * |
|
1338 | - * @return Array the hour list |
|
1339 | - * |
|
1340 | - */ |
|
1336 | + * Counts all hours of today |
|
1337 | + * |
|
1338 | + * @return Array the hour list |
|
1339 | + * |
|
1340 | + */ |
|
1341 | 1341 | public function countAllHoursFromToday($filters = array()) |
1342 | 1342 | { |
1343 | 1343 | global $globalTimezone, $globalDBdriver; |
@@ -1377,12 +1377,12 @@ discard block |
||
1377 | 1377 | } |
1378 | 1378 | |
1379 | 1379 | |
1380 | - /** |
|
1381 | - * Gets the Barrie Spotter ID based on the FlightAware ID |
|
1382 | - * |
|
1383 | - * @return Integer the Barrie Spotter ID |
|
1380 | + /** |
|
1381 | + * Gets the Barrie Spotter ID based on the FlightAware ID |
|
1382 | + * |
|
1383 | + * @return Integer the Barrie Spotter ID |
|
1384 | 1384 | q * |
1385 | - */ |
|
1385 | + */ |
|
1386 | 1386 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
1387 | 1387 | { |
1388 | 1388 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
@@ -1403,13 +1403,13 @@ discard block |
||
1403 | 1403 | |
1404 | 1404 | |
1405 | 1405 | /** |
1406 | - * Parses a date string |
|
1407 | - * |
|
1408 | - * @param String $dateString the date string |
|
1409 | - * @param String $timezone the timezone of a user |
|
1410 | - * @return Array the time information |
|
1411 | - * |
|
1412 | - */ |
|
1406 | + * Parses a date string |
|
1407 | + * |
|
1408 | + * @param String $dateString the date string |
|
1409 | + * @param String $timezone the timezone of a user |
|
1410 | + * @return Array the time information |
|
1411 | + * |
|
1412 | + */ |
|
1413 | 1413 | public function parseDateString($dateString, $timezone = '') |
1414 | 1414 | { |
1415 | 1415 | $time_array = array(); |
@@ -1442,12 +1442,12 @@ discard block |
||
1442 | 1442 | } |
1443 | 1443 | |
1444 | 1444 | /** |
1445 | - * Parses the direction degrees to working |
|
1446 | - * |
|
1447 | - * @param Float $direction the direction in degrees |
|
1448 | - * @return Array the direction information |
|
1449 | - * |
|
1450 | - */ |
|
1445 | + * Parses the direction degrees to working |
|
1446 | + * |
|
1447 | + * @param Float $direction the direction in degrees |
|
1448 | + * @return Array the direction information |
|
1449 | + * |
|
1450 | + */ |
|
1451 | 1451 | public function parseDirection($direction = 0) |
1452 | 1452 | { |
1453 | 1453 | if ($direction == '') $direction = 0; |
@@ -1526,12 +1526,12 @@ discard block |
||
1526 | 1526 | |
1527 | 1527 | |
1528 | 1528 | /** |
1529 | - * Gets Country from latitude/longitude |
|
1530 | - * |
|
1531 | - * @param Float $latitude latitute of the flight |
|
1532 | - * @param Float $longitude longitute of the flight |
|
1533 | - * @return String the countrie |
|
1534 | - */ |
|
1529 | + * Gets Country from latitude/longitude |
|
1530 | + * |
|
1531 | + * @param Float $latitude latitute of the flight |
|
1532 | + * @param Float $longitude longitute of the flight |
|
1533 | + * @return String the countrie |
|
1534 | + */ |
|
1535 | 1535 | public function getCountryFromLatitudeLongitude($latitude,$longitude) |
1536 | 1536 | { |
1537 | 1537 | global $globalDBdriver, $globalDebug; |
@@ -1568,11 +1568,11 @@ discard block |
||
1568 | 1568 | } |
1569 | 1569 | |
1570 | 1570 | /** |
1571 | - * Gets Country from iso2 |
|
1572 | - * |
|
1573 | - * @param String $iso2 ISO2 country code |
|
1574 | - * @return String the countrie |
|
1575 | - */ |
|
1571 | + * Gets Country from iso2 |
|
1572 | + * |
|
1573 | + * @param String $iso2 ISO2 country code |
|
1574 | + * @return String the countrie |
|
1575 | + */ |
|
1576 | 1576 | public function getCountryFromISO2($iso2) |
1577 | 1577 | { |
1578 | 1578 | global $globalDBdriver, $globalDebug; |
@@ -1601,12 +1601,12 @@ discard block |
||
1601 | 1601 | |
1602 | 1602 | |
1603 | 1603 | /** |
1604 | - * Gets the short url from bit.ly |
|
1605 | - * |
|
1606 | - * @param String $url the full url |
|
1607 | - * @return String the bit.ly url |
|
1608 | - * |
|
1609 | - */ |
|
1604 | + * Gets the short url from bit.ly |
|
1605 | + * |
|
1606 | + * @param String $url the full url |
|
1607 | + * @return String the bit.ly url |
|
1608 | + * |
|
1609 | + */ |
|
1610 | 1610 | public function getBitlyURL($url) |
1611 | 1611 | { |
1612 | 1612 | global $globalBitlyAccessToken; |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | |
13 | 13 | |
14 | 14 | /** |
15 | - * Get SQL query part for filter used |
|
16 | - * @param Array $filter the filter |
|
17 | - * @return Array the SQL part |
|
18 | - */ |
|
15 | + * Get SQL query part for filter used |
|
16 | + * @param Array $filter the filter |
|
17 | + * @return Array the SQL part |
|
18 | + */ |
|
19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
21 | 21 | $filters = array(); |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
131 | - * Gets all the spotter information based on the latest data entry |
|
132 | - * |
|
133 | - * @return Array the spotter information |
|
134 | - * |
|
135 | - */ |
|
131 | + * Gets all the spotter information based on the latest data entry |
|
132 | + * |
|
133 | + * @return Array the spotter information |
|
134 | + * |
|
135 | + */ |
|
136 | 136 | public function getLiveSpotterData($limit = '', $sort = '', $filter = array()) |
137 | 137 | { |
138 | 138 | global $globalDBdriver, $globalLiveInterval; |
@@ -174,11 +174,11 @@ discard block |
||
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
177 | - * Gets Minimal Live Spotter data |
|
178 | - * |
|
179 | - * @return Array the spotter information |
|
180 | - * |
|
181 | - */ |
|
177 | + * Gets Minimal Live Spotter data |
|
178 | + * |
|
179 | + * @return Array the spotter information |
|
180 | + * |
|
181 | + */ |
|
182 | 182 | public function getMinLiveSpotterData($filter = array()) |
183 | 183 | { |
184 | 184 | global $globalDBdriver, $globalLiveInterval; |
@@ -231,11 +231,11 @@ discard block |
||
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
234 | - * Gets Minimal Live Spotter data since xx seconds |
|
235 | - * |
|
236 | - * @return Array the spotter information |
|
237 | - * |
|
238 | - */ |
|
234 | + * Gets Minimal Live Spotter data since xx seconds |
|
235 | + * |
|
236 | + * @return Array the spotter information |
|
237 | + * |
|
238 | + */ |
|
239 | 239 | public function getMinLastLiveSpotterData($filter = array()) |
240 | 240 | { |
241 | 241 | global $globalDBdriver, $globalLiveInterval; |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
254 | 254 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
255 | 255 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
256 | - } else { |
|
256 | + } else { |
|
257 | 257 | /* |
258 | 258 | $query = "SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
259 | 259 | FROM spotter_live LEFT JOIN (SELECT aircraft_shadow,engine_type, engine_count, wake_category, icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | // echo $query; |
266 | 266 | } |
267 | 267 | |
268 | - try { |
|
268 | + try { |
|
269 | 269 | $sth = $this->db->prepare($query); |
270 | 270 | $sth->execute(); |
271 | 271 | } catch(PDOException $e) { |
@@ -277,11 +277,11 @@ discard block |
||
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
280 | - * Gets number of latest data entry |
|
281 | - * |
|
282 | - * @return String number of entry |
|
283 | - * |
|
284 | - */ |
|
280 | + * Gets number of latest data entry |
|
281 | + * |
|
282 | + * @return String number of entry |
|
283 | + * |
|
284 | + */ |
|
285 | 285 | public function getLiveSpotterCount($filter = array()) |
286 | 286 | { |
287 | 287 | global $globalDBdriver, $globalLiveInterval; |
@@ -308,11 +308,11 @@ discard block |
||
308 | 308 | } |
309 | 309 | |
310 | 310 | /** |
311 | - * Gets all the spotter information based on the latest data entry and coord |
|
312 | - * |
|
313 | - * @return Array the spotter information |
|
314 | - * |
|
315 | - */ |
|
311 | + * Gets all the spotter information based on the latest data entry and coord |
|
312 | + * |
|
313 | + * @return Array the spotter information |
|
314 | + * |
|
315 | + */ |
|
316 | 316 | public function getLiveSpotterDatabyCoord($coord, $filter = array()) |
317 | 317 | { |
318 | 318 | global $globalDBdriver, $globalLiveInterval; |
@@ -337,11 +337,11 @@ discard block |
||
337 | 337 | } |
338 | 338 | |
339 | 339 | /** |
340 | - * Gets all the spotter information based on a user's latitude and longitude |
|
341 | - * |
|
342 | - * @return Array the spotter information |
|
343 | - * |
|
344 | - */ |
|
340 | + * Gets all the spotter information based on a user's latitude and longitude |
|
341 | + * |
|
342 | + * @return Array the spotter information |
|
343 | + * |
|
344 | + */ |
|
345 | 345 | public function getLatestSpotterForLayar($lat, $lng, $radius, $interval) |
346 | 346 | { |
347 | 347 | $Spotter = new Spotter($this->db); |
@@ -351,145 +351,145 @@ discard block |
||
351 | 351 | return false; |
352 | 352 | } |
353 | 353 | } |
354 | - if ($lng != '') |
|
355 | - { |
|
356 | - if (!is_numeric($lng)) |
|
357 | - { |
|
358 | - return false; |
|
359 | - } |
|
360 | - } |
|
361 | - |
|
362 | - if ($radius != '') |
|
363 | - { |
|
364 | - if (!is_numeric($radius)) |
|
365 | - { |
|
366 | - return false; |
|
367 | - } |
|
368 | - } |
|
354 | + if ($lng != '') |
|
355 | + { |
|
356 | + if (!is_numeric($lng)) |
|
357 | + { |
|
358 | + return false; |
|
359 | + } |
|
360 | + } |
|
361 | + |
|
362 | + if ($radius != '') |
|
363 | + { |
|
364 | + if (!is_numeric($radius)) |
|
365 | + { |
|
366 | + return false; |
|
367 | + } |
|
368 | + } |
|
369 | 369 | $additional_query = ''; |
370 | - if ($interval != '') |
|
371 | - { |
|
372 | - if (!is_string($interval)) |
|
373 | - { |
|
374 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
375 | - return false; |
|
376 | - } else { |
|
377 | - if ($interval == '1m') |
|
378 | - { |
|
379 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
380 | - } else if ($interval == '15m'){ |
|
381 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
382 | - } |
|
383 | - } |
|
384 | - } else { |
|
385 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
386 | - } |
|
387 | - |
|
388 | - $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
370 | + if ($interval != '') |
|
371 | + { |
|
372 | + if (!is_string($interval)) |
|
373 | + { |
|
374 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
375 | + return false; |
|
376 | + } else { |
|
377 | + if ($interval == '1m') |
|
378 | + { |
|
379 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
380 | + } else if ($interval == '15m'){ |
|
381 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
382 | + } |
|
383 | + } |
|
384 | + } else { |
|
385 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
386 | + } |
|
387 | + |
|
388 | + $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
389 | 389 | WHERE spotter_live.latitude <> '' |
390 | 390 | AND spotter_live.longitude <> '' |
391 | 391 | ".$additional_query." |
392 | 392 | HAVING distance < :radius |
393 | 393 | ORDER BY distance"; |
394 | 394 | |
395 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
395 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
396 | 396 | |
397 | - return $spotter_array; |
|
398 | - } |
|
397 | + return $spotter_array; |
|
398 | + } |
|
399 | 399 | |
400 | 400 | |
401 | - /** |
|
402 | - * Gets all the spotter information based on a particular callsign |
|
403 | - * |
|
404 | - * @return Array the spotter information |
|
405 | - * |
|
406 | - */ |
|
401 | + /** |
|
402 | + * Gets all the spotter information based on a particular callsign |
|
403 | + * |
|
404 | + * @return Array the spotter information |
|
405 | + * |
|
406 | + */ |
|
407 | 407 | public function getLastLiveSpotterDataByIdent($ident) |
408 | 408 | { |
409 | 409 | $Spotter = new Spotter($this->db); |
410 | 410 | date_default_timezone_set('UTC'); |
411 | 411 | |
412 | 412 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
413 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
413 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
414 | 414 | |
415 | 415 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
416 | 416 | |
417 | 417 | return $spotter_array; |
418 | 418 | } |
419 | 419 | |
420 | - /** |
|
421 | - * Gets all the spotter information based on a particular callsign |
|
422 | - * |
|
423 | - * @return Array the spotter information |
|
424 | - * |
|
425 | - */ |
|
420 | + /** |
|
421 | + * Gets all the spotter information based on a particular callsign |
|
422 | + * |
|
423 | + * @return Array the spotter information |
|
424 | + * |
|
425 | + */ |
|
426 | 426 | public function getDateLiveSpotterDataByIdent($ident,$date) |
427 | 427 | { |
428 | 428 | $Spotter = new Spotter($this->db); |
429 | 429 | date_default_timezone_set('UTC'); |
430 | 430 | |
431 | 431 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
432 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
432 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
433 | 433 | |
434 | - $date = date('c',$date); |
|
434 | + $date = date('c',$date); |
|
435 | 435 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
436 | 436 | |
437 | 437 | return $spotter_array; |
438 | 438 | } |
439 | 439 | |
440 | - /** |
|
441 | - * Gets last spotter information based on a particular callsign |
|
442 | - * |
|
443 | - * @return Array the spotter information |
|
444 | - * |
|
445 | - */ |
|
440 | + /** |
|
441 | + * Gets last spotter information based on a particular callsign |
|
442 | + * |
|
443 | + * @return Array the spotter information |
|
444 | + * |
|
445 | + */ |
|
446 | 446 | public function getLastLiveSpotterDataById($id) |
447 | 447 | { |
448 | 448 | $Spotter = new Spotter($this->db); |
449 | 449 | date_default_timezone_set('UTC'); |
450 | 450 | |
451 | 451 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
452 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
452 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
453 | 453 | |
454 | 454 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
455 | 455 | |
456 | 456 | return $spotter_array; |
457 | 457 | } |
458 | 458 | |
459 | - /** |
|
460 | - * Gets last spotter information based on a particular callsign |
|
461 | - * |
|
462 | - * @return Array the spotter information |
|
463 | - * |
|
464 | - */ |
|
459 | + /** |
|
460 | + * Gets last spotter information based on a particular callsign |
|
461 | + * |
|
462 | + * @return Array the spotter information |
|
463 | + * |
|
464 | + */ |
|
465 | 465 | public function getDateLiveSpotterDataById($id,$date) |
466 | 466 | { |
467 | 467 | $Spotter = new Spotter($this->db); |
468 | 468 | date_default_timezone_set('UTC'); |
469 | 469 | |
470 | 470 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
471 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
472 | - $date = date('c',$date); |
|
471 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
472 | + $date = date('c',$date); |
|
473 | 473 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
474 | 474 | |
475 | 475 | return $spotter_array; |
476 | 476 | } |
477 | 477 | |
478 | - /** |
|
479 | - * Gets altitude information based on a particular callsign |
|
480 | - * |
|
481 | - * @return Array the spotter information |
|
482 | - * |
|
483 | - */ |
|
478 | + /** |
|
479 | + * Gets altitude information based on a particular callsign |
|
480 | + * |
|
481 | + * @return Array the spotter information |
|
482 | + * |
|
483 | + */ |
|
484 | 484 | public function getAltitudeLiveSpotterDataByIdent($ident) |
485 | 485 | { |
486 | 486 | |
487 | 487 | date_default_timezone_set('UTC'); |
488 | 488 | |
489 | 489 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
490 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
490 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
491 | 491 | |
492 | - try { |
|
492 | + try { |
|
493 | 493 | |
494 | 494 | $sth = $this->db->prepare($query); |
495 | 495 | $sth->execute(array(':ident' => $ident)); |
@@ -502,12 +502,12 @@ discard block |
||
502 | 502 | return $spotter_array; |
503 | 503 | } |
504 | 504 | |
505 | - /** |
|
506 | - * Gets all the spotter information based on a particular id |
|
507 | - * |
|
508 | - * @return Array the spotter information |
|
509 | - * |
|
510 | - */ |
|
505 | + /** |
|
506 | + * Gets all the spotter information based on a particular id |
|
507 | + * |
|
508 | + * @return Array the spotter information |
|
509 | + * |
|
510 | + */ |
|
511 | 511 | public function getAllLiveSpotterDataById($id,$liveinterval = false) |
512 | 512 | { |
513 | 513 | global $globalDBdriver, $globalLiveInterval; |
@@ -535,18 +535,18 @@ discard block |
||
535 | 535 | return $spotter_array; |
536 | 536 | } |
537 | 537 | |
538 | - /** |
|
539 | - * Gets all the spotter information based on a particular ident |
|
540 | - * |
|
541 | - * @return Array the spotter information |
|
542 | - * |
|
543 | - */ |
|
538 | + /** |
|
539 | + * Gets all the spotter information based on a particular ident |
|
540 | + * |
|
541 | + * @return Array the spotter information |
|
542 | + * |
|
543 | + */ |
|
544 | 544 | public function getAllLiveSpotterDataByIdent($ident) |
545 | 545 | { |
546 | 546 | date_default_timezone_set('UTC'); |
547 | 547 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
548 | 548 | $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
549 | - try { |
|
549 | + try { |
|
550 | 550 | |
551 | 551 | $sth = $this->db->prepare($query); |
552 | 552 | $sth->execute(array(':ident' => $ident)); |
@@ -560,23 +560,23 @@ discard block |
||
560 | 560 | |
561 | 561 | |
562 | 562 | /** |
563 | - * Deletes all info in the table |
|
564 | - * |
|
565 | - * @return String success or false |
|
566 | - * |
|
567 | - */ |
|
563 | + * Deletes all info in the table |
|
564 | + * |
|
565 | + * @return String success or false |
|
566 | + * |
|
567 | + */ |
|
568 | 568 | public function deleteLiveSpotterData() |
569 | 569 | { |
570 | 570 | global $globalDBdriver; |
571 | 571 | if ($globalDBdriver == 'mysql') { |
572 | 572 | //$query = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date"; |
573 | 573 | $query = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date'; |
574 | - //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
574 | + //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
575 | 575 | } else { |
576 | 576 | $query = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date"; |
577 | 577 | } |
578 | 578 | |
579 | - try { |
|
579 | + try { |
|
580 | 580 | |
581 | 581 | $sth = $this->db->prepare($query); |
582 | 582 | $sth->execute(); |
@@ -588,18 +588,18 @@ discard block |
||
588 | 588 | } |
589 | 589 | |
590 | 590 | /** |
591 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
592 | - * |
|
593 | - * @return String success or false |
|
594 | - * |
|
595 | - */ |
|
591 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
592 | + * |
|
593 | + * @return String success or false |
|
594 | + * |
|
595 | + */ |
|
596 | 596 | public function deleteLiveSpotterDataNotUpdated() |
597 | 597 | { |
598 | 598 | global $globalDBdriver, $globalDebug; |
599 | 599 | if ($globalDBdriver == 'mysql') { |
600 | 600 | //$query = 'SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < spotter_live.date) LIMIT 800 OFFSET 0'; |
601 | - $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
602 | - try { |
|
601 | + $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
602 | + try { |
|
603 | 603 | |
604 | 604 | $sth = $this->db->prepare($query); |
605 | 605 | $sth->execute(); |
@@ -607,8 +607,8 @@ discard block |
||
607 | 607 | return "error"; |
608 | 608 | } |
609 | 609 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
610 | - $i = 0; |
|
611 | - $j =0; |
|
610 | + $i = 0; |
|
611 | + $j =0; |
|
612 | 612 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
613 | 613 | foreach($all as $row) |
614 | 614 | { |
@@ -616,20 +616,20 @@ discard block |
||
616 | 616 | $j++; |
617 | 617 | if ($j == 30) { |
618 | 618 | if ($globalDebug) echo "."; |
619 | - try { |
|
619 | + try { |
|
620 | 620 | |
621 | 621 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
622 | 622 | $sth->execute(); |
623 | 623 | } catch(PDOException $e) { |
624 | 624 | return "error"; |
625 | 625 | } |
626 | - $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
627 | - $j = 0; |
|
626 | + $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
627 | + $j = 0; |
|
628 | 628 | } |
629 | 629 | $query_delete .= "'".$row['flightaware_id']."',"; |
630 | 630 | } |
631 | 631 | if ($i > 0) { |
632 | - try { |
|
632 | + try { |
|
633 | 633 | |
634 | 634 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
635 | 635 | $sth->execute(); |
@@ -640,9 +640,9 @@ discard block |
||
640 | 640 | return "success"; |
641 | 641 | } elseif ($globalDBdriver == 'pgsql') { |
642 | 642 | //$query = "SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < spotter_live.date) LIMIT 800 OFFSET 0"; |
643 | - //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
644 | - $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
645 | - try { |
|
643 | + //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
644 | + $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
645 | + try { |
|
646 | 646 | |
647 | 647 | $sth = $this->db->prepare($query); |
648 | 648 | $sth->execute(); |
@@ -686,17 +686,17 @@ discard block |
||
686 | 686 | } |
687 | 687 | |
688 | 688 | /** |
689 | - * Deletes all info in the table for an ident |
|
690 | - * |
|
691 | - * @return String success or false |
|
692 | - * |
|
693 | - */ |
|
689 | + * Deletes all info in the table for an ident |
|
690 | + * |
|
691 | + * @return String success or false |
|
692 | + * |
|
693 | + */ |
|
694 | 694 | public function deleteLiveSpotterDataByIdent($ident) |
695 | 695 | { |
696 | 696 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
697 | 697 | $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
698 | 698 | |
699 | - try { |
|
699 | + try { |
|
700 | 700 | |
701 | 701 | $sth = $this->db->prepare($query); |
702 | 702 | $sth->execute(array(':ident' => $ident)); |
@@ -708,17 +708,17 @@ discard block |
||
708 | 708 | } |
709 | 709 | |
710 | 710 | /** |
711 | - * Deletes all info in the table for an id |
|
712 | - * |
|
713 | - * @return String success or false |
|
714 | - * |
|
715 | - */ |
|
711 | + * Deletes all info in the table for an id |
|
712 | + * |
|
713 | + * @return String success or false |
|
714 | + * |
|
715 | + */ |
|
716 | 716 | public function deleteLiveSpotterDataById($id) |
717 | 717 | { |
718 | 718 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
719 | 719 | $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
720 | 720 | |
721 | - try { |
|
721 | + try { |
|
722 | 722 | |
723 | 723 | $sth = $this->db->prepare($query); |
724 | 724 | $sth->execute(array(':id' => $id)); |
@@ -731,11 +731,11 @@ discard block |
||
731 | 731 | |
732 | 732 | |
733 | 733 | /** |
734 | - * Gets the aircraft ident within the last hour |
|
735 | - * |
|
736 | - * @return String the ident |
|
737 | - * |
|
738 | - */ |
|
734 | + * Gets the aircraft ident within the last hour |
|
735 | + * |
|
736 | + * @return String the ident |
|
737 | + * |
|
738 | + */ |
|
739 | 739 | public function getIdentFromLastHour($ident) |
740 | 740 | { |
741 | 741 | global $globalDBdriver, $globalTimezone; |
@@ -761,14 +761,14 @@ discard block |
||
761 | 761 | $ident_result = $row['ident']; |
762 | 762 | } |
763 | 763 | return $ident_result; |
764 | - } |
|
764 | + } |
|
765 | 765 | |
766 | 766 | /** |
767 | - * Check recent aircraft |
|
768 | - * |
|
769 | - * @return String the ident |
|
770 | - * |
|
771 | - */ |
|
767 | + * Check recent aircraft |
|
768 | + * |
|
769 | + * @return String the ident |
|
770 | + * |
|
771 | + */ |
|
772 | 772 | public function checkIdentRecent($ident) |
773 | 773 | { |
774 | 774 | global $globalDBdriver, $globalTimezone; |
@@ -794,14 +794,14 @@ discard block |
||
794 | 794 | $ident_result = $row['flightaware_id']; |
795 | 795 | } |
796 | 796 | return $ident_result; |
797 | - } |
|
797 | + } |
|
798 | 798 | |
799 | 799 | /** |
800 | - * Check recent aircraft by id |
|
801 | - * |
|
802 | - * @return String the ident |
|
803 | - * |
|
804 | - */ |
|
800 | + * Check recent aircraft by id |
|
801 | + * |
|
802 | + * @return String the ident |
|
803 | + * |
|
804 | + */ |
|
805 | 805 | public function checkIdRecent($id) |
806 | 806 | { |
807 | 807 | global $globalDBdriver, $globalTimezone; |
@@ -827,14 +827,14 @@ discard block |
||
827 | 827 | $ident_result = $row['flightaware_id']; |
828 | 828 | } |
829 | 829 | return $ident_result; |
830 | - } |
|
830 | + } |
|
831 | 831 | |
832 | 832 | /** |
833 | - * Check recent aircraft by ModeS |
|
834 | - * |
|
835 | - * @return String the ModeS |
|
836 | - * |
|
837 | - */ |
|
833 | + * Check recent aircraft by ModeS |
|
834 | + * |
|
835 | + * @return String the ModeS |
|
836 | + * |
|
837 | + */ |
|
838 | 838 | public function checkModeSRecent($modes) |
839 | 839 | { |
840 | 840 | global $globalDBdriver, $globalTimezone; |
@@ -861,19 +861,19 @@ discard block |
||
861 | 861 | $ident_result = $row['flightaware_id']; |
862 | 862 | } |
863 | 863 | return $ident_result; |
864 | - } |
|
864 | + } |
|
865 | 865 | |
866 | 866 | /** |
867 | - * Adds a new spotter data |
|
868 | - * |
|
869 | - * @param String $flightaware_id the ID from flightaware |
|
870 | - * @param String $ident the flight ident |
|
871 | - * @param String $aircraft_icao the aircraft type |
|
872 | - * @param String $departure_airport_icao the departure airport |
|
873 | - * @param String $arrival_airport_icao the arrival airport |
|
874 | - * @return String success or false |
|
875 | - * |
|
876 | - */ |
|
867 | + * Adds a new spotter data |
|
868 | + * |
|
869 | + * @param String $flightaware_id the ID from flightaware |
|
870 | + * @param String $ident the flight ident |
|
871 | + * @param String $aircraft_icao the aircraft type |
|
872 | + * @param String $departure_airport_icao the departure airport |
|
873 | + * @param String $arrival_airport_icao the arrival airport |
|
874 | + * @return String success or false |
|
875 | + * |
|
876 | + */ |
|
877 | 877 | public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
878 | 878 | { |
879 | 879 | global $globalURL, $globalArchive, $globalDebug; |
@@ -1008,10 +1008,10 @@ discard block |
||
1008 | 1008 | $arrival_airport_country = ''; |
1009 | 1009 | |
1010 | 1010 | |
1011 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1012 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1013 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1014 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1011 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1012 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1013 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1014 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1015 | 1015 | |
1016 | 1016 | $query = 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) |
1017 | 1017 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country)'; |
@@ -1021,14 +1021,14 @@ discard block |
||
1021 | 1021 | |
1022 | 1022 | $sth = $this->db->prepare($query); |
1023 | 1023 | $sth->execute($query_values); |
1024 | - } catch(PDOException $e) { |
|
1025 | - return "error : ".$e->getMessage(); |
|
1026 | - } |
|
1024 | + } catch(PDOException $e) { |
|
1025 | + return "error : ".$e->getMessage(); |
|
1026 | + } |
|
1027 | 1027 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1028 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
1029 | - $SpotterArchive = new SpotterArchive($this->db); |
|
1030 | - $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
1031 | - if ($globalDebug) echo $result.')'; |
|
1028 | + if ($globalDebug) echo '(Add to SBS archive : '; |
|
1029 | + $SpotterArchive = new SpotterArchive($this->db); |
|
1030 | + $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
1031 | + if ($globalDebug) echo $result.')'; |
|
1032 | 1032 | } |
1033 | 1033 | return "success"; |
1034 | 1034 |
@@ -2,10 +2,10 @@ discard block |
||
2 | 2 | require_once(dirname(__FILE__).'/settings.php'); |
3 | 3 | require_once(dirname(__FILE__).'/class.Common.php'); |
4 | 4 | class aprs { |
5 | - private $socket; |
|
6 | - private $connected = false; |
|
5 | + private $socket; |
|
6 | + private $connected = false; |
|
7 | 7 | |
8 | - protected $symbols = array('!' => 'Police', |
|
8 | + protected $symbols = array('!' => 'Police', |
|
9 | 9 | '#' => 'DIGI', |
10 | 10 | '$' => 'Phone', |
11 | 11 | '%' => 'DX Cluster', |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | 'y' => 'Yagi At QTH'); |
90 | 90 | |
91 | 91 | |
92 | - private function urshift($n, $s) { |
|
92 | + private function urshift($n, $s) { |
|
93 | 93 | return ($n >= 0) ? ($n >> $s) : |
94 | - (($n & 0x7fffffff) >> $s) | |
|
94 | + (($n & 0x7fffffff) >> $s) | |
|
95 | 95 | (0x40000000 >> ($s - 1)); |
96 | - } |
|
96 | + } |
|
97 | 97 | |
98 | - public function parse($input) { |
|
98 | + public function parse($input) { |
|
99 | 99 | global $globalDebug; |
100 | 100 | $debug = false; |
101 | 101 | $result = array(); |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | |
108 | 108 | /* Check that end was found and body has at least one byte. */ |
109 | 109 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
110 | - if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; |
|
111 | - return false; |
|
110 | + if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; |
|
111 | + return false; |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | if ($debug) echo 'input : '.$input."\n"; |
@@ -122,31 +122,31 @@ discard block |
||
122 | 122 | /* Parse source, target and path. */ |
123 | 123 | //FLRDF0A52>APRS,qAS,LSTB |
124 | 124 | if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) { |
125 | - $ident = $matches[1]; |
|
126 | - $all_elements = $matches[2]; |
|
127 | - if ($ident == 'AIRCRAFT') { |
|
125 | + $ident = $matches[1]; |
|
126 | + $all_elements = $matches[2]; |
|
127 | + if ($ident == 'AIRCRAFT') { |
|
128 | 128 | $result['format_source'] = 'famaprs'; |
129 | 129 | $result['source_type'] = 'modes'; |
130 | - } elseif ($ident == 'MARINE') { |
|
130 | + } elseif ($ident == 'MARINE') { |
|
131 | 131 | $result['format_source'] = 'famaprs'; |
132 | 132 | $result['source_type'] = 'ais'; |
133 | - } else { |
|
133 | + } else { |
|
134 | 134 | if ($debug) echo 'ident : '.$ident."\n"; |
135 | 135 | $result['ident'] = $ident; |
136 | - } |
|
136 | + } |
|
137 | 137 | } else return false; |
138 | 138 | $elements = explode(',',$all_elements); |
139 | 139 | $source = end($elements); |
140 | 140 | $result['source'] = $source; |
141 | 141 | foreach ($elements as $element) { |
142 | - if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
143 | - //echo "ok"; |
|
144 | - //if ($element == 'TCPIP*') return false; |
|
145 | - } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
142 | + if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
143 | + //echo "ok"; |
|
144 | + //if ($element == 'TCPIP*') return false; |
|
145 | + } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
146 | 146 | if ($debug) echo 'element : '.$element."\n"; |
147 | 147 | return false; |
148 | - } |
|
149 | - /* |
|
148 | + } |
|
149 | + /* |
|
150 | 150 | } elseif (preg_match('/^([0-9A-F]{32})$/',$element)) { |
151 | 151 | //echo "ok"; |
152 | 152 | } else { |
@@ -171,49 +171,49 @@ discard block |
||
171 | 171 | $body_parse = substr($body,1); |
172 | 172 | //echo 'Body : '.$body."\n"; |
173 | 173 | if (preg_match('/^;(.){9}\*/',$body,$matches)) { |
174 | - $body_parse = substr($body_parse,10); |
|
175 | - $find = true; |
|
176 | - //echo $body_parse."\n"; |
|
174 | + $body_parse = substr($body_parse,10); |
|
175 | + $find = true; |
|
176 | + //echo $body_parse."\n"; |
|
177 | 177 | } |
178 | 178 | if (preg_match('/^`(.*)\//',$body,$matches)) { |
179 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
180 | - $find = true; |
|
181 | - //echo $body_parse."\n"; |
|
179 | + $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
180 | + $find = true; |
|
181 | + //echo $body_parse."\n"; |
|
182 | 182 | } |
183 | 183 | if (preg_match("/^'(.*)\//",$body,$matches)) { |
184 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
185 | - $find = true; |
|
186 | - //echo $body_parse."\n"; |
|
184 | + $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
185 | + $find = true; |
|
186 | + //echo $body_parse."\n"; |
|
187 | 187 | } |
188 | 188 | if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) { |
189 | - $find = true; |
|
190 | - //print_r($matches); |
|
191 | - $timestamp = $matches[0]; |
|
192 | - if ($matches[4] == 'h') { |
|
189 | + $find = true; |
|
190 | + //print_r($matches); |
|
191 | + $timestamp = $matches[0]; |
|
192 | + if ($matches[4] == 'h') { |
|
193 | 193 | $timestamp = strtotime($matches[1].':'.$matches[2].':'.$matches[3]); |
194 | 194 | //echo 'timestamp : '.$timestamp.' - now : '.time()."\n"; |
195 | 195 | /* |
196 | 196 | if (time() + 3900 < $timestamp) $timestamp -= 86400; |
197 | 197 | elseif (time() - 82500 > $timestamp) $timestamp += 86400; |
198 | 198 | */ |
199 | - } elseif ($matches[4] == 'z' || $matches[4] == '/') { |
|
199 | + } elseif ($matches[4] == 'z' || $matches[4] == '/') { |
|
200 | 200 | // This work or not ? |
201 | 201 | $timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]); |
202 | - } |
|
203 | - $body_parse = substr($body_parse,7); |
|
204 | - $result['timestamp'] = $timestamp; |
|
205 | - //echo date('Ymd H:i:s',$timestamp); |
|
202 | + } |
|
203 | + $body_parse = substr($body_parse,7); |
|
204 | + $result['timestamp'] = $timestamp; |
|
205 | + //echo date('Ymd H:i:s',$timestamp); |
|
206 | 206 | } |
207 | 207 | if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) { |
208 | - $find = true; |
|
209 | - $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); |
|
210 | - $body_parse = substr($body_parse,8); |
|
211 | - $result['timestamp'] = $timestamp; |
|
212 | - //echo date('Ymd H:i:s',$timestamp); |
|
208 | + $find = true; |
|
209 | + $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); |
|
210 | + $body_parse = substr($body_parse,8); |
|
211 | + $result['timestamp'] = $timestamp; |
|
212 | + //echo date('Ymd H:i:s',$timestamp); |
|
213 | 213 | } |
214 | 214 | //if (strlen($body_parse) > 19) { |
215 | - if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) { |
|
216 | - $find = true; |
|
215 | + if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) { |
|
216 | + $find = true; |
|
217 | 217 | // 4658.70N/00707.78Ez |
218 | 218 | //print_r(str_split($body_parse)); |
219 | 219 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $lon = intval($lon_deg); |
231 | 231 | if ($lat > 89 || $lon > 179) return false; |
232 | 232 | |
233 | - /* |
|
233 | + /* |
|
234 | 234 | $tmp_5b = str_replace('.','',$lat_min); |
235 | 235 | if (preg_match('/^([0-9]{0,4})( {0,4})$/',$tmp_5b,$matches)) { |
236 | 236 | print_r($matches); |
@@ -244,9 +244,9 @@ discard block |
||
244 | 244 | $result['longitude'] = $longitude; |
245 | 245 | $body_parse = substr($body_parse,18); |
246 | 246 | $body_parse_len = strlen($body_parse); |
247 | - } |
|
248 | - $body_parse_len = strlen($body_parse); |
|
249 | - if ($body_parse_len > 0) { |
|
247 | + } |
|
248 | + $body_parse_len = strlen($body_parse); |
|
249 | + if ($body_parse_len > 0) { |
|
250 | 250 | /* |
251 | 251 | if (!isset($result['timestamp']) && !isset($result['latitude'])) { |
252 | 252 | $body_split = str_split($body); |
@@ -276,86 +276,86 @@ discard block |
||
276 | 276 | if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; |
277 | 277 | if ($symbol_code != '_') { |
278 | 278 | } |
279 | - //$body_parse = substr($body_parse,1); |
|
280 | - //$body_parse = trim($body_parse); |
|
281 | - //$body_parse_len = strlen($body_parse); |
|
282 | - if ($body_parse_len >= 7) { |
|
279 | + //$body_parse = substr($body_parse,1); |
|
280 | + //$body_parse = trim($body_parse); |
|
281 | + //$body_parse_len = strlen($body_parse); |
|
282 | + if ($body_parse_len >= 7) { |
|
283 | 283 | |
284 | - if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
285 | - $course = substr($body_parse,0,3); |
|
286 | - $tmp_s = intval($course); |
|
287 | - if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
|
288 | - $speed = substr($body_parse,4,3); |
|
289 | - if ($speed != '...') { |
|
290 | - //$result['speed'] = round($speed*1.852); |
|
291 | - $result['speed'] = intval($speed); |
|
292 | - } |
|
293 | - $body_parse = substr($body_parse,7); |
|
294 | - } |
|
295 | - // Check PHGR, PHG, RNG |
|
296 | - } |
|
297 | - /* |
|
284 | + if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
285 | + $course = substr($body_parse,0,3); |
|
286 | + $tmp_s = intval($course); |
|
287 | + if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
|
288 | + $speed = substr($body_parse,4,3); |
|
289 | + if ($speed != '...') { |
|
290 | + //$result['speed'] = round($speed*1.852); |
|
291 | + $result['speed'] = intval($speed); |
|
292 | + } |
|
293 | + $body_parse = substr($body_parse,7); |
|
294 | + } |
|
295 | + // Check PHGR, PHG, RNG |
|
296 | + } |
|
297 | + /* |
|
298 | 298 | else if ($body_parse_len > 0) { |
299 | 299 | $rest = $body_parse; |
300 | 300 | } |
301 | 301 | */ |
302 | - if (strlen($body_parse) > 0) { |
|
303 | - if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
304 | - $altitude = intval($matches[1]); |
|
305 | - //$result['altitude'] = round($altitude*0.3048); |
|
306 | - $result['altitude'] = $altitude; |
|
307 | - //$body_parse = trim(substr($body_parse,strlen($matches[0]))); |
|
308 | - $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); |
|
309 | - } |
|
310 | - } |
|
302 | + if (strlen($body_parse) > 0) { |
|
303 | + if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
304 | + $altitude = intval($matches[1]); |
|
305 | + //$result['altitude'] = round($altitude*0.3048); |
|
306 | + $result['altitude'] = $altitude; |
|
307 | + //$body_parse = trim(substr($body_parse,strlen($matches[0]))); |
|
308 | + $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); |
|
309 | + } |
|
310 | + } |
|
311 | 311 | |
312 | - // Telemetry |
|
313 | - /* |
|
312 | + // Telemetry |
|
313 | + /* |
|
314 | 314 | if (preg_match('/^([0-9]+),(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,([01]{0,8})/',$body_parse,$matches)) { |
315 | 315 | // Nothing yet... |
316 | 316 | } |
317 | 317 | */ |
318 | - // DAO |
|
319 | - if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
320 | - $dao = $matches[1]; |
|
321 | - if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
318 | + // DAO |
|
319 | + if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
320 | + $dao = $matches[1]; |
|
321 | + if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
322 | 322 | $dao_split = str_split($dao); |
323 | - $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
|
324 | - $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
|
323 | + $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
|
324 | + $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
|
325 | 325 | |
326 | 326 | if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
327 | 327 | else $result['latitude'] += $lat_off; |
328 | 328 | if ($result['longitude'] < 0) $result['longitude'] -= $lon_off; |
329 | 329 | else $result['longitude'] += $lon_off; |
330 | - } |
|
331 | - $body_parse = substr($body_parse,6); |
|
332 | - } |
|
330 | + } |
|
331 | + $body_parse = substr($body_parse,6); |
|
332 | + } |
|
333 | 333 | |
334 | - if (preg_match('/CS=([0-9A-Z]*)/',$body_parse,$matches)) { |
|
334 | + if (preg_match('/CS=([0-9A-Z]*)/',$body_parse,$matches)) { |
|
335 | 335 | $result['ident'] = $matches[1]; |
336 | - } |
|
337 | - if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { |
|
336 | + } |
|
337 | + if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { |
|
338 | 338 | $result['squawk'] = $matches[1]; |
339 | - } |
|
340 | - if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { |
|
339 | + } |
|
340 | + if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { |
|
341 | 341 | $result['aircraft_icao'] = $matches[1]; |
342 | - } |
|
343 | - if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { |
|
342 | + } |
|
343 | + if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { |
|
344 | 344 | $result['typeid'] = $matches[1]; |
345 | - } |
|
346 | - if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { |
|
345 | + } |
|
346 | + if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { |
|
347 | 347 | $result['imo'] = $matches[1]; |
348 | - } |
|
349 | - if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { |
|
348 | + } |
|
349 | + if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { |
|
350 | 350 | $result['arrival_date'] = $matches[1]; |
351 | - } |
|
352 | - if (preg_match('/AC=([0-9A-Z]*)/',$body_parse,$matches)) { |
|
351 | + } |
|
352 | + if (preg_match('/AC=([0-9A-Z]*)/',$body_parse,$matches)) { |
|
353 | 353 | $result['arrival_code'] = $matches[1]; |
354 | - } |
|
355 | - // OGN comment |
|
354 | + } |
|
355 | + // OGN comment |
|
356 | 356 | // echo "Before OGN : ".$body_parse."\n"; |
357 | - //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
|
358 | - if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { |
|
357 | + //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
|
358 | + if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { |
|
359 | 359 | $id = $matches[1]; |
360 | 360 | //$mode = substr($id,0,2); |
361 | 361 | $address = substr($id,2); |
@@ -385,53 +385,53 @@ discard block |
||
385 | 385 | $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
386 | 386 | $result['stealth'] = $stealth; |
387 | 387 | $result['address'] = $address; |
388 | - } |
|
388 | + } |
|
389 | 389 | |
390 | - //Comment |
|
391 | - $result['comment'] = trim($body_parse); |
|
390 | + //Comment |
|
391 | + $result['comment'] = trim($body_parse); |
|
392 | 392 | } else { |
393 | - // parse weather |
|
394 | - //$body_parse = substr($body_parse,1); |
|
395 | - //$body_parse_len = strlen($body_parse); |
|
393 | + // parse weather |
|
394 | + //$body_parse = substr($body_parse,1); |
|
395 | + //$body_parse_len = strlen($body_parse); |
|
396 | 396 | |
397 | - if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
398 | - $result['wind_dir'] = intval($matches[1]); |
|
399 | - $result['wind_speed'] = round(intval($matches[2])*1.60934,1); |
|
400 | - $result['wind_gust'] = round(intval($matches[3])*1.60934,1); |
|
401 | - $result['temp'] = round(5/9*((intval($matches[4]))-32),1); |
|
402 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
403 | - } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
397 | + if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
398 | + $result['wind_dir'] = intval($matches[1]); |
|
399 | + $result['wind_speed'] = round(intval($matches[2])*1.60934,1); |
|
400 | + $result['wind_gust'] = round(intval($matches[3])*1.60934,1); |
|
401 | + $result['temp'] = round(5/9*((intval($matches[4]))-32),1); |
|
402 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
403 | + } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
404 | 404 | $result['wind_dir'] = intval($matches[1]); |
405 | 405 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
406 | 406 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
407 | 407 | $result['temp'] = round(5/9*(($matches[4])-32),1); |
408 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
409 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
408 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
409 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
410 | 410 | $result['wind_dir'] = intval($matches[1]); |
411 | 411 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
412 | 412 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
413 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
414 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { |
|
413 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
414 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { |
|
415 | 415 | $result['wind_dir'] = intval($matches[1]); |
416 | 416 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
417 | 417 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
418 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
419 | - } |
|
420 | - if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
|
418 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
419 | + } |
|
420 | + if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
|
421 | 421 | $result['temp'] = round(5/9*(($matches[1])-32),1); |
422 | - } |
|
422 | + } |
|
423 | 423 | } |
424 | 424 | } else $result['comment'] = trim($body_parse); |
425 | 425 | |
426 | - } |
|
426 | + } |
|
427 | 427 | //} |
428 | 428 | if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
429 | 429 | if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
430 | 430 | if ($debug) print_r($result); |
431 | 431 | return $result; |
432 | - } |
|
432 | + } |
|
433 | 433 | |
434 | - function connect() { |
|
434 | + function connect() { |
|
435 | 435 | global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport; |
436 | 436 | $aprs_connect = 0; |
437 | 437 | $aprs_keep = 120; |
@@ -454,24 +454,24 @@ discard block |
||
454 | 454 | $send = socket_send( $this->socket , $aprs_login , strlen($aprs_login) , 0 ); |
455 | 455 | while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) { |
456 | 456 | if (strpos($msgin, "$aprs_ssid verified") !== FALSE) { |
457 | - echo 'APRS user verified !'."\n"; |
|
458 | - $this->connected = true; |
|
459 | - return true; |
|
460 | - break; |
|
457 | + echo 'APRS user verified !'."\n"; |
|
458 | + $this->connected = true; |
|
459 | + return true; |
|
460 | + break; |
|
461 | 461 | } |
462 | 462 | if (time()-$authstart > 5) { |
463 | - echo 'APRS timeout'."\n"; |
|
464 | - break; |
|
463 | + echo 'APRS timeout'."\n"; |
|
464 | + break; |
|
465 | 465 | } |
466 | 466 | } |
467 | 467 | } |
468 | - } |
|
468 | + } |
|
469 | 469 | |
470 | - function send($data) { |
|
470 | + function send($data) { |
|
471 | 471 | if ($this->connected === false) $this->connect(); |
472 | 472 | $send = socket_send( $this->socket , $data , strlen($data),0); |
473 | 473 | if ($send === FALSE) $this->connect(); |
474 | - } |
|
474 | + } |
|
475 | 475 | } |
476 | 476 | |
477 | 477 | class APRSSpotter extends APRS { |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
16 | 16 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
17 | 17 | if (isset($globalMarine) && $globalMarine) { |
18 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
19 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
18 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
19 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | if (!isset($globalDebug)) $globalDebug = FALSE; |
@@ -24,40 +24,40 @@ discard block |
||
24 | 24 | // Check if schema is at latest version |
25 | 25 | $Connection = new Connection(); |
26 | 26 | if ($Connection->latest() === false) { |
27 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
28 | - exit(); |
|
27 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
28 | + exit(); |
|
29 | 29 | } |
30 | 30 | if (PHP_SAPI != 'cli') { |
31 | - echo "This script MUST be called from console, not a web browser."; |
|
31 | + echo "This script MUST be called from console, not a web browser."; |
|
32 | 32 | // exit(); |
33 | 33 | } |
34 | 34 | |
35 | 35 | // This is to be compatible with old version of settings.php |
36 | 36 | if (!isset($globalSources)) { |
37 | - if (isset($globalSBS1Hosts)) { |
|
38 | - //$hosts = $globalSBS1Hosts; |
|
39 | - foreach ($globalSBS1Hosts as $host) { |
|
40 | - $globalSources[] = array('host' => $host); |
|
41 | - } |
|
42 | - } else { |
|
43 | - if (!isset($globalSBS1Host)) { |
|
44 | - echo '$globalSources MUST be defined !'; |
|
45 | - die; |
|
37 | + if (isset($globalSBS1Hosts)) { |
|
38 | + //$hosts = $globalSBS1Hosts; |
|
39 | + foreach ($globalSBS1Hosts as $host) { |
|
40 | + $globalSources[] = array('host' => $host); |
|
41 | + } |
|
42 | + } else { |
|
43 | + if (!isset($globalSBS1Host)) { |
|
44 | + echo '$globalSources MUST be defined !'; |
|
45 | + die; |
|
46 | 46 | } |
47 | 47 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
48 | 48 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
49 | - } |
|
49 | + } |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::')); |
53 | 53 | //if (isset($options['s'])) $hosts = array($options['s']); |
54 | 54 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
55 | 55 | if (isset($options['s'])) { |
56 | - $globalSources = array(); |
|
57 | - $globalSources[] = array('host' => $options['s']); |
|
56 | + $globalSources = array(); |
|
57 | + $globalSources[] = array('host' => $options['s']); |
|
58 | 58 | } elseif (isset($options['source'])) { |
59 | - $globalSources = array(); |
|
60 | - $globalSources[] = array('host' => $options['source']); |
|
59 | + $globalSources = array(); |
|
60 | + $globalSources[] = array('host' => $options['source']); |
|
61 | 61 | } |
62 | 62 | if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
63 | 63 | if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
67 | 67 | else $id_source = 1; |
68 | 68 | if (isset($globalServer) && $globalServer) { |
69 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
70 | - $SI=new SpotterServer(); |
|
69 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
70 | + $SI=new SpotterServer(); |
|
71 | 71 | /* |
72 | 72 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
73 | 73 | $SI = new adsb2aprs(); |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | } else $SI=new SpotterImport($Connection->db); |
77 | 77 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
78 | 78 | if (isset($globalMarine) && $globalMarine) { |
79 | - $AIS = new AIS(); |
|
80 | - $MI = new MarineImport($Connection->db); |
|
79 | + $AIS = new AIS(); |
|
80 | + $MI = new MarineImport($Connection->db); |
|
81 | 81 | } |
82 | 82 | //$APRS=new APRS($Connection->db); |
83 | 83 | $SBS=new SBS(); |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | //$servertz = system('date +%Z'); |
88 | 88 | // signal handler - playing nice with sockets and dump1090 |
89 | 89 | if (function_exists('pcntl_fork')) { |
90 | - pcntl_signal(SIGINT, function() { |
|
91 | - global $sockets; |
|
92 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
93 | - die("Bye!\n"); |
|
94 | - }); |
|
95 | - pcntl_signal_dispatch(); |
|
90 | + pcntl_signal(SIGINT, function() { |
|
91 | + global $sockets; |
|
92 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
93 | + die("Bye!\n"); |
|
94 | + }); |
|
95 | + pcntl_signal_dispatch(); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | // let's try and connect |
@@ -102,153 +102,153 @@ discard block |
||
102 | 102 | $reset = 0; |
103 | 103 | |
104 | 104 | function connect_all($hosts) { |
105 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
106 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
107 | - $reset++; |
|
108 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
109 | - foreach ($hosts as $id => $value) { |
|
105 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
106 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
107 | + $reset++; |
|
108 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
109 | + foreach ($hosts as $id => $value) { |
|
110 | 110 | $host = $value['host']; |
111 | 111 | $globalSources[$id]['last_exec'] = 0; |
112 | 112 | // Here we check type of source(s) |
113 | 113 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
114 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
115 | - //$formats[$id] = 'deltadbtxt'; |
|
116 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
117 | - //$last_exec['deltadbtxt'] = 0; |
|
118 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
119 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
120 | - //$formats[$id] = 'vatsimtxt'; |
|
121 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
122 | - //$last_exec['vatsimtxt'] = 0; |
|
123 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
124 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
125 | - //$formats[$id] = 'aircraftlistjson'; |
|
126 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
127 | - //$last_exec['aircraftlistjson'] = 0; |
|
128 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
129 | - } else if (preg_match('/opensky/i',$host)) { |
|
130 | - //$formats[$id] = 'aircraftlistjson'; |
|
131 | - $globalSources[$id]['format'] = 'opensky'; |
|
132 | - //$last_exec['aircraftlistjson'] = 0; |
|
133 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
134 | - } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
135 | - //$formats[$id] = 'radarvirtueljson'; |
|
136 | - $globalSources[$id]['format'] = 'radarvirtueljson'; |
|
137 | - //$last_exec['radarvirtueljson'] = 0; |
|
138 | - if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
139 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
140 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
141 | - exit(0); |
|
142 | - } |
|
143 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
144 | - //$formats[$id] = 'planeupdatefaa'; |
|
145 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
146 | - //$last_exec['planeupdatefaa'] = 0; |
|
147 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
148 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
149 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
150 | - exit(0); |
|
151 | - } |
|
152 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
153 | - //$formats[$id] = 'phpvmacars'; |
|
154 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
155 | - //$last_exec['phpvmacars'] = 0; |
|
156 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
157 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
158 | - //$formats[$id] = 'phpvmacars'; |
|
159 | - $globalSources[$id]['format'] = 'vam'; |
|
160 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
161 | - } else if (preg_match('/whazzup/i',$host)) { |
|
162 | - //$formats[$id] = 'whazzup'; |
|
163 | - $globalSources[$id]['format'] = 'whazzup'; |
|
164 | - //$last_exec['whazzup'] = 0; |
|
165 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
166 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
167 | - //$formats[$id] = 'pirepsjson'; |
|
168 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
169 | - //$last_exec['pirepsjson'] = 0; |
|
170 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
171 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
172 | - //$formats[$id] = 'fr24json'; |
|
173 | - $globalSources[$id]['format'] = 'fr24json'; |
|
174 | - //$last_exec['fr24json'] = 0; |
|
175 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
176 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
177 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
178 | - exit(0); |
|
179 | - } |
|
180 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
181 | - //$formats[$id] = 'fr24json'; |
|
182 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
183 | - //$last_exec['fr24json'] = 0; |
|
184 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
185 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
186 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
187 | - exit(0); |
|
188 | - } |
|
189 | - //} else if (preg_match('/10001/',$host)) { |
|
190 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
191 | - //$formats[$id] = 'tsv'; |
|
192 | - $globalSources[$id]['format'] = 'tsv'; |
|
193 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
194 | - } |
|
195 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
196 | - if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
197 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
198 | - if ($idf !== false) { |
|
199 | - $httpfeeds[$id] = $idf; |
|
200 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
201 | - } |
|
202 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
203 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
204 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
205 | - $hostport = explode(':',$host); |
|
206 | - if (isset($hostport[1])) { |
|
114 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
115 | + //$formats[$id] = 'deltadbtxt'; |
|
116 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
117 | + //$last_exec['deltadbtxt'] = 0; |
|
118 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
119 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
120 | + //$formats[$id] = 'vatsimtxt'; |
|
121 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
122 | + //$last_exec['vatsimtxt'] = 0; |
|
123 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
124 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
125 | + //$formats[$id] = 'aircraftlistjson'; |
|
126 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
127 | + //$last_exec['aircraftlistjson'] = 0; |
|
128 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
129 | + } else if (preg_match('/opensky/i',$host)) { |
|
130 | + //$formats[$id] = 'aircraftlistjson'; |
|
131 | + $globalSources[$id]['format'] = 'opensky'; |
|
132 | + //$last_exec['aircraftlistjson'] = 0; |
|
133 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
134 | + } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
135 | + //$formats[$id] = 'radarvirtueljson'; |
|
136 | + $globalSources[$id]['format'] = 'radarvirtueljson'; |
|
137 | + //$last_exec['radarvirtueljson'] = 0; |
|
138 | + if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
139 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
140 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
141 | + exit(0); |
|
142 | + } |
|
143 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
144 | + //$formats[$id] = 'planeupdatefaa'; |
|
145 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
146 | + //$last_exec['planeupdatefaa'] = 0; |
|
147 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
148 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
149 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
150 | + exit(0); |
|
151 | + } |
|
152 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
153 | + //$formats[$id] = 'phpvmacars'; |
|
154 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
155 | + //$last_exec['phpvmacars'] = 0; |
|
156 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
157 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
158 | + //$formats[$id] = 'phpvmacars'; |
|
159 | + $globalSources[$id]['format'] = 'vam'; |
|
160 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
161 | + } else if (preg_match('/whazzup/i',$host)) { |
|
162 | + //$formats[$id] = 'whazzup'; |
|
163 | + $globalSources[$id]['format'] = 'whazzup'; |
|
164 | + //$last_exec['whazzup'] = 0; |
|
165 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
166 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
167 | + //$formats[$id] = 'pirepsjson'; |
|
168 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
169 | + //$last_exec['pirepsjson'] = 0; |
|
170 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
171 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
172 | + //$formats[$id] = 'fr24json'; |
|
173 | + $globalSources[$id]['format'] = 'fr24json'; |
|
174 | + //$last_exec['fr24json'] = 0; |
|
175 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
176 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
177 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
178 | + exit(0); |
|
179 | + } |
|
180 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
181 | + //$formats[$id] = 'fr24json'; |
|
182 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
183 | + //$last_exec['fr24json'] = 0; |
|
184 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
185 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
186 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
187 | + exit(0); |
|
188 | + } |
|
189 | + //} else if (preg_match('/10001/',$host)) { |
|
190 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
191 | + //$formats[$id] = 'tsv'; |
|
192 | + $globalSources[$id]['format'] = 'tsv'; |
|
193 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
194 | + } |
|
195 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
196 | + if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
197 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
198 | + if ($idf !== false) { |
|
199 | + $httpfeeds[$id] = $idf; |
|
200 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
201 | + } |
|
202 | + elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
203 | + } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
204 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
205 | + $hostport = explode(':',$host); |
|
206 | + if (isset($hostport[1])) { |
|
207 | 207 | $port = $hostport[1]; |
208 | 208 | $hostn = $hostport[0]; |
209 | - } else { |
|
209 | + } else { |
|
210 | 210 | $port = $globalSources[$id]['port']; |
211 | 211 | $hostn = $globalSources[$id]['host']; |
212 | - } |
|
213 | - $Common = new Common(); |
|
214 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
215 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
216 | - } else { |
|
217 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
218 | - } |
|
219 | - if ($s) { |
|
220 | - $sockets[$id] = $s; |
|
221 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
222 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
212 | + } |
|
213 | + $Common = new Common(); |
|
214 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
215 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
216 | + } else { |
|
217 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
218 | + } |
|
219 | + if ($s) { |
|
220 | + $sockets[$id] = $s; |
|
221 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
222 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
223 | 223 | //$formats[$id] = 'aprs'; |
224 | 224 | $globalSources[$id]['format'] = 'aprs'; |
225 | 225 | //$aprs_connect = 0; |
226 | 226 | //$use_aprs = true; |
227 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
227 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
228 | 228 | $globalSources[$id]['format'] = 'vrstcp'; |
229 | - } elseif ($port == '10001') { |
|
230 | - //$formats[$id] = 'tsv'; |
|
231 | - $globalSources[$id]['format'] = 'tsv'; |
|
232 | - } elseif ($port == '30002') { |
|
233 | - //$formats[$id] = 'raw'; |
|
234 | - $globalSources[$id]['format'] = 'raw'; |
|
235 | - } elseif ($port == '5001') { |
|
236 | - //$formats[$id] = 'raw'; |
|
237 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
238 | - } elseif ($port == '30005') { |
|
229 | + } elseif ($port == '10001') { |
|
230 | + //$formats[$id] = 'tsv'; |
|
231 | + $globalSources[$id]['format'] = 'tsv'; |
|
232 | + } elseif ($port == '30002') { |
|
233 | + //$formats[$id] = 'raw'; |
|
234 | + $globalSources[$id]['format'] = 'raw'; |
|
235 | + } elseif ($port == '5001') { |
|
236 | + //$formats[$id] = 'raw'; |
|
237 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
238 | + } elseif ($port == '30005') { |
|
239 | 239 | // Not yet supported |
240 | - //$formats[$id] = 'beast'; |
|
241 | - $globalSources[$id]['format'] = 'beast'; |
|
242 | - //} else $formats[$id] = 'sbs'; |
|
243 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
244 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
240 | + //$formats[$id] = 'beast'; |
|
241 | + $globalSources[$id]['format'] = 'beast'; |
|
242 | + //} else $formats[$id] = 'sbs'; |
|
243 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
244 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
245 | 245 | } |
246 | 246 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
247 | - } else { |
|
247 | + } else { |
|
248 | 248 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
249 | - } |
|
250 | - } |
|
251 | - } |
|
249 | + } |
|
250 | + } |
|
251 | + } |
|
252 | 252 | } |
253 | 253 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
254 | 254 | |
@@ -271,9 +271,9 @@ discard block |
||
271 | 271 | //connect_all($globalSources); |
272 | 272 | |
273 | 273 | if (isset($globalProxy) && $globalProxy) { |
274 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
274 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
275 | 275 | } else { |
276 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
276 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | // APRS Configuration |
@@ -282,18 +282,18 @@ discard block |
||
282 | 282 | die; |
283 | 283 | } |
284 | 284 | foreach ($globalSources as $key => $source) { |
285 | - if (!isset($source['format'])) { |
|
286 | - $globalSources[$key]['format'] = 'auto'; |
|
287 | - } |
|
285 | + if (!isset($source['format'])) { |
|
286 | + $globalSources[$key]['format'] = 'auto'; |
|
287 | + } |
|
288 | 288 | } |
289 | 289 | connect_all($globalSources); |
290 | 290 | foreach ($globalSources as $key => $source) { |
291 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
291 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
292 | 292 | $aprs_connect = 0; |
293 | 293 | $use_aprs = true; |
294 | 294 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
295 | 295 | break; |
296 | - } |
|
296 | + } |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | if ($use_aprs) { |
@@ -335,152 +335,152 @@ discard block |
||
335 | 335 | |
336 | 336 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
337 | 337 | while ($i > 0) { |
338 | - if (!$globalDaemon) $i = $endtime-time(); |
|
339 | - // Delete old ATC |
|
340 | - if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
338 | + if (!$globalDaemon) $i = $endtime-time(); |
|
339 | + // Delete old ATC |
|
340 | + if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
341 | 341 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
342 | - $ATC->deleteOldATC(); |
|
343 | - } |
|
342 | + $ATC->deleteOldATC(); |
|
343 | + } |
|
344 | 344 | |
345 | - //if (count($last_exec) > 0) { |
|
346 | - if (count($last_exec) == count($globalSources)) { |
|
345 | + //if (count($last_exec) > 0) { |
|
346 | + if (count($last_exec) == count($globalSources)) { |
|
347 | 347 | $max = $globalMinFetch; |
348 | 348 | foreach ($last_exec as $last) { |
349 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
349 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
350 | 350 | } |
351 | 351 | if ($max != $globalMinFetch) { |
352 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
353 | - sleep($globalMinFetch-$max+2); |
|
352 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
353 | + sleep($globalMinFetch-$max+2); |
|
354 | + } |
|
354 | 355 | } |
355 | - } |
|
356 | 356 | |
357 | 357 | |
358 | - //foreach ($formats as $id => $value) { |
|
359 | - foreach ($globalSources as $id => $value) { |
|
358 | + //foreach ($formats as $id => $value) { |
|
359 | + foreach ($globalSources as $id => $value) { |
|
360 | 360 | date_default_timezone_set('UTC'); |
361 | 361 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
362 | 362 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
363 | - //$buffer = $Common->getData($hosts[$id]); |
|
364 | - $buffer = $Common->getData($value['host']); |
|
365 | - if ($buffer != '') $reset = 0; |
|
366 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
367 | - $buffer = explode('\n',$buffer); |
|
368 | - foreach ($buffer as $line) { |
|
369 | - if ($line != '' && count($line) > 7) { |
|
370 | - $line = explode(',', $line); |
|
371 | - $data = array(); |
|
372 | - $data['hex'] = $line[1]; // hex |
|
373 | - $data['ident'] = $line[2]; // ident |
|
374 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
375 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
376 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
377 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
378 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
379 | - $data['verticalrate'] = ''; // vertical rate |
|
380 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
381 | - $data['emergency'] = ''; // emergency |
|
382 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
383 | - $data['format_source'] = 'deltadbtxt'; |
|
384 | - $data['id_source'] = $id_source; |
|
385 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
386 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
387 | - $SI->add($data); |
|
388 | - unset($data); |
|
389 | - } |
|
390 | - } |
|
391 | - $last_exec[$id]['last'] = time(); |
|
363 | + //$buffer = $Common->getData($hosts[$id]); |
|
364 | + $buffer = $Common->getData($value['host']); |
|
365 | + if ($buffer != '') $reset = 0; |
|
366 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
367 | + $buffer = explode('\n',$buffer); |
|
368 | + foreach ($buffer as $line) { |
|
369 | + if ($line != '' && count($line) > 7) { |
|
370 | + $line = explode(',', $line); |
|
371 | + $data = array(); |
|
372 | + $data['hex'] = $line[1]; // hex |
|
373 | + $data['ident'] = $line[2]; // ident |
|
374 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
375 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
376 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
377 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
378 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
379 | + $data['verticalrate'] = ''; // vertical rate |
|
380 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
381 | + $data['emergency'] = ''; // emergency |
|
382 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
383 | + $data['format_source'] = 'deltadbtxt'; |
|
384 | + $data['id_source'] = $id_source; |
|
385 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
386 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
387 | + $SI->add($data); |
|
388 | + unset($data); |
|
389 | + } |
|
390 | + } |
|
391 | + $last_exec[$id]['last'] = time(); |
|
392 | 392 | } elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
393 | - date_default_timezone_set('CET'); |
|
394 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
395 | - date_default_timezone_set('UTC'); |
|
396 | - if ($buffer != '') $reset = 0; |
|
397 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
398 | - $buffer = explode('\n',$buffer); |
|
399 | - foreach ($buffer as $line) { |
|
393 | + date_default_timezone_set('CET'); |
|
394 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
395 | + date_default_timezone_set('UTC'); |
|
396 | + if ($buffer != '') $reset = 0; |
|
397 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
398 | + $buffer = explode('\n',$buffer); |
|
399 | + foreach ($buffer as $line) { |
|
400 | 400 | if ($line != '') { |
401 | - echo "'".$line."'\n"; |
|
402 | - $add = false; |
|
403 | - $ais_data = $AIS->parse_line(trim($line)); |
|
404 | - $data = array(); |
|
405 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
406 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
407 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
408 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
409 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
410 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
411 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
412 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
413 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
414 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
415 | - if (isset($ais_data['timestamp'])) { |
|
401 | + echo "'".$line."'\n"; |
|
402 | + $add = false; |
|
403 | + $ais_data = $AIS->parse_line(trim($line)); |
|
404 | + $data = array(); |
|
405 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
406 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
407 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
408 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
409 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
410 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
411 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
412 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
413 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
414 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
415 | + if (isset($ais_data['timestamp'])) { |
|
416 | 416 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
417 | 417 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
418 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
419 | - $add = true; |
|
418 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
419 | + $add = true; |
|
420 | 420 | } |
421 | - } else { |
|
421 | + } else { |
|
422 | 422 | $data['datetime'] = date('Y-m-d H:i:s'); |
423 | 423 | $add = true; |
424 | - } |
|
425 | - $data['format_source'] = 'aisnmeatxt'; |
|
426 | - $data['id_source'] = $id_source; |
|
427 | - print_r($data); |
|
428 | - echo 'Add...'."\n"; |
|
429 | - if ($add && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
430 | - unset($data); |
|
424 | + } |
|
425 | + $data['format_source'] = 'aisnmeatxt'; |
|
426 | + $data['id_source'] = $id_source; |
|
427 | + print_r($data); |
|
428 | + echo 'Add...'."\n"; |
|
429 | + if ($add && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
430 | + unset($data); |
|
431 | 431 | } |
432 | - } |
|
433 | - $last_exec[$id]['last'] = time(); |
|
432 | + } |
|
433 | + $last_exec[$id]['last'] = time(); |
|
434 | 434 | } elseif ($value['format'] == 'aisnmeahttp') { |
435 | - $arr = $httpfeeds; |
|
436 | - $w = $e = null; |
|
435 | + $arr = $httpfeeds; |
|
436 | + $w = $e = null; |
|
437 | 437 | |
438 | - if (isset($arr[$id])) { |
|
439 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
440 | - if ($nn > 0) { |
|
438 | + if (isset($arr[$id])) { |
|
439 | + $nn = stream_select($arr,$w,$e,$timeout); |
|
440 | + if ($nn > 0) { |
|
441 | 441 | foreach ($httpfeeds as $feed) { |
442 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
443 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
444 | - $buffer = explode('\n',$buffer); |
|
445 | - foreach ($buffer as $line) { |
|
442 | + $buffer = stream_get_line($feed,2000,"\n"); |
|
443 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
444 | + $buffer = explode('\n',$buffer); |
|
445 | + foreach ($buffer as $line) { |
|
446 | 446 | if ($line != '') { |
447 | - $ais_data = $AIS->parse_line(trim($line)); |
|
448 | - $data = array(); |
|
449 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
450 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
451 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
452 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
453 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
454 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
455 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
456 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
457 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
458 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
459 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
460 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
461 | - if (isset($ais_data['timestamp'])) { |
|
447 | + $ais_data = $AIS->parse_line(trim($line)); |
|
448 | + $data = array(); |
|
449 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
450 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
451 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
452 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
453 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
454 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
455 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
456 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
457 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
458 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
459 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
460 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
461 | + if (isset($ais_data['timestamp'])) { |
|
462 | 462 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
463 | - } else { |
|
463 | + } else { |
|
464 | 464 | $data['datetime'] = date('Y-m-d H:i:s'); |
465 | - } |
|
466 | - $data['format_source'] = 'aisnmeahttp'; |
|
467 | - $data['id_source'] = $id_source; |
|
468 | - if ($ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
469 | - unset($data); |
|
465 | + } |
|
466 | + $data['format_source'] = 'aisnmeahttp'; |
|
467 | + $data['id_source'] = $id_source; |
|
468 | + if ($ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
469 | + unset($data); |
|
470 | 470 | } |
471 | - } |
|
471 | + } |
|
472 | + } |
|
472 | 473 | } |
473 | 474 | } |
474 | - } |
|
475 | 475 | } elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
476 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
477 | - if ($buffer != '') { |
|
476 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
477 | + if ($buffer != '') { |
|
478 | 478 | //echo $buffer; |
479 | 479 | $all_data = json_decode($buffer,true); |
480 | 480 | //print_r($all_data); |
481 | 481 | if (isset($all_data[0]['DATA'])) { |
482 | 482 | foreach ($all_data[0]['DATA'] as $line) { |
483 | - if ($line != '') { |
|
483 | + if ($line != '') { |
|
484 | 484 | $data = array(); |
485 | 485 | $data['ident'] = $line['NAME']; |
486 | 486 | $data['mmsi'] = $line['MMSI']; |
@@ -496,87 +496,87 @@ discard block |
||
496 | 496 | $data['id_source'] = $id_source; |
497 | 497 | $MI->add($data); |
498 | 498 | unset($data); |
499 | - } |
|
499 | + } |
|
500 | 500 | } |
501 | 501 | } |
502 | 502 | |
503 | - } |
|
504 | - $last_exec[$id]['last'] = time(); |
|
503 | + } |
|
504 | + $last_exec[$id]['last'] = time(); |
|
505 | 505 | } elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
506 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
507 | - if ($buffer != '') { |
|
506 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
507 | + if ($buffer != '') { |
|
508 | 508 | $all_data = json_decode($buffer,true); |
509 | 509 | if (isset($all_data[0]['mmsi'])) { |
510 | - foreach ($all_data as $line) { |
|
510 | + foreach ($all_data as $line) { |
|
511 | 511 | if ($line != '') { |
512 | - $data = array(); |
|
513 | - $data['ident'] = $line['shipname']; |
|
514 | - $data['callsign'] = $line['callsign']; |
|
515 | - $data['mmsi'] = $line['mmsi']; |
|
516 | - $data['speed'] = $line['sog']; |
|
517 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
518 | - $data['latitude'] = $line['latitude']; |
|
519 | - $data['longitude'] = $line['longitude']; |
|
520 | - $data['type_id'] = $line['shiptype']; |
|
521 | - $data['arrival_code'] = $line['destination']; |
|
522 | - $data['datetime'] = $line['time']; |
|
523 | - $data['format_source'] = 'boatbeaconapp'; |
|
524 | - $data['id_source'] = $id_source; |
|
525 | - $MI->add($data); |
|
526 | - unset($data); |
|
512 | + $data = array(); |
|
513 | + $data['ident'] = $line['shipname']; |
|
514 | + $data['callsign'] = $line['callsign']; |
|
515 | + $data['mmsi'] = $line['mmsi']; |
|
516 | + $data['speed'] = $line['sog']; |
|
517 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
518 | + $data['latitude'] = $line['latitude']; |
|
519 | + $data['longitude'] = $line['longitude']; |
|
520 | + $data['type_id'] = $line['shiptype']; |
|
521 | + $data['arrival_code'] = $line['destination']; |
|
522 | + $data['datetime'] = $line['time']; |
|
523 | + $data['format_source'] = 'boatbeaconapp'; |
|
524 | + $data['id_source'] = $id_source; |
|
525 | + $MI->add($data); |
|
526 | + unset($data); |
|
527 | + } |
|
527 | 528 | } |
528 | - } |
|
529 | 529 | } |
530 | 530 | |
531 | - } |
|
532 | - $last_exec[$id]['last'] = time(); |
|
531 | + } |
|
532 | + $last_exec[$id]['last'] = time(); |
|
533 | 533 | } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
534 | - echo 'download...'; |
|
535 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
536 | - echo 'done !'."\n"; |
|
537 | - if ($buffer != '') $reset = 0; |
|
538 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
539 | - $buffer = explode('\n',$buffer); |
|
540 | - foreach ($buffer as $line) { |
|
534 | + echo 'download...'; |
|
535 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
536 | + echo 'done !'."\n"; |
|
537 | + if ($buffer != '') $reset = 0; |
|
538 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
539 | + $buffer = explode('\n',$buffer); |
|
540 | + foreach ($buffer as $line) { |
|
541 | 541 | if ($line != '') { |
542 | - $data = array(); |
|
543 | - $data['mmsi'] = (int)substr($line,0,9); |
|
544 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
545 | - //$data['status'] = substr($line,21,2); |
|
546 | - //$data['type'] = substr($line,24,3); |
|
547 | - $data['latitude'] = substr($line,29,9); |
|
548 | - $data['longitude'] = substr($line,41,9); |
|
549 | - $data['speed'] = round(substr($line,51,5)); |
|
550 | - //$data['course'] = substr($line,57,5); |
|
551 | - $data['heading'] = round(substr($line,63,3)); |
|
552 | - //$data['draft'] = substr($line,67,4); |
|
553 | - //$data['length'] = substr($line,72,3); |
|
554 | - //$data['beam'] = substr($line,76,2); |
|
555 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
556 | - //$data['callsign'] = trim(substr($line,100,7); |
|
557 | - //$data['dest'] = substr($line,108,20); |
|
558 | - //$data['etaDate'] = substr($line,129,5); |
|
559 | - //$data['etaTime'] = substr($line,135,5); |
|
560 | - $data['format_source'] = 'shipplotter'; |
|
561 | - $data['id_source'] = $id_source; |
|
562 | - print_r($data); |
|
563 | - echo 'Add...'."\n"; |
|
564 | - $MI->add($data); |
|
565 | - unset($data); |
|
542 | + $data = array(); |
|
543 | + $data['mmsi'] = (int)substr($line,0,9); |
|
544 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
545 | + //$data['status'] = substr($line,21,2); |
|
546 | + //$data['type'] = substr($line,24,3); |
|
547 | + $data['latitude'] = substr($line,29,9); |
|
548 | + $data['longitude'] = substr($line,41,9); |
|
549 | + $data['speed'] = round(substr($line,51,5)); |
|
550 | + //$data['course'] = substr($line,57,5); |
|
551 | + $data['heading'] = round(substr($line,63,3)); |
|
552 | + //$data['draft'] = substr($line,67,4); |
|
553 | + //$data['length'] = substr($line,72,3); |
|
554 | + //$data['beam'] = substr($line,76,2); |
|
555 | + $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
556 | + //$data['callsign'] = trim(substr($line,100,7); |
|
557 | + //$data['dest'] = substr($line,108,20); |
|
558 | + //$data['etaDate'] = substr($line,129,5); |
|
559 | + //$data['etaTime'] = substr($line,135,5); |
|
560 | + $data['format_source'] = 'shipplotter'; |
|
561 | + $data['id_source'] = $id_source; |
|
562 | + print_r($data); |
|
563 | + echo 'Add...'."\n"; |
|
564 | + $MI->add($data); |
|
565 | + unset($data); |
|
566 | 566 | } |
567 | - } |
|
568 | - $last_exec[$id]['last'] = time(); |
|
567 | + } |
|
568 | + $last_exec[$id]['last'] = time(); |
|
569 | 569 | //} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
570 | 570 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
571 | - //$buffer = $Common->getData($hosts[$id]); |
|
572 | - $buffer = $Common->getData($value['host']); |
|
573 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
574 | - $buffer = explode('\n',$buffer); |
|
575 | - $reset = 0; |
|
576 | - foreach ($buffer as $line) { |
|
577 | - if ($line != '') { |
|
578 | - $line = explode(':', $line); |
|
579 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
571 | + //$buffer = $Common->getData($hosts[$id]); |
|
572 | + $buffer = $Common->getData($value['host']); |
|
573 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
574 | + $buffer = explode('\n',$buffer); |
|
575 | + $reset = 0; |
|
576 | + foreach ($buffer as $line) { |
|
577 | + if ($line != '') { |
|
578 | + $line = explode(':', $line); |
|
579 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
580 | 580 | $data = array(); |
581 | 581 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
582 | 582 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -589,36 +589,36 @@ discard block |
||
589 | 589 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
590 | 590 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
591 | 591 | $data['latitude'] = $line[5]; // lat |
592 | - $data['longitude'] = $line[6]; // long |
|
593 | - $data['verticalrate'] = ''; // vertical rate |
|
594 | - $data['squawk'] = ''; // squawk |
|
595 | - $data['emergency'] = ''; // emergency |
|
596 | - $data['waypoints'] = $line[30]; |
|
592 | + $data['longitude'] = $line[6]; // long |
|
593 | + $data['verticalrate'] = ''; // vertical rate |
|
594 | + $data['squawk'] = ''; // squawk |
|
595 | + $data['emergency'] = ''; // emergency |
|
596 | + $data['waypoints'] = $line[30]; |
|
597 | 597 | $data['datetime'] = date('Y-m-d H:i:s'); |
598 | 598 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
599 | 599 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
600 | - $data['departure_airport_icao'] = $line[11]; |
|
601 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
602 | - $data['arrival_airport_icao'] = $line[13]; |
|
600 | + $data['departure_airport_icao'] = $line[11]; |
|
601 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
602 | + $data['arrival_airport_icao'] = $line[13]; |
|
603 | 603 | $data['frequency'] = $line[4]; |
604 | 604 | $data['type'] = $line[18]; |
605 | 605 | $data['range'] = $line[19]; |
606 | 606 | if (isset($line[35])) $data['info'] = $line[35]; |
607 | - $data['id_source'] = $id_source; |
|
608 | - //$data['arrival_airport_time'] = ; |
|
609 | - if ($line[9] != '') { |
|
610 | - $aircraft_data = explode('/',$line[9]); |
|
611 | - if (isset($aircraft_data[1])) { |
|
612 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
613 | - } |
|
614 | - } |
|
615 | - /* |
|
607 | + $data['id_source'] = $id_source; |
|
608 | + //$data['arrival_airport_time'] = ; |
|
609 | + if ($line[9] != '') { |
|
610 | + $aircraft_data = explode('/',$line[9]); |
|
611 | + if (isset($aircraft_data[1])) { |
|
612 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
613 | + } |
|
614 | + } |
|
615 | + /* |
|
616 | 616 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; |
617 | 617 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
618 | 618 | */ |
619 | - $data['format_source'] = $value['format']; |
|
619 | + $data['format_source'] = $value['format']; |
|
620 | 620 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
621 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
621 | + if ($line[3] == 'PILOT') $SI->add($data); |
|
622 | 622 | elseif ($line[3] == 'ATC') { |
623 | 623 | //print_r($data); |
624 | 624 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -636,247 +636,247 @@ discard block |
||
636 | 636 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
637 | 637 | if (isset($ATC)) echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
638 | 638 | } |
639 | - unset($data); |
|
640 | - } |
|
641 | - } |
|
642 | - } |
|
643 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
644 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
645 | - $last_exec[$id]['last'] = time(); |
|
646 | - //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
647 | - } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
648 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
649 | - if ($buffer != '') { |
|
650 | - $all_data = json_decode($buffer,true); |
|
651 | - if (isset($all_data['acList'])) { |
|
639 | + unset($data); |
|
640 | + } |
|
641 | + } |
|
642 | + } |
|
643 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
644 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
645 | + $last_exec[$id]['last'] = time(); |
|
646 | + //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
647 | + } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
648 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
649 | + if ($buffer != '') { |
|
650 | + $all_data = json_decode($buffer,true); |
|
651 | + if (isset($all_data['acList'])) { |
|
652 | 652 | $reset = 0; |
653 | 653 | foreach ($all_data['acList'] as $line) { |
654 | - $data = array(); |
|
655 | - $data['hex'] = $line['Icao']; // hex |
|
656 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
657 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
658 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
659 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
660 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
661 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
662 | - //$data['verticalrate'] = $line['']; // verticale rate |
|
663 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
664 | - $data['emergency'] = ''; // emergency |
|
665 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
666 | - /* |
|
654 | + $data = array(); |
|
655 | + $data['hex'] = $line['Icao']; // hex |
|
656 | + if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
657 | + if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
658 | + if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
659 | + if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
660 | + if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
661 | + if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
662 | + //$data['verticalrate'] = $line['']; // verticale rate |
|
663 | + if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
664 | + $data['emergency'] = ''; // emergency |
|
665 | + if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
666 | + /* |
|
667 | 667 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
668 | 668 | else $data['datetime'] = date('Y-m-d H:i:s'); |
669 | 669 | */ |
670 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
671 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
672 | - $data['format_source'] = 'aircraftlistjson'; |
|
673 | - $data['id_source'] = $id_source; |
|
674 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
675 | - if (isset($data['latitude'])) $SI->add($data); |
|
676 | - unset($data); |
|
670 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
671 | + if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
672 | + $data['format_source'] = 'aircraftlistjson'; |
|
673 | + $data['id_source'] = $id_source; |
|
674 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
675 | + if (isset($data['latitude'])) $SI->add($data); |
|
676 | + unset($data); |
|
677 | 677 | } |
678 | - } elseif (is_array($all_data)) { |
|
678 | + } elseif (is_array($all_data)) { |
|
679 | 679 | $reset = 0; |
680 | 680 | foreach ($all_data as $line) { |
681 | - $data = array(); |
|
682 | - $data['hex'] = $line['hex']; // hex |
|
683 | - $data['ident'] = $line['flight']; // ident |
|
684 | - $data['altitude'] = $line['altitude']; // altitude |
|
685 | - $data['speed'] = $line['speed']; // speed |
|
686 | - $data['heading'] = $line['track']; // heading |
|
687 | - $data['latitude'] = $line['lat']; // lat |
|
688 | - $data['longitude'] = $line['lon']; // long |
|
689 | - $data['verticalrate'] = $line['vrt']; // verticale rate |
|
690 | - $data['squawk'] = $line['squawk']; // squawk |
|
691 | - $data['emergency'] = ''; // emergency |
|
692 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
693 | - $data['format_source'] = 'aircraftlistjson'; |
|
694 | - $data['id_source'] = $id_source; |
|
695 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
696 | - $SI->add($data); |
|
697 | - unset($data); |
|
681 | + $data = array(); |
|
682 | + $data['hex'] = $line['hex']; // hex |
|
683 | + $data['ident'] = $line['flight']; // ident |
|
684 | + $data['altitude'] = $line['altitude']; // altitude |
|
685 | + $data['speed'] = $line['speed']; // speed |
|
686 | + $data['heading'] = $line['track']; // heading |
|
687 | + $data['latitude'] = $line['lat']; // lat |
|
688 | + $data['longitude'] = $line['lon']; // long |
|
689 | + $data['verticalrate'] = $line['vrt']; // verticale rate |
|
690 | + $data['squawk'] = $line['squawk']; // squawk |
|
691 | + $data['emergency'] = ''; // emergency |
|
692 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
693 | + $data['format_source'] = 'aircraftlistjson'; |
|
694 | + $data['id_source'] = $id_source; |
|
695 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
696 | + $SI->add($data); |
|
697 | + unset($data); |
|
698 | + } |
|
698 | 699 | } |
699 | - } |
|
700 | - } |
|
701 | - //$last_exec['aircraftlistjson'] = time(); |
|
702 | - $last_exec[$id]['last'] = time(); |
|
703 | - //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
704 | - } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
705 | - $buffer = $Common->getData($value['host']); |
|
706 | - $all_data = json_decode($buffer,true); |
|
707 | - if (isset($all_data['planes'])) { |
|
700 | + } |
|
701 | + //$last_exec['aircraftlistjson'] = time(); |
|
702 | + $last_exec[$id]['last'] = time(); |
|
703 | + //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
704 | + } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
705 | + $buffer = $Common->getData($value['host']); |
|
706 | + $all_data = json_decode($buffer,true); |
|
707 | + if (isset($all_data['planes'])) { |
|
708 | 708 | $reset = 0; |
709 | 709 | foreach ($all_data['planes'] as $key => $line) { |
710 | - $data = array(); |
|
711 | - $data['hex'] = $key; // hex |
|
712 | - $data['ident'] = $line[3]; // ident |
|
713 | - $data['altitude'] = $line[6]; // altitude |
|
714 | - $data['speed'] = $line[8]; // speed |
|
715 | - $data['heading'] = $line[7]; // heading |
|
716 | - $data['latitude'] = $line[4]; // lat |
|
717 | - $data['longitude'] = $line[5]; // long |
|
718 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
719 | - $data['squawk'] = $line[10]; // squawk |
|
720 | - $data['emergency'] = ''; // emergency |
|
721 | - $data['registration'] = $line[2]; |
|
722 | - $data['aircraft_icao'] = $line[0]; |
|
723 | - $deparr = explode('-',$line[1]); |
|
724 | - if (count($deparr) == 2) { |
|
710 | + $data = array(); |
|
711 | + $data['hex'] = $key; // hex |
|
712 | + $data['ident'] = $line[3]; // ident |
|
713 | + $data['altitude'] = $line[6]; // altitude |
|
714 | + $data['speed'] = $line[8]; // speed |
|
715 | + $data['heading'] = $line[7]; // heading |
|
716 | + $data['latitude'] = $line[4]; // lat |
|
717 | + $data['longitude'] = $line[5]; // long |
|
718 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
719 | + $data['squawk'] = $line[10]; // squawk |
|
720 | + $data['emergency'] = ''; // emergency |
|
721 | + $data['registration'] = $line[2]; |
|
722 | + $data['aircraft_icao'] = $line[0]; |
|
723 | + $deparr = explode('-',$line[1]); |
|
724 | + if (count($deparr) == 2) { |
|
725 | 725 | $data['departure_airport_icao'] = $deparr[0]; |
726 | 726 | $data['arrival_airport_icao'] = $deparr[1]; |
727 | - } |
|
728 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
729 | - $data['format_source'] = 'planeupdatefaa'; |
|
730 | - $data['id_source'] = $id_source; |
|
731 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
732 | - $SI->add($data); |
|
733 | - unset($data); |
|
727 | + } |
|
728 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
729 | + $data['format_source'] = 'planeupdatefaa'; |
|
730 | + $data['id_source'] = $id_source; |
|
731 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
732 | + $SI->add($data); |
|
733 | + unset($data); |
|
734 | + } |
|
734 | 735 | } |
735 | - } |
|
736 | - //$last_exec['planeupdatefaa'] = time(); |
|
737 | - $last_exec[$id]['last'] = time(); |
|
738 | - } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
739 | - $buffer = $Common->getData($value['host']); |
|
740 | - $all_data = json_decode($buffer,true); |
|
741 | - if (isset($all_data['states'])) { |
|
736 | + //$last_exec['planeupdatefaa'] = time(); |
|
737 | + $last_exec[$id]['last'] = time(); |
|
738 | + } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
739 | + $buffer = $Common->getData($value['host']); |
|
740 | + $all_data = json_decode($buffer,true); |
|
741 | + if (isset($all_data['states'])) { |
|
742 | 742 | $reset = 0; |
743 | 743 | foreach ($all_data['states'] as $key => $line) { |
744 | - $data = array(); |
|
745 | - $data['hex'] = $line[0]; // hex |
|
746 | - $data['ident'] = trim($line[1]); // ident |
|
747 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
748 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
749 | - $data['heading'] = round($line[10]); // heading |
|
750 | - $data['latitude'] = $line[5]; // lat |
|
751 | - $data['longitude'] = $line[6]; // long |
|
752 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
753 | - //$data['squawk'] = $line[10]; // squawk |
|
754 | - //$data['emergency'] = ''; // emergency |
|
755 | - //$data['registration'] = $line[2]; |
|
756 | - //$data['aircraft_icao'] = $line[0]; |
|
757 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
758 | - $data['format_source'] = 'opensky'; |
|
759 | - $data['id_source'] = $id_source; |
|
760 | - $SI->add($data); |
|
761 | - unset($data); |
|
744 | + $data = array(); |
|
745 | + $data['hex'] = $line[0]; // hex |
|
746 | + $data['ident'] = trim($line[1]); // ident |
|
747 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
748 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
749 | + $data['heading'] = round($line[10]); // heading |
|
750 | + $data['latitude'] = $line[5]; // lat |
|
751 | + $data['longitude'] = $line[6]; // long |
|
752 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
753 | + //$data['squawk'] = $line[10]; // squawk |
|
754 | + //$data['emergency'] = ''; // emergency |
|
755 | + //$data['registration'] = $line[2]; |
|
756 | + //$data['aircraft_icao'] = $line[0]; |
|
757 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
758 | + $data['format_source'] = 'opensky'; |
|
759 | + $data['id_source'] = $id_source; |
|
760 | + $SI->add($data); |
|
761 | + unset($data); |
|
762 | + } |
|
762 | 763 | } |
763 | - } |
|
764 | - //$last_exec['planeupdatefaa'] = time(); |
|
765 | - $last_exec[$id]['last'] = time(); |
|
766 | - //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
767 | - } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
768 | - //$buffer = $Common->getData($hosts[$id]); |
|
769 | - $buffer = $Common->getData($value['host']); |
|
770 | - $all_data = json_decode($buffer,true); |
|
771 | - if (!empty($all_data)) $reset = 0; |
|
772 | - foreach ($all_data as $key => $line) { |
|
764 | + //$last_exec['planeupdatefaa'] = time(); |
|
765 | + $last_exec[$id]['last'] = time(); |
|
766 | + //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
767 | + } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
768 | + //$buffer = $Common->getData($hosts[$id]); |
|
769 | + $buffer = $Common->getData($value['host']); |
|
770 | + $all_data = json_decode($buffer,true); |
|
771 | + if (!empty($all_data)) $reset = 0; |
|
772 | + foreach ($all_data as $key => $line) { |
|
773 | 773 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
774 | - $data = array(); |
|
775 | - $data['hex'] = $line[0]; |
|
776 | - $data['ident'] = $line[16]; //$line[13] |
|
777 | - $data['altitude'] = $line[4]; // altitude |
|
778 | - $data['speed'] = $line[5]; // speed |
|
779 | - $data['heading'] = $line[3]; // heading |
|
780 | - $data['latitude'] = $line[1]; // lat |
|
781 | - $data['longitude'] = $line[2]; // long |
|
782 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
783 | - $data['squawk'] = $line[6]; // squawk |
|
784 | - $data['aircraft_icao'] = $line[8]; |
|
785 | - $data['registration'] = $line[9]; |
|
786 | - $data['departure_airport_iata'] = $line[11]; |
|
787 | - $data['arrival_airport_iata'] = $line[12]; |
|
788 | - $data['emergency'] = ''; // emergency |
|
789 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
790 | - $data['format_source'] = 'fr24json'; |
|
791 | - $data['id_source'] = $id_source; |
|
792 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
793 | - $SI->add($data); |
|
794 | - unset($data); |
|
774 | + $data = array(); |
|
775 | + $data['hex'] = $line[0]; |
|
776 | + $data['ident'] = $line[16]; //$line[13] |
|
777 | + $data['altitude'] = $line[4]; // altitude |
|
778 | + $data['speed'] = $line[5]; // speed |
|
779 | + $data['heading'] = $line[3]; // heading |
|
780 | + $data['latitude'] = $line[1]; // lat |
|
781 | + $data['longitude'] = $line[2]; // long |
|
782 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
783 | + $data['squawk'] = $line[6]; // squawk |
|
784 | + $data['aircraft_icao'] = $line[8]; |
|
785 | + $data['registration'] = $line[9]; |
|
786 | + $data['departure_airport_iata'] = $line[11]; |
|
787 | + $data['arrival_airport_iata'] = $line[12]; |
|
788 | + $data['emergency'] = ''; // emergency |
|
789 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
790 | + $data['format_source'] = 'fr24json'; |
|
791 | + $data['id_source'] = $id_source; |
|
792 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
793 | + $SI->add($data); |
|
794 | + unset($data); |
|
795 | + } |
|
795 | 796 | } |
796 | - } |
|
797 | - //$last_exec['fr24json'] = time(); |
|
798 | - $last_exec[$id]['last'] = time(); |
|
799 | - //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
800 | - } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
801 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
802 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
803 | - //echo $buffer; |
|
804 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
805 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
806 | - $all_data = json_decode($buffer,true); |
|
807 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
797 | + //$last_exec['fr24json'] = time(); |
|
798 | + $last_exec[$id]['last'] = time(); |
|
799 | + //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
800 | + } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
801 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
802 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
803 | + //echo $buffer; |
|
804 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
805 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
806 | + $all_data = json_decode($buffer,true); |
|
807 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
808 | 808 | die(json_last_error_msg()); |
809 | - } |
|
810 | - if (isset($all_data['mrkrs'])) { |
|
809 | + } |
|
810 | + if (isset($all_data['mrkrs'])) { |
|
811 | 811 | $reset = 0; |
812 | 812 | foreach ($all_data['mrkrs'] as $key => $line) { |
813 | - if (isset($line['inf'])) { |
|
813 | + if (isset($line['inf'])) { |
|
814 | 814 | $data = array(); |
815 | 815 | $data['hex'] = $line['inf']['ia']; |
816 | 816 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
817 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
818 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
819 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
820 | - $data['latitude'] = $line['pt'][0]; // lat |
|
821 | - $data['longitude'] = $line['pt'][1]; // long |
|
822 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
823 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
824 | - //$data['aircraft_icao'] = $line[8]; |
|
825 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
817 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
818 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
819 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
820 | + $data['latitude'] = $line['pt'][0]; // lat |
|
821 | + $data['longitude'] = $line['pt'][1]; // long |
|
822 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
823 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
824 | + //$data['aircraft_icao'] = $line[8]; |
|
825 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
826 | 826 | //$data['departure_airport_iata'] = $line[11]; |
827 | 827 | //$data['arrival_airport_iata'] = $line[12]; |
828 | - //$data['emergency'] = ''; // emergency |
|
828 | + //$data['emergency'] = ''; // emergency |
|
829 | 829 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
830 | - $data['format_source'] = 'radarvirtueljson'; |
|
831 | - $data['id_source'] = $id_source; |
|
830 | + $data['format_source'] = 'radarvirtueljson'; |
|
831 | + $data['id_source'] = $id_source; |
|
832 | 832 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
833 | 833 | $SI->add($data); |
834 | 834 | unset($data); |
835 | - } |
|
835 | + } |
|
836 | 836 | } |
837 | - } |
|
838 | - //$last_exec['radarvirtueljson'] = time(); |
|
839 | - $last_exec[$id]['last'] = time(); |
|
840 | - //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
841 | - } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
842 | - //$buffer = $Common->getData($hosts[$id]); |
|
843 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
844 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
837 | + } |
|
838 | + //$last_exec['radarvirtueljson'] = time(); |
|
839 | + $last_exec[$id]['last'] = time(); |
|
840 | + //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
841 | + } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
842 | + //$buffer = $Common->getData($hosts[$id]); |
|
843 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
844 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
845 | 845 | |
846 | - if (isset($all_data['pireps'])) { |
|
846 | + if (isset($all_data['pireps'])) { |
|
847 | 847 | $reset = 0; |
848 | - foreach ($all_data['pireps'] as $line) { |
|
849 | - $data = array(); |
|
850 | - $data['id'] = $line['id']; |
|
851 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
852 | - $data['ident'] = $line['callsign']; // ident |
|
853 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
854 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
855 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
856 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
857 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
858 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
859 | - $data['latitude'] = $line['lat']; // lat |
|
860 | - $data['longitude'] = $line['lon']; // long |
|
861 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
862 | - //$data['squawk'] = $line['squawk']; // squawk |
|
863 | - //$data['emergency'] = ''; // emergency |
|
864 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
865 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
866 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
867 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
868 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
869 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
870 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
871 | - else $data['info'] = ''; |
|
872 | - $data['format_source'] = 'pireps'; |
|
873 | - $data['id_source'] = $id_source; |
|
874 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
875 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
876 | - if ($line['icon'] == 'plane') { |
|
848 | + foreach ($all_data['pireps'] as $line) { |
|
849 | + $data = array(); |
|
850 | + $data['id'] = $line['id']; |
|
851 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
852 | + $data['ident'] = $line['callsign']; // ident |
|
853 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
854 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
855 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
856 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
857 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
858 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
859 | + $data['latitude'] = $line['lat']; // lat |
|
860 | + $data['longitude'] = $line['lon']; // long |
|
861 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
862 | + //$data['squawk'] = $line['squawk']; // squawk |
|
863 | + //$data['emergency'] = ''; // emergency |
|
864 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
865 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
866 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
867 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
868 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
869 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
870 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
871 | + else $data['info'] = ''; |
|
872 | + $data['format_source'] = 'pireps'; |
|
873 | + $data['id_source'] = $id_source; |
|
874 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
875 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
876 | + if ($line['icon'] == 'plane') { |
|
877 | 877 | $SI->add($data); |
878 | - // print_r($data); |
|
879 | - } elseif ($line['icon'] == 'ct') { |
|
878 | + // print_r($data); |
|
879 | + } elseif ($line['icon'] == 'ct') { |
|
880 | 880 | $data['info'] = str_replace('^§','<br />',$data['info']); |
881 | 881 | $data['info'] = str_replace('&sect;','',$data['info']); |
882 | 882 | $typec = substr($data['ident'],-3); |
@@ -891,190 +891,190 @@ discard block |
||
891 | 891 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
892 | 892 | else $data['type'] = 'Observer'; |
893 | 893 | 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']); |
894 | - } |
|
895 | - unset($data); |
|
894 | + } |
|
895 | + unset($data); |
|
896 | 896 | } |
897 | - } |
|
898 | - //$last_exec['pirepsjson'] = time(); |
|
899 | - $last_exec[$id]['last'] = time(); |
|
900 | - //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
901 | - } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
902 | - //$buffer = $Common->getData($hosts[$id]); |
|
903 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
904 | - $buffer = $Common->getData($value['host']); |
|
905 | - $all_data = json_decode($buffer,true); |
|
906 | - if ($buffer != '' && is_array($all_data)) { |
|
897 | + } |
|
898 | + //$last_exec['pirepsjson'] = time(); |
|
899 | + $last_exec[$id]['last'] = time(); |
|
900 | + //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
901 | + } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
902 | + //$buffer = $Common->getData($hosts[$id]); |
|
903 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
904 | + $buffer = $Common->getData($value['host']); |
|
905 | + $all_data = json_decode($buffer,true); |
|
906 | + if ($buffer != '' && is_array($all_data)) { |
|
907 | 907 | $reset = 0; |
908 | 908 | foreach ($all_data as $line) { |
909 | - $data = array(); |
|
910 | - //$data['id'] = $line['id']; // id not usable |
|
911 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
912 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
913 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
914 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
915 | - $data['ident'] = $line['flightnum']; // ident |
|
916 | - $data['altitude'] = $line['alt']; // altitude |
|
917 | - $data['speed'] = $line['gs']; // speed |
|
918 | - $data['heading'] = $line['heading']; // heading |
|
919 | - $data['latitude'] = $line['lat']; // lat |
|
920 | - $data['longitude'] = $line['lng']; // long |
|
921 | - $data['verticalrate'] = ''; // verticale rate |
|
922 | - $data['squawk'] = ''; // squawk |
|
923 | - $data['emergency'] = ''; // emergency |
|
924 | - //$data['datetime'] = $line['lastupdate']; |
|
925 | - $data['last_update'] = $line['lastupdate']; |
|
926 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
927 | - $data['departure_airport_icao'] = $line['depicao']; |
|
928 | - $data['departure_airport_time'] = $line['deptime']; |
|
929 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
930 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
931 | - $data['registration'] = $line['aircraft']; |
|
932 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
933 | - if (isset($line['aircraftname'])) { |
|
909 | + $data = array(); |
|
910 | + //$data['id'] = $line['id']; // id not usable |
|
911 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
912 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
913 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
914 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
915 | + $data['ident'] = $line['flightnum']; // ident |
|
916 | + $data['altitude'] = $line['alt']; // altitude |
|
917 | + $data['speed'] = $line['gs']; // speed |
|
918 | + $data['heading'] = $line['heading']; // heading |
|
919 | + $data['latitude'] = $line['lat']; // lat |
|
920 | + $data['longitude'] = $line['lng']; // long |
|
921 | + $data['verticalrate'] = ''; // verticale rate |
|
922 | + $data['squawk'] = ''; // squawk |
|
923 | + $data['emergency'] = ''; // emergency |
|
924 | + //$data['datetime'] = $line['lastupdate']; |
|
925 | + $data['last_update'] = $line['lastupdate']; |
|
926 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
927 | + $data['departure_airport_icao'] = $line['depicao']; |
|
928 | + $data['departure_airport_time'] = $line['deptime']; |
|
929 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
930 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
931 | + $data['registration'] = $line['aircraft']; |
|
932 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
933 | + if (isset($line['aircraftname'])) { |
|
934 | 934 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
935 | 935 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
936 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
937 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
|
938 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
|
939 | - else { |
|
940 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
941 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
|
942 | - else $data['aircraft_icao'] = $line['aircraftname']; |
|
943 | - } |
|
944 | - } |
|
945 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
946 | - $data['id_source'] = $id_source; |
|
947 | - $data['format_source'] = 'phpvmacars'; |
|
948 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
949 | - $SI->add($data); |
|
950 | - unset($data); |
|
936 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
937 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
|
938 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
|
939 | + else { |
|
940 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
941 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
|
942 | + else $data['aircraft_icao'] = $line['aircraftname']; |
|
943 | + } |
|
944 | + } |
|
945 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
946 | + $data['id_source'] = $id_source; |
|
947 | + $data['format_source'] = 'phpvmacars'; |
|
948 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
949 | + $SI->add($data); |
|
950 | + unset($data); |
|
951 | 951 | } |
952 | 952 | if ($globalDebug) echo 'No more data...'."\n"; |
953 | 953 | unset($buffer); |
954 | 954 | unset($all_data); |
955 | - } |
|
956 | - //$last_exec['phpvmacars'] = time(); |
|
957 | - $last_exec[$id]['last'] = time(); |
|
958 | - } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
959 | - //$buffer = $Common->getData($hosts[$id]); |
|
960 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
961 | - $buffer = $Common->getData($value['host']); |
|
962 | - $all_data = json_decode($buffer,true); |
|
963 | - if ($buffer != '' && is_array($all_data)) { |
|
955 | + } |
|
956 | + //$last_exec['phpvmacars'] = time(); |
|
957 | + $last_exec[$id]['last'] = time(); |
|
958 | + } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
959 | + //$buffer = $Common->getData($hosts[$id]); |
|
960 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
961 | + $buffer = $Common->getData($value['host']); |
|
962 | + $all_data = json_decode($buffer,true); |
|
963 | + if ($buffer != '' && is_array($all_data)) { |
|
964 | 964 | $reset = 0; |
965 | 965 | foreach ($all_data as $line) { |
966 | - $data = array(); |
|
967 | - //$data['id'] = $line['id']; // id not usable |
|
968 | - $data['id'] = trim($line['flight_id']); |
|
969 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
970 | - $data['pilot_name'] = $line['pilot_name']; |
|
971 | - $data['pilot_id'] = $line['pilot_id']; |
|
972 | - $data['ident'] = trim($line['callsign']); // ident |
|
973 | - $data['altitude'] = $line['altitude']; // altitude |
|
974 | - $data['speed'] = $line['gs']; // speed |
|
975 | - $data['heading'] = $line['heading']; // heading |
|
976 | - $data['latitude'] = $line['latitude']; // lat |
|
977 | - $data['longitude'] = $line['longitude']; // long |
|
978 | - $data['verticalrate'] = ''; // verticale rate |
|
979 | - $data['squawk'] = ''; // squawk |
|
980 | - $data['emergency'] = ''; // emergency |
|
981 | - //$data['datetime'] = $line['lastupdate']; |
|
982 | - $data['last_update'] = $line['last_update']; |
|
983 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
984 | - $data['departure_airport_icao'] = $line['departure']; |
|
985 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
986 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
987 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
988 | - //$data['registration'] = $line['aircraft']; |
|
989 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
990 | - $data['aircraft_icao'] = $line['plane_type']; |
|
991 | - $data['id_source'] = $id_source; |
|
992 | - $data['format_source'] = 'vam'; |
|
993 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
994 | - $SI->add($data); |
|
995 | - unset($data); |
|
966 | + $data = array(); |
|
967 | + //$data['id'] = $line['id']; // id not usable |
|
968 | + $data['id'] = trim($line['flight_id']); |
|
969 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
970 | + $data['pilot_name'] = $line['pilot_name']; |
|
971 | + $data['pilot_id'] = $line['pilot_id']; |
|
972 | + $data['ident'] = trim($line['callsign']); // ident |
|
973 | + $data['altitude'] = $line['altitude']; // altitude |
|
974 | + $data['speed'] = $line['gs']; // speed |
|
975 | + $data['heading'] = $line['heading']; // heading |
|
976 | + $data['latitude'] = $line['latitude']; // lat |
|
977 | + $data['longitude'] = $line['longitude']; // long |
|
978 | + $data['verticalrate'] = ''; // verticale rate |
|
979 | + $data['squawk'] = ''; // squawk |
|
980 | + $data['emergency'] = ''; // emergency |
|
981 | + //$data['datetime'] = $line['lastupdate']; |
|
982 | + $data['last_update'] = $line['last_update']; |
|
983 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
984 | + $data['departure_airport_icao'] = $line['departure']; |
|
985 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
986 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
987 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
988 | + //$data['registration'] = $line['aircraft']; |
|
989 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
990 | + $data['aircraft_icao'] = $line['plane_type']; |
|
991 | + $data['id_source'] = $id_source; |
|
992 | + $data['format_source'] = 'vam'; |
|
993 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
994 | + $SI->add($data); |
|
995 | + unset($data); |
|
996 | 996 | } |
997 | 997 | if ($globalDebug) echo 'No more data...'."\n"; |
998 | 998 | unset($buffer); |
999 | 999 | unset($all_data); |
1000 | - } |
|
1001 | - //$last_exec['phpvmacars'] = time(); |
|
1002 | - $last_exec[$id]['last'] = time(); |
|
1000 | + } |
|
1001 | + //$last_exec['phpvmacars'] = time(); |
|
1002 | + $last_exec[$id]['last'] = time(); |
|
1003 | 1003 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
1004 | 1004 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { |
1005 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1006 | - //$last_exec[$id]['last'] = time(); |
|
1005 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1006 | + //$last_exec[$id]['last'] = time(); |
|
1007 | 1007 | |
1008 | - //$read = array( $sockets[$id] ); |
|
1009 | - $read = $sockets; |
|
1010 | - $write = NULL; |
|
1011 | - $e = NULL; |
|
1012 | - $n = socket_select($read, $write, $e, $timeout); |
|
1013 | - if ($e != NULL) var_dump($e); |
|
1014 | - if ($n > 0) { |
|
1008 | + //$read = array( $sockets[$id] ); |
|
1009 | + $read = $sockets; |
|
1010 | + $write = NULL; |
|
1011 | + $e = NULL; |
|
1012 | + $n = socket_select($read, $write, $e, $timeout); |
|
1013 | + if ($e != NULL) var_dump($e); |
|
1014 | + if ($n > 0) { |
|
1015 | 1015 | $reset = 0; |
1016 | 1016 | foreach ($read as $nb => $r) { |
1017 | - //$value = $formats[$nb]; |
|
1018 | - $format = $globalSources[$nb]['format']; |
|
1019 | - if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3' || $format == 'vrstcp') { |
|
1020 | - $buffer = socket_read($r, 6000,PHP_NORMAL_READ); |
|
1021 | - } else { |
|
1022 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
1023 | - } |
|
1024 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1025 | - //echo $buffer."\n"; |
|
1026 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
1027 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1028 | - $error = false; |
|
1029 | - //$SI::del(); |
|
1030 | - if ($format == 'vrstcp') { |
|
1017 | + //$value = $formats[$nb]; |
|
1018 | + $format = $globalSources[$nb]['format']; |
|
1019 | + if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3' || $format == 'vrstcp') { |
|
1020 | + $buffer = socket_read($r, 6000,PHP_NORMAL_READ); |
|
1021 | + } else { |
|
1022 | + $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
1023 | + } |
|
1024 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1025 | + //echo $buffer."\n"; |
|
1026 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
1027 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1028 | + $error = false; |
|
1029 | + //$SI::del(); |
|
1030 | + if ($format == 'vrstcp') { |
|
1031 | 1031 | $buffer = explode('},{',$buffer); |
1032 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1033 | - // SBS format is CSV format |
|
1034 | - if ($buffer != '') { |
|
1032 | + } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1033 | + // SBS format is CSV format |
|
1034 | + if ($buffer != '') { |
|
1035 | 1035 | $tt[$format] = 0; |
1036 | 1036 | if ($format == 'acarssbs3') { |
1037 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1038 | - $ACARS->add(trim($buffer)); |
|
1039 | - $ACARS->deleteLiveAcarsData(); |
|
1037 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1038 | + $ACARS->add(trim($buffer)); |
|
1039 | + $ACARS->deleteLiveAcarsData(); |
|
1040 | 1040 | } elseif ($format == 'raw') { |
1041 | - // AVR format |
|
1042 | - $data = $SBS->parse($buffer); |
|
1043 | - if (is_array($data)) { |
|
1041 | + // AVR format |
|
1042 | + $data = $SBS->parse($buffer); |
|
1043 | + if (is_array($data)) { |
|
1044 | 1044 | $data['datetime'] = date('Y-m-d H:i:s'); |
1045 | 1045 | $data['format_source'] = 'raw'; |
1046 | 1046 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1047 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1048 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1049 | - } |
|
1050 | - } elseif ($format == 'ais') { |
|
1051 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
1052 | - $data = array(); |
|
1053 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1054 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1055 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1056 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1057 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1058 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1059 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1060 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1061 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1062 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1063 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1064 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1047 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1048 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1049 | + } |
|
1050 | + } elseif ($format == 'ais') { |
|
1051 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
1052 | + $data = array(); |
|
1053 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1054 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1055 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1056 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1057 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1058 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1059 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1060 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1061 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1062 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1063 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1064 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1065 | 1065 | |
1066 | - if (isset($ais_data['timestamp'])) { |
|
1066 | + if (isset($ais_data['timestamp'])) { |
|
1067 | 1067 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
1068 | - } else { |
|
1068 | + } else { |
|
1069 | 1069 | $data['datetime'] = date('Y-m-d H:i:s'); |
1070 | - } |
|
1071 | - $data['format_source'] = 'aisnmea'; |
|
1072 | - $data['id_source'] = $id_source; |
|
1073 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1074 | - unset($data); |
|
1075 | - } elseif ($format == 'flightgearsp') { |
|
1076 | - //echo $buffer."\n"; |
|
1077 | - if (strlen($buffer) > 5) { |
|
1070 | + } |
|
1071 | + $data['format_source'] = 'aisnmea'; |
|
1072 | + $data['id_source'] = $id_source; |
|
1073 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1074 | + unset($data); |
|
1075 | + } elseif ($format == 'flightgearsp') { |
|
1076 | + //echo $buffer."\n"; |
|
1077 | + if (strlen($buffer) > 5) { |
|
1078 | 1078 | $line = explode(',',$buffer); |
1079 | 1079 | $data = array(); |
1080 | 1080 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1090,37 +1090,37 @@ discard block |
||
1090 | 1090 | $data['format_source'] = 'flightgearsp'; |
1091 | 1091 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1092 | 1092 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1093 | - } |
|
1094 | - } elseif ($format == 'acars') { |
|
1095 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1096 | - $ACARS->add(trim($buffer)); |
|
1097 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1098 | - $ACARS->deleteLiveAcarsData(); |
|
1093 | + } |
|
1094 | + } elseif ($format == 'acars') { |
|
1095 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1096 | + $ACARS->add(trim($buffer)); |
|
1097 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1098 | + $ACARS->deleteLiveAcarsData(); |
|
1099 | 1099 | } elseif ($format == 'flightgearmp') { |
1100 | - if (substr($buffer,0,1) != '#') { |
|
1100 | + if (substr($buffer,0,1) != '#') { |
|
1101 | 1101 | $data = array(); |
1102 | 1102 | //echo $buffer."\n"; |
1103 | 1103 | $line = explode(' ',$buffer); |
1104 | 1104 | if (count($line) == 11) { |
1105 | - $userserver = explode('@',$line[0]); |
|
1106 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1107 | - $data['ident'] = $userserver[0]; |
|
1108 | - $data['registration'] = $userserver[0]; |
|
1109 | - $data['latitude'] = $line[4]; |
|
1110 | - $data['longitude'] = $line[5]; |
|
1111 | - $data['altitude'] = $line[6]; |
|
1112 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1113 | - $aircraft_type = $line[10]; |
|
1114 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1115 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1116 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1105 | + $userserver = explode('@',$line[0]); |
|
1106 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1107 | + $data['ident'] = $userserver[0]; |
|
1108 | + $data['registration'] = $userserver[0]; |
|
1109 | + $data['latitude'] = $line[4]; |
|
1110 | + $data['longitude'] = $line[5]; |
|
1111 | + $data['altitude'] = $line[6]; |
|
1112 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1113 | + $aircraft_type = $line[10]; |
|
1114 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1115 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1116 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1117 | + } |
|
1117 | 1118 | } |
1118 | - } |
|
1119 | 1119 | } elseif ($format == 'beast') { |
1120 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1121 | - die; |
|
1120 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1121 | + die; |
|
1122 | 1122 | } elseif ($format == 'vrstcp') { |
1123 | - foreach($buffer as $all_data) { |
|
1123 | + foreach($buffer as $all_data) { |
|
1124 | 1124 | $line = json_decode('{'.$all_data.'}',true); |
1125 | 1125 | $data = array(); |
1126 | 1126 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1140,100 +1140,100 @@ discard block |
||
1140 | 1140 | */ |
1141 | 1141 | $data['datetime'] = date('Y-m-d H:i:s'); |
1142 | 1142 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
1143 | - $data['format_source'] = 'vrstcp'; |
|
1143 | + $data['format_source'] = 'vrstcp'; |
|
1144 | 1144 | $data['id_source'] = $id_source; |
1145 | 1145 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1146 | 1146 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1147 | 1147 | unset($data); |
1148 | - } |
|
1148 | + } |
|
1149 | 1149 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
1150 | - $line = explode("\t", $buffer); |
|
1151 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1150 | + $line = explode("\t", $buffer); |
|
1151 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
1152 | 1152 | $key = $line[$k]; |
1153 | - $lined[$key] = $line[$k+1]; |
|
1154 | - } |
|
1155 | - if (count($lined) > 3) { |
|
1156 | - $data['hex'] = $lined['hexid']; |
|
1157 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1158 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1159 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1160 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1161 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1162 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1163 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1164 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1165 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1166 | - $data['id_source'] = $id_source; |
|
1167 | - $data['format_source'] = 'tsv'; |
|
1168 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1169 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1170 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1171 | - unset($lined); |
|
1172 | - unset($data); |
|
1173 | - } else $error = true; |
|
1153 | + $lined[$key] = $line[$k+1]; |
|
1154 | + } |
|
1155 | + if (count($lined) > 3) { |
|
1156 | + $data['hex'] = $lined['hexid']; |
|
1157 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1158 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
1159 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1160 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1161 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1162 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1163 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1164 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1165 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1166 | + $data['id_source'] = $id_source; |
|
1167 | + $data['format_source'] = 'tsv'; |
|
1168 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1169 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1170 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1171 | + unset($lined); |
|
1172 | + unset($data); |
|
1173 | + } else $error = true; |
|
1174 | 1174 | } elseif ($format == 'aprs' && $use_aprs) { |
1175 | - if ($aprs_connect == 0) { |
|
1175 | + if ($aprs_connect == 0) { |
|
1176 | 1176 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
1177 | 1177 | $aprs_connect = 1; |
1178 | - } |
|
1178 | + } |
|
1179 | 1179 | |
1180 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1180 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1181 | 1181 | $aprs_last_tx = time(); |
1182 | 1182 | $data_aprs = "# Keep alive"; |
1183 | 1183 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1184 | - } |
|
1184 | + } |
|
1185 | 1185 | |
1186 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1187 | - //echo 'APRS data : '.$buffer."\n"; |
|
1188 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1189 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1190 | - //echo $buffer."\n"; |
|
1191 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1186 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1187 | + //echo 'APRS data : '.$buffer."\n"; |
|
1188 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
1189 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
1190 | + //echo $buffer."\n"; |
|
1191 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1192 | 1192 | $line = $APRS->parse($buffer); |
1193 | 1193 | //print_r($line); |
1194 | 1194 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1195 | 1195 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']))) { |
1196 | - $aprs_last_tx = time(); |
|
1197 | - $data = array(); |
|
1198 | - //print_r($line); |
|
1199 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1200 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1201 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1202 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1203 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1204 | - $data['latitude'] = $line['latitude']; |
|
1205 | - $data['longitude'] = $line['longitude']; |
|
1206 | - //$data['verticalrate'] = $line[16]; |
|
1207 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1208 | - else $data['speed'] = 0; |
|
1209 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1210 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1211 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1212 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1213 | - //else $data['heading'] = 0; |
|
1214 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1215 | - if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
1216 | - $data['id_source'] = $id_source; |
|
1217 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1218 | - else $data['format_source'] = 'aprs'; |
|
1219 | - $data['source_name'] = $line['source']; |
|
1220 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1221 | - else $data['source_type'] = 'flarm'; |
|
1222 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1223 | - $currentdate = date('Y-m-d H:i:s'); |
|
1224 | - $aprsdate = strtotime($data['datetime']); |
|
1225 | - // Accept data if time <= system time + 20s |
|
1226 | - 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'])))) { |
|
1196 | + $aprs_last_tx = time(); |
|
1197 | + $data = array(); |
|
1198 | + //print_r($line); |
|
1199 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1200 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1201 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1202 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1203 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1204 | + $data['latitude'] = $line['latitude']; |
|
1205 | + $data['longitude'] = $line['longitude']; |
|
1206 | + //$data['verticalrate'] = $line[16]; |
|
1207 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1208 | + else $data['speed'] = 0; |
|
1209 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1210 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1211 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1212 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1213 | + //else $data['heading'] = 0; |
|
1214 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1215 | + if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
1216 | + $data['id_source'] = $id_source; |
|
1217 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1218 | + else $data['format_source'] = 'aprs'; |
|
1219 | + $data['source_name'] = $line['source']; |
|
1220 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1221 | + else $data['source_type'] = 'flarm'; |
|
1222 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1223 | + $currentdate = date('Y-m-d H:i:s'); |
|
1224 | + $aprsdate = strtotime($data['datetime']); |
|
1225 | + // Accept data if time <= system time + 20s |
|
1226 | + 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'])))) { |
|
1227 | 1227 | $send = $SI->add($data); |
1228 | - } elseif (isset($line['stealth'])) { |
|
1228 | + } elseif (isset($line['stealth'])) { |
|
1229 | 1229 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
1230 | 1230 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
1231 | - //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1232 | - } 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') { |
|
1231 | + //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1232 | + } 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') { |
|
1233 | 1233 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1234 | 1234 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
1235 | - } |
|
1236 | - unset($data); |
|
1235 | + } |
|
1236 | + unset($data); |
|
1237 | 1237 | } |
1238 | 1238 | elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
1239 | 1239 | echo '!! Weather Station not yet supported'."\n"; |
@@ -1243,12 +1243,12 @@ discard block |
||
1243 | 1243 | } |
1244 | 1244 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
1245 | 1245 | //elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
1246 | - } |
|
1246 | + } |
|
1247 | 1247 | } else { |
1248 | - $line = explode(',', $buffer); |
|
1249 | - if (count($line) > 20) { |
|
1250 | - $data['hex'] = $line[4]; |
|
1251 | - /* |
|
1248 | + $line = explode(',', $buffer); |
|
1249 | + if (count($line) > 20) { |
|
1250 | + $data['hex'] = $line[4]; |
|
1251 | + /* |
|
1252 | 1252 | $data['datetime'] = $line[6].' '.$line[7]; |
1253 | 1253 | date_default_timezone_set($globalTimezone); |
1254 | 1254 | $datetime = new DateTime($data['datetime']); |
@@ -1256,29 +1256,29 @@ discard block |
||
1256 | 1256 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1257 | 1257 | date_default_timezone_set('UTC'); |
1258 | 1258 | */ |
1259 | - // Force datetime to current UTC datetime |
|
1260 | - date_default_timezone_set('UTC'); |
|
1261 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1262 | - $data['ident'] = trim($line[10]); |
|
1263 | - $data['latitude'] = $line[14]; |
|
1264 | - $data['longitude'] = $line[15]; |
|
1265 | - $data['verticalrate'] = $line[16]; |
|
1266 | - $data['emergency'] = $line[20]; |
|
1267 | - $data['speed'] = $line[12]; |
|
1268 | - $data['squawk'] = $line[17]; |
|
1269 | - $data['altitude'] = $line[11]; |
|
1270 | - $data['heading'] = $line[13]; |
|
1271 | - $data['ground'] = $line[21]; |
|
1272 | - $data['emergency'] = $line[19]; |
|
1273 | - $data['format_source'] = 'sbs'; |
|
1259 | + // Force datetime to current UTC datetime |
|
1260 | + date_default_timezone_set('UTC'); |
|
1261 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1262 | + $data['ident'] = trim($line[10]); |
|
1263 | + $data['latitude'] = $line[14]; |
|
1264 | + $data['longitude'] = $line[15]; |
|
1265 | + $data['verticalrate'] = $line[16]; |
|
1266 | + $data['emergency'] = $line[20]; |
|
1267 | + $data['speed'] = $line[12]; |
|
1268 | + $data['squawk'] = $line[17]; |
|
1269 | + $data['altitude'] = $line[11]; |
|
1270 | + $data['heading'] = $line[13]; |
|
1271 | + $data['ground'] = $line[21]; |
|
1272 | + $data['emergency'] = $line[19]; |
|
1273 | + $data['format_source'] = 'sbs'; |
|
1274 | 1274 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1275 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1276 | - $data['id_source'] = $id_source; |
|
1277 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1278 | - else $error = true; |
|
1279 | - unset($data); |
|
1280 | - } else $error = true; |
|
1281 | - if ($error) { |
|
1275 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1276 | + $data['id_source'] = $id_source; |
|
1277 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1278 | + else $error = true; |
|
1279 | + unset($data); |
|
1280 | + } else $error = true; |
|
1281 | + if ($error) { |
|
1282 | 1282 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
1283 | 1283 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
1284 | 1284 | } else { |
@@ -1294,13 +1294,13 @@ discard block |
||
1294 | 1294 | connect_all($sourceer); |
1295 | 1295 | $sourceer = array(); |
1296 | 1296 | } |
1297 | - } |
|
1297 | + } |
|
1298 | 1298 | } |
1299 | 1299 | // Sleep for xxx microseconds |
1300 | 1300 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
1301 | - } else { |
|
1301 | + } else { |
|
1302 | 1302 | if ($format == 'flightgearmp') { |
1303 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1303 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1304 | 1304 | //@socket_close($r); |
1305 | 1305 | sleep($globalMinFetch); |
1306 | 1306 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1309,9 +1309,9 @@ discard block |
||
1309 | 1309 | break; |
1310 | 1310 | |
1311 | 1311 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1312 | - if (isset($tt[$format])) $tt[$format]++; |
|
1313 | - else $tt[$format] = 0; |
|
1314 | - if ($tt[$format] > 30) { |
|
1312 | + if (isset($tt[$format])) $tt[$format]++; |
|
1313 | + else $tt[$format] = 0; |
|
1314 | + if ($tt[$format] > 30) { |
|
1315 | 1315 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
1316 | 1316 | //@socket_close($r); |
1317 | 1317 | sleep(2); |
@@ -1322,23 +1322,23 @@ discard block |
||
1322 | 1322 | //connect_all($globalSources); |
1323 | 1323 | $tt[$format]=0; |
1324 | 1324 | break; |
1325 | - } |
|
1325 | + } |
|
1326 | + } |
|
1326 | 1327 | } |
1327 | - } |
|
1328 | 1328 | } |
1329 | - } else { |
|
1329 | + } else { |
|
1330 | 1330 | $error = socket_strerror(socket_last_error()); |
1331 | 1331 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1332 | 1332 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
1333 | 1333 | if (isset($globalDebug)) echo "Restarting...\n"; |
1334 | 1334 | // Restart the script if possible |
1335 | 1335 | if (is_array($sockets)) { |
1336 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
1336 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
1337 | 1337 | |
1338 | - foreach ($sockets as $sock) { |
|
1338 | + foreach ($sockets as $sock) { |
|
1339 | 1339 | @socket_shutdown($sock,2); |
1340 | 1340 | @socket_close($sock); |
1341 | - } |
|
1341 | + } |
|
1342 | 1342 | |
1343 | 1343 | } |
1344 | 1344 | if ($globalDebug) echo "Restart all connections..."; |
@@ -1349,13 +1349,13 @@ discard block |
||
1349 | 1349 | if ($reset > 40) exit('Too many attempts...'); |
1350 | 1350 | connect_all($globalSources); |
1351 | 1351 | } |
1352 | - } |
|
1352 | + } |
|
1353 | 1353 | } |
1354 | 1354 | if ($globalDaemon === false) { |
1355 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1356 | - $SI->checkAll(); |
|
1355 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
1356 | + $SI->checkAll(); |
|
1357 | + } |
|
1357 | 1358 | } |
1358 | - } |
|
1359 | 1359 | } |
1360 | 1360 | |
1361 | 1361 | ?> |
@@ -8,7 +8,7 @@ |
||
8 | 8 | if (!isset($filter_name)) $filter_name = ''; |
9 | 9 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
10 | 10 | if ($airline_icao == '' && isset($globalFilter)) { |
11 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
11 | + if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
12 | 12 | } |
13 | 13 | setcookie('stats_airline_icao',$airline_icao,time()+60*60*24,'/'); |
14 | 14 | $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | if (!isset($filter_name)) $filter_name = ''; |
9 | 9 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
10 | 10 | if ($airline_icao == '' && isset($globalFilter)) { |
11 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
11 | + if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
12 | 12 | } |
13 | 13 | $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
14 | 14 | $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | $airport_airport_array = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month); |
29 | 29 | |
30 | 30 | print 'var series = ['; |
31 | - $airport_data = ''; |
|
31 | + $airport_data = ''; |
|
32 | 32 | foreach($airport_airport_array as $airport_item) |
33 | 33 | { |
34 | 34 | $airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_icao'].'",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],'; |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | if (!isset($filter_name)) $filter_name = ''; |
9 | 9 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
10 | 10 | if ($airline_icao == '' && isset($globalFilter)) { |
11 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
11 | + if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | require_once('header.php'); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | */ |
31 | 31 | print '<div id="chart" class="chart" width="100%"></div><script>'; |
32 | 32 | print 'var series = ['; |
33 | - $flightover_data = ''; |
|
33 | + $flightover_data = ''; |
|
34 | 34 | foreach($flightover_array as $flightover_item) |
35 | 35 | { |
36 | 36 | $flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],'; |
@@ -8,7 +8,7 @@ |
||
8 | 8 | if (!isset($filter_name)) $filter_name = ''; |
9 | 9 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
10 | 10 | if ($airline_icao == '' && isset($globalFilter)) { |
11 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
11 | + if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
12 | 12 | } |
13 | 13 | $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
14 | 14 | $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone); |
52 | 52 | print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>'; |
53 | 53 | } |
54 | - ?> |
|
54 | + ?> |
|
55 | 55 | </div> |
56 | 56 | <?php include('statistics-sub-menu.php'); ?> |
57 | 57 | <p class="global-stats"> |
@@ -60,23 +60,23 @@ discard block |
||
60 | 60 | <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Arrivals seen"); ?></span> |
61 | 61 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
62 | 62 | <?php |
63 | - if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) { |
|
63 | + if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) { |
|
64 | 64 | ?> |
65 | 65 | <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Pilots"); ?></span> |
66 | 66 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
67 | 67 | <?php |
68 | - } else { |
|
69 | - ?> |
|
68 | + } else { |
|
69 | + ?> |
|
70 | 70 | <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Owners"); ?></span> |
71 | 71 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
72 | 72 | <?php |
73 | - } |
|
74 | - ?> |
|
73 | + } |
|
74 | + ?> |
|
75 | 75 | <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Aircrafts types"); ?></span> |
76 | 76 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
77 | 77 | <?php |
78 | - if ($airline_icao == '') { |
|
79 | - ?> |
|
78 | + if ($airline_icao == '') { |
|
79 | + ?> |
|
80 | 80 | <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name,$year,$month)); ?></span> <?php echo _("Airlines"); ?></span> |
81 | 81 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
82 | 82 | <?php |
@@ -99,88 +99,88 @@ discard block |
||
99 | 99 | <div class="col-md-6"> |
100 | 100 | <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2> |
101 | 101 | <?php |
102 | - $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month); |
|
103 | - if (count($aircraft_array) == 0) print _("No data available"); |
|
104 | - else { |
|
105 | - print '<div id="chart1" class="chart" width="100%"></div><script>'; |
|
106 | - $aircraft_data = ''; |
|
107 | - foreach($aircraft_array as $aircraft_item) |
|
108 | - { |
|
109 | - $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
|
110 | - } |
|
111 | - $aircraft_data = substr($aircraft_data, 0, -1); |
|
112 | - print 'var series = ['.$aircraft_data.'];'; |
|
113 | - print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);'; |
|
114 | - print 'var paletteScale = d3.scale.linear().domain([minValue,maxValue]).range(["#e6e6f6","#1a3151"]);'; |
|
115 | - print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});'; |
|
116 | - print 'var aircraftype = new d3pie("chart1",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":'; |
|
117 | - print 'dataset'; |
|
118 | - print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});'; |
|
119 | - print '</script>'; |
|
120 | - } |
|
121 | - ?> |
|
102 | + $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month); |
|
103 | + if (count($aircraft_array) == 0) print _("No data available"); |
|
104 | + else { |
|
105 | + print '<div id="chart1" class="chart" width="100%"></div><script>'; |
|
106 | + $aircraft_data = ''; |
|
107 | + foreach($aircraft_array as $aircraft_item) |
|
108 | + { |
|
109 | + $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
|
110 | + } |
|
111 | + $aircraft_data = substr($aircraft_data, 0, -1); |
|
112 | + print 'var series = ['.$aircraft_data.'];'; |
|
113 | + print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);'; |
|
114 | + print 'var paletteScale = d3.scale.linear().domain([minValue,maxValue]).range(["#e6e6f6","#1a3151"]);'; |
|
115 | + print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});'; |
|
116 | + print 'var aircraftype = new d3pie("chart1",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":'; |
|
117 | + print 'dataset'; |
|
118 | + print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});'; |
|
119 | + print '</script>'; |
|
120 | + } |
|
121 | + ?> |
|
122 | 122 | <div class="more"> |
123 | 123 | <?php |
124 | - if ($year != '' && $month != '') { |
|
125 | - ?> |
|
124 | + if ($year != '' && $month != '') { |
|
125 | + ?> |
|
126 | 126 | <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
127 | 127 | <?php |
128 | - } else { |
|
129 | - ?> |
|
128 | + } else { |
|
129 | + ?> |
|
130 | 130 | <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
131 | 131 | <?php |
132 | - } |
|
133 | - ?> |
|
132 | + } |
|
133 | + ?> |
|
134 | 134 | </div> |
135 | 135 | </div> |
136 | 136 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
137 | 137 | <?php |
138 | 138 | // echo $airline_icao; |
139 | - if ($airline_icao == '' || $airline_icao == 'all') { |
|
139 | + if ($airline_icao == '' || $airline_icao == 'all') { |
|
140 | 140 | $airline_array = $Stats->countAllAirlines(true,$filter_name,$year,$month); |
141 | 141 | if (count($airline_array) > 0) { |
142 | - print '<div class="col-md-6">'; |
|
143 | - print '<h2>'._("Top 10 Most Common Airline").'</h2>'; |
|
144 | - print '<div id="chart2" class="chart" width="100%"></div><script>'; |
|
145 | - $airline_data = ''; |
|
146 | - foreach($airline_array as $airline_item) |
|
147 | - { |
|
142 | + print '<div class="col-md-6">'; |
|
143 | + print '<h2>'._("Top 10 Most Common Airline").'</h2>'; |
|
144 | + print '<div id="chart2" class="chart" width="100%"></div><script>'; |
|
145 | + $airline_data = ''; |
|
146 | + foreach($airline_array as $airline_item) |
|
147 | + { |
|
148 | 148 | $airline_data .= '["'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],'; |
149 | - } |
|
150 | - $airline_data = substr($airline_data, 0, -1); |
|
151 | - print 'var series = ['.$airline_data.'];'; |
|
152 | - print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);'; |
|
153 | - print 'var paletteScale = d3.scale.linear().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);'; |
|
154 | - print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});'; |
|
155 | - print 'var airlinescnt = new d3pie("chart2",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":'; |
|
156 | - print 'dataset'; |
|
157 | - print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});'; |
|
158 | - print '</script>'; |
|
159 | - if ($year != '' && $month != '') { |
|
149 | + } |
|
150 | + $airline_data = substr($airline_data, 0, -1); |
|
151 | + print 'var series = ['.$airline_data.'];'; |
|
152 | + print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);'; |
|
153 | + print 'var paletteScale = d3.scale.linear().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);'; |
|
154 | + print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});'; |
|
155 | + print 'var airlinescnt = new d3pie("chart2",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":'; |
|
156 | + print 'dataset'; |
|
157 | + print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});'; |
|
158 | + print '</script>'; |
|
159 | + if ($year != '' && $month != '') { |
|
160 | 160 | print '<div class="more"><a href="'.$globalURL.'/statistics/airline'; |
161 | 161 | if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
162 | 162 | print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
163 | - } else { |
|
163 | + } else { |
|
164 | 164 | print '<div class="more"><a href="'.$globalURL.'/statistics/airline'; |
165 | 165 | if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
166 | 166 | print '" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
167 | - } |
|
168 | - print '</div>'; |
|
167 | + } |
|
168 | + print '</div>'; |
|
169 | 169 | } |
170 | 170 | ?> |
171 | 171 | </div> |
172 | 172 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
173 | 173 | <?php |
174 | - } |
|
174 | + } |
|
175 | 175 | ?> |
176 | 176 | <div class="row column"> |
177 | 177 | <?php |
178 | - $flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month); |
|
179 | - if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) { |
|
178 | + $flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month); |
|
179 | + if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) { |
|
180 | 180 | if (empty($flightover_array)) { |
181 | - print '<div class="col-md-12">'; |
|
181 | + print '<div class="col-md-12">'; |
|
182 | 182 | } else { |
183 | - print '<div class="col-md-6">'; |
|
183 | + print '<div class="col-md-6">'; |
|
184 | 184 | } |
185 | 185 | ?> |
186 | 186 | <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2> |
@@ -188,23 +188,23 @@ discard block |
||
188 | 188 | $pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month); |
189 | 189 | if (count($pilot_array) == 0) print _("No data available"); |
190 | 190 | else { |
191 | - print '<div id="chart7" class="chart" width="100%"></div><script>'; |
|
192 | - $pilot_data = ''; |
|
193 | - foreach($pilot_array as $pilot_item) |
|
194 | - { |
|
191 | + print '<div id="chart7" class="chart" width="100%"></div><script>'; |
|
192 | + $pilot_data = ''; |
|
193 | + foreach($pilot_array as $pilot_item) |
|
194 | + { |
|
195 | 195 | $pilot_data .= '["'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],'; |
196 | - } |
|
197 | - $pilot_data = substr($pilot_data, 0, -1); |
|
198 | - print 'var series = ['.$pilot_data.'];'; |
|
199 | - print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);'; |
|
200 | - print 'var paletteScale = d3.scale.linear().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);'; |
|
201 | - print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});'; |
|
202 | - print 'var pilotcnt = new d3pie("chart7",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":'; |
|
203 | - print 'dataset'; |
|
204 | - print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});'; |
|
205 | - print '</script>'; |
|
206 | - } |
|
207 | - print '<div class="more">'; |
|
196 | + } |
|
197 | + $pilot_data = substr($pilot_data, 0, -1); |
|
198 | + print 'var series = ['.$pilot_data.'];'; |
|
199 | + print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);'; |
|
200 | + print 'var paletteScale = d3.scale.linear().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);'; |
|
201 | + print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});'; |
|
202 | + print 'var pilotcnt = new d3pie("chart7",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":'; |
|
203 | + print 'dataset'; |
|
204 | + print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});'; |
|
205 | + print '</script>'; |
|
206 | + } |
|
207 | + print '<div class="more">'; |
|
208 | 208 | print '<a href="'.$globalURL.'/statistics/pilot'; |
209 | 209 | if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
210 | 210 | print'" class="btn btn-default btn" role="button">'._("See full statistic").'»</a>'; |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | |
215 | 215 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
216 | 216 | <?php |
217 | - } else { |
|
217 | + } else { |
|
218 | 218 | ?> |
219 | 219 | <div class="col-md-6"> |
220 | 220 | <h2><?php echo _("Top 10 Most Common Owners"); ?></h2> |
@@ -222,21 +222,21 @@ discard block |
||
222 | 222 | $owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month); |
223 | 223 | if (count($owner_array) == 0) print _("No data available"); |
224 | 224 | else { |
225 | - print '<div id="chart7" class="chart" width="100%"></div><script>'; |
|
226 | - $owner_data = ''; |
|
227 | - foreach($owner_array as $owner_item) |
|
228 | - { |
|
225 | + print '<div id="chart7" class="chart" width="100%"></div><script>'; |
|
226 | + $owner_data = ''; |
|
227 | + foreach($owner_array as $owner_item) |
|
228 | + { |
|
229 | 229 | $owner_data .= '["'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],'; |
230 | - } |
|
231 | - $owner_data = substr($owner_data, 0, -1); |
|
232 | - print 'var series = ['.$owner_data.'];'; |
|
233 | - print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);'; |
|
234 | - print 'var paletteScale = d3.scale.linear().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);'; |
|
235 | - print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});'; |
|
236 | - print 'var ownercnt = new d3pie("chart7",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":'; |
|
237 | - print 'dataset'; |
|
238 | - print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});'; |
|
239 | - print '</script>'; |
|
230 | + } |
|
231 | + $owner_data = substr($owner_data, 0, -1); |
|
232 | + print 'var series = ['.$owner_data.'];'; |
|
233 | + print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);'; |
|
234 | + print 'var paletteScale = d3.scale.linear().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);'; |
|
235 | + print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});'; |
|
236 | + print 'var ownercnt = new d3pie("chart7",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":'; |
|
237 | + print 'dataset'; |
|
238 | + print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});'; |
|
239 | + print '</script>'; |
|
240 | 240 | } |
241 | 241 | ?> |
242 | 242 | <div class="more"> |
@@ -246,8 +246,8 @@ discard block |
||
246 | 246 | |
247 | 247 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
248 | 248 | <?php |
249 | - } |
|
250 | - if (!empty($flightover_array)) { |
|
249 | + } |
|
250 | + if (!empty($flightover_array)) { |
|
251 | 251 | ?> |
252 | 252 | <div class="col-md-6"> |
253 | 253 | <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2> |
@@ -255,20 +255,20 @@ discard block |
||
255 | 255 | //$flightover_array = $Stats->countAllFlightOverCountries(); |
256 | 256 | if (count($flightover_array) == 0) print _("No data available"); |
257 | 257 | else { |
258 | - print '<div id="chart10" class="chart" width="100%"></div><script>'; |
|
259 | - print 'var series = ['; |
|
260 | - $flightover_data = ''; |
|
261 | - foreach($flightover_array as $flightover_item) |
|
262 | - { |
|
258 | + print '<div id="chart10" class="chart" width="100%"></div><script>'; |
|
259 | + print 'var series = ['; |
|
260 | + $flightover_data = ''; |
|
261 | + foreach($flightover_array as $flightover_item) |
|
262 | + { |
|
263 | 263 | $flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],'; |
264 | - } |
|
265 | - $flightover_data = substr($flightover_data, 0, -1); |
|
266 | - print $flightover_data; |
|
267 | - print '];'; |
|
268 | - print 'var dataset = {};var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);'; |
|
269 | - print 'var paletteScale = d3.scale.linear().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);'; |
|
270 | - print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});'; |
|
271 | - print 'new Datamap({ |
|
264 | + } |
|
265 | + $flightover_data = substr($flightover_data, 0, -1); |
|
266 | + print $flightover_data; |
|
267 | + print '];'; |
|
268 | + print 'var dataset = {};var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);'; |
|
269 | + print 'var paletteScale = d3.scale.linear().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);'; |
|
270 | + print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});'; |
|
271 | + print 'new Datamap({ |
|
272 | 272 | element: document.getElementById("chart10"), |
273 | 273 | projection: "mercator", // big world map |
274 | 274 | fills: { defaultFill: "#F5F5F5" }, |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | } |
294 | 294 | } |
295 | 295 | });"; |
296 | - print '</script>'; |
|
296 | + print '</script>'; |
|
297 | 297 | } |
298 | 298 | ?> |
299 | 299 | <div class="more"> |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | </div> |
302 | 302 | </div> |
303 | 303 | <?php |
304 | - } |
|
304 | + } |
|
305 | 305 | ?> |
306 | 306 | </div> |
307 | 307 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -311,13 +311,13 @@ discard block |
||
311 | 311 | <div class="row column"> |
312 | 312 | <div class="col-md-6"> |
313 | 313 | <?php |
314 | - $airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month); |
|
315 | - if (count($airport_airport_array) > 0) { |
|
314 | + $airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month); |
|
315 | + if (count($airport_airport_array) > 0) { |
|
316 | 316 | print '<h2>'._("Top 10 Most Common Departure Airports").'</h2>'; |
317 | 317 | print '<div id="chart3" class="chart" width="100%"></div><script>'; |
318 | - print "\n"; |
|
319 | - print 'var series = ['; |
|
320 | - $airport_data = ''; |
|
318 | + print "\n"; |
|
319 | + print 'var series = ['; |
|
320 | + $airport_data = ''; |
|
321 | 321 | foreach($airport_airport_array as $airport_item) |
322 | 322 | { |
323 | 323 | $airport_data .= '[ "'.$airport_item['airport_departure_icao_count'].'", "'.$airport_item['airport_departure_icao'].'",'.$airport_item['airport_departure_latitude'].','.$airport_item['airport_departure_longitude'].'],'; |
@@ -366,20 +366,20 @@ discard block |
||
366 | 366 | print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; |
367 | 367 | if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
368 | 368 | print '" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
369 | - } |
|
369 | + } |
|
370 | 370 | ?> |
371 | 371 | </div> |
372 | 372 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
373 | 373 | |
374 | 374 | <div class="col-md-6"> |
375 | 375 | <?php |
376 | - $airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month); |
|
377 | - if (count($airport_airport_array2) > 0) { |
|
376 | + $airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month); |
|
377 | + if (count($airport_airport_array2) > 0) { |
|
378 | 378 | print '<h2>'._("Top 10 Most Common Arrival Airports").'</h2>'; |
379 | 379 | print '<div id="chart4" class="chart" width="100%"></div><script>'; |
380 | - print "\n"; |
|
381 | - print 'var series = ['; |
|
382 | - $airport_data = ''; |
|
380 | + print "\n"; |
|
381 | + print 'var series = ['; |
|
382 | + $airport_data = ''; |
|
383 | 383 | foreach($airport_airport_array2 as $airport_item) |
384 | 384 | { |
385 | 385 | $airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_icao'].'",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],'; |
@@ -429,28 +429,28 @@ discard block |
||
429 | 429 | print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival'; |
430 | 430 | if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
431 | 431 | print '" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
432 | - } |
|
432 | + } |
|
433 | 433 | ?> |
434 | 434 | </div> |
435 | 435 | </div> |
436 | 436 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
437 | 437 | <?php |
438 | - if ($year == '' && $month == '') { |
|
438 | + if ($year == '' && $month == '') { |
|
439 | 439 | ?> |
440 | 440 | <div class="row column"> |
441 | 441 | <div class="col-md-6"> |
442 | 442 | <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2> |
443 | 443 | <?php |
444 | - $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name); |
|
445 | - if (count($year_array) == 0) print _("No data available"); |
|
446 | - else { |
|
444 | + $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name); |
|
445 | + if (count($year_array) == 0) print _("No data available"); |
|
446 | + else { |
|
447 | 447 | print '<div id="chart8" class="chart" width="100%"></div><script>'; |
448 | 448 | $year_data = ''; |
449 | 449 | $year_cnt = ''; |
450 | 450 | foreach($year_array as $year_item) |
451 | 451 | { |
452 | - $year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",'; |
|
453 | - $year_cnt .= $year_item['date_count'].','; |
|
452 | + $year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",'; |
|
453 | + $year_cnt .= $year_item['date_count'].','; |
|
454 | 454 | } |
455 | 455 | $year_data = "['x',".substr($year_data, 0, -1)."]"; |
456 | 456 | $year_cnt = "['flights',".substr($year_cnt,0,-1)."]"; |
@@ -460,8 +460,8 @@ discard block |
||
460 | 460 | columns: ['.$year_data.','.$year_cnt.'], types: { flights: "area-spline"}, colors: { flights: "#1a3151"}}, |
461 | 461 | axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m"}}, y: { label: "# of Flights"}},legend: { show: false }});'; |
462 | 462 | print '</script>'; |
463 | - } |
|
464 | - ?> |
|
463 | + } |
|
464 | + ?> |
|
465 | 465 | <div class="more"> |
466 | 466 | <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
467 | 467 | </div> |
@@ -470,16 +470,16 @@ discard block |
||
470 | 470 | <div class="col-md-6"> |
471 | 471 | <h2><?php echo _("Busiest Day in the last Month"); ?></h2> |
472 | 472 | <?php |
473 | - $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name); |
|
474 | - if (count($month_array) == 0) print _("No data available"); |
|
475 | - else { |
|
476 | - print '<div id="chart9" class="chart" width="100%"></div><script>'; |
|
477 | - $month_data = ''; |
|
473 | + $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name); |
|
474 | + if (count($month_array) == 0) print _("No data available"); |
|
475 | + else { |
|
476 | + print '<div id="chart9" class="chart" width="100%"></div><script>'; |
|
477 | + $month_data = ''; |
|
478 | 478 | $month_cnt = ''; |
479 | 479 | foreach($month_array as $month_item) |
480 | 480 | { |
481 | - $month_data .= '"'.$month_item['date_name'].'",'; |
|
482 | - $month_cnt .= $month_item['date_count'].','; |
|
481 | + $month_data .= '"'.$month_item['date_name'].'",'; |
|
482 | + $month_cnt .= $month_item['date_count'].','; |
|
483 | 483 | } |
484 | 484 | $month_data = "['x',".substr($month_data, 0, -1)."]"; |
485 | 485 | $month_cnt = "['flights',".substr($month_cnt,0,-1)."]"; |
@@ -489,9 +489,9 @@ discard block |
||
489 | 489 | columns: ['.$month_data.','.$month_cnt.'], types: { flights: "area-spline"}, colors: { flights: "#1a3151"}}, |
490 | 490 | axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m-%d"}}, y: { label: "# of Flights"}},legend: { show: false }});'; |
491 | 491 | |
492 | - print '</script>'; |
|
493 | - } |
|
494 | - ?> |
|
492 | + print '</script>'; |
|
493 | + } |
|
494 | + ?> |
|
495 | 495 | <div class="more"> |
496 | 496 | <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
497 | 497 | </div> |
@@ -501,16 +501,16 @@ discard block |
||
501 | 501 | <div class="col-md-6"> |
502 | 502 | <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2> |
503 | 503 | <?php |
504 | - $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name); |
|
505 | - if (empty($date_array)) print _("No data available"); |
|
506 | - else { |
|
507 | - print '<div id="chart5" class="chart" width="100%"></div><script>'; |
|
508 | - $date_data = ''; |
|
504 | + $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name); |
|
505 | + if (empty($date_array)) print _("No data available"); |
|
506 | + else { |
|
507 | + print '<div id="chart5" class="chart" width="100%"></div><script>'; |
|
508 | + $date_data = ''; |
|
509 | 509 | $date_cnt = ''; |
510 | 510 | foreach($date_array as $date_item) |
511 | 511 | { |
512 | - $date_data .= '"'.$date_item['date_name'].'",'; |
|
513 | - $date_cnt .= $date_item['date_count'].','; |
|
512 | + $date_data .= '"'.$date_item['date_name'].'",'; |
|
513 | + $date_cnt .= $date_item['date_count'].','; |
|
514 | 514 | } |
515 | 515 | $date_data = "['x',".substr($date_data, 0, -1)."]"; |
516 | 516 | $date_cnt = "['flights',".substr($date_cnt,0,-1)."]"; |
@@ -520,9 +520,9 @@ discard block |
||
520 | 520 | columns: ['.$date_data.','.$date_cnt.'], types: { flights: "area-spline"}, colors: { flights: "#1a3151"}}, |
521 | 521 | axis: { x: { type: "timeseries",tick: { format: "%Y-%m-%d"}}, y: { label: "# of Flights"}},legend: { show: false }});'; |
522 | 522 | |
523 | - print '</script>'; |
|
524 | - } |
|
525 | - ?> |
|
523 | + print '</script>'; |
|
524 | + } |
|
525 | + ?> |
|
526 | 526 | <div class="more"> |
527 | 527 | <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
528 | 528 | </div> |
@@ -531,16 +531,16 @@ discard block |
||
531 | 531 | <div class="col-md-6"> |
532 | 532 | <h2><?php echo _("Busiest Time of the Day"); ?></h2> |
533 | 533 | <?php |
534 | - $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name); |
|
535 | - if (empty($hour_array)) print _("No data available"); |
|
536 | - else { |
|
537 | - print '<div id="chart6" class="chart" width="100%"></div><script>'; |
|
538 | - $hour_data = ''; |
|
534 | + $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name); |
|
535 | + if (empty($hour_array)) print _("No data available"); |
|
536 | + else { |
|
537 | + print '<div id="chart6" class="chart" width="100%"></div><script>'; |
|
538 | + $hour_data = ''; |
|
539 | 539 | $hour_cnt = ''; |
540 | 540 | foreach($hour_array as $hour_item) |
541 | 541 | { |
542 | - $hour_data .= '"'.$hour_item['hour_name'].':00",'; |
|
543 | - $hour_cnt .= $hour_item['hour_count'].','; |
|
542 | + $hour_data .= '"'.$hour_item['hour_name'].':00",'; |
|
543 | + $hour_cnt .= $hour_item['hour_count'].','; |
|
544 | 544 | } |
545 | 545 | $hour_data = "[".substr($hour_data, 0, -1)."]"; |
546 | 546 | $hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]"; |
@@ -550,9 +550,9 @@ discard block |
||
550 | 550 | columns: ['.$hour_cnt.'], types: { flights: "area-spline"}, colors: { flights: "#1a3151"}}, |
551 | 551 | axis: { x: { type: "category", categories: '.$hour_data.'},y: { label: "# of Flights"}},legend: { show: false }});'; |
552 | 552 | |
553 | - print '</script>'; |
|
554 | - } |
|
555 | - ?> |
|
553 | + print '</script>'; |
|
554 | + } |
|
555 | + ?> |
|
556 | 556 | <div class="more"> |
557 | 557 | <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
558 | 558 | </div> |
@@ -560,26 +560,26 @@ discard block |
||
560 | 560 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
561 | 561 | </div> |
562 | 562 | <?php |
563 | - } |
|
563 | + } |
|
564 | 564 | ?> |
565 | 565 | |
566 | 566 | <?php |
567 | - if (($airline_icao == '' || $airline_icao == 'all') && $year == '' && $month == '' && isset($globalAccidents) && $globalAccidents) { |
|
567 | + if (($airline_icao == '' || $airline_icao == 'all') && $year == '' && $month == '' && isset($globalAccidents) && $globalAccidents) { |
|
568 | 568 | ?> |
569 | 569 | <div class="row column"> |
570 | 570 | <div class="col-md-6"> |
571 | 571 | <h2><?php echo _("Fatalities by Years"); ?></h2> |
572 | 572 | <?php |
573 | - $year_array = $Stats->countFatalitiesByYear(); |
|
574 | - if (count($year_array) == 0) print _("No data available"); |
|
575 | - else { |
|
573 | + $year_array = $Stats->countFatalitiesByYear(); |
|
574 | + if (count($year_array) == 0) print _("No data available"); |
|
575 | + else { |
|
576 | 576 | print '<div id="chart32" class="chart" width="100%"></div><script>'; |
577 | - $year_data = ''; |
|
577 | + $year_data = ''; |
|
578 | 578 | $year_cnt = ''; |
579 | 579 | foreach($year_array as $year_item) |
580 | 580 | { |
581 | - $year_data .= '"'.$year_item['year'].'-01-01",'; |
|
582 | - $year_cnt .= $year_item['count'].','; |
|
581 | + $year_data .= '"'.$year_item['year'].'-01-01",'; |
|
582 | + $year_cnt .= $year_item['count'].','; |
|
583 | 583 | } |
584 | 584 | $year_data = "['x',".substr($year_data, 0, -1)."]"; |
585 | 585 | $year_cnt = "['flights',".substr($year_cnt,0,-1)."]"; |
@@ -590,8 +590,8 @@ discard block |
||
590 | 590 | axis: { x: { type: "timeseries",tick: { format: "%Y"}}, y: { label: "# of Flights"}},legend: { show: false }});'; |
591 | 591 | |
592 | 592 | print '</script>'; |
593 | - } |
|
594 | - ?> |
|
593 | + } |
|
594 | + ?> |
|
595 | 595 | <div class="more"> |
596 | 596 | <a href="<?php print $globalURL; ?>/statistics/fatalities/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
597 | 597 | </div> |
@@ -602,16 +602,16 @@ discard block |
||
602 | 602 | <div class="col-md-6"> |
603 | 603 | <h2><?php echo _("Fatalities last 12 Months"); ?></h2> |
604 | 604 | <?php |
605 | - $year_array = $Stats->countFatalitiesLast12Months(); |
|
606 | - if (count($year_array) == 0) print _("No data available"); |
|
607 | - else { |
|
605 | + $year_array = $Stats->countFatalitiesLast12Months(); |
|
606 | + if (count($year_array) == 0) print _("No data available"); |
|
607 | + else { |
|
608 | 608 | print '<div id="chart33" class="chart" width="100%"></div><script>'; |
609 | - $year_data = ''; |
|
609 | + $year_data = ''; |
|
610 | 610 | $year_cnt = ''; |
611 | 611 | foreach($year_array as $year_item) |
612 | 612 | { |
613 | - $year_data .= '"'.$year_item['year'].'-'.$year_item['month'].'-01",'; |
|
614 | - $year_cnt .= $year_item['count'].','; |
|
613 | + $year_data .= '"'.$year_item['year'].'-'.$year_item['month'].'-01",'; |
|
614 | + $year_cnt .= $year_item['count'].','; |
|
615 | 615 | } |
616 | 616 | $year_data = "['x',".substr($year_data, 0, -1)."]"; |
617 | 617 | $year_cnt = "['flights',".substr($year_cnt,0,-1)."]"; |
@@ -621,8 +621,8 @@ discard block |
||
621 | 621 | columns: ['.$year_data.','.$year_cnt.'], types: { flights: "area-spline"}, colors: { flights: "#1a3151"}}, |
622 | 622 | axis: { x: { type: "timeseries",tick: { format: "%Y-%m"}}, y: { label: "# of Flights"}},legend: { show: false }});'; |
623 | 623 | print '</script>'; |
624 | - } |
|
625 | - ?> |
|
624 | + } |
|
625 | + ?> |
|
626 | 626 | <div class="more"> |
627 | 627 | <a href="<?php print $globalURL; ?>/statistics/fatalities/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
628 | 628 | </div> |
@@ -630,30 +630,30 @@ discard block |
||
630 | 630 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
631 | 631 | <br/> |
632 | 632 | <?php |
633 | - } |
|
633 | + } |
|
634 | 634 | ?> |
635 | 635 | |
636 | 636 | <?php |
637 | - if (($airline_icao == '' || $airline_icao == 'all') && $filter_name == '' && $year == '' && $month == '') { |
|
637 | + if (($airline_icao == '' || $airline_icao == 'all') && $filter_name == '' && $year == '' && $month == '') { |
|
638 | 638 | ?> |
639 | 639 | <div class="row column"> |
640 | 640 | <?php |
641 | - //$polar = $Stats->getStatsSource(date('Y-m-d'),'polar'); |
|
642 | - if ($year == '' && $month == '') { |
|
643 | - $polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d')); |
|
644 | - } else { |
|
645 | - $polar = $Stats->getStatsSource('polar',$year,$month); |
|
646 | - } |
|
647 | - if (!empty($polar)) { |
|
648 | - print '<h2>'._("Coverage pattern").'</h2>'; |
|
649 | - foreach ($polar as $eachpolar) { |
|
650 | - unset($polar_data); |
|
651 | - $Spotter = new Spotter(); |
|
652 | - $data = json_decode($eachpolar['source_data']); |
|
653 | - foreach($data as $value => $key) { |
|
654 | - $direction = $Spotter->parseDirection(($value*22.5)); |
|
655 | - $distance = $key; |
|
656 | - $unit = 'km'; |
|
641 | + //$polar = $Stats->getStatsSource(date('Y-m-d'),'polar'); |
|
642 | + if ($year == '' && $month == '') { |
|
643 | + $polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d')); |
|
644 | + } else { |
|
645 | + $polar = $Stats->getStatsSource('polar',$year,$month); |
|
646 | + } |
|
647 | + if (!empty($polar)) { |
|
648 | + print '<h2>'._("Coverage pattern").'</h2>'; |
|
649 | + foreach ($polar as $eachpolar) { |
|
650 | + unset($polar_data); |
|
651 | + $Spotter = new Spotter(); |
|
652 | + $data = json_decode($eachpolar['source_data']); |
|
653 | + foreach($data as $value => $key) { |
|
654 | + $direction = $Spotter->parseDirection(($value*22.5)); |
|
655 | + $distance = $key; |
|
656 | + $unit = 'km'; |
|
657 | 657 | if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) { |
658 | 658 | $distance = round($distance*0.539957); |
659 | 659 | $unit = 'nm'; |
@@ -664,10 +664,10 @@ discard block |
||
664 | 664 | $distance = $distance; |
665 | 665 | $unit = 'km'; |
666 | 666 | } |
667 | - if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
668 | - else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
669 | - } |
|
670 | - ?> |
|
667 | + if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
668 | + else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
669 | + } |
|
670 | + ?> |
|
671 | 671 | <div class="col-md-6"> |
672 | 672 | <h4><?php print $eachpolar['source_name']; ?></h4> |
673 | 673 | <div id="polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div> |
@@ -699,27 +699,27 @@ discard block |
||
699 | 699 | </script> |
700 | 700 | </div> |
701 | 701 | <?php |
702 | - } |
|
703 | - } |
|
704 | - ?> |
|
702 | + } |
|
703 | + } |
|
704 | + ?> |
|
705 | 705 | </div> |
706 | 706 | <div class="row column"> |
707 | 707 | <div class="col-md-6"> |
708 | 708 | <?php |
709 | - //$msg = $Stats->getStatsSource(date('Y-m-d'),'msg'); |
|
710 | - if ($year == '' && $month == '') { |
|
711 | - $msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d')); |
|
712 | - } else { |
|
713 | - $msg = $Stats->getStatsSource('msg',$year,$month); |
|
714 | - } |
|
715 | - if (!empty($msg)) { |
|
716 | - print '<h2>'._("Messages received").'</h2>'; |
|
717 | - foreach ($msg as $eachmsg) { |
|
718 | - //$eachmsg = $msg[0]; |
|
719 | - $data = $eachmsg['source_data']; |
|
720 | - if ($data > 500) $max = (round(($data+100)/100))*100; |
|
721 | - else $max = 500; |
|
722 | - ?> |
|
709 | + //$msg = $Stats->getStatsSource(date('Y-m-d'),'msg'); |
|
710 | + if ($year == '' && $month == '') { |
|
711 | + $msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d')); |
|
712 | + } else { |
|
713 | + $msg = $Stats->getStatsSource('msg',$year,$month); |
|
714 | + } |
|
715 | + if (!empty($msg)) { |
|
716 | + print '<h2>'._("Messages received").'</h2>'; |
|
717 | + foreach ($msg as $eachmsg) { |
|
718 | + //$eachmsg = $msg[0]; |
|
719 | + $data = $eachmsg['source_data']; |
|
720 | + if ($data > 500) $max = (round(($data+100)/100))*100; |
|
721 | + else $max = 500; |
|
722 | + ?> |
|
723 | 723 | <div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div> |
724 | 724 | <script> |
725 | 725 | var g = new JustGage({ |
@@ -735,9 +735,9 @@ discard block |
||
735 | 735 | }); |
736 | 736 | </script> |
737 | 737 | <?php |
738 | - } |
|
739 | - } |
|
740 | - ?> |
|
738 | + } |
|
739 | + } |
|
740 | + ?> |
|
741 | 741 | </div> |
742 | 742 | </div> |
743 | 743 | <div class="row column"> |
@@ -775,26 +775,26 @@ discard block |
||
775 | 775 | //$hist_data = substr($hist_data, 0, -1); |
776 | 776 | $distance_data = "['x',".substr($distance_data, 0, -1)."]"; |
777 | 777 | $nb_data = "['flights',".substr($nb_data, 0, -1)."]"; |
778 | - ?> |
|
778 | + ?> |
|
779 | 779 | <div class="col-md-6"> |
780 | 780 | <h2><?php echo sprintf(_("Flights Distance for %s"),$source); ?></h2> |
781 | 781 | <?php |
782 | - print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div><script>'; |
|
783 | - print 'c3.generate({ |
|
782 | + print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div><script>'; |
|
783 | + print 'c3.generate({ |
|
784 | 784 | bindto: "#charthist-'.str_replace(' ','_',strtolower($source)).'", |
785 | 785 | data: { x: "x", |
786 | 786 | columns: ['.$distance_data.','.$nb_data.'], types: { flights: "area-spline"}, colors: { flights: "#1a3151"}}, |
787 | 787 | axis: { x: {label : { text: "Distance in '.$unit.'", position: "outer-right"}}, y: { label: "# of Flights"}},legend: { show: false }});'; |
788 | - print '</script>'; |
|
789 | - ?> |
|
788 | + print '</script>'; |
|
789 | + ?> |
|
790 | 790 | </div> |
791 | 791 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
792 | 792 | <?php |
793 | - } |
|
794 | - ?> |
|
793 | + } |
|
794 | + ?> |
|
795 | 795 | </div> |
796 | 796 | <?php |
797 | - } |
|
797 | + } |
|
798 | 798 | ?> |
799 | 799 | </div> |
800 | 800 | </div> |