@@ -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'])) { |
@@ -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 | } |
@@ -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); |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | print '<th class="arrival"><span class="nomobile">'._("Going to").'</span><span class="mobile">'._("To").'</span></th>'; |
278 | 278 | } |
279 | 279 | } |
280 | - if ($type == 'aircraft') { |
|
280 | + if ($type == 'aircraft') { |
|
281 | 281 | if ((isset($globalUsePilot) && $globalUsePilot) || (!isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalVAM) && $globalVAM) || (isset($globalphpVMS) && $globalphpVMS)))) { |
282 | 282 | print '<th class="pilot"><span class="nomobile">'._("Pilot name").'</span><span class="mobile">'._("Pilot").'</span></a></th>'; |
283 | 283 | } |
@@ -579,7 +579,7 @@ discard block |
||
579 | 579 | } elseif(strtolower($current_page) != "currently" && strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive" && strtolower($current_page) != "accident-latest" && strtolower($current_page) != "incident-latest" && strtolower($current_page) != "accident-detailed" && strtolower($current_page) != "incident-detailed"){ |
580 | 580 | if ($type == 'aircraft') { |
581 | 581 | if (!isset($spotter_item['squawk']) || $spotter_item['squawk'] == 0) { |
582 | - $spotter_item['squawk'] = '-'; |
|
582 | + $spotter_item['squawk'] = '-'; |
|
583 | 583 | } |
584 | 584 | if ($spotter_item['image_thumbnail'] != "") |
585 | 585 | { |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | print '</td>'."\n"; |
619 | 619 | } else { |
620 | 620 | print '<td class="aircraft_thumbnail">'."\n"; |
621 | - // print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$globalURL.'/images/placeholder_thumb.png" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>'; |
|
621 | + // print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$globalURL.'/images/placeholder_thumb.png" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>'; |
|
622 | 622 | //} |
623 | 623 | if (!isset($spotter_item['airline_name']) && !isset($spotter_item['aircraft_name'])) { |
624 | 624 | print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$globalURL.'/images/placeholder_thumb.png" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '._("Not available").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n"; |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | |
13 | 13 | |
14 | 14 | /** |
15 | - * Get SQL query part for filter used |
|
16 | - * @param Array $filter the filter |
|
17 | - * @return Array the SQL part |
|
18 | - */ |
|
15 | + * Get SQL query part for filter used |
|
16 | + * @param Array $filter the filter |
|
17 | + * @return Array the SQL part |
|
18 | + */ |
|
19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
21 | 21 | $filters = array(); |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
131 | - * Gets all the spotter information based on the latest data entry |
|
132 | - * |
|
133 | - * @return Array the spotter information |
|
134 | - * |
|
135 | - */ |
|
131 | + * Gets all the spotter information based on the latest data entry |
|
132 | + * |
|
133 | + * @return Array the spotter information |
|
134 | + * |
|
135 | + */ |
|
136 | 136 | public function getLiveSpotterData($limit = '', $sort = '', $filter = array()) |
137 | 137 | { |
138 | 138 | global $globalDBdriver, $globalLiveInterval; |
@@ -175,11 +175,11 @@ discard block |
||
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
178 | - * Gets Minimal Live Spotter data |
|
179 | - * |
|
180 | - * @return Array the spotter information |
|
181 | - * |
|
182 | - */ |
|
178 | + * Gets Minimal Live Spotter data |
|
179 | + * |
|
180 | + * @return Array the spotter information |
|
181 | + * |
|
182 | + */ |
|
183 | 183 | public function getMinLiveSpotterData($filter = array()) |
184 | 184 | { |
185 | 185 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -216,11 +216,11 @@ discard block |
||
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
219 | - * Gets Minimal Live Spotter data since xx seconds |
|
220 | - * |
|
221 | - * @return Array the spotter information |
|
222 | - * |
|
223 | - */ |
|
219 | + * Gets Minimal Live Spotter data since xx seconds |
|
220 | + * |
|
221 | + * @return Array the spotter information |
|
222 | + * |
|
223 | + */ |
|
224 | 224 | public function getMinLastLiveSpotterData($filter = array()) |
225 | 225 | { |
226 | 226 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
251 | 251 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
252 | 252 | } |
253 | - } else { |
|
253 | + } else { |
|
254 | 254 | if (isset($globalArchive) && $globalArchive === TRUE) { |
255 | 255 | /* |
256 | 256 | $query = "SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
275 | 275 | } |
276 | 276 | } |
277 | - try { |
|
277 | + try { |
|
278 | 278 | $sth = $this->db->prepare($query); |
279 | 279 | $sth->execute(); |
280 | 280 | } catch(PDOException $e) { |
@@ -286,11 +286,11 @@ discard block |
||
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
289 | - * Gets number of latest data entry |
|
290 | - * |
|
291 | - * @return String number of entry |
|
292 | - * |
|
293 | - */ |
|
289 | + * Gets number of latest data entry |
|
290 | + * |
|
291 | + * @return String number of entry |
|
292 | + * |
|
293 | + */ |
|
294 | 294 | public function getLiveSpotterCount($filter = array()) |
295 | 295 | { |
296 | 296 | global $globalDBdriver, $globalLiveInterval; |
@@ -317,11 +317,11 @@ discard block |
||
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
320 | - * Gets all the spotter information based on the latest data entry and coord |
|
321 | - * |
|
322 | - * @return Array the spotter information |
|
323 | - * |
|
324 | - */ |
|
320 | + * Gets all the spotter information based on the latest data entry and coord |
|
321 | + * |
|
322 | + * @return Array the spotter information |
|
323 | + * |
|
324 | + */ |
|
325 | 325 | public function getLiveSpotterDatabyCoord($coord, $filter = array()) |
326 | 326 | { |
327 | 327 | global $globalDBdriver, $globalLiveInterval; |
@@ -346,11 +346,11 @@ discard block |
||
346 | 346 | } |
347 | 347 | |
348 | 348 | /** |
349 | - * Gets all the spotter information based on the latest data entry and coord |
|
350 | - * |
|
351 | - * @return Array the spotter information |
|
352 | - * |
|
353 | - */ |
|
349 | + * Gets all the spotter information based on the latest data entry and coord |
|
350 | + * |
|
351 | + * @return Array the spotter information |
|
352 | + * |
|
353 | + */ |
|
354 | 354 | public function getMinLiveSpotterDatabyCoord($coord, $filter = array()) |
355 | 355 | { |
356 | 356 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -415,11 +415,11 @@ discard block |
||
415 | 415 | } |
416 | 416 | |
417 | 417 | /** |
418 | - * Gets all the spotter information based on a user's latitude and longitude |
|
419 | - * |
|
420 | - * @return Array the spotter information |
|
421 | - * |
|
422 | - */ |
|
418 | + * Gets all the spotter information based on a user's latitude and longitude |
|
419 | + * |
|
420 | + * @return Array the spotter information |
|
421 | + * |
|
422 | + */ |
|
423 | 423 | public function getLatestSpotterForLayar($lat, $lng, $radius, $interval) |
424 | 424 | { |
425 | 425 | $Spotter = new Spotter($this->db); |
@@ -429,98 +429,98 @@ discard block |
||
429 | 429 | return false; |
430 | 430 | } |
431 | 431 | } |
432 | - if ($lng != '') |
|
433 | - { |
|
434 | - if (!is_numeric($lng)) |
|
435 | - { |
|
436 | - return false; |
|
437 | - } |
|
438 | - } |
|
439 | - |
|
440 | - if ($radius != '') |
|
441 | - { |
|
442 | - if (!is_numeric($radius)) |
|
443 | - { |
|
444 | - return false; |
|
445 | - } |
|
446 | - } |
|
432 | + if ($lng != '') |
|
433 | + { |
|
434 | + if (!is_numeric($lng)) |
|
435 | + { |
|
436 | + return false; |
|
437 | + } |
|
438 | + } |
|
439 | + |
|
440 | + if ($radius != '') |
|
441 | + { |
|
442 | + if (!is_numeric($radius)) |
|
443 | + { |
|
444 | + return false; |
|
445 | + } |
|
446 | + } |
|
447 | 447 | $additional_query = ''; |
448 | - if ($interval != '') |
|
449 | - { |
|
450 | - if (!is_string($interval)) |
|
451 | - { |
|
452 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
453 | - return false; |
|
454 | - } else { |
|
455 | - if ($interval == '1m') |
|
456 | - { |
|
457 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
458 | - } else if ($interval == '15m'){ |
|
459 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
460 | - } |
|
461 | - } |
|
462 | - } else { |
|
463 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
464 | - } |
|
465 | - |
|
466 | - $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
448 | + if ($interval != '') |
|
449 | + { |
|
450 | + if (!is_string($interval)) |
|
451 | + { |
|
452 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
453 | + return false; |
|
454 | + } else { |
|
455 | + if ($interval == '1m') |
|
456 | + { |
|
457 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
458 | + } else if ($interval == '15m'){ |
|
459 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
460 | + } |
|
461 | + } |
|
462 | + } else { |
|
463 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
464 | + } |
|
465 | + |
|
466 | + $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
467 | 467 | WHERE spotter_live.latitude <> '' |
468 | 468 | AND spotter_live.longitude <> '' |
469 | 469 | ".$additional_query." |
470 | 470 | HAVING distance < :radius |
471 | 471 | ORDER BY distance"; |
472 | 472 | |
473 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
473 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
474 | 474 | |
475 | - return $spotter_array; |
|
476 | - } |
|
475 | + return $spotter_array; |
|
476 | + } |
|
477 | 477 | |
478 | 478 | |
479 | - /** |
|
480 | - * Gets all the spotter information based on a particular callsign |
|
481 | - * |
|
482 | - * @return Array the spotter information |
|
483 | - * |
|
484 | - */ |
|
479 | + /** |
|
480 | + * Gets all the spotter information based on a particular callsign |
|
481 | + * |
|
482 | + * @return Array the spotter information |
|
483 | + * |
|
484 | + */ |
|
485 | 485 | public function getLastLiveSpotterDataByIdent($ident) |
486 | 486 | { |
487 | 487 | $Spotter = new Spotter($this->db); |
488 | 488 | date_default_timezone_set('UTC'); |
489 | 489 | |
490 | 490 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
491 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
491 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
492 | 492 | |
493 | 493 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
494 | 494 | |
495 | 495 | return $spotter_array; |
496 | 496 | } |
497 | 497 | |
498 | - /** |
|
499 | - * Gets all the spotter information based on a particular callsign |
|
500 | - * |
|
501 | - * @return Array the spotter information |
|
502 | - * |
|
503 | - */ |
|
498 | + /** |
|
499 | + * Gets all the spotter information based on a particular callsign |
|
500 | + * |
|
501 | + * @return Array the spotter information |
|
502 | + * |
|
503 | + */ |
|
504 | 504 | public function getDateLiveSpotterDataByIdent($ident,$date) |
505 | 505 | { |
506 | 506 | $Spotter = new Spotter($this->db); |
507 | 507 | date_default_timezone_set('UTC'); |
508 | 508 | |
509 | 509 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
510 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
510 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
511 | 511 | |
512 | - $date = date('c',$date); |
|
512 | + $date = date('c',$date); |
|
513 | 513 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
514 | 514 | |
515 | 515 | return $spotter_array; |
516 | 516 | } |
517 | 517 | |
518 | - /** |
|
519 | - * Gets last spotter information based on a particular callsign |
|
520 | - * |
|
521 | - * @return Array the spotter information |
|
522 | - * |
|
523 | - */ |
|
518 | + /** |
|
519 | + * Gets last spotter information based on a particular callsign |
|
520 | + * |
|
521 | + * @return Array the spotter information |
|
522 | + * |
|
523 | + */ |
|
524 | 524 | public function getLastLiveSpotterDataById($id) |
525 | 525 | { |
526 | 526 | $Spotter = new Spotter($this->db); |
@@ -531,12 +531,12 @@ discard block |
||
531 | 531 | return $spotter_array; |
532 | 532 | } |
533 | 533 | |
534 | - /** |
|
535 | - * Gets last spotter information based on a particular callsign |
|
536 | - * |
|
537 | - * @return Array the spotter information |
|
538 | - * |
|
539 | - */ |
|
534 | + /** |
|
535 | + * Gets last spotter information based on a particular callsign |
|
536 | + * |
|
537 | + * @return Array the spotter information |
|
538 | + * |
|
539 | + */ |
|
540 | 540 | public function getDateLiveSpotterDataById($id,$date) |
541 | 541 | { |
542 | 542 | $Spotter = new Spotter($this->db); |
@@ -549,21 +549,21 @@ discard block |
||
549 | 549 | return $spotter_array; |
550 | 550 | } |
551 | 551 | |
552 | - /** |
|
553 | - * Gets altitude information based on a particular callsign |
|
554 | - * |
|
555 | - * @return Array the spotter information |
|
556 | - * |
|
557 | - */ |
|
552 | + /** |
|
553 | + * Gets altitude information based on a particular callsign |
|
554 | + * |
|
555 | + * @return Array the spotter information |
|
556 | + * |
|
557 | + */ |
|
558 | 558 | public function getAltitudeLiveSpotterDataByIdent($ident) |
559 | 559 | { |
560 | 560 | |
561 | 561 | date_default_timezone_set('UTC'); |
562 | 562 | |
563 | 563 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
564 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
564 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
565 | 565 | |
566 | - try { |
|
566 | + try { |
|
567 | 567 | |
568 | 568 | $sth = $this->db->prepare($query); |
569 | 569 | $sth->execute(array(':ident' => $ident)); |
@@ -576,12 +576,12 @@ discard block |
||
576 | 576 | return $spotter_array; |
577 | 577 | } |
578 | 578 | |
579 | - /** |
|
580 | - * Gets all the spotter information based on a particular id |
|
581 | - * |
|
582 | - * @return Array the spotter information |
|
583 | - * |
|
584 | - */ |
|
579 | + /** |
|
580 | + * Gets all the spotter information based on a particular id |
|
581 | + * |
|
582 | + * @return Array the spotter information |
|
583 | + * |
|
584 | + */ |
|
585 | 585 | public function getAllLiveSpotterDataById($id,$liveinterval = false) |
586 | 586 | { |
587 | 587 | global $globalDBdriver, $globalLiveInterval; |
@@ -609,18 +609,18 @@ discard block |
||
609 | 609 | return $spotter_array; |
610 | 610 | } |
611 | 611 | |
612 | - /** |
|
613 | - * Gets all the spotter information based on a particular ident |
|
614 | - * |
|
615 | - * @return Array the spotter information |
|
616 | - * |
|
617 | - */ |
|
612 | + /** |
|
613 | + * Gets all the spotter information based on a particular ident |
|
614 | + * |
|
615 | + * @return Array the spotter information |
|
616 | + * |
|
617 | + */ |
|
618 | 618 | public function getAllLiveSpotterDataByIdent($ident) |
619 | 619 | { |
620 | 620 | date_default_timezone_set('UTC'); |
621 | 621 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
622 | 622 | $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
623 | - try { |
|
623 | + try { |
|
624 | 624 | |
625 | 625 | $sth = $this->db->prepare($query); |
626 | 626 | $sth->execute(array(':ident' => $ident)); |
@@ -634,23 +634,23 @@ discard block |
||
634 | 634 | |
635 | 635 | |
636 | 636 | /** |
637 | - * Deletes all info in the table |
|
638 | - * |
|
639 | - * @return String success or false |
|
640 | - * |
|
641 | - */ |
|
637 | + * Deletes all info in the table |
|
638 | + * |
|
639 | + * @return String success or false |
|
640 | + * |
|
641 | + */ |
|
642 | 642 | public function deleteLiveSpotterData() |
643 | 643 | { |
644 | 644 | global $globalDBdriver; |
645 | 645 | if ($globalDBdriver == 'mysql') { |
646 | 646 | //$query = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date"; |
647 | 647 | $query = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date'; |
648 | - //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
648 | + //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
649 | 649 | } else { |
650 | 650 | $query = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date"; |
651 | 651 | } |
652 | 652 | |
653 | - try { |
|
653 | + try { |
|
654 | 654 | |
655 | 655 | $sth = $this->db->prepare($query); |
656 | 656 | $sth->execute(); |
@@ -662,18 +662,18 @@ discard block |
||
662 | 662 | } |
663 | 663 | |
664 | 664 | /** |
665 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
666 | - * |
|
667 | - * @return String success or false |
|
668 | - * |
|
669 | - */ |
|
665 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
666 | + * |
|
667 | + * @return String success or false |
|
668 | + * |
|
669 | + */ |
|
670 | 670 | public function deleteLiveSpotterDataNotUpdated() |
671 | 671 | { |
672 | 672 | global $globalDBdriver, $globalDebug; |
673 | 673 | if ($globalDBdriver == 'mysql') { |
674 | 674 | //$query = 'SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < spotter_live.date) LIMIT 800 OFFSET 0'; |
675 | - $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0"; |
|
676 | - try { |
|
675 | + $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0"; |
|
676 | + try { |
|
677 | 677 | |
678 | 678 | $sth = $this->db->prepare($query); |
679 | 679 | $sth->execute(); |
@@ -681,8 +681,8 @@ discard block |
||
681 | 681 | return "error"; |
682 | 682 | } |
683 | 683 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
684 | - $i = 0; |
|
685 | - $j =0; |
|
684 | + $i = 0; |
|
685 | + $j =0; |
|
686 | 686 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
687 | 687 | foreach($all as $row) |
688 | 688 | { |
@@ -690,20 +690,20 @@ discard block |
||
690 | 690 | $j++; |
691 | 691 | if ($j == 30) { |
692 | 692 | if ($globalDebug) echo "."; |
693 | - try { |
|
693 | + try { |
|
694 | 694 | |
695 | 695 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
696 | 696 | $sth->execute(); |
697 | 697 | } catch(PDOException $e) { |
698 | 698 | return "error"; |
699 | 699 | } |
700 | - $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
701 | - $j = 0; |
|
700 | + $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
701 | + $j = 0; |
|
702 | 702 | } |
703 | 703 | $query_delete .= "'".$row['flightaware_id']."',"; |
704 | 704 | } |
705 | 705 | if ($i > 0) { |
706 | - try { |
|
706 | + try { |
|
707 | 707 | |
708 | 708 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
709 | 709 | $sth->execute(); |
@@ -714,9 +714,9 @@ discard block |
||
714 | 714 | return "success"; |
715 | 715 | } elseif ($globalDBdriver == 'pgsql') { |
716 | 716 | //$query = "SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < spotter_live.date) LIMIT 800 OFFSET 0"; |
717 | - //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
718 | - $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)"; |
|
719 | - try { |
|
717 | + //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
718 | + $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)"; |
|
719 | + try { |
|
720 | 720 | |
721 | 721 | $sth = $this->db->prepare($query); |
722 | 722 | $sth->execute(); |
@@ -760,17 +760,17 @@ discard block |
||
760 | 760 | } |
761 | 761 | |
762 | 762 | /** |
763 | - * Deletes all info in the table for an ident |
|
764 | - * |
|
765 | - * @return String success or false |
|
766 | - * |
|
767 | - */ |
|
763 | + * Deletes all info in the table for an ident |
|
764 | + * |
|
765 | + * @return String success or false |
|
766 | + * |
|
767 | + */ |
|
768 | 768 | public function deleteLiveSpotterDataByIdent($ident) |
769 | 769 | { |
770 | 770 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
771 | 771 | $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
772 | 772 | |
773 | - try { |
|
773 | + try { |
|
774 | 774 | |
775 | 775 | $sth = $this->db->prepare($query); |
776 | 776 | $sth->execute(array(':ident' => $ident)); |
@@ -782,17 +782,17 @@ discard block |
||
782 | 782 | } |
783 | 783 | |
784 | 784 | /** |
785 | - * Deletes all info in the table for an id |
|
786 | - * |
|
787 | - * @return String success or false |
|
788 | - * |
|
789 | - */ |
|
785 | + * Deletes all info in the table for an id |
|
786 | + * |
|
787 | + * @return String success or false |
|
788 | + * |
|
789 | + */ |
|
790 | 790 | public function deleteLiveSpotterDataById($id) |
791 | 791 | { |
792 | 792 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
793 | 793 | $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
794 | 794 | |
795 | - try { |
|
795 | + try { |
|
796 | 796 | |
797 | 797 | $sth = $this->db->prepare($query); |
798 | 798 | $sth->execute(array(':id' => $id)); |
@@ -805,11 +805,11 @@ discard block |
||
805 | 805 | |
806 | 806 | |
807 | 807 | /** |
808 | - * Gets the aircraft ident within the last hour |
|
809 | - * |
|
810 | - * @return String the ident |
|
811 | - * |
|
812 | - */ |
|
808 | + * Gets the aircraft ident within the last hour |
|
809 | + * |
|
810 | + * @return String the ident |
|
811 | + * |
|
812 | + */ |
|
813 | 813 | public function getIdentFromLastHour($ident) |
814 | 814 | { |
815 | 815 | global $globalDBdriver, $globalTimezone; |
@@ -835,14 +835,14 @@ discard block |
||
835 | 835 | $ident_result = $row['ident']; |
836 | 836 | } |
837 | 837 | return $ident_result; |
838 | - } |
|
838 | + } |
|
839 | 839 | |
840 | 840 | /** |
841 | - * Check recent aircraft |
|
842 | - * |
|
843 | - * @return String the ident |
|
844 | - * |
|
845 | - */ |
|
841 | + * Check recent aircraft |
|
842 | + * |
|
843 | + * @return String the ident |
|
844 | + * |
|
845 | + */ |
|
846 | 846 | public function checkIdentRecent($ident) |
847 | 847 | { |
848 | 848 | global $globalDBdriver, $globalTimezone; |
@@ -868,14 +868,14 @@ discard block |
||
868 | 868 | $ident_result = $row['flightaware_id']; |
869 | 869 | } |
870 | 870 | return $ident_result; |
871 | - } |
|
871 | + } |
|
872 | 872 | |
873 | 873 | /** |
874 | - * Check recent aircraft by id |
|
875 | - * |
|
876 | - * @return String the ident |
|
877 | - * |
|
878 | - */ |
|
874 | + * Check recent aircraft by id |
|
875 | + * |
|
876 | + * @return String the ident |
|
877 | + * |
|
878 | + */ |
|
879 | 879 | public function checkIdRecent($id) |
880 | 880 | { |
881 | 881 | global $globalDBdriver, $globalTimezone; |
@@ -901,14 +901,14 @@ discard block |
||
901 | 901 | $ident_result = $row['flightaware_id']; |
902 | 902 | } |
903 | 903 | return $ident_result; |
904 | - } |
|
904 | + } |
|
905 | 905 | |
906 | 906 | /** |
907 | - * Check recent aircraft by ModeS |
|
908 | - * |
|
909 | - * @return String the ModeS |
|
910 | - * |
|
911 | - */ |
|
907 | + * Check recent aircraft by ModeS |
|
908 | + * |
|
909 | + * @return String the ModeS |
|
910 | + * |
|
911 | + */ |
|
912 | 912 | public function checkModeSRecent($modes) |
913 | 913 | { |
914 | 914 | global $globalDBdriver, $globalTimezone; |
@@ -935,19 +935,19 @@ discard block |
||
935 | 935 | $ident_result = $row['flightaware_id']; |
936 | 936 | } |
937 | 937 | return $ident_result; |
938 | - } |
|
938 | + } |
|
939 | 939 | |
940 | 940 | /** |
941 | - * Adds a new spotter data |
|
942 | - * |
|
943 | - * @param String $flightaware_id the ID from flightaware |
|
944 | - * @param String $ident the flight ident |
|
945 | - * @param String $aircraft_icao the aircraft type |
|
946 | - * @param String $departure_airport_icao the departure airport |
|
947 | - * @param String $arrival_airport_icao the arrival airport |
|
948 | - * @return String success or false |
|
949 | - * |
|
950 | - */ |
|
941 | + * Adds a new spotter data |
|
942 | + * |
|
943 | + * @param String $flightaware_id the ID from flightaware |
|
944 | + * @param String $ident the flight ident |
|
945 | + * @param String $aircraft_icao the aircraft type |
|
946 | + * @param String $departure_airport_icao the departure airport |
|
947 | + * @param String $arrival_airport_icao the arrival airport |
|
948 | + * @return String success or false |
|
949 | + * |
|
950 | + */ |
|
951 | 951 | public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
952 | 952 | { |
953 | 953 | global $globalURL, $globalArchive, $globalDebug; |
@@ -1090,10 +1090,10 @@ discard block |
||
1090 | 1090 | $arrival_airport_country = ''; |
1091 | 1091 | |
1092 | 1092 | |
1093 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1094 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1095 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1096 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1093 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1094 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1095 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1096 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1097 | 1097 | |
1098 | 1098 | $query = ''; |
1099 | 1099 | if ($globalArchive) { |
@@ -1114,10 +1114,10 @@ discard block |
||
1114 | 1114 | return "error : ".$e->getMessage(); |
1115 | 1115 | } |
1116 | 1116 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1117 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
1118 | - $SpotterArchive = new SpotterArchive($this->db); |
|
1119 | - $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
1120 | - if ($globalDebug) echo $result.')'; |
|
1117 | + if ($globalDebug) echo '(Add to SBS archive : '; |
|
1118 | + $SpotterArchive = new SpotterArchive($this->db); |
|
1119 | + $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
1120 | + if ($globalDebug) echo $result.')'; |
|
1121 | 1121 | } elseif ($globalDebug && $putinarchive !== true) { |
1122 | 1122 | echo '(Not adding to archive)'; |
1123 | 1123 | } elseif ($globalDebug && $noarchive === true) { |