@@ -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'); |
@@ -200,11 +200,11 @@ discard block |
||
200 | 200 | |
201 | 201 | |
202 | 202 | /** |
203 | - * Gets all the spotter information based on the latest data entry |
|
204 | - * |
|
205 | - * @return Array the spotter information |
|
206 | - * |
|
207 | - */ |
|
203 | + * Gets all the spotter information based on the latest data entry |
|
204 | + * |
|
205 | + * @return Array the spotter information |
|
206 | + * |
|
207 | + */ |
|
208 | 208 | public function getLatestTrackerData($limit = '', $sort = '', $filter = array()) |
209 | 209 | { |
210 | 210 | global $global_query; |
@@ -262,11 +262,11 @@ discard block |
||
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
265 | - * Gets all the spotter information based on the callsign |
|
266 | - * |
|
267 | - * @return Array the spotter information |
|
268 | - * |
|
269 | - */ |
|
265 | + * Gets all the spotter information based on the callsign |
|
266 | + * |
|
267 | + * @return Array the spotter information |
|
268 | + * |
|
269 | + */ |
|
270 | 270 | public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '', $filter = array()) |
271 | 271 | { |
272 | 272 | global $global_query; |
@@ -377,12 +377,12 @@ discard block |
||
377 | 377 | |
378 | 378 | |
379 | 379 | /** |
380 | - * Gets all source name |
|
381 | - * |
|
382 | - * @param String type format of source |
|
383 | - * @return Array list of source name |
|
384 | - * |
|
385 | - */ |
|
380 | + * Gets all source name |
|
381 | + * |
|
382 | + * @param String type format of source |
|
383 | + * @return Array list of source name |
|
384 | + * |
|
385 | + */ |
|
386 | 386 | public function getAllSourceName($type = '',$filters = array()) |
387 | 387 | { |
388 | 388 | $filter_query = $this->getFilter($filters,true,true); |
@@ -412,11 +412,11 @@ discard block |
||
412 | 412 | |
413 | 413 | |
414 | 414 | /** |
415 | - * Gets a list of all idents/callsigns |
|
416 | - * |
|
417 | - * @return Array list of ident/callsign names |
|
418 | - * |
|
419 | - */ |
|
415 | + * Gets a list of all idents/callsigns |
|
416 | + * |
|
417 | + * @return Array list of ident/callsign names |
|
418 | + * |
|
419 | + */ |
|
420 | 420 | public function getAllIdents($filters = array()) |
421 | 421 | { |
422 | 422 | $filter_query = $this->getFilter($filters,true,true); |
@@ -484,18 +484,18 @@ discard block |
||
484 | 484 | |
485 | 485 | |
486 | 486 | /** |
487 | - * Update ident spotter data |
|
488 | - * |
|
489 | - * @param String $flightaware_id the ID from flightaware |
|
490 | - * @param String $ident the flight ident |
|
491 | - * @return String success or false |
|
492 | - * |
|
493 | - */ |
|
487 | + * Update ident spotter data |
|
488 | + * |
|
489 | + * @param String $flightaware_id the ID from flightaware |
|
490 | + * @param String $ident the flight ident |
|
491 | + * @return String success or false |
|
492 | + * |
|
493 | + */ |
|
494 | 494 | public function updateIdentTrackerData($famtrackid = '', $ident = '',$fromsource = NULL) |
495 | 495 | { |
496 | 496 | |
497 | 497 | $query = 'UPDATE tracker_output SET ident = :ident WHERE famtrackid = :famtrackid'; |
498 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident); |
|
498 | + $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident); |
|
499 | 499 | |
500 | 500 | try { |
501 | 501 | $sth = $this->db->prepare($query); |
@@ -508,18 +508,18 @@ discard block |
||
508 | 508 | |
509 | 509 | } |
510 | 510 | /** |
511 | - * Update latest spotter data |
|
512 | - * |
|
513 | - * @param String $flightaware_id the ID from flightaware |
|
514 | - * @param String $ident the flight ident |
|
515 | - * @param String $arrival_airport_icao the arrival airport |
|
516 | - * @return String success or false |
|
517 | - * |
|
518 | - */ |
|
511 | + * Update latest spotter data |
|
512 | + * |
|
513 | + * @param String $flightaware_id the ID from flightaware |
|
514 | + * @param String $ident the flight ident |
|
515 | + * @param String $arrival_airport_icao the arrival airport |
|
516 | + * @return String success or false |
|
517 | + * |
|
518 | + */ |
|
519 | 519 | public function updateLatestTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $groundspeed = NULL, $date = '') |
520 | 520 | { |
521 | 521 | $query = 'UPDATE tracker_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE famtrackid = :famtrackid'; |
522 | - $query_values = array(':famtrackid' => $famtrackid,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
522 | + $query_values = array(':famtrackid' => $famtrackid,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
523 | 523 | |
524 | 524 | try { |
525 | 525 | $sth = $this->db->prepare($query); |
@@ -533,32 +533,32 @@ discard block |
||
533 | 533 | } |
534 | 534 | |
535 | 535 | /** |
536 | - * Adds a new spotter data |
|
537 | - * |
|
538 | - * @param String $flightaware_id the ID from flightaware |
|
539 | - * @param String $ident the flight ident |
|
540 | - * @param String $aircraft_icao the aircraft type |
|
541 | - * @param String $departure_airport_icao the departure airport |
|
542 | - * @param String $arrival_airport_icao the arrival airport |
|
543 | - * @param String $latitude latitude of flight |
|
544 | - * @param String $longitude latitude of flight |
|
545 | - * @param String $waypoints waypoints of flight |
|
546 | - * @param String $altitude altitude of flight |
|
547 | - * @param String $heading heading of flight |
|
548 | - * @param String $groundspeed speed of flight |
|
549 | - * @param String $date date of flight |
|
550 | - * @param String $departure_airport_time departure time of flight |
|
551 | - * @param String $arrival_airport_time arrival time of flight |
|
552 | - * @param String $squawk squawk code of flight |
|
553 | - * @param String $route_stop route stop of flight |
|
554 | - * @param String $highlight highlight or not |
|
555 | - * @param String $ModeS ModesS code of flight |
|
556 | - * @param String $registration registration code of flight |
|
557 | - * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
558 | - * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
559 | - * @param String $verticalrate vertival rate of flight |
|
560 | - * @return String success or false |
|
561 | - */ |
|
536 | + * Adds a new spotter data |
|
537 | + * |
|
538 | + * @param String $flightaware_id the ID from flightaware |
|
539 | + * @param String $ident the flight ident |
|
540 | + * @param String $aircraft_icao the aircraft type |
|
541 | + * @param String $departure_airport_icao the departure airport |
|
542 | + * @param String $arrival_airport_icao the arrival airport |
|
543 | + * @param String $latitude latitude of flight |
|
544 | + * @param String $longitude latitude of flight |
|
545 | + * @param String $waypoints waypoints of flight |
|
546 | + * @param String $altitude altitude of flight |
|
547 | + * @param String $heading heading of flight |
|
548 | + * @param String $groundspeed speed of flight |
|
549 | + * @param String $date date of flight |
|
550 | + * @param String $departure_airport_time departure time of flight |
|
551 | + * @param String $arrival_airport_time arrival time of flight |
|
552 | + * @param String $squawk squawk code of flight |
|
553 | + * @param String $route_stop route stop of flight |
|
554 | + * @param String $highlight highlight or not |
|
555 | + * @param String $ModeS ModesS code of flight |
|
556 | + * @param String $registration registration code of flight |
|
557 | + * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
558 | + * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
559 | + * @param String $verticalrate vertival rate of flight |
|
560 | + * @return String success or false |
|
561 | + */ |
|
562 | 562 | public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '',$format_source = '', $source_name = '') |
563 | 563 | { |
564 | 564 | global $globalURL; |
@@ -643,16 +643,16 @@ discard block |
||
643 | 643 | $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
644 | 644 | $type = filter_var($type,FILTER_SANITIZE_STRING); |
645 | 645 | |
646 | - if ($latitude == '' && $longitude == '') { |
|
647 | - $latitude = 0; |
|
648 | - $longitude = 0; |
|
649 | - } |
|
650 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
651 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
652 | - $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) |
|
646 | + if ($latitude == '' && $longitude == '') { |
|
647 | + $latitude = 0; |
|
648 | + $longitude = 0; |
|
649 | + } |
|
650 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
651 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
652 | + $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) |
|
653 | 653 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)"; |
654 | 654 | |
655 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':comment' => $comment,':type' => $type); |
|
655 | + $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':comment' => $comment,':type' => $type); |
|
656 | 656 | |
657 | 657 | try { |
658 | 658 | |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | $sth->execute($query_values); |
661 | 661 | $this->db = null; |
662 | 662 | } catch (PDOException $e) { |
663 | - return "error : ".$e->getMessage(); |
|
663 | + return "error : ".$e->getMessage(); |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | return "success"; |
@@ -669,11 +669,11 @@ discard block |
||
669 | 669 | |
670 | 670 | |
671 | 671 | /** |
672 | - * Gets the aircraft ident within the last hour |
|
673 | - * |
|
674 | - * @return String the ident |
|
675 | - * |
|
676 | - */ |
|
672 | + * Gets the aircraft ident within the last hour |
|
673 | + * |
|
674 | + * @return String the ident |
|
675 | + * |
|
676 | + */ |
|
677 | 677 | public function getIdentFromLastHour($ident) |
678 | 678 | { |
679 | 679 | global $globalDBdriver, $globalTimezone; |
@@ -689,11 +689,11 @@ discard block |
||
689 | 689 | AND tracker_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
690 | 690 | AND tracker_output.date < now() AT TIME ZONE 'UTC'"; |
691 | 691 | $query_data = array(':ident' => $ident); |
692 | - } |
|
692 | + } |
|
693 | 693 | |
694 | 694 | $sth = $this->db->prepare($query); |
695 | 695 | $sth->execute($query_data); |
696 | - $ident_result=''; |
|
696 | + $ident_result=''; |
|
697 | 697 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
698 | 698 | { |
699 | 699 | $ident_result = $row['ident']; |
@@ -704,11 +704,11 @@ discard block |
||
704 | 704 | |
705 | 705 | |
706 | 706 | /** |
707 | - * Gets the aircraft data from the last 20 seconds |
|
708 | - * |
|
709 | - * @return Array the spotter data |
|
710 | - * |
|
711 | - */ |
|
707 | + * Gets the aircraft data from the last 20 seconds |
|
708 | + * |
|
709 | + * @return Array the spotter data |
|
710 | + * |
|
711 | + */ |
|
712 | 712 | public function getRealTimeData($q = '') |
713 | 713 | { |
714 | 714 | global $globalDBdriver; |
@@ -746,11 +746,11 @@ discard block |
||
746 | 746 | |
747 | 747 | |
748 | 748 | /** |
749 | - * Gets all number of flight over countries |
|
750 | - * |
|
751 | - * @return Array the airline country list |
|
752 | - * |
|
753 | - */ |
|
749 | + * Gets all number of flight over countries |
|
750 | + * |
|
751 | + * @return Array the airline country list |
|
752 | + * |
|
753 | + */ |
|
754 | 754 | |
755 | 755 | public function countAllTrackerOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
756 | 756 | { |
@@ -821,11 +821,11 @@ discard block |
||
821 | 821 | } |
822 | 822 | |
823 | 823 | /** |
824 | - * Gets all callsigns that have flown over |
|
825 | - * |
|
826 | - * @return Array the callsign list |
|
827 | - * |
|
828 | - */ |
|
824 | + * Gets all callsigns that have flown over |
|
825 | + * |
|
826 | + * @return Array the callsign list |
|
827 | + * |
|
828 | + */ |
|
829 | 829 | public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
830 | 830 | { |
831 | 831 | global $globalDBdriver; |
@@ -892,11 +892,11 @@ discard block |
||
892 | 892 | |
893 | 893 | |
894 | 894 | /** |
895 | - * Counts all dates |
|
896 | - * |
|
897 | - * @return Array the date list |
|
898 | - * |
|
899 | - */ |
|
895 | + * Counts all dates |
|
896 | + * |
|
897 | + * @return Array the date list |
|
898 | + * |
|
899 | + */ |
|
900 | 900 | public function countAllDates($filters = array()) |
901 | 901 | { |
902 | 902 | global $globalTimezone, $globalDBdriver; |
@@ -942,11 +942,11 @@ discard block |
||
942 | 942 | |
943 | 943 | |
944 | 944 | /** |
945 | - * Counts all dates during the last 7 days |
|
946 | - * |
|
947 | - * @return Array the date list |
|
948 | - * |
|
949 | - */ |
|
945 | + * Counts all dates during the last 7 days |
|
946 | + * |
|
947 | + * @return Array the date list |
|
948 | + * |
|
949 | + */ |
|
950 | 950 | public function countAllDatesLast7Days($filters = array()) |
951 | 951 | { |
952 | 952 | global $globalTimezone, $globalDBdriver; |
@@ -968,7 +968,7 @@ discard block |
||
968 | 968 | $query .= " GROUP BY date_name |
969 | 969 | ORDER BY date_name ASC"; |
970 | 970 | $query_data = array(':offset' => $offset); |
971 | - } |
|
971 | + } |
|
972 | 972 | |
973 | 973 | $sth = $this->db->prepare($query); |
974 | 974 | $sth->execute($query_data); |
@@ -988,11 +988,11 @@ discard block |
||
988 | 988 | } |
989 | 989 | |
990 | 990 | /** |
991 | - * Counts all dates during the last month |
|
992 | - * |
|
993 | - * @return Array the date list |
|
994 | - * |
|
995 | - */ |
|
991 | + * Counts all dates during the last month |
|
992 | + * |
|
993 | + * @return Array the date list |
|
994 | + * |
|
995 | + */ |
|
996 | 996 | public function countAllDatesLastMonth($filters = array()) |
997 | 997 | { |
998 | 998 | global $globalTimezone, $globalDBdriver; |
@@ -1014,7 +1014,7 @@ discard block |
||
1014 | 1014 | $query .= " GROUP BY date_name |
1015 | 1015 | ORDER BY date_name ASC"; |
1016 | 1016 | $query_data = array(':offset' => $offset); |
1017 | - } |
|
1017 | + } |
|
1018 | 1018 | |
1019 | 1019 | $sth = $this->db->prepare($query); |
1020 | 1020 | $sth->execute($query_data); |
@@ -1036,11 +1036,11 @@ discard block |
||
1036 | 1036 | |
1037 | 1037 | |
1038 | 1038 | /** |
1039 | - * Counts all month |
|
1040 | - * |
|
1041 | - * @return Array the month list |
|
1042 | - * |
|
1043 | - */ |
|
1039 | + * Counts all month |
|
1040 | + * |
|
1041 | + * @return Array the month list |
|
1042 | + * |
|
1043 | + */ |
|
1044 | 1044 | public function countAllMonths($filters = array()) |
1045 | 1045 | { |
1046 | 1046 | global $globalTimezone, $globalDBdriver; |
@@ -1085,11 +1085,11 @@ discard block |
||
1085 | 1085 | |
1086 | 1086 | |
1087 | 1087 | /** |
1088 | - * Counts all dates during the last year |
|
1089 | - * |
|
1090 | - * @return Array the date list |
|
1091 | - * |
|
1092 | - */ |
|
1088 | + * Counts all dates during the last year |
|
1089 | + * |
|
1090 | + * @return Array the date list |
|
1091 | + * |
|
1092 | + */ |
|
1093 | 1093 | public function countAllMonthsLastYear($filters) |
1094 | 1094 | { |
1095 | 1095 | global $globalTimezone, $globalDBdriver; |
@@ -1111,7 +1111,7 @@ discard block |
||
1111 | 1111 | $query .= " GROUP BY year_name, month_name |
1112 | 1112 | ORDER BY year_name, month_name ASC"; |
1113 | 1113 | $query_data = array(':offset' => $offset); |
1114 | - } |
|
1114 | + } |
|
1115 | 1115 | |
1116 | 1116 | $sth = $this->db->prepare($query); |
1117 | 1117 | $sth->execute($query_data); |
@@ -1134,11 +1134,11 @@ discard block |
||
1134 | 1134 | |
1135 | 1135 | |
1136 | 1136 | /** |
1137 | - * Counts all hours |
|
1138 | - * |
|
1139 | - * @return Array the hour list |
|
1140 | - * |
|
1141 | - */ |
|
1137 | + * Counts all hours |
|
1138 | + * |
|
1139 | + * @return Array the hour list |
|
1140 | + * |
|
1141 | + */ |
|
1142 | 1142 | public function countAllHours($orderby,$filters = array()) |
1143 | 1143 | { |
1144 | 1144 | global $globalTimezone, $globalDBdriver; |
@@ -1201,11 +1201,11 @@ discard block |
||
1201 | 1201 | |
1202 | 1202 | |
1203 | 1203 | /** |
1204 | - * Counts all hours by date |
|
1205 | - * |
|
1206 | - * @return Array the hour list |
|
1207 | - * |
|
1208 | - */ |
|
1204 | + * Counts all hours by date |
|
1205 | + * |
|
1206 | + * @return Array the hour list |
|
1207 | + * |
|
1208 | + */ |
|
1209 | 1209 | public function countAllHoursByDate($date, $filters = array()) |
1210 | 1210 | { |
1211 | 1211 | global $globalTimezone, $globalDBdriver; |
@@ -1249,11 +1249,11 @@ discard block |
||
1249 | 1249 | |
1250 | 1250 | |
1251 | 1251 | /** |
1252 | - * Counts all hours by a ident/callsign |
|
1253 | - * |
|
1254 | - * @return Array the hour list |
|
1255 | - * |
|
1256 | - */ |
|
1252 | + * Counts all hours by a ident/callsign |
|
1253 | + * |
|
1254 | + * @return Array the hour list |
|
1255 | + * |
|
1256 | + */ |
|
1257 | 1257 | public function countAllHoursByIdent($ident, $filters = array()) |
1258 | 1258 | { |
1259 | 1259 | global $globalTimezone, $globalDBdriver; |
@@ -1298,11 +1298,11 @@ discard block |
||
1298 | 1298 | |
1299 | 1299 | |
1300 | 1300 | /** |
1301 | - * Counts all trackers that have flown over |
|
1302 | - * |
|
1303 | - * @return Integer the number of trackers |
|
1304 | - * |
|
1305 | - */ |
|
1301 | + * Counts all trackers that have flown over |
|
1302 | + * |
|
1303 | + * @return Integer the number of trackers |
|
1304 | + * |
|
1305 | + */ |
|
1306 | 1306 | public function countOverallTracker($filters = array(),$year = '',$month = '') |
1307 | 1307 | { |
1308 | 1308 | global $globalDBdriver; |
@@ -1337,11 +1337,11 @@ discard block |
||
1337 | 1337 | } |
1338 | 1338 | |
1339 | 1339 | /** |
1340 | - * Counts all trackers type that have flown over |
|
1341 | - * |
|
1342 | - * @return Integer the number of flights |
|
1343 | - * |
|
1344 | - */ |
|
1340 | + * Counts all trackers type that have flown over |
|
1341 | + * |
|
1342 | + * @return Integer the number of flights |
|
1343 | + * |
|
1344 | + */ |
|
1345 | 1345 | public function countOverallTrackerTypes($filters = array(),$year = '',$month = '') |
1346 | 1346 | { |
1347 | 1347 | global $globalDBdriver; |
@@ -1376,11 +1376,11 @@ discard block |
||
1376 | 1376 | |
1377 | 1377 | |
1378 | 1378 | /** |
1379 | - * Counts all hours of today |
|
1380 | - * |
|
1381 | - * @return Array the hour list |
|
1382 | - * |
|
1383 | - */ |
|
1379 | + * Counts all hours of today |
|
1380 | + * |
|
1381 | + * @return Array the hour list |
|
1382 | + * |
|
1383 | + */ |
|
1384 | 1384 | public function countAllHoursFromToday($filters = array()) |
1385 | 1385 | { |
1386 | 1386 | global $globalTimezone, $globalDBdriver; |
@@ -1420,12 +1420,12 @@ discard block |
||
1420 | 1420 | } |
1421 | 1421 | |
1422 | 1422 | |
1423 | - /** |
|
1424 | - * Gets the Barrie Spotter ID based on the FlightAware ID |
|
1425 | - * |
|
1426 | - * @return Integer the Barrie Spotter ID |
|
1423 | + /** |
|
1424 | + * Gets the Barrie Spotter ID based on the FlightAware ID |
|
1425 | + * |
|
1426 | + * @return Integer the Barrie Spotter ID |
|
1427 | 1427 | q * |
1428 | - */ |
|
1428 | + */ |
|
1429 | 1429 | public function getTrackerIDBasedOnFamTrackID($famtrackid) |
1430 | 1430 | { |
1431 | 1431 | $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
@@ -1446,13 +1446,13 @@ discard block |
||
1446 | 1446 | |
1447 | 1447 | |
1448 | 1448 | /** |
1449 | - * Parses a date string |
|
1450 | - * |
|
1451 | - * @param String $dateString the date string |
|
1452 | - * @param String $timezone the timezone of a user |
|
1453 | - * @return Array the time information |
|
1454 | - * |
|
1455 | - */ |
|
1449 | + * Parses a date string |
|
1450 | + * |
|
1451 | + * @param String $dateString the date string |
|
1452 | + * @param String $timezone the timezone of a user |
|
1453 | + * @return Array the time information |
|
1454 | + * |
|
1455 | + */ |
|
1456 | 1456 | public function parseDateString($dateString, $timezone = '') |
1457 | 1457 | { |
1458 | 1458 | $time_array = array(); |
@@ -1485,12 +1485,12 @@ discard block |
||
1485 | 1485 | } |
1486 | 1486 | |
1487 | 1487 | /** |
1488 | - * Parses the direction degrees to working |
|
1489 | - * |
|
1490 | - * @param Float $direction the direction in degrees |
|
1491 | - * @return Array the direction information |
|
1492 | - * |
|
1493 | - */ |
|
1488 | + * Parses the direction degrees to working |
|
1489 | + * |
|
1490 | + * @param Float $direction the direction in degrees |
|
1491 | + * @return Array the direction information |
|
1492 | + * |
|
1493 | + */ |
|
1494 | 1494 | public function parseDirection($direction = 0) |
1495 | 1495 | { |
1496 | 1496 | if ($direction == '') $direction = 0; |
@@ -1569,12 +1569,12 @@ discard block |
||
1569 | 1569 | |
1570 | 1570 | |
1571 | 1571 | /** |
1572 | - * Gets Country from latitude/longitude |
|
1573 | - * |
|
1574 | - * @param Float $latitude latitute of the flight |
|
1575 | - * @param Float $longitude longitute of the flight |
|
1576 | - * @return String the countrie |
|
1577 | - */ |
|
1572 | + * Gets Country from latitude/longitude |
|
1573 | + * |
|
1574 | + * @param Float $latitude latitute of the flight |
|
1575 | + * @param Float $longitude longitute of the flight |
|
1576 | + * @return String the countrie |
|
1577 | + */ |
|
1578 | 1578 | public function getCountryFromLatitudeLongitude($latitude,$longitude) |
1579 | 1579 | { |
1580 | 1580 | global $globalDBdriver, $globalDebug; |
@@ -1611,11 +1611,11 @@ discard block |
||
1611 | 1611 | } |
1612 | 1612 | |
1613 | 1613 | /** |
1614 | - * Gets Country from iso2 |
|
1615 | - * |
|
1616 | - * @param String $iso2 ISO2 country code |
|
1617 | - * @return String the countrie |
|
1618 | - */ |
|
1614 | + * Gets Country from iso2 |
|
1615 | + * |
|
1616 | + * @param String $iso2 ISO2 country code |
|
1617 | + * @return String the countrie |
|
1618 | + */ |
|
1619 | 1619 | public function getCountryFromISO2($iso2) |
1620 | 1620 | { |
1621 | 1621 | global $globalDBdriver, $globalDebug; |
@@ -1643,11 +1643,11 @@ discard block |
||
1643 | 1643 | } |
1644 | 1644 | |
1645 | 1645 | /** |
1646 | - * Gets all vessels types that have flown over |
|
1647 | - * |
|
1648 | - * @return Array the vessel type list |
|
1649 | - * |
|
1650 | - */ |
|
1646 | + * Gets all vessels types that have flown over |
|
1647 | + * |
|
1648 | + * @return Array the vessel type list |
|
1649 | + * |
|
1650 | + */ |
|
1651 | 1651 | public function countAllTrackerTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
1652 | 1652 | { |
1653 | 1653 | global $globalDBdriver; |
@@ -1714,12 +1714,12 @@ discard block |
||
1714 | 1714 | |
1715 | 1715 | |
1716 | 1716 | /** |
1717 | - * Gets the short url from bit.ly |
|
1718 | - * |
|
1719 | - * @param String $url the full url |
|
1720 | - * @return String the bit.ly url |
|
1721 | - * |
|
1722 | - */ |
|
1717 | + * Gets the short url from bit.ly |
|
1718 | + * |
|
1719 | + * @param String $url the full url |
|
1720 | + * @return String the bit.ly url |
|
1721 | + * |
|
1722 | + */ |
|
1723 | 1723 | public function getBitlyURL($url) |
1724 | 1724 | { |
1725 | 1725 | global $globalBitlyAccessToken; |
@@ -9,25 +9,25 @@ discard block |
||
9 | 9 | require_once(dirname(__FILE__).'/class.Stats.php'); |
10 | 10 | require_once(dirname(__FILE__).'/class.Source.php'); |
11 | 11 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
12 | - require_once(dirname(__FILE__).'/class.APRS.php'); |
|
12 | + require_once(dirname(__FILE__).'/class.APRS.php'); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | class MarineImport { |
16 | - private $all_tracked = array(); |
|
17 | - private $last_delete_hourly = 0; |
|
18 | - private $last_delete = 0; |
|
19 | - private $stats = array(); |
|
20 | - private $tmd = 0; |
|
21 | - private $source_location = array(); |
|
22 | - public $db = null; |
|
23 | - public $nb = 0; |
|
16 | + private $all_tracked = array(); |
|
17 | + private $last_delete_hourly = 0; |
|
18 | + private $last_delete = 0; |
|
19 | + private $stats = array(); |
|
20 | + private $tmd = 0; |
|
21 | + private $source_location = array(); |
|
22 | + public $db = null; |
|
23 | + public $nb = 0; |
|
24 | 24 | |
25 | - public function __construct($dbc = null) { |
|
25 | + public function __construct($dbc = null) { |
|
26 | 26 | global $globalBeta, $globalServerAPRS, $APRSMarine, $globalNoDB; |
27 | 27 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
28 | - $Connection = new Connection($dbc); |
|
29 | - $this->db = $Connection->db(); |
|
30 | - date_default_timezone_set('UTC'); |
|
28 | + $Connection = new Connection($dbc); |
|
29 | + $this->db = $Connection->db(); |
|
30 | + date_default_timezone_set('UTC'); |
|
31 | 31 | } |
32 | 32 | // Get previous source stats |
33 | 33 | /* |
@@ -46,55 +46,55 @@ discard block |
||
46 | 46 | } |
47 | 47 | */ |
48 | 48 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
49 | - $APRSMarine = new APRSMarine(); |
|
50 | - //$APRSSpotter->connect(); |
|
49 | + $APRSMarine = new APRSMarine(); |
|
50 | + //$APRSSpotter->connect(); |
|
51 | + } |
|
51 | 52 | } |
52 | - } |
|
53 | 53 | |
54 | - public function checkAll() { |
|
54 | + public function checkAll() { |
|
55 | 55 | global $globalDebug; |
56 | 56 | if ($globalDebug) echo "Update last seen tracked data...\n"; |
57 | 57 | foreach ($this->all_tracked as $key => $flight) { |
58 | - if (isset($this->all_tracked[$key]['id'])) { |
|
58 | + if (isset($this->all_tracked[$key]['id'])) { |
|
59 | 59 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
60 | - $Marine = new Marine($this->db); |
|
61 | - $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
62 | - } |
|
60 | + $Marine = new Marine($this->db); |
|
61 | + $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
62 | + } |
|
63 | + } |
|
63 | 64 | } |
64 | - } |
|
65 | 65 | |
66 | - public function del() { |
|
66 | + public function del() { |
|
67 | 67 | global $globalDebug, $globalNoDB, $globalNoImport; |
68 | 68 | // Delete old infos |
69 | 69 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
70 | 70 | foreach ($this->all_tracked as $key => $flight) { |
71 | - if (isset($flight['lastupdate'])) { |
|
72 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
73 | - if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
74 | - if (isset($this->all_tracked[$key]['id'])) { |
|
75 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
76 | - /* |
|
71 | + if (isset($flight['lastupdate'])) { |
|
72 | + if ($flight['lastupdate'] < (time()-3000)) { |
|
73 | + if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
74 | + if (isset($this->all_tracked[$key]['id'])) { |
|
75 | + if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
76 | + /* |
|
77 | 77 | $MarineLive = new MarineLive(); |
78 | 78 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
79 | 79 | $MarineLive->db = null; |
80 | 80 | */ |
81 | - //$real_arrival = $this->arrival($key); |
|
82 | - $Marine = new Marine($this->db); |
|
83 | - if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
81 | + //$real_arrival = $this->arrival($key); |
|
82 | + $Marine = new Marine($this->db); |
|
83 | + if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
84 | 84 | $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
85 | 85 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
86 | - } |
|
87 | - // Put in archive |
|
86 | + } |
|
87 | + // Put in archive |
|
88 | 88 | // $Marine->db = null; |
89 | 89 | } |
90 | - } |
|
91 | - unset($this->all_tracked[$key]); |
|
92 | - } |
|
93 | - } |
|
94 | - } |
|
95 | - } |
|
90 | + } |
|
91 | + unset($this->all_tracked[$key]); |
|
92 | + } |
|
93 | + } |
|
94 | + } |
|
95 | + } |
|
96 | 96 | |
97 | - public function add($line) { |
|
97 | + public function add($line) { |
|
98 | 98 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
99 | 99 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
100 | 100 | date_default_timezone_set('UTC'); |
@@ -103,83 +103,83 @@ discard block |
||
103 | 103 | |
104 | 104 | // SBS format is CSV format |
105 | 105 | if(is_array($line) && isset($line['mmsi'])) { |
106 | - //print_r($line); |
|
107 | - if (isset($line['mmsi'])) { |
|
106 | + //print_r($line); |
|
107 | + if (isset($line['mmsi'])) { |
|
108 | 108 | |
109 | 109 | |
110 | 110 | // Increment message number |
111 | 111 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
112 | - $current_date = date('Y-m-d'); |
|
113 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
114 | - else $source = ''; |
|
115 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
116 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
117 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
118 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
119 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
112 | + $current_date = date('Y-m-d'); |
|
113 | + if (isset($line['source_name'])) $source = $line['source_name']; |
|
114 | + else $source = ''; |
|
115 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
116 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
117 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
118 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
119 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | |
123 | 123 | $Common = new Common(); |
124 | 124 | $AIS = new AIS(); |
125 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
126 | - else $id = trim($line['id']); |
|
125 | + if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
126 | + else $id = trim($line['id']); |
|
127 | 127 | |
128 | 128 | if (!isset($this->all_tracked[$id])) { |
129 | - $this->all_tracked[$id] = array(); |
|
130 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
131 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
|
132 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
133 | - if (!isset($line['id'])) { |
|
129 | + $this->all_tracked[$id] = array(); |
|
130 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
131 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
|
132 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
133 | + if (!isset($line['id'])) { |
|
134 | 134 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
135 | 135 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
136 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
137 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
136 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
137 | + if ($globalAllTracked !== FALSE) $dataFound = true; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
141 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
142 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
141 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
142 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
143 | 143 | $Marine = new Marine($this->db); |
144 | 144 | $identity = $Marine->getIdentity($line['mmsi']); |
145 | 145 | if (!empty($identity)) { |
146 | - $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
147 | - $this->all_tracked[$id]['type'] = $identity['type']; |
|
146 | + $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
147 | + $this->all_tracked[$id]['type'] = $identity['type']; |
|
148 | 148 | } |
149 | 149 | //print_r($identity); |
150 | 150 | unset($Marine); |
151 | 151 | //$dataFound = true; |
152 | - } |
|
152 | + } |
|
153 | 153 | } |
154 | 154 | if (isset($line['type_id'])) { |
155 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
155 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
156 | 156 | } |
157 | 157 | if (isset($line['type']) && $line['type'] != '') { |
158 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
158 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
159 | 159 | } |
160 | 160 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
161 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
161 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
162 | 162 | } |
163 | 163 | if (isset($line['imo']) && $line['imo'] != '') { |
164 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
164 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
165 | 165 | } |
166 | 166 | if (isset($line['callsign']) && $line['callsign'] != '') { |
167 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
167 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
168 | 168 | } |
169 | 169 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
170 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
170 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
171 | 171 | } |
172 | 172 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
173 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
173 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | |
177 | 177 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
178 | 178 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
179 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
180 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
179 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
180 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
181 | 181 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
182 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
182 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
183 | 183 | $timeelapsed = microtime(true); |
184 | 184 | $Marine = new Marine($this->db); |
185 | 185 | $fromsource = NULL; |
@@ -187,20 +187,20 @@ discard block |
||
187 | 187 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
188 | 188 | $Marine->db = null; |
189 | 189 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
190 | - } |
|
190 | + } |
|
191 | + } |
|
191 | 192 | } |
192 | - } |
|
193 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
193 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
197 | - if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
197 | + if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
198 | 198 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
199 | - } else { |
|
199 | + } else { |
|
200 | 200 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
201 | 201 | elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
202 | 202 | return ''; |
203 | - } |
|
203 | + } |
|
204 | 204 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
205 | 205 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
206 | 206 | return ''; |
@@ -217,24 +217,24 @@ discard block |
||
217 | 217 | |
218 | 218 | |
219 | 219 | if (isset($line['speed'])) { |
220 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
221 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
220 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
221 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
222 | 222 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
223 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
224 | - if ($distance > 1000 && $distance < 10000) { |
|
223 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
224 | + if ($distance > 1000 && $distance < 10000) { |
|
225 | 225 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
226 | 226 | $speed = $speed*3.6; |
227 | 227 | if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
228 | 228 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
229 | - } |
|
229 | + } |
|
230 | 230 | } |
231 | 231 | |
232 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
233 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
234 | - else unset($timediff); |
|
235 | - if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
232 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
233 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
234 | + else unset($timediff); |
|
235 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
236 | 236 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
237 | - if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
237 | + if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
238 | 238 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
239 | 239 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
240 | 240 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -242,211 +242,211 @@ discard block |
||
242 | 242 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
243 | 243 | $timeelapsed = microtime(true); |
244 | 244 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
245 | - $Marine = new Marine($this->db); |
|
246 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
247 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
248 | - $Marine->db = null; |
|
249 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
245 | + $Marine = new Marine($this->db); |
|
246 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
247 | + if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
248 | + $Marine->db = null; |
|
249 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
250 | 250 | } |
251 | 251 | $this->tmd = 0; |
252 | 252 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
253 | - } |
|
253 | + } |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
257 | 257 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
258 | 258 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
259 | - $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
260 | - $dataFound = true; |
|
261 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
259 | + $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
260 | + $dataFound = true; |
|
261 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
262 | 262 | } |
263 | 263 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
264 | 264 | } |
265 | 265 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
266 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
266 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
267 | 267 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
268 | 268 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
269 | - $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
270 | - $dataFound = true; |
|
271 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
269 | + $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
270 | + $dataFound = true; |
|
271 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
272 | 272 | } |
273 | 273 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
274 | 274 | } |
275 | 275 | |
276 | - } else if ($globalDebug && $timediff > 20) { |
|
276 | + } else if ($globalDebug && $timediff > 20) { |
|
277 | 277 | $this->tmd = $this->tmd + 1; |
278 | 278 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
279 | 279 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
280 | 280 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
281 | 281 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
282 | - } |
|
282 | + } |
|
283 | 283 | } |
284 | 284 | if (isset($line['last_update']) && $line['last_update'] != '') { |
285 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
286 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
285 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
286 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
287 | 287 | } |
288 | 288 | if (isset($line['format_source']) && $line['format_source'] != '') { |
289 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
289 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
290 | 290 | } |
291 | 291 | if (isset($line['source_name']) && $line['source_name'] != '') { |
292 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
292 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
293 | 293 | } |
294 | 294 | if (isset($line['status']) && $line['status'] != '') { |
295 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
295 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
296 | 296 | } |
297 | 297 | if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) { |
298 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
299 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
298 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
299 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
300 | 300 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
301 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
301 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
302 | 302 | $Marine = new Marine($this->db); |
303 | 303 | $Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']); |
304 | 304 | unset($Marine); |
305 | - } |
|
305 | + } |
|
306 | + } |
|
306 | 307 | } |
307 | - } |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
311 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
311 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | if (isset($line['heading']) && $line['heading'] != '') { |
315 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
316 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
317 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
318 | - //$dataFound = true; |
|
315 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
316 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
317 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
318 | + //$dataFound = true; |
|
319 | 319 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
320 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
321 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
322 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
323 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
320 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
321 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
322 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
323 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
324 | 324 | } |
325 | 325 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
326 | 326 | |
327 | 327 | |
328 | 328 | |
329 | 329 | if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) { |
330 | - $this->all_tracked[$id]['lastupdate'] = time(); |
|
331 | - if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
332 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
333 | - if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
330 | + $this->all_tracked[$id]['lastupdate'] = time(); |
|
331 | + if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
332 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
333 | + if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
334 | 334 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
335 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
336 | - $timeelapsed = microtime(true); |
|
337 | - $MarineLive = new MarineLive($this->db); |
|
338 | - if (isset($line['id'])) { |
|
335 | + if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
336 | + $timeelapsed = microtime(true); |
|
337 | + $MarineLive = new MarineLive($this->db); |
|
338 | + if (isset($line['id'])) { |
|
339 | 339 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
340 | 340 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
341 | - } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
341 | + } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
342 | 342 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
343 | 343 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
344 | - } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
344 | + } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
345 | 345 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
346 | 346 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
347 | - } else $recent_ident = ''; |
|
348 | - $MarineLive->db=null; |
|
349 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
350 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
347 | + } else $recent_ident = ''; |
|
348 | + $MarineLive->db=null; |
|
349 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
350 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
351 | 351 | } else $recent_ident = ''; |
352 | - } else { |
|
352 | + } else { |
|
353 | 353 | $recent_ident = ''; |
354 | 354 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
355 | - } |
|
356 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
357 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
358 | - { |
|
355 | + } |
|
356 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
357 | + if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
358 | + { |
|
359 | 359 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
360 | 360 | //adds the spotter data for the archive |
361 | - $highlight = ''; |
|
362 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
363 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
361 | + $highlight = ''; |
|
362 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
363 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
364 | 364 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
365 | - $timeelapsed = microtime(true); |
|
366 | - $Marine = new Marine($this->db); |
|
367 | - $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
368 | - $Marine->db = null; |
|
369 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
370 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
365 | + $timeelapsed = microtime(true); |
|
366 | + $Marine = new Marine($this->db); |
|
367 | + $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
368 | + $Marine->db = null; |
|
369 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
370 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
371 | 371 | } |
372 | - } |
|
373 | - if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
|
372 | + } |
|
373 | + if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
|
374 | 374 | // Add source stat in DB |
375 | 375 | $Stats = new Stats($this->db); |
376 | 376 | if (!empty($this->stats)) { |
377 | - if ($globalDebug) echo 'Add source stats : '; |
|
378 | - foreach($this->stats as $date => $data) { |
|
377 | + if ($globalDebug) echo 'Add source stats : '; |
|
378 | + foreach($this->stats as $date => $data) { |
|
379 | 379 | foreach($data as $source => $sourced) { |
380 | - //print_r($sourced); |
|
381 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
382 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
383 | - if (isset($sourced['msg'])) { |
|
384 | - if (time() - $sourced['msg']['date'] > 10) { |
|
385 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
386 | - echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
387 | - unset($this->stats[$date][$source]['msg']); |
|
388 | - } |
|
389 | - } |
|
390 | - } |
|
391 | - if ($date != date('Y-m-d')) { |
|
392 | - unset($this->stats[$date]); |
|
393 | - } |
|
394 | - } |
|
395 | - if ($globalDebug) echo 'Done'."\n"; |
|
380 | + //print_r($sourced); |
|
381 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
382 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
383 | + if (isset($sourced['msg'])) { |
|
384 | + if (time() - $sourced['msg']['date'] > 10) { |
|
385 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
386 | + echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
387 | + unset($this->stats[$date][$source]['msg']); |
|
388 | + } |
|
389 | + } |
|
390 | + } |
|
391 | + if ($date != date('Y-m-d')) { |
|
392 | + unset($this->stats[$date]); |
|
393 | + } |
|
394 | + } |
|
395 | + if ($globalDebug) echo 'Done'."\n"; |
|
396 | 396 | } |
397 | 397 | $Stats->db = null; |
398 | - } |
|
398 | + } |
|
399 | 399 | |
400 | - $this->del(); |
|
400 | + $this->del(); |
|
401 | 401 | //$ignoreImport = false; |
402 | 402 | $this->all_tracked[$id]['addedMarine'] = 1; |
403 | 403 | //print_r($this->all_tracked[$id]); |
404 | 404 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
405 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
406 | - //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
407 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
405 | + if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
406 | + //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
407 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
408 | 408 | $MarineLive = new MarineLive($this->db); |
409 | 409 | $MarineLive->deleteLiveMarineData(); |
410 | 410 | $MarineLive->db=null; |
411 | 411 | if ($globalDebug) echo " Done\n"; |
412 | - } |
|
413 | - $this->last_delete = time(); |
|
412 | + } |
|
413 | + $this->last_delete = time(); |
|
414 | 414 | } |
415 | - } elseif ($recent_ident != '') { |
|
415 | + } elseif ($recent_ident != '') { |
|
416 | 416 | $this->all_tracked[$id]['id'] = $recent_ident; |
417 | 417 | $this->all_tracked[$id]['addedMarine'] = 1; |
418 | 418 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
419 | - if (isset($globalDaemon) && !$globalDaemon) { |
|
419 | + if (isset($globalDaemon) && !$globalDaemon) { |
|
420 | 420 | $Marine = new Marine($this->db); |
421 | 421 | $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']); |
422 | 422 | $Marine->db = null; |
423 | - } |
|
423 | + } |
|
424 | 424 | } |
425 | 425 | |
426 | - } |
|
426 | + } |
|
427 | + } |
|
427 | 428 | } |
428 | - } |
|
429 | - //adds the spotter LIVE data |
|
430 | - if ($globalDebug) { |
|
429 | + //adds the spotter LIVE data |
|
430 | + if ($globalDebug) { |
|
431 | 431 | echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n"; |
432 | - } |
|
433 | - $ignoreImport = false; |
|
432 | + } |
|
433 | + $ignoreImport = false; |
|
434 | 434 | |
435 | - if (!$ignoreImport) { |
|
435 | + if (!$ignoreImport) { |
|
436 | 436 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
437 | 437 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
438 | 438 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
439 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
439 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
440 | 440 | $timeelapsed = microtime(true); |
441 | 441 | $MarineLive = new MarineLive($this->db); |
442 | 442 | $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
443 | 443 | $MarineLive->db = null; |
444 | 444 | if ($globalDebug) echo $result."\n"; |
445 | 445 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
446 | - } |
|
446 | + } |
|
447 | 447 | } |
448 | 448 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
449 | - $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
449 | + $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
450 | 450 | } |
451 | 451 | $this->all_tracked[$id]['putinarchive'] = false; |
452 | 452 | |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | if ($stats_heading == 16) $stats_heading = 0; |
479 | 479 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
480 | 480 | for ($i=0;$i<=15;$i++) { |
481 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
481 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
482 | 482 | } |
483 | 483 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
484 | 484 | } else { |
@@ -491,11 +491,11 @@ discard block |
||
491 | 491 | //var_dump($this->stats); |
492 | 492 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
493 | 493 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
494 | - end($this->stats[$current_date][$source]['hist']); |
|
495 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
494 | + end($this->stats[$current_date][$source]['hist']); |
|
495 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
496 | 496 | } else $mini = 0; |
497 | 497 | for ($i=$mini;$i<=$distance;$i+=10) { |
498 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
498 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
499 | 499 | } |
500 | 500 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
501 | 501 | } else { |
@@ -511,24 +511,24 @@ discard block |
||
511 | 511 | |
512 | 512 | |
513 | 513 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
514 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
514 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
515 | 515 | if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
516 | 516 | $MarineLive = new MarineLive($this->db); |
517 | 517 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
518 | 518 | $MarineLive->db = null; |
519 | 519 | //MarineLive->deleteLiveMarineData(); |
520 | 520 | if ($globalDebug) echo " Done\n"; |
521 | - } |
|
522 | - $this->last_delete_hourly = time(); |
|
521 | + } |
|
522 | + $this->last_delete_hourly = time(); |
|
523 | 523 | } |
524 | 524 | |
525 | - } |
|
526 | - //$ignoreImport = false; |
|
525 | + } |
|
526 | + //$ignoreImport = false; |
|
527 | 527 | } |
528 | 528 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
529 | 529 | if ($send) return $this->all_tracked[$id]; |
530 | - } |
|
530 | + } |
|
531 | + } |
|
531 | 532 | } |
532 | - } |
|
533 | 533 | } |
534 | 534 | ?> |
@@ -39,30 +39,30 @@ discard block |
||
39 | 39 | |
40 | 40 | |
41 | 41 | function quaternionrotate($heading, $attitude = 0, $bank = 0) { |
42 | - // Assuming the angles are in radians. |
|
43 | - $c1 = cos($heading/2); |
|
44 | - $s1 = sin($heading/2); |
|
45 | - $c2 = cos($attitude/2); |
|
46 | - $s2 = sin($attitude/2); |
|
47 | - $c3 = cos($bank/2); |
|
48 | - $s3 = sin($bank/2); |
|
49 | - $c1c2 = $c1*$c2; |
|
50 | - $s1s2 = $s1*$s2; |
|
51 | - $w =$c1c2*$c3 - $s1s2*$s3; |
|
52 | - $x =$c1c2*$s3 + $s1s2*$c3; |
|
53 | - $y =$s1*$c2*$c3 + $c1*$s2*$s3; |
|
54 | - $z =$c1*$s2*$c3 - $s1*$c2*$s3; |
|
55 | - return array('x' => $x,'y' => $y,'z' => $z,'w' => $w); |
|
42 | + // Assuming the angles are in radians. |
|
43 | + $c1 = cos($heading/2); |
|
44 | + $s1 = sin($heading/2); |
|
45 | + $c2 = cos($attitude/2); |
|
46 | + $s2 = sin($attitude/2); |
|
47 | + $c3 = cos($bank/2); |
|
48 | + $s3 = sin($bank/2); |
|
49 | + $c1c2 = $c1*$c2; |
|
50 | + $s1s2 = $s1*$s2; |
|
51 | + $w =$c1c2*$c3 - $s1s2*$s3; |
|
52 | + $x =$c1c2*$s3 + $s1s2*$c3; |
|
53 | + $y =$s1*$c2*$c3 + $c1*$s2*$s3; |
|
54 | + $z =$c1*$s2*$c3 - $s1*$c2*$s3; |
|
55 | + return array('x' => $x,'y' => $y,'z' => $z,'w' => $w); |
|
56 | 56 | // return array('x' => '0.0','y' => '-0.931','z' => '0.0','w' => '0.365'); |
57 | 57 | |
58 | 58 | } |
59 | 59 | |
60 | 60 | |
61 | 61 | if (isset($_GET['download'])) { |
62 | - if ($_GET['download'] == "true") |
|
63 | - { |
|
62 | + if ($_GET['download'] == "true") |
|
63 | + { |
|
64 | 64 | header('Content-disposition: attachment; filename="flightairmap.json"'); |
65 | - } |
|
65 | + } |
|
66 | 66 | } |
67 | 67 | header('Content-Type: text/javascript'); |
68 | 68 | |
@@ -229,10 +229,10 @@ discard block |
||
229 | 229 | $image = "images/placeholder_thumb.png"; |
230 | 230 | } |
231 | 231 | |
232 | - if (isset($spotter_item['flightaware_id'])) $id = $spotter_item['flightaware_id']; |
|
233 | - elseif (isset($spotter_item['famtrackid'])) $id = $spotter_item['famtrackid']; |
|
234 | - elseif (isset($spotter_item['fammarine_id'])) $id = $spotter_item['fammarine_id']; |
|
235 | - if ($prev_flightaware_id != $id) { |
|
232 | + if (isset($spotter_item['flightaware_id'])) $id = $spotter_item['flightaware_id']; |
|
233 | + elseif (isset($spotter_item['famtrackid'])) $id = $spotter_item['famtrackid']; |
|
234 | + elseif (isset($spotter_item['fammarine_id'])) $id = $spotter_item['fammarine_id']; |
|
235 | + if ($prev_flightaware_id != $id) { |
|
236 | 236 | if ($prev_flightaware_id != '') { |
237 | 237 | $output .= ']'; |
238 | 238 | $output .= '}'; |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | $spotter_item['wake_category'] = $aircraft_info[0]['wake_category']; |
272 | 272 | $spotter_item['engine_count'] = $aircraft_info[0]['engine_count']; |
273 | 273 | } else $aircraft_shadow = ''; |
274 | - $output .= ' "billboard" : {"image" : "'.$globalURL.'/images/aircrafts/new/'.$aircraft_shadow.'","scale" : 0.5'; |
|
274 | + $output .= ' "billboard" : {"image" : "'.$globalURL.'/images/aircrafts/new/'.$aircraft_shadow.'","scale" : 0.5'; |
|
275 | 275 | if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] && isset($_COOKIE['IconColor'])) { |
276 | 276 | $rgb = $Common->hex2rgb($_COOKIE['IconColor']); |
277 | 277 | $output .= ',"color": {"rgba" : ['.$rgb[0].','.$rgb[1].','.$rgb[2].',255]}'; |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | $rgb = $Common->hex2rgb($_COOKIE['IconColor']); |
302 | 302 | $output .= ',"color": {"rgba" : ['.$rgb[0].','.$rgb[1].','.$rgb[2].',255]}'; |
303 | 303 | } |
304 | - $output .= '},'; |
|
304 | + $output .= '},'; |
|
305 | 305 | } elseif ($aircraft_icao != '') { |
306 | 306 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_icao); |
307 | 307 | if (isset($aircraft_info[0]['engine_type'])) { |
@@ -10,61 +10,61 @@ discard block |
||
10 | 10 | } |
11 | 11 | |
12 | 12 | |
13 | - /** |
|
14 | - * Get SQL query part for filter used |
|
15 | - * @param Array $filter the filter |
|
16 | - * @return Array the SQL part |
|
17 | - */ |
|
18 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
13 | + /** |
|
14 | + * Get SQL query part for filter used |
|
15 | + * @param Array $filter the filter |
|
16 | + * @return Array the SQL part |
|
17 | + */ |
|
18 | + public function getFilter($filter = array(),$where = false,$and = false) { |
|
19 | 19 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
20 | 20 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
21 | - if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
|
21 | + if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
|
22 | 22 | foreach($globalStatsFilters[$globalFilterName] as $source) { |
23 | 23 | if (isset($source['source'])) $filter['source'][] = $source['source']; |
24 | 24 | } |
25 | - } else { |
|
25 | + } else { |
|
26 | 26 | $filter = $globalStatsFilters[$globalFilterName]; |
27 | - } |
|
27 | + } |
|
28 | 28 | } |
29 | 29 | if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
30 | 30 | $filter_query_join = ''; |
31 | 31 | $filter_query_where = ''; |
32 | 32 | if (isset($filter['source']) && !empty($filter['source'])) { |
33 | - $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
|
33 | + $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
|
34 | 34 | } |
35 | 35 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
36 | 36 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
37 | 37 | $filter_query = $filter_query_join.$filter_query_where; |
38 | 38 | return $filter_query; |
39 | - } |
|
39 | + } |
|
40 | 40 | |
41 | - public function getAll() { |
|
42 | - $filter_query = $this->getFilter(array()); |
|
43 | - $query = "SELECT * FROM atc".$filter_query; |
|
44 | - $query_values = array(); |
|
45 | - try { |
|
46 | - $sth = $this->db->prepare($query); |
|
47 | - $sth->execute($query_values); |
|
48 | - } catch(PDOException $e) { |
|
49 | - return "error : ".$e->getMessage(); |
|
50 | - } |
|
51 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
52 | - return $all; |
|
53 | - } |
|
41 | + public function getAll() { |
|
42 | + $filter_query = $this->getFilter(array()); |
|
43 | + $query = "SELECT * FROM atc".$filter_query; |
|
44 | + $query_values = array(); |
|
45 | + try { |
|
46 | + $sth = $this->db->prepare($query); |
|
47 | + $sth->execute($query_values); |
|
48 | + } catch(PDOException $e) { |
|
49 | + return "error : ".$e->getMessage(); |
|
50 | + } |
|
51 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
52 | + return $all; |
|
53 | + } |
|
54 | 54 | |
55 | 55 | public function getById($id) { |
56 | - $filter_query = $this->getFilter(array(),true); |
|
57 | - $query = "SELECT * FROM atc".$filter_query." atc_id = :id"; |
|
58 | - $query_values = array(':id' => $id); |
|
59 | - try { |
|
60 | - $sth = $this->db->prepare($query); |
|
61 | - $sth->execute($query_values); |
|
62 | - } catch(PDOException $e) { |
|
63 | - return "error : ".$e->getMessage(); |
|
64 | - } |
|
65 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
66 | - return $all; |
|
67 | - } |
|
56 | + $filter_query = $this->getFilter(array(),true); |
|
57 | + $query = "SELECT * FROM atc".$filter_query." atc_id = :id"; |
|
58 | + $query_values = array(':id' => $id); |
|
59 | + try { |
|
60 | + $sth = $this->db->prepare($query); |
|
61 | + $sth->execute($query_values); |
|
62 | + } catch(PDOException $e) { |
|
63 | + return "error : ".$e->getMessage(); |
|
64 | + } |
|
65 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
66 | + return $all; |
|
67 | + } |
|
68 | 68 | |
69 | 69 | public function getByIdent($ident,$format_source = '') { |
70 | 70 | $filter_query = $this->getFilter(array(),true); |
@@ -117,53 +117,53 @@ discard block |
||
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | - public function deleteById($id) { |
|
121 | - $query = "DELETE FROM atc WHERE atc_id = :id"; |
|
122 | - $query_values = array(':id' => $id); |
|
123 | - try { |
|
124 | - $sth = $this->db->prepare($query); |
|
125 | - $sth->execute($query_values); |
|
126 | - } catch(PDOException $e) { |
|
127 | - return "error : ".$e->getMessage(); |
|
128 | - } |
|
129 | - } |
|
120 | + public function deleteById($id) { |
|
121 | + $query = "DELETE FROM atc WHERE atc_id = :id"; |
|
122 | + $query_values = array(':id' => $id); |
|
123 | + try { |
|
124 | + $sth = $this->db->prepare($query); |
|
125 | + $sth->execute($query_values); |
|
126 | + } catch(PDOException $e) { |
|
127 | + return "error : ".$e->getMessage(); |
|
128 | + } |
|
129 | + } |
|
130 | 130 | |
131 | - public function deleteByIdent($ident,$format_source) { |
|
132 | - $query = "DELETE FROM atc WHERE ident = :ident AND format_source = :format_source"; |
|
133 | - $query_values = array(':ident' => $ident,':format_source' => $format_source); |
|
134 | - try { |
|
135 | - $sth = $this->db->prepare($query); |
|
136 | - $sth->execute($query_values); |
|
137 | - } catch(PDOException $e) { |
|
138 | - return "error : ".$e->getMessage(); |
|
139 | - } |
|
140 | - } |
|
131 | + public function deleteByIdent($ident,$format_source) { |
|
132 | + $query = "DELETE FROM atc WHERE ident = :ident AND format_source = :format_source"; |
|
133 | + $query_values = array(':ident' => $ident,':format_source' => $format_source); |
|
134 | + try { |
|
135 | + $sth = $this->db->prepare($query); |
|
136 | + $sth->execute($query_values); |
|
137 | + } catch(PDOException $e) { |
|
138 | + return "error : ".$e->getMessage(); |
|
139 | + } |
|
140 | + } |
|
141 | 141 | |
142 | - public function deleteAll() { |
|
143 | - $query = "DELETE FROM atc"; |
|
144 | - $query_values = array(); |
|
145 | - try { |
|
146 | - $sth = $this->db->prepare($query); |
|
147 | - $sth->execute($query_values); |
|
148 | - } catch(PDOException $e) { |
|
149 | - return "error : ".$e->getMessage(); |
|
150 | - } |
|
151 | - } |
|
142 | + public function deleteAll() { |
|
143 | + $query = "DELETE FROM atc"; |
|
144 | + $query_values = array(); |
|
145 | + try { |
|
146 | + $sth = $this->db->prepare($query); |
|
147 | + $sth->execute($query_values); |
|
148 | + } catch(PDOException $e) { |
|
149 | + return "error : ".$e->getMessage(); |
|
150 | + } |
|
151 | + } |
|
152 | 152 | |
153 | 153 | public function deleteOldATC() { |
154 | - global $globalDBdriver; |
|
155 | - if ($globalDBdriver == 'mysql') { |
|
156 | - $query = "DELETE FROM atc WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= atc.atc_lastseen"; |
|
157 | - } else { |
|
158 | - $query = "DELETE FROM atc WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR' >= atc.atc_lastseen"; |
|
159 | - } |
|
160 | - try { |
|
161 | - $sth = $this->db->prepare($query); |
|
162 | - $sth->execute(); |
|
163 | - } catch(PDOException $e) { |
|
164 | - return "error"; |
|
165 | - } |
|
166 | - return "success"; |
|
167 | - } |
|
154 | + global $globalDBdriver; |
|
155 | + if ($globalDBdriver == 'mysql') { |
|
156 | + $query = "DELETE FROM atc WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= atc.atc_lastseen"; |
|
157 | + } else { |
|
158 | + $query = "DELETE FROM atc WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR' >= atc.atc_lastseen"; |
|
159 | + } |
|
160 | + try { |
|
161 | + $sth = $this->db->prepare($query); |
|
162 | + $sth->execute(); |
|
163 | + } catch(PDOException $e) { |
|
164 | + return "error"; |
|
165 | + } |
|
166 | + return "success"; |
|
167 | + } |
|
168 | 168 | } |
169 | 169 | ?> |
170 | 170 | \ No newline at end of file |
@@ -720,12 +720,12 @@ |
||
720 | 720 | update_airportsLayer(); |
721 | 721 | } |
722 | 722 | <?php |
723 | - if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
|
723 | + if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
|
724 | 724 | ?> |
725 | 725 | update_atcLayer(); |
726 | 726 | setInterval(function(){update_atcLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>); |
727 | 727 | <?php |
728 | - } |
|
728 | + } |
|
729 | 729 | ?> |
730 | 730 | |
731 | 731 | function iconColor(color) { |
@@ -40,15 +40,15 @@ |
||
40 | 40 | //print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>'; |
41 | 41 | print '<div><span>'._("Coordinates").'</span>'.round($spotter_item['latitude'],3).', '.round($spotter_item['longitude'],3).'</div>'; |
42 | 42 | if ($spotter_item['atc_range'] > 0) { |
43 | - print '<div><span>'._("Range").'</span>'; |
|
44 | - print $spotter_item['atc_range']; |
|
45 | - print '</div>'; |
|
43 | + print '<div><span>'._("Range").'</span>'; |
|
44 | + print $spotter_item['atc_range']; |
|
45 | + print '</div>'; |
|
46 | 46 | } |
47 | 47 | print '</div>'; |
48 | 48 | if ($spotter_item['info'] != '') { |
49 | - print '<div class="notamtext"><span>'._("Info").'</span>'; |
|
50 | - print $spotter_item['info']; |
|
51 | - print '</div>'; |
|
49 | + print '<div class="notamtext"><span>'._("Info").'</span>'; |
|
50 | + print $spotter_item['info']; |
|
51 | + print '</div>'; |
|
52 | 52 | } |
53 | 53 | print '</div>'; |
54 | 54 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | date_default_timezone_set('UTC'); |
25 | 25 | //waypoint plotting |
26 | 26 | $output .= '{"type": "Feature",'; |
27 | - $output .= '"properties": {'; |
|
27 | + $output .= '"properties": {'; |
|
28 | 28 | $output .= '"ref": "'.$spotter_item['atc_id'].'",'; |
29 | 29 | $output .= '"ident": "'.$spotter_item['ident'].'",'; |
30 | 30 | $output .= '"frequency": "'.$spotter_item['frequency'].'",'; |
@@ -50,18 +50,18 @@ discard block |
||
50 | 50 | } else { |
51 | 51 | $output .= '"icon": "images/atc.png"'; |
52 | 52 | } |
53 | - $output .= '},'; |
|
54 | - $output .= '"geometry": {'; |
|
53 | + $output .= '},'; |
|
54 | + $output .= '"geometry": {'; |
|
55 | 55 | $output .= '"type": "Point",'; |
56 | 56 | $output .= '"coordinates": ['; |
57 | - $output .= $spotter_item['longitude'].', '.$spotter_item['latitude']; |
|
57 | + $output .= $spotter_item['longitude'].', '.$spotter_item['latitude']; |
|
58 | 58 | $output .= ']'; |
59 | - $output .= '}'; |
|
59 | + $output .= '}'; |
|
60 | 60 | $output .= '},'; |
61 | 61 | $radius = $spotter_item['atc_range']*100; |
62 | 62 | if ($radius > 0) { |
63 | 63 | $output .= '{"type": "Feature",'; |
64 | - $output .= '"properties": {'; |
|
64 | + $output .= '"properties": {'; |
|
65 | 65 | $output .= '"ref": "'.$spotter_item['atc_id'].'",'; |
66 | 66 | $output .= '"ident": "'.$spotter_item['ident'].'",'; |
67 | 67 | $output .= '"frequency": "'.$spotter_item['frequency'].'",'; |
@@ -87,13 +87,13 @@ discard block |
||
87 | 87 | } else { |
88 | 88 | $output .= '"atccolor": "#888219"'; |
89 | 89 | } |
90 | - $output .= '},'; |
|
91 | - $output .= '"geometry": {'; |
|
90 | + $output .= '},'; |
|
91 | + $output .= '"geometry": {'; |
|
92 | 92 | $output .= '"type": "Point",'; |
93 | 93 | $output .= '"coordinates": ['; |
94 | - $output .= $spotter_item['longitude'].', '.$spotter_item['latitude']; |
|
94 | + $output .= $spotter_item['longitude'].', '.$spotter_item['latitude']; |
|
95 | 95 | $output .= ']'; |
96 | - $output .= '}'; |
|
96 | + $output .= '}'; |
|
97 | 97 | $output .= '},'; |
98 | 98 | } |
99 | 99 | } |
@@ -79,24 +79,24 @@ discard block |
||
79 | 79 | <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Arrivals seen"); ?></span> |
80 | 80 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
81 | 81 | <?php |
82 | - if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) { |
|
82 | + if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) { |
|
83 | 83 | ?> |
84 | 84 | <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Pilots"); ?></span> |
85 | 85 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
86 | 86 | <?php |
87 | - } |
|
88 | - if ((isset($globalUseOwner) && $globalUseOwner) || (!isset($globalUseOwner) && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM))) { |
|
89 | - ?> |
|
87 | + } |
|
88 | + if ((isset($globalUseOwner) && $globalUseOwner) || (!isset($globalUseOwner) && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM))) { |
|
89 | + ?> |
|
90 | 90 | <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Owners"); ?></span> |
91 | 91 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
92 | 92 | <?php |
93 | - } |
|
94 | - ?> |
|
93 | + } |
|
94 | + ?> |
|
95 | 95 | <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Aircrafts types"); ?></span> |
96 | 96 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
97 | 97 | <?php |
98 | - if ($airline_icao == '') { |
|
99 | - ?> |
|
98 | + if ($airline_icao == '') { |
|
99 | + ?> |
|
100 | 100 | <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name,$year,$month)); ?></span> <?php echo _("Airlines"); ?></span> |
101 | 101 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
102 | 102 | <?php |
@@ -139,39 +139,39 @@ discard block |
||
139 | 139 | <div class="col-md-6"> |
140 | 140 | <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2> |
141 | 141 | <?php |
142 | - $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month); |
|
143 | - if (count($aircraft_array) == 0) print _("No data available"); |
|
144 | - else { |
|
145 | - print '<div id="chart1" class="chart" width="100%"></div><script>'; |
|
146 | - $aircraft_data = ''; |
|
147 | - foreach($aircraft_array as $aircraft_item) |
|
148 | - { |
|
149 | - if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
|
150 | - else $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
|
151 | - } |
|
152 | - $aircraft_data = substr($aircraft_data, 0, -1); |
|
153 | - print 'var series = ['.$aircraft_data.'];'; |
|
154 | - 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);'; |
|
155 | - print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#e6e6f6","#1a3151"]);'; |
|
156 | - print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});'; |
|
157 | - 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":'; |
|
158 | - print 'dataset'; |
|
159 | - 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}}});'; |
|
160 | - print '</script>'; |
|
161 | - } |
|
162 | - ?> |
|
142 | + $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month); |
|
143 | + if (count($aircraft_array) == 0) print _("No data available"); |
|
144 | + else { |
|
145 | + print '<div id="chart1" class="chart" width="100%"></div><script>'; |
|
146 | + $aircraft_data = ''; |
|
147 | + foreach($aircraft_array as $aircraft_item) |
|
148 | + { |
|
149 | + if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
|
150 | + else $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
|
151 | + } |
|
152 | + $aircraft_data = substr($aircraft_data, 0, -1); |
|
153 | + print 'var series = ['.$aircraft_data.'];'; |
|
154 | + 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);'; |
|
155 | + print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#e6e6f6","#1a3151"]);'; |
|
156 | + print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});'; |
|
157 | + 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":'; |
|
158 | + print 'dataset'; |
|
159 | + 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}}});'; |
|
160 | + print '</script>'; |
|
161 | + } |
|
162 | + ?> |
|
163 | 163 | <div class="more"> |
164 | 164 | <?php |
165 | - if ($year != '' && $month != '') { |
|
166 | - ?> |
|
165 | + if ($year != '' && $month != '') { |
|
166 | + ?> |
|
167 | 167 | <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> |
168 | 168 | <?php |
169 | - } else { |
|
170 | - ?> |
|
169 | + } else { |
|
170 | + ?> |
|
171 | 171 | <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> |
172 | 172 | <?php |
173 | - } |
|
174 | - ?> |
|
173 | + } |
|
174 | + ?> |
|
175 | 175 | </div> |
176 | 176 | </div> |
177 | 177 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -224,29 +224,29 @@ discard block |
||
224 | 224 | <div class="col-md-6"> |
225 | 225 | <h2><?php echo _("Top 10 Most Common Vessel Type"); ?></h2> |
226 | 226 | <?php |
227 | - $marine_array = $Marine->countAllMarineTypes(true,0,'',array(),$year,$month); |
|
228 | - if (count($marine_array) == 0) print _("No data available"); |
|
229 | - else { |
|
230 | - print '<div id="chart1" class="chart" width="100%"></div><script>'; |
|
231 | - $marine_data = ''; |
|
232 | - foreach($marine_array as $marine_item) |
|
233 | - { |
|
234 | - $marine_data .= '["'.$marine_item['marine_type'].'",'.$marine_item['marine_type_count'].'],'; |
|
235 | - } |
|
236 | - $marine_data = substr($marine_data, 0, -1); |
|
237 | - print 'var series = ['.$marine_data.'];'; |
|
238 | - 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);'; |
|
239 | - print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#e6e6f6","#1a3151"]);'; |
|
240 | - print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});'; |
|
241 | - print 'var marinetype = 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":'; |
|
242 | - print 'dataset'; |
|
243 | - 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}}});'; |
|
244 | - print '</script>'; |
|
245 | - } |
|
246 | - ?> |
|
227 | + $marine_array = $Marine->countAllMarineTypes(true,0,'',array(),$year,$month); |
|
228 | + if (count($marine_array) == 0) print _("No data available"); |
|
229 | + else { |
|
230 | + print '<div id="chart1" class="chart" width="100%"></div><script>'; |
|
231 | + $marine_data = ''; |
|
232 | + foreach($marine_array as $marine_item) |
|
233 | + { |
|
234 | + $marine_data .= '["'.$marine_item['marine_type'].'",'.$marine_item['marine_type_count'].'],'; |
|
235 | + } |
|
236 | + $marine_data = substr($marine_data, 0, -1); |
|
237 | + print 'var series = ['.$marine_data.'];'; |
|
238 | + 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);'; |
|
239 | + print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#e6e6f6","#1a3151"]);'; |
|
240 | + print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});'; |
|
241 | + print 'var marinetype = 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":'; |
|
242 | + print 'dataset'; |
|
243 | + 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}}});'; |
|
244 | + print '</script>'; |
|
245 | + } |
|
246 | + ?> |
|
247 | 247 | <div class="more"> |
248 | 248 | <?php |
249 | - /* |
|
249 | + /* |
|
250 | 250 | if ($year != '' && $month != '') { |
251 | 251 | ?> |
252 | 252 | <a href="<?php print $globalURL; ?>/marine/statistics/type/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | <?php |
258 | 258 | } |
259 | 259 | */ |
260 | - ?> |
|
260 | + ?> |
|
261 | 261 | </div> |
262 | 262 | </div> |
263 | 263 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -272,29 +272,29 @@ discard block |
||
272 | 272 | <div class="col-md-6"> |
273 | 273 | <h2><?php echo _("Top 10 Most Common Tracker Type"); ?></h2> |
274 | 274 | <?php |
275 | - $tracker_array = $Tracker->countAllTrackerTypes(true,0,'',array(),$year,$month); |
|
276 | - if (count($tracker_array) == 0) print _("No data available"); |
|
277 | - else { |
|
278 | - print '<div id="chart1" class="chart" width="100%"></div><script>'; |
|
279 | - $tracker_data = ''; |
|
280 | - foreach($tracker_array as $tracker_item) |
|
281 | - { |
|
282 | - $tracker_data .= '["'.$tracker_item['tracker_type'].'",'.$tracker_item['tracker_type_count'].'],'; |
|
283 | - } |
|
284 | - $tracker_data = substr($tracker_data, 0, -1); |
|
285 | - print 'var series = ['.$tracker_data.'];'; |
|
286 | - 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);'; |
|
287 | - print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#e6e6f6","#1a3151"]);'; |
|
288 | - print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});'; |
|
289 | - print 'var trackertype = 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":'; |
|
290 | - print 'dataset'; |
|
291 | - 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}}});'; |
|
292 | - print '</script>'; |
|
293 | - } |
|
294 | - ?> |
|
275 | + $tracker_array = $Tracker->countAllTrackerTypes(true,0,'',array(),$year,$month); |
|
276 | + if (count($tracker_array) == 0) print _("No data available"); |
|
277 | + else { |
|
278 | + print '<div id="chart1" class="chart" width="100%"></div><script>'; |
|
279 | + $tracker_data = ''; |
|
280 | + foreach($tracker_array as $tracker_item) |
|
281 | + { |
|
282 | + $tracker_data .= '["'.$tracker_item['tracker_type'].'",'.$tracker_item['tracker_type_count'].'],'; |
|
283 | + } |
|
284 | + $tracker_data = substr($tracker_data, 0, -1); |
|
285 | + print 'var series = ['.$tracker_data.'];'; |
|
286 | + 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);'; |
|
287 | + print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#e6e6f6","#1a3151"]);'; |
|
288 | + print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});'; |
|
289 | + print 'var trackertype = 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":'; |
|
290 | + print 'dataset'; |
|
291 | + 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}}});'; |
|
292 | + print '</script>'; |
|
293 | + } |
|
294 | + ?> |
|
295 | 295 | <div class="more"> |
296 | 296 | <?php |
297 | - /* |
|
297 | + /* |
|
298 | 298 | if ($year != '' && $month != '') { |
299 | 299 | ?> |
300 | 300 | <a href="<?php print $globalURL; ?>/marine/statistics/type/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | <?php |
306 | 306 | } |
307 | 307 | */ |
308 | - ?> |
|
308 | + ?> |
|
309 | 309 | </div> |
310 | 310 | </div> |
311 | 311 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -5,23 +5,23 @@ discard block |
||
5 | 5 | $marine = false; |
6 | 6 | $usecoord = false; |
7 | 7 | if (isset($_GET['tracker'])) { |
8 | - $tracker = true; |
|
8 | + $tracker = true; |
|
9 | 9 | } |
10 | 10 | if (isset($_GET['marine'])) { |
11 | - $marine = true; |
|
11 | + $marine = true; |
|
12 | 12 | } |
13 | 13 | if ($tracker) { |
14 | - require_once('require/class.Tracker.php'); |
|
15 | - require_once('require/class.TrackerLive.php'); |
|
16 | - require_once('require/class.TrackerArchive.php'); |
|
14 | + require_once('require/class.Tracker.php'); |
|
15 | + require_once('require/class.TrackerLive.php'); |
|
16 | + require_once('require/class.TrackerArchive.php'); |
|
17 | 17 | } elseif ($marine) { |
18 | - require_once('require/class.Marine.php'); |
|
19 | - require_once('require/class.MarineLive.php'); |
|
20 | - require_once('require/class.MarineArchive.php'); |
|
18 | + require_once('require/class.Marine.php'); |
|
19 | + require_once('require/class.MarineLive.php'); |
|
20 | + require_once('require/class.MarineArchive.php'); |
|
21 | 21 | } else { |
22 | - require_once('require/class.Spotter.php'); |
|
23 | - require_once('require/class.SpotterLive.php'); |
|
24 | - require_once('require/class.SpotterArchive.php'); |
|
22 | + require_once('require/class.Spotter.php'); |
|
23 | + require_once('require/class.SpotterLive.php'); |
|
24 | + require_once('require/class.SpotterArchive.php'); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | $begintime = microtime(true); |
@@ -41,10 +41,10 @@ discard block |
||
41 | 41 | $Common = new Common(); |
42 | 42 | |
43 | 43 | if (isset($_GET['download'])) { |
44 | - if ($_GET['download'] == "true") |
|
45 | - { |
|
44 | + if ($_GET['download'] == "true") |
|
45 | + { |
|
46 | 46 | header('Content-disposition: attachment; filename="flightairmap.json"'); |
47 | - } |
|
47 | + } |
|
48 | 48 | } |
49 | 49 | header('Content-Type: text/javascript'); |
50 | 50 | |
@@ -498,17 +498,17 @@ discard block |
||
498 | 498 | if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
499 | 499 | |
500 | 500 | if ( |
501 | - (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') |
|
502 | - || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory) |
|
501 | + (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') |
|
502 | + || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory) |
|
503 | 503 | // || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id'])) |
504 | 504 | // || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident']) |
505 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
506 | - || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']) |
|
507 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id'])) |
|
508 | - || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id']) |
|
509 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid'])) |
|
510 | - || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid']) |
|
511 | - ) { |
|
505 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
506 | + || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']) |
|
507 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id'])) |
|
508 | + || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id']) |
|
509 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid'])) |
|
510 | + || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid']) |
|
511 | + ) { |
|
512 | 512 | if ($tracker) { |
513 | 513 | if ($from_archive || $globalArchive) { |
514 | 514 | $spotter_history_array = $TrackerArchive->getAllArchiveTrackerDataById($spotter_item['famtrackid']); |
@@ -597,65 +597,65 @@ discard block |
||
597 | 597 | } |
598 | 598 | |
599 | 599 | if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
600 | - || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
|
601 | - && (isset($spotter_item['departure_airport']) |
|
602 | - && $spotter_item['departure_airport'] != 'NA' |
|
603 | - && isset($spotter_item['arrival_airport']) |
|
604 | - && $spotter_item['arrival_airport'] != 'NA' |
|
605 | - && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") |
|
606 | - || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) { |
|
607 | - if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
608 | - else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
609 | - if (isset($spotter_item['departure_airport_latitude'])) { |
|
600 | + || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
|
601 | + && (isset($spotter_item['departure_airport']) |
|
602 | + && $spotter_item['departure_airport'] != 'NA' |
|
603 | + && isset($spotter_item['arrival_airport']) |
|
604 | + && $spotter_item['arrival_airport'] != 'NA' |
|
605 | + && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") |
|
606 | + || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) { |
|
607 | + if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
608 | + else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
609 | + if (isset($spotter_item['departure_airport_latitude'])) { |
|
610 | 610 | $output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],'; |
611 | - } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') { |
|
611 | + } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') { |
|
612 | 612 | $dairport = $Spotter->getAllAirportInfo($spotter_item['departure_airport']); |
613 | 613 | if (isset($dairport[0]['latitude'])) { |
614 | - $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],'; |
|
614 | + $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],'; |
|
615 | 615 | } |
616 | - } |
|
617 | - if (isset($spotter_item['arrival_airport_latitude'])) { |
|
616 | + } |
|
617 | + if (isset($spotter_item['arrival_airport_latitude'])) { |
|
618 | 618 | $output_air .= '['.$spotter_item['arrival_airport_longitude'].','.$spotter_item['arrival_airport_latitude'].'],'; |
619 | - } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
|
619 | + } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
|
620 | 620 | $aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']); |
621 | 621 | if (isset($aairport[0]['latitude'])) { |
622 | - $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].'],'; |
|
622 | + $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].'],'; |
|
623 | 623 | } |
624 | - } |
|
625 | - $output_air = substr($output_air, 0, -1); |
|
626 | - $output_air .= ']}},'; |
|
627 | - $output .= $output_air; |
|
628 | - unset($output_air); |
|
624 | + } |
|
625 | + $output_air = substr($output_air, 0, -1); |
|
626 | + $output_air .= ']}},'; |
|
627 | + $output .= $output_air; |
|
628 | + unset($output_air); |
|
629 | 629 | } |
630 | 630 | |
631 | 631 | //if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) { |
632 | 632 | //if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) { |
633 | 633 | if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
634 | - || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
|
635 | - && (isset($spotter_item['arrival_airport']) |
|
636 | - && $spotter_item['arrival_airport'] != 'NA' |
|
637 | - && ((isset($_COOKIE['MapRemainingRoute']) && $_COOKIE['MapRemainingRoute'] == "true") |
|
638 | - || (!isset($_COOKIE['MapRemainaingRoute']) && (!isset($globalMapRemainingRoute) |
|
639 | - || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) { |
|
640 | - $havedata = false; |
|
641 | - if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
642 | - else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
643 | - $output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],'; |
|
634 | + || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
|
635 | + && (isset($spotter_item['arrival_airport']) |
|
636 | + && $spotter_item['arrival_airport'] != 'NA' |
|
637 | + && ((isset($_COOKIE['MapRemainingRoute']) && $_COOKIE['MapRemainingRoute'] == "true") |
|
638 | + || (!isset($_COOKIE['MapRemainaingRoute']) && (!isset($globalMapRemainingRoute) |
|
639 | + || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) { |
|
640 | + $havedata = false; |
|
641 | + if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
642 | + else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
643 | + $output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],'; |
|
644 | 644 | |
645 | - if (isset($spotter_item['arrival_airport_latitude'])) { |
|
645 | + if (isset($spotter_item['arrival_airport_latitude'])) { |
|
646 | 646 | $output_dest .= '['.$spotter_item['arrival_airport_longitude'].','.$spotter_item['arrival_airport_latitude'].']'; |
647 | 647 | $havedata = true; |
648 | - } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
|
648 | + } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
|
649 | 649 | $aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']); |
650 | 650 | if (isset($aairport[0]['latitude'])) { |
651 | - $output_dest .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']'; |
|
652 | - $havedata = true; |
|
651 | + $output_dest .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']'; |
|
652 | + $havedata = true; |
|
653 | 653 | } |
654 | - } |
|
655 | - //$output_dest = substr($output_dest, 0, -1); |
|
656 | - $output_dest .= ']}},'; |
|
657 | - if ($havedata) $output .= $output_dest; |
|
658 | - unset($output_dest); |
|
654 | + } |
|
655 | + //$output_dest = substr($output_dest, 0, -1); |
|
656 | + $output_dest .= ']}},'; |
|
657 | + if ($havedata) $output .= $output_dest; |
|
658 | + unset($output_dest); |
|
659 | 659 | } |
660 | 660 | } |
661 | 661 | $output = substr($output, 0, -1); |