@@ -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 countAllTrackedOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
756 | 756 | { |
@@ -801,11 +801,11 @@ discard block |
||
801 | 801 | |
802 | 802 | |
803 | 803 | /** |
804 | - * Gets all callsigns that have flown over |
|
805 | - * |
|
806 | - * @return Array the callsign list |
|
807 | - * |
|
808 | - */ |
|
804 | + * Gets all callsigns that have flown over |
|
805 | + * |
|
806 | + * @return Array the callsign list |
|
807 | + * |
|
808 | + */ |
|
809 | 809 | public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
810 | 810 | { |
811 | 811 | global $globalDBdriver; |
@@ -872,11 +872,11 @@ discard block |
||
872 | 872 | |
873 | 873 | |
874 | 874 | /** |
875 | - * Counts all dates |
|
876 | - * |
|
877 | - * @return Array the date list |
|
878 | - * |
|
879 | - */ |
|
875 | + * Counts all dates |
|
876 | + * |
|
877 | + * @return Array the date list |
|
878 | + * |
|
879 | + */ |
|
880 | 880 | public function countAllDates($filters = array()) |
881 | 881 | { |
882 | 882 | global $globalTimezone, $globalDBdriver; |
@@ -922,11 +922,11 @@ discard block |
||
922 | 922 | |
923 | 923 | |
924 | 924 | /** |
925 | - * Counts all dates during the last 7 days |
|
926 | - * |
|
927 | - * @return Array the date list |
|
928 | - * |
|
929 | - */ |
|
925 | + * Counts all dates during the last 7 days |
|
926 | + * |
|
927 | + * @return Array the date list |
|
928 | + * |
|
929 | + */ |
|
930 | 930 | public function countAllDatesLast7Days($filters = array()) |
931 | 931 | { |
932 | 932 | global $globalTimezone, $globalDBdriver; |
@@ -948,7 +948,7 @@ discard block |
||
948 | 948 | $query .= " GROUP BY date_name |
949 | 949 | ORDER BY date_name ASC"; |
950 | 950 | $query_data = array(':offset' => $offset); |
951 | - } |
|
951 | + } |
|
952 | 952 | |
953 | 953 | $sth = $this->db->prepare($query); |
954 | 954 | $sth->execute($query_data); |
@@ -968,11 +968,11 @@ discard block |
||
968 | 968 | } |
969 | 969 | |
970 | 970 | /** |
971 | - * Counts all dates during the last month |
|
972 | - * |
|
973 | - * @return Array the date list |
|
974 | - * |
|
975 | - */ |
|
971 | + * Counts all dates during the last month |
|
972 | + * |
|
973 | + * @return Array the date list |
|
974 | + * |
|
975 | + */ |
|
976 | 976 | public function countAllDatesLastMonth($filters = array()) |
977 | 977 | { |
978 | 978 | global $globalTimezone, $globalDBdriver; |
@@ -994,7 +994,7 @@ discard block |
||
994 | 994 | $query .= " GROUP BY date_name |
995 | 995 | ORDER BY date_name ASC"; |
996 | 996 | $query_data = array(':offset' => $offset); |
997 | - } |
|
997 | + } |
|
998 | 998 | |
999 | 999 | $sth = $this->db->prepare($query); |
1000 | 1000 | $sth->execute($query_data); |
@@ -1016,11 +1016,11 @@ discard block |
||
1016 | 1016 | |
1017 | 1017 | |
1018 | 1018 | /** |
1019 | - * Counts all month |
|
1020 | - * |
|
1021 | - * @return Array the month list |
|
1022 | - * |
|
1023 | - */ |
|
1019 | + * Counts all month |
|
1020 | + * |
|
1021 | + * @return Array the month list |
|
1022 | + * |
|
1023 | + */ |
|
1024 | 1024 | public function countAllMonths($filters = array()) |
1025 | 1025 | { |
1026 | 1026 | global $globalTimezone, $globalDBdriver; |
@@ -1065,11 +1065,11 @@ discard block |
||
1065 | 1065 | |
1066 | 1066 | |
1067 | 1067 | /** |
1068 | - * Counts all dates during the last year |
|
1069 | - * |
|
1070 | - * @return Array the date list |
|
1071 | - * |
|
1072 | - */ |
|
1068 | + * Counts all dates during the last year |
|
1069 | + * |
|
1070 | + * @return Array the date list |
|
1071 | + * |
|
1072 | + */ |
|
1073 | 1073 | public function countAllMonthsLastYear($filters) |
1074 | 1074 | { |
1075 | 1075 | global $globalTimezone, $globalDBdriver; |
@@ -1091,7 +1091,7 @@ discard block |
||
1091 | 1091 | $query .= " GROUP BY year_name, month_name |
1092 | 1092 | ORDER BY year_name, month_name ASC"; |
1093 | 1093 | $query_data = array(':offset' => $offset); |
1094 | - } |
|
1094 | + } |
|
1095 | 1095 | |
1096 | 1096 | $sth = $this->db->prepare($query); |
1097 | 1097 | $sth->execute($query_data); |
@@ -1114,11 +1114,11 @@ discard block |
||
1114 | 1114 | |
1115 | 1115 | |
1116 | 1116 | /** |
1117 | - * Counts all hours |
|
1118 | - * |
|
1119 | - * @return Array the hour list |
|
1120 | - * |
|
1121 | - */ |
|
1117 | + * Counts all hours |
|
1118 | + * |
|
1119 | + * @return Array the hour list |
|
1120 | + * |
|
1121 | + */ |
|
1122 | 1122 | public function countAllHours($orderby,$filters = array()) |
1123 | 1123 | { |
1124 | 1124 | global $globalTimezone, $globalDBdriver; |
@@ -1181,11 +1181,11 @@ discard block |
||
1181 | 1181 | |
1182 | 1182 | |
1183 | 1183 | /** |
1184 | - * Counts all hours by date |
|
1185 | - * |
|
1186 | - * @return Array the hour list |
|
1187 | - * |
|
1188 | - */ |
|
1184 | + * Counts all hours by date |
|
1185 | + * |
|
1186 | + * @return Array the hour list |
|
1187 | + * |
|
1188 | + */ |
|
1189 | 1189 | public function countAllHoursByDate($date, $filters = array()) |
1190 | 1190 | { |
1191 | 1191 | global $globalTimezone, $globalDBdriver; |
@@ -1229,11 +1229,11 @@ discard block |
||
1229 | 1229 | |
1230 | 1230 | |
1231 | 1231 | /** |
1232 | - * Counts all hours by a ident/callsign |
|
1233 | - * |
|
1234 | - * @return Array the hour list |
|
1235 | - * |
|
1236 | - */ |
|
1232 | + * Counts all hours by a ident/callsign |
|
1233 | + * |
|
1234 | + * @return Array the hour list |
|
1235 | + * |
|
1236 | + */ |
|
1237 | 1237 | public function countAllHoursByIdent($ident, $filters = array()) |
1238 | 1238 | { |
1239 | 1239 | global $globalTimezone, $globalDBdriver; |
@@ -1278,11 +1278,11 @@ discard block |
||
1278 | 1278 | |
1279 | 1279 | |
1280 | 1280 | /** |
1281 | - * Counts all flights that have flown over |
|
1282 | - * |
|
1283 | - * @return Integer the number of flights |
|
1284 | - * |
|
1285 | - */ |
|
1281 | + * Counts all flights that have flown over |
|
1282 | + * |
|
1283 | + * @return Integer the number of flights |
|
1284 | + * |
|
1285 | + */ |
|
1286 | 1286 | public function countOverallTracked($filters = array(),$year = '',$month = '') |
1287 | 1287 | { |
1288 | 1288 | global $globalDBdriver; |
@@ -1317,11 +1317,11 @@ discard block |
||
1317 | 1317 | |
1318 | 1318 | |
1319 | 1319 | /** |
1320 | - * Counts all hours of today |
|
1321 | - * |
|
1322 | - * @return Array the hour list |
|
1323 | - * |
|
1324 | - */ |
|
1320 | + * Counts all hours of today |
|
1321 | + * |
|
1322 | + * @return Array the hour list |
|
1323 | + * |
|
1324 | + */ |
|
1325 | 1325 | public function countAllHoursFromToday($filters = array()) |
1326 | 1326 | { |
1327 | 1327 | global $globalTimezone, $globalDBdriver; |
@@ -1361,12 +1361,12 @@ discard block |
||
1361 | 1361 | } |
1362 | 1362 | |
1363 | 1363 | |
1364 | - /** |
|
1365 | - * Gets the Barrie Spotter ID based on the FlightAware ID |
|
1366 | - * |
|
1367 | - * @return Integer the Barrie Spotter ID |
|
1364 | + /** |
|
1365 | + * Gets the Barrie Spotter ID based on the FlightAware ID |
|
1366 | + * |
|
1367 | + * @return Integer the Barrie Spotter ID |
|
1368 | 1368 | q * |
1369 | - */ |
|
1369 | + */ |
|
1370 | 1370 | public function getTrackerIDBasedOnFamTrackID($famtrackid) |
1371 | 1371 | { |
1372 | 1372 | $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
@@ -1387,13 +1387,13 @@ discard block |
||
1387 | 1387 | |
1388 | 1388 | |
1389 | 1389 | /** |
1390 | - * Parses a date string |
|
1391 | - * |
|
1392 | - * @param String $dateString the date string |
|
1393 | - * @param String $timezone the timezone of a user |
|
1394 | - * @return Array the time information |
|
1395 | - * |
|
1396 | - */ |
|
1390 | + * Parses a date string |
|
1391 | + * |
|
1392 | + * @param String $dateString the date string |
|
1393 | + * @param String $timezone the timezone of a user |
|
1394 | + * @return Array the time information |
|
1395 | + * |
|
1396 | + */ |
|
1397 | 1397 | public function parseDateString($dateString, $timezone = '') |
1398 | 1398 | { |
1399 | 1399 | $time_array = array(); |
@@ -1426,12 +1426,12 @@ discard block |
||
1426 | 1426 | } |
1427 | 1427 | |
1428 | 1428 | /** |
1429 | - * Parses the direction degrees to working |
|
1430 | - * |
|
1431 | - * @param Float $direction the direction in degrees |
|
1432 | - * @return Array the direction information |
|
1433 | - * |
|
1434 | - */ |
|
1429 | + * Parses the direction degrees to working |
|
1430 | + * |
|
1431 | + * @param Float $direction the direction in degrees |
|
1432 | + * @return Array the direction information |
|
1433 | + * |
|
1434 | + */ |
|
1435 | 1435 | public function parseDirection($direction = 0) |
1436 | 1436 | { |
1437 | 1437 | if ($direction == '') $direction = 0; |
@@ -1510,12 +1510,12 @@ discard block |
||
1510 | 1510 | |
1511 | 1511 | |
1512 | 1512 | /** |
1513 | - * Gets Country from latitude/longitude |
|
1514 | - * |
|
1515 | - * @param Float $latitude latitute of the flight |
|
1516 | - * @param Float $longitude longitute of the flight |
|
1517 | - * @return String the countrie |
|
1518 | - */ |
|
1513 | + * Gets Country from latitude/longitude |
|
1514 | + * |
|
1515 | + * @param Float $latitude latitute of the flight |
|
1516 | + * @param Float $longitude longitute of the flight |
|
1517 | + * @return String the countrie |
|
1518 | + */ |
|
1519 | 1519 | public function getCountryFromLatitudeLongitude($latitude,$longitude) |
1520 | 1520 | { |
1521 | 1521 | global $globalDBdriver, $globalDebug; |
@@ -1552,11 +1552,11 @@ discard block |
||
1552 | 1552 | } |
1553 | 1553 | |
1554 | 1554 | /** |
1555 | - * Gets Country from iso2 |
|
1556 | - * |
|
1557 | - * @param String $iso2 ISO2 country code |
|
1558 | - * @return String the countrie |
|
1559 | - */ |
|
1555 | + * Gets Country from iso2 |
|
1556 | + * |
|
1557 | + * @param String $iso2 ISO2 country code |
|
1558 | + * @return String the countrie |
|
1559 | + */ |
|
1560 | 1560 | public function getCountryFromISO2($iso2) |
1561 | 1561 | { |
1562 | 1562 | global $globalDBdriver, $globalDebug; |
@@ -1585,12 +1585,12 @@ discard block |
||
1585 | 1585 | |
1586 | 1586 | |
1587 | 1587 | /** |
1588 | - * Gets the short url from bit.ly |
|
1589 | - * |
|
1590 | - * @param String $url the full url |
|
1591 | - * @return String the bit.ly url |
|
1592 | - * |
|
1593 | - */ |
|
1588 | + * Gets the short url from bit.ly |
|
1589 | + * |
|
1590 | + * @param String $url the full url |
|
1591 | + * @return String the bit.ly url |
|
1592 | + * |
|
1593 | + */ |
|
1594 | 1594 | public function getBitlyURL($url) |
1595 | 1595 | { |
1596 | 1596 | global $globalBitlyAccessToken; |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | |
13 | 13 | |
14 | 14 | /** |
15 | - * Get SQL query part for filter used |
|
16 | - * @param Array $filter the filter |
|
17 | - * @return Array the SQL part |
|
18 | - */ |
|
15 | + * Get SQL query part for filter used |
|
16 | + * @param Array $filter the filter |
|
17 | + * @return Array the SQL part |
|
18 | + */ |
|
19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
21 | 21 | $filters = array(); |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
89 | - * Gets all the spotter information based on the latest data entry |
|
90 | - * |
|
91 | - * @return Array the spotter information |
|
92 | - * |
|
93 | - */ |
|
89 | + * Gets all the spotter information based on the latest data entry |
|
90 | + * |
|
91 | + * @return Array the spotter information |
|
92 | + * |
|
93 | + */ |
|
94 | 94 | public function getLiveTrackerData($limit = '', $sort = '', $filter = array()) |
95 | 95 | { |
96 | 96 | global $globalDBdriver, $globalLiveInterval; |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
135 | - * Gets Minimal Live Spotter data |
|
136 | - * |
|
137 | - * @return Array the spotter information |
|
138 | - * |
|
139 | - */ |
|
135 | + * Gets Minimal Live Spotter data |
|
136 | + * |
|
137 | + * @return Array the spotter information |
|
138 | + * |
|
139 | + */ |
|
140 | 140 | public function getMinLiveTrackerData($filter = array()) |
141 | 141 | { |
142 | 142 | global $globalDBdriver, $globalLiveInterval; |
@@ -170,11 +170,11 @@ discard block |
||
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
173 | - * Gets Minimal Live Spotter data since xx seconds |
|
174 | - * |
|
175 | - * @return Array the spotter information |
|
176 | - * |
|
177 | - */ |
|
173 | + * Gets Minimal Live Spotter data since xx seconds |
|
174 | + * |
|
175 | + * @return Array the spotter information |
|
176 | + * |
|
177 | + */ |
|
178 | 178 | public function getMinLastLiveTrackerData($filter = array()) |
179 | 179 | { |
180 | 180 | global $globalDBdriver, $globalLiveInterval; |
@@ -187,13 +187,13 @@ discard block |
||
187 | 187 | $query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
188 | 188 | FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' |
189 | 189 | ORDER BY tracker_live.famtrackid, tracker_live.date"; |
190 | - } else { |
|
190 | + } else { |
|
191 | 191 | $query = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
192 | 192 | FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' |
193 | 193 | ORDER BY tracker_live.famtrackid, tracker_live.date"; |
194 | 194 | } |
195 | 195 | |
196 | - try { |
|
196 | + try { |
|
197 | 197 | $sth = $this->db->prepare($query); |
198 | 198 | $sth->execute(); |
199 | 199 | } catch(PDOException $e) { |
@@ -205,11 +205,11 @@ discard block |
||
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
208 | - * Gets number of latest data entry |
|
209 | - * |
|
210 | - * @return String number of entry |
|
211 | - * |
|
212 | - */ |
|
208 | + * Gets number of latest data entry |
|
209 | + * |
|
210 | + * @return String number of entry |
|
211 | + * |
|
212 | + */ |
|
213 | 213 | public function getLiveTrackerCount($filter = array()) |
214 | 214 | { |
215 | 215 | global $globalDBdriver, $globalLiveInterval; |
@@ -234,11 +234,11 @@ discard block |
||
234 | 234 | } |
235 | 235 | |
236 | 236 | /** |
237 | - * Gets all the spotter information based on the latest data entry and coord |
|
238 | - * |
|
239 | - * @return Array the spotter information |
|
240 | - * |
|
241 | - */ |
|
237 | + * Gets all the spotter information based on the latest data entry and coord |
|
238 | + * |
|
239 | + * @return Array the spotter information |
|
240 | + * |
|
241 | + */ |
|
242 | 242 | public function getLiveTrackerDatabyCoord($coord, $filter = array()) |
243 | 243 | { |
244 | 244 | global $globalDBdriver, $globalLiveInterval; |
@@ -262,11 +262,11 @@ discard block |
||
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
265 | - * Gets all the spotter information based on a user's latitude and longitude |
|
266 | - * |
|
267 | - * @return Array the spotter information |
|
268 | - * |
|
269 | - */ |
|
265 | + * Gets all the spotter information based on a user's latitude and longitude |
|
266 | + * |
|
267 | + * @return Array the spotter information |
|
268 | + * |
|
269 | + */ |
|
270 | 270 | public function getLatestTrackerForLayar($lat, $lng, $radius, $interval) |
271 | 271 | { |
272 | 272 | $Tracker = new Tracker($this->db); |
@@ -279,142 +279,142 @@ discard block |
||
279 | 279 | if ($lng != '') |
280 | 280 | { |
281 | 281 | if (!is_numeric($lng)) |
282 | - { |
|
283 | - return false; |
|
284 | - } |
|
285 | - } |
|
286 | - |
|
287 | - if ($radius != '') |
|
288 | - { |
|
289 | - if (!is_numeric($radius)) |
|
290 | - { |
|
291 | - return false; |
|
292 | - } |
|
293 | - } |
|
282 | + { |
|
283 | + return false; |
|
284 | + } |
|
285 | + } |
|
286 | + |
|
287 | + if ($radius != '') |
|
288 | + { |
|
289 | + if (!is_numeric($radius)) |
|
290 | + { |
|
291 | + return false; |
|
292 | + } |
|
293 | + } |
|
294 | 294 | $additional_query = ''; |
295 | 295 | if ($interval != '') |
296 | - { |
|
297 | - if (!is_string($interval)) |
|
298 | - { |
|
299 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
300 | - return false; |
|
301 | - } else { |
|
302 | - if ($interval == '1m') |
|
303 | - { |
|
304 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
305 | - } else if ($interval == '15m'){ |
|
306 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
|
307 | - } |
|
308 | - } |
|
309 | - } else { |
|
310 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
311 | - } |
|
312 | - |
|
313 | - $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
296 | + { |
|
297 | + if (!is_string($interval)) |
|
298 | + { |
|
299 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
300 | + return false; |
|
301 | + } else { |
|
302 | + if ($interval == '1m') |
|
303 | + { |
|
304 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
305 | + } else if ($interval == '15m'){ |
|
306 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
|
307 | + } |
|
308 | + } |
|
309 | + } else { |
|
310 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
311 | + } |
|
312 | + |
|
313 | + $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
314 | 314 | WHERE tracker_live.latitude <> '' |
315 | 315 | AND tracker_live.longitude <> '' |
316 | 316 | ".$additional_query." |
317 | 317 | HAVING distance < :radius |
318 | 318 | ORDER BY distance"; |
319 | 319 | |
320 | - $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
320 | + $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
321 | 321 | |
322 | - return $spotter_array; |
|
323 | - } |
|
322 | + return $spotter_array; |
|
323 | + } |
|
324 | 324 | |
325 | 325 | |
326 | - /** |
|
327 | - * Gets all the spotter information based on a particular callsign |
|
328 | - * |
|
329 | - * @return Array the spotter information |
|
330 | - * |
|
331 | - */ |
|
326 | + /** |
|
327 | + * Gets all the spotter information based on a particular callsign |
|
328 | + * |
|
329 | + * @return Array the spotter information |
|
330 | + * |
|
331 | + */ |
|
332 | 332 | public function getLastLiveTrackerDataByIdent($ident) |
333 | 333 | { |
334 | 334 | $Tracker = new Tracker($this->db); |
335 | 335 | date_default_timezone_set('UTC'); |
336 | 336 | |
337 | 337 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
338 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
338 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
339 | 339 | |
340 | 340 | $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true); |
341 | 341 | |
342 | 342 | return $spotter_array; |
343 | 343 | } |
344 | 344 | |
345 | - /** |
|
346 | - * Gets all the spotter information based on a particular callsign |
|
347 | - * |
|
348 | - * @return Array the spotter information |
|
349 | - * |
|
350 | - */ |
|
345 | + /** |
|
346 | + * Gets all the spotter information based on a particular callsign |
|
347 | + * |
|
348 | + * @return Array the spotter information |
|
349 | + * |
|
350 | + */ |
|
351 | 351 | public function getDateLiveTrackerDataByIdent($ident,$date) |
352 | 352 | { |
353 | 353 | $Tracker = new Tracker($this->db); |
354 | 354 | date_default_timezone_set('UTC'); |
355 | 355 | |
356 | 356 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
357 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
357 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
358 | 358 | |
359 | - $date = date('c',$date); |
|
359 | + $date = date('c',$date); |
|
360 | 360 | $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
361 | 361 | |
362 | 362 | return $spotter_array; |
363 | 363 | } |
364 | 364 | |
365 | - /** |
|
366 | - * Gets last spotter information based on a particular callsign |
|
367 | - * |
|
368 | - * @return Array the spotter information |
|
369 | - * |
|
370 | - */ |
|
365 | + /** |
|
366 | + * Gets last spotter information based on a particular callsign |
|
367 | + * |
|
368 | + * @return Array the spotter information |
|
369 | + * |
|
370 | + */ |
|
371 | 371 | public function getLastLiveTrackerDataById($id) |
372 | 372 | { |
373 | 373 | $Tracker = new Tracker($this->db); |
374 | 374 | date_default_timezone_set('UTC'); |
375 | 375 | |
376 | 376 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
377 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
377 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
378 | 378 | |
379 | 379 | $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true); |
380 | 380 | |
381 | 381 | return $spotter_array; |
382 | 382 | } |
383 | 383 | |
384 | - /** |
|
385 | - * Gets last spotter information based on a particular callsign |
|
386 | - * |
|
387 | - * @return Array the spotter information |
|
388 | - * |
|
389 | - */ |
|
384 | + /** |
|
385 | + * Gets last spotter information based on a particular callsign |
|
386 | + * |
|
387 | + * @return Array the spotter information |
|
388 | + * |
|
389 | + */ |
|
390 | 390 | public function getDateLiveTrackerDataById($id,$date) |
391 | 391 | { |
392 | 392 | $Tracker = new Tracker($this->db); |
393 | 393 | date_default_timezone_set('UTC'); |
394 | 394 | |
395 | 395 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
396 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
397 | - $date = date('c',$date); |
|
396 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
397 | + $date = date('c',$date); |
|
398 | 398 | $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
399 | 399 | |
400 | 400 | return $spotter_array; |
401 | 401 | } |
402 | 402 | |
403 | - /** |
|
404 | - * Gets altitude information based on a particular callsign |
|
405 | - * |
|
406 | - * @return Array the spotter information |
|
407 | - * |
|
408 | - */ |
|
403 | + /** |
|
404 | + * Gets altitude information based on a particular callsign |
|
405 | + * |
|
406 | + * @return Array the spotter information |
|
407 | + * |
|
408 | + */ |
|
409 | 409 | public function getAltitudeLiveTrackerDataByIdent($ident) |
410 | 410 | { |
411 | 411 | |
412 | 412 | date_default_timezone_set('UTC'); |
413 | 413 | |
414 | 414 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
415 | - $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
415 | + $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
416 | 416 | |
417 | - try { |
|
417 | + try { |
|
418 | 418 | |
419 | 419 | $sth = $this->db->prepare($query); |
420 | 420 | $sth->execute(array(':ident' => $ident)); |
@@ -427,12 +427,12 @@ discard block |
||
427 | 427 | return $spotter_array; |
428 | 428 | } |
429 | 429 | |
430 | - /** |
|
431 | - * Gets all the spotter information based on a particular id |
|
432 | - * |
|
433 | - * @return Array the spotter information |
|
434 | - * |
|
435 | - */ |
|
430 | + /** |
|
431 | + * Gets all the spotter information based on a particular id |
|
432 | + * |
|
433 | + * @return Array the spotter information |
|
434 | + * |
|
435 | + */ |
|
436 | 436 | public function getAllLiveTrackerDataById($id,$liveinterval = false) |
437 | 437 | { |
438 | 438 | global $globalDBdriver, $globalLiveInterval; |
@@ -460,18 +460,18 @@ discard block |
||
460 | 460 | return $spotter_array; |
461 | 461 | } |
462 | 462 | |
463 | - /** |
|
464 | - * Gets all the spotter information based on a particular ident |
|
465 | - * |
|
466 | - * @return Array the spotter information |
|
467 | - * |
|
468 | - */ |
|
463 | + /** |
|
464 | + * Gets all the spotter information based on a particular ident |
|
465 | + * |
|
466 | + * @return Array the spotter information |
|
467 | + * |
|
468 | + */ |
|
469 | 469 | public function getAllLiveTrackerDataByIdent($ident) |
470 | 470 | { |
471 | 471 | date_default_timezone_set('UTC'); |
472 | 472 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
473 | 473 | $query = self::$global_query.' WHERE tracker_live.ident = :ident'; |
474 | - try { |
|
474 | + try { |
|
475 | 475 | |
476 | 476 | $sth = $this->db->prepare($query); |
477 | 477 | $sth->execute(array(':ident' => $ident)); |
@@ -485,23 +485,23 @@ discard block |
||
485 | 485 | |
486 | 486 | |
487 | 487 | /** |
488 | - * Deletes all info in the table |
|
489 | - * |
|
490 | - * @return String success or false |
|
491 | - * |
|
492 | - */ |
|
488 | + * Deletes all info in the table |
|
489 | + * |
|
490 | + * @return String success or false |
|
491 | + * |
|
492 | + */ |
|
493 | 493 | public function deleteLiveTrackerData() |
494 | 494 | { |
495 | 495 | global $globalDBdriver; |
496 | 496 | if ($globalDBdriver == 'mysql') { |
497 | 497 | //$query = "DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= tracker_live.date"; |
498 | 498 | $query = 'DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= tracker_live.date'; |
499 | - //$query = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)"; |
|
499 | + //$query = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)"; |
|
500 | 500 | } else { |
501 | 501 | $query = "DELETE FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date"; |
502 | 502 | } |
503 | 503 | |
504 | - try { |
|
504 | + try { |
|
505 | 505 | |
506 | 506 | $sth = $this->db->prepare($query); |
507 | 507 | $sth->execute(); |
@@ -513,18 +513,18 @@ discard block |
||
513 | 513 | } |
514 | 514 | |
515 | 515 | /** |
516 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
517 | - * |
|
518 | - * @return String success or false |
|
519 | - * |
|
520 | - */ |
|
516 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
517 | + * |
|
518 | + * @return String success or false |
|
519 | + * |
|
520 | + */ |
|
521 | 521 | public function deleteLiveTrackerDataNotUpdated() |
522 | 522 | { |
523 | 523 | global $globalDBdriver, $globalDebug; |
524 | 524 | if ($globalDBdriver == 'mysql') { |
525 | 525 | //$query = 'SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < tracker_live.date) LIMIT 800 OFFSET 0'; |
526 | - $query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
527 | - try { |
|
526 | + $query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
527 | + try { |
|
528 | 528 | |
529 | 529 | $sth = $this->db->prepare($query); |
530 | 530 | $sth->execute(); |
@@ -532,8 +532,8 @@ discard block |
||
532 | 532 | return "error"; |
533 | 533 | } |
534 | 534 | $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
535 | - $i = 0; |
|
536 | - $j =0; |
|
535 | + $i = 0; |
|
536 | + $j =0; |
|
537 | 537 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
538 | 538 | foreach($all as $row) |
539 | 539 | { |
@@ -541,20 +541,20 @@ discard block |
||
541 | 541 | $j++; |
542 | 542 | if ($j == 30) { |
543 | 543 | if ($globalDebug) echo "."; |
544 | - try { |
|
544 | + try { |
|
545 | 545 | |
546 | 546 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
547 | 547 | $sth->execute(); |
548 | 548 | } catch(PDOException $e) { |
549 | 549 | return "error"; |
550 | 550 | } |
551 | - $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
|
552 | - $j = 0; |
|
551 | + $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
|
552 | + $j = 0; |
|
553 | 553 | } |
554 | 554 | $query_delete .= "'".$row['famtrackid']."',"; |
555 | 555 | } |
556 | 556 | if ($i > 0) { |
557 | - try { |
|
557 | + try { |
|
558 | 558 | |
559 | 559 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
560 | 560 | $sth->execute(); |
@@ -565,9 +565,9 @@ discard block |
||
565 | 565 | return "success"; |
566 | 566 | } elseif ($globalDBdriver == 'pgsql') { |
567 | 567 | //$query = "SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < tracker_live.date) LIMIT 800 OFFSET 0"; |
568 | - //$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
569 | - $query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
570 | - try { |
|
568 | + //$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
569 | + $query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
570 | + try { |
|
571 | 571 | |
572 | 572 | $sth = $this->db->prepare($query); |
573 | 573 | $sth->execute(); |
@@ -611,17 +611,17 @@ discard block |
||
611 | 611 | } |
612 | 612 | |
613 | 613 | /** |
614 | - * Deletes all info in the table for an ident |
|
615 | - * |
|
616 | - * @return String success or false |
|
617 | - * |
|
618 | - */ |
|
614 | + * Deletes all info in the table for an ident |
|
615 | + * |
|
616 | + * @return String success or false |
|
617 | + * |
|
618 | + */ |
|
619 | 619 | public function deleteLiveTrackerDataByIdent($ident) |
620 | 620 | { |
621 | 621 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
622 | 622 | $query = 'DELETE FROM tracker_live WHERE ident = :ident'; |
623 | 623 | |
624 | - try { |
|
624 | + try { |
|
625 | 625 | |
626 | 626 | $sth = $this->db->prepare($query); |
627 | 627 | $sth->execute(array(':ident' => $ident)); |
@@ -633,17 +633,17 @@ discard block |
||
633 | 633 | } |
634 | 634 | |
635 | 635 | /** |
636 | - * Deletes all info in the table for an id |
|
637 | - * |
|
638 | - * @return String success or false |
|
639 | - * |
|
640 | - */ |
|
636 | + * Deletes all info in the table for an id |
|
637 | + * |
|
638 | + * @return String success or false |
|
639 | + * |
|
640 | + */ |
|
641 | 641 | public function deleteLiveTrackerDataById($id) |
642 | 642 | { |
643 | 643 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
644 | 644 | $query = 'DELETE FROM tracker_live WHERE famtrackid = :id'; |
645 | 645 | |
646 | - try { |
|
646 | + try { |
|
647 | 647 | |
648 | 648 | $sth = $this->db->prepare($query); |
649 | 649 | $sth->execute(array(':id' => $id)); |
@@ -656,11 +656,11 @@ discard block |
||
656 | 656 | |
657 | 657 | |
658 | 658 | /** |
659 | - * Gets the aircraft ident within the last hour |
|
660 | - * |
|
661 | - * @return String the ident |
|
662 | - * |
|
663 | - */ |
|
659 | + * Gets the aircraft ident within the last hour |
|
660 | + * |
|
661 | + * @return String the ident |
|
662 | + * |
|
663 | + */ |
|
664 | 664 | public function getIdentFromLastHour($ident) |
665 | 665 | { |
666 | 666 | global $globalDBdriver, $globalTimezone; |
@@ -686,14 +686,14 @@ discard block |
||
686 | 686 | $ident_result = $row['ident']; |
687 | 687 | } |
688 | 688 | return $ident_result; |
689 | - } |
|
689 | + } |
|
690 | 690 | |
691 | 691 | /** |
692 | - * Check recent aircraft |
|
693 | - * |
|
694 | - * @return String the ident |
|
695 | - * |
|
696 | - */ |
|
692 | + * Check recent aircraft |
|
693 | + * |
|
694 | + * @return String the ident |
|
695 | + * |
|
696 | + */ |
|
697 | 697 | public function checkIdentRecent($ident) |
698 | 698 | { |
699 | 699 | global $globalDBdriver, $globalTimezone; |
@@ -719,14 +719,14 @@ discard block |
||
719 | 719 | $ident_result = $row['famtrackid']; |
720 | 720 | } |
721 | 721 | return $ident_result; |
722 | - } |
|
722 | + } |
|
723 | 723 | |
724 | 724 | /** |
725 | - * Check recent aircraft by id |
|
726 | - * |
|
727 | - * @return String the ident |
|
728 | - * |
|
729 | - */ |
|
725 | + * Check recent aircraft by id |
|
726 | + * |
|
727 | + * @return String the ident |
|
728 | + * |
|
729 | + */ |
|
730 | 730 | public function checkIdRecent($id) |
731 | 731 | { |
732 | 732 | global $globalDBdriver, $globalTimezone; |
@@ -752,19 +752,19 @@ discard block |
||
752 | 752 | $ident_result = $row['famtrackid']; |
753 | 753 | } |
754 | 754 | return $ident_result; |
755 | - } |
|
755 | + } |
|
756 | 756 | |
757 | 757 | /** |
758 | - * Adds a new spotter data |
|
759 | - * |
|
760 | - * @param String $famtrackid the ID from flightaware |
|
761 | - * @param String $ident the flight ident |
|
762 | - * @param String $aircraft_icao the aircraft type |
|
763 | - * @param String $departure_airport_icao the departure airport |
|
764 | - * @param String $arrival_airport_icao the arrival airport |
|
765 | - * @return String success or false |
|
766 | - * |
|
767 | - */ |
|
758 | + * Adds a new spotter data |
|
759 | + * |
|
760 | + * @param String $famtrackid the ID from flightaware |
|
761 | + * @param String $ident the flight ident |
|
762 | + * @param String $aircraft_icao the aircraft type |
|
763 | + * @param String $departure_airport_icao the departure airport |
|
764 | + * @param String $arrival_airport_icao the arrival airport |
|
765 | + * @return String success or false |
|
766 | + * |
|
767 | + */ |
|
768 | 768 | public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
769 | 769 | { |
770 | 770 | global $globalURL, $globalArchive, $globalDebug; |
@@ -837,8 +837,8 @@ discard block |
||
837 | 837 | $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
838 | 838 | $type = filter_var($type,FILTER_SANITIZE_STRING); |
839 | 839 | |
840 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
841 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
840 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
841 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
842 | 842 | |
843 | 843 | $query = 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
844 | 844 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)'; |
@@ -848,9 +848,9 @@ discard block |
||
848 | 848 | |
849 | 849 | $sth = $this->db->prepare($query); |
850 | 850 | $sth->execute($query_values); |
851 | - } catch(PDOException $e) { |
|
852 | - return "error : ".$e->getMessage(); |
|
853 | - } |
|
851 | + } catch(PDOException $e) { |
|
852 | + return "error : ".$e->getMessage(); |
|
853 | + } |
|
854 | 854 | /* |
855 | 855 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
856 | 856 | if ($globalDebug) echo '(Add to SBS archive : '; |
@@ -7,18 +7,18 @@ discard block |
||
7 | 7 | public $latest_schema = 37; |
8 | 8 | |
9 | 9 | public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { |
10 | - global $globalDBdriver; |
|
11 | - if ($dbc === null) { |
|
10 | + global $globalDBdriver; |
|
11 | + if ($dbc === null) { |
|
12 | 12 | if ($this->db === null && $dbname === null) { |
13 | - if ($user === null && $pass === null) { |
|
13 | + if ($user === null && $pass === null) { |
|
14 | 14 | $this->createDBConnection(); |
15 | - } else { |
|
15 | + } else { |
|
16 | 16 | $this->createDBConnection(null,$user,$pass); |
17 | - } |
|
17 | + } |
|
18 | 18 | } else { |
19 | - $this->createDBConnection($dbname); |
|
19 | + $this->createDBConnection($dbname); |
|
20 | 20 | } |
21 | - } elseif ($dbname === null || $dbname === 'default') { |
|
21 | + } elseif ($dbname === null || $dbname === 'default') { |
|
22 | 22 | $this->db = $dbc; |
23 | 23 | if ($this->connectionExists() === false) { |
24 | 24 | /* |
@@ -28,10 +28,10 @@ discard block |
||
28 | 28 | */ |
29 | 29 | $this->createDBConnection(); |
30 | 30 | } |
31 | - } else { |
|
31 | + } else { |
|
32 | 32 | //$this->connectionExists(); |
33 | 33 | $this->dbs[$dbname] = $dbc; |
34 | - } |
|
34 | + } |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | public function db() { |
@@ -47,11 +47,11 @@ discard block |
||
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
50 | - * Creates the database connection |
|
51 | - * |
|
52 | - * @return Boolean of the database connection |
|
53 | - * |
|
54 | - */ |
|
50 | + * Creates the database connection |
|
51 | + * |
|
52 | + * @return Boolean of the database connection |
|
53 | + * |
|
54 | + */ |
|
55 | 55 | |
56 | 56 | public function createDBConnection($DBname = null, $user = null, $pass = null) |
57 | 57 | { |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | return false; |
149 | 149 | } |
150 | 150 | if($results->rowCount()>0) { |
151 | - return true; |
|
151 | + return true; |
|
152 | 152 | } |
153 | 153 | else return false; |
154 | 154 | } |
@@ -165,14 +165,14 @@ discard block |
||
165 | 165 | $sum = $sum->fetchColumn(0); |
166 | 166 | } else $sum = 0; |
167 | 167 | if (intval($sum) !== 2) { |
168 | - return false; |
|
168 | + return false; |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | } catch(PDOException $e) { |
172 | 172 | if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
173 | - throw $e; |
|
174 | - } |
|
175 | - //echo 'error ! '.$e->getMessage(); |
|
173 | + throw $e; |
|
174 | + } |
|
175 | + //echo 'error ! '.$e->getMessage(); |
|
176 | 176 | return false; |
177 | 177 | } |
178 | 178 | return true; |
@@ -276,8 +276,8 @@ discard block |
||
276 | 276 | $version = 0; |
277 | 277 | if ($this->tableExists('aircraft')) { |
278 | 278 | if (!$this->tableExists('config')) { |
279 | - $version = '1'; |
|
280 | - return $version; |
|
279 | + $version = '1'; |
|
280 | + return $version; |
|
281 | 281 | } else { |
282 | 282 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
283 | 283 | try { |
@@ -298,8 +298,8 @@ discard block |
||
298 | 298 | * @return Boolean if latest version or not |
299 | 299 | */ |
300 | 300 | public function latest() { |
301 | - if ($this->check_schema_version() == $this->latest_schema) return true; |
|
302 | - else return false; |
|
301 | + if ($this->check_schema_version() == $this->latest_schema) return true; |
|
302 | + else return false; |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | } |
@@ -9,16 +9,16 @@ discard block |
||
9 | 9 | require_once(dirname(__FILE__).'/class.Source.php'); |
10 | 10 | |
11 | 11 | class TrackerImport { |
12 | - private $all_tracked = array(); |
|
13 | - private $last_delete_hourly = 0; |
|
14 | - private $last_delete = 0; |
|
15 | - private $stats = array(); |
|
16 | - private $tmd = 0; |
|
17 | - private $source_location = array(); |
|
18 | - public $db = null; |
|
19 | - public $nb = 0; |
|
12 | + private $all_tracked = array(); |
|
13 | + private $last_delete_hourly = 0; |
|
14 | + private $last_delete = 0; |
|
15 | + private $stats = array(); |
|
16 | + private $tmd = 0; |
|
17 | + private $source_location = array(); |
|
18 | + public $db = null; |
|
19 | + public $nb = 0; |
|
20 | 20 | |
21 | - public function __construct($dbc = null) { |
|
21 | + public function __construct($dbc = null) { |
|
22 | 22 | global $globalBeta; |
23 | 23 | $Connection = new Connection($dbc); |
24 | 24 | $this->db = $Connection->db(); |
@@ -40,50 +40,50 @@ discard block |
||
40 | 40 | } |
41 | 41 | } |
42 | 42 | */ |
43 | - } |
|
43 | + } |
|
44 | 44 | |
45 | - public function checkAll() { |
|
45 | + public function checkAll() { |
|
46 | 46 | global $globalDebug; |
47 | 47 | if ($globalDebug) echo "Update last seen tracked data...\n"; |
48 | 48 | foreach ($this->all_tracked as $key => $flight) { |
49 | - if (isset($this->all_tracked[$key]['id'])) { |
|
49 | + if (isset($this->all_tracked[$key]['id'])) { |
|
50 | 50 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
51 | - $Tracker = new Tracker($this->db); |
|
52 | - $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
53 | - } |
|
51 | + $Tracker = new Tracker($this->db); |
|
52 | + $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
53 | + } |
|
54 | + } |
|
54 | 55 | } |
55 | - } |
|
56 | 56 | |
57 | - public function del() { |
|
57 | + public function del() { |
|
58 | 58 | global $globalDebug; |
59 | 59 | // Delete old infos |
60 | 60 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
61 | 61 | foreach ($this->all_tracked as $key => $flight) { |
62 | - if (isset($flight['lastupdate'])) { |
|
63 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
64 | - if (isset($this->all_tracked[$key]['id'])) { |
|
65 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
62 | + if (isset($flight['lastupdate'])) { |
|
63 | + if ($flight['lastupdate'] < (time()-3000)) { |
|
64 | + if (isset($this->all_tracked[$key]['id'])) { |
|
65 | + if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
66 | 66 | /* |
67 | 67 | $TrackerLive = new TrackerLive(); |
68 | 68 | $TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']); |
69 | 69 | $TrackerLive->db = null; |
70 | 70 | */ |
71 | - //$real_arrival = $this->arrival($key); |
|
72 | - $Tracker = new Tracker($this->db); |
|
73 | - if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
71 | + //$real_arrival = $this->arrival($key); |
|
72 | + $Tracker = new Tracker($this->db); |
|
73 | + if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
74 | 74 | $result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']); |
75 | 75 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
76 | 76 | } |
77 | 77 | // Put in archive |
78 | 78 | // $Tracker->db = null; |
79 | - } |
|
80 | - unset($this->all_tracked[$key]); |
|
81 | - } |
|
82 | - } |
|
83 | - } |
|
84 | - } |
|
79 | + } |
|
80 | + unset($this->all_tracked[$key]); |
|
81 | + } |
|
82 | + } |
|
83 | + } |
|
84 | + } |
|
85 | 85 | |
86 | - public function add($line) { |
|
86 | + public function add($line) { |
|
87 | 87 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked; |
88 | 88 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
89 | 89 | date_default_timezone_set('UTC'); |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | |
93 | 93 | // SBS format is CSV format |
94 | 94 | if(is_array($line) && isset($line['ident'])) { |
95 | - //print_r($line); |
|
96 | - if (isset($line['ident'])) { |
|
95 | + //print_r($line); |
|
96 | + if (isset($line['ident'])) { |
|
97 | 97 | |
98 | 98 | /* |
99 | 99 | // Increment message number |
@@ -109,29 +109,29 @@ discard block |
||
109 | 109 | */ |
110 | 110 | |
111 | 111 | $Common = new Common(); |
112 | - if (!isset($line['id'])) $id = trim($line['ident']); |
|
113 | - else $id = trim($line['id']); |
|
112 | + if (!isset($line['id'])) $id = trim($line['ident']); |
|
113 | + else $id = trim($line['id']); |
|
114 | 114 | |
115 | 115 | if (!isset($this->all_tracked[$id])) { |
116 | - $this->all_tracked[$id] = array(); |
|
117 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0)); |
|
118 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
|
119 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
120 | - if (!isset($line['id'])) { |
|
116 | + $this->all_tracked[$id] = array(); |
|
117 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0)); |
|
118 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
|
119 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
120 | + if (!isset($line['id'])) { |
|
121 | 121 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
122 | 122 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
123 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
124 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
123 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
124 | + if ($globalAllTracked !== FALSE) $dataFound = true; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60) { |
128 | - if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
|
128 | + if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
|
129 | 129 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
130 | - } else { |
|
130 | + } else { |
|
131 | 131 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
132 | 132 | 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"; |
133 | 133 | return ''; |
134 | - } |
|
134 | + } |
|
135 | 135 | } else { |
136 | 136 | date_default_timezone_set('UTC'); |
137 | 137 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
@@ -139,38 +139,38 @@ discard block |
||
139 | 139 | |
140 | 140 | //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'])) { |
141 | 141 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
142 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
143 | - if ($this->all_tracked[$id]['addedTracker'] == 1) { |
|
142 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
143 | + if ($this->all_tracked[$id]['addedTracker'] == 1) { |
|
144 | 144 | $timeelapsed = microtime(true); |
145 | - $Tracker = new Tracker($this->db); |
|
146 | - $fromsource = NULL; |
|
147 | - $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
145 | + $Tracker = new Tracker($this->db); |
|
146 | + $fromsource = NULL; |
|
147 | + $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
148 | 148 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
149 | 149 | $Tracker->db = null; |
150 | 150 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
151 | - } |
|
152 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
151 | + } |
|
152 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | if (isset($line['speed']) && $line['speed'] != '') { |
156 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
157 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
156 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
157 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
158 | 158 | } 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'])) { |
159 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
160 | - if ($distance > 1000 && $distance < 10000) { |
|
159 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
160 | + if ($distance > 1000 && $distance < 10000) { |
|
161 | 161 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
162 | 162 | $speed = $speed*3.6; |
163 | 163 | if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
164 | 164 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
165 | - } |
|
165 | + } |
|
166 | 166 | } |
167 | 167 | |
168 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
169 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
170 | - else unset($timediff); |
|
171 | - 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')))) { |
|
168 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
169 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
170 | + else unset($timediff); |
|
171 | + 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')))) { |
|
172 | 172 | 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'])) { |
173 | - 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'])) { |
|
173 | + 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'])) { |
|
174 | 174 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
175 | 175 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
176 | 176 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -184,120 +184,120 @@ discard block |
||
184 | 184 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
185 | 185 | $this->tmd = 0; |
186 | 186 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
187 | - } |
|
187 | + } |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
191 | 191 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
192 | 192 | 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') { |
193 | - $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
194 | - $dataFound = true; |
|
195 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
193 | + $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
194 | + $dataFound = true; |
|
195 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
196 | 196 | } |
197 | 197 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
198 | 198 | } |
199 | 199 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
200 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
200 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
201 | 201 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
202 | 202 | 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') { |
203 | - $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
204 | - $dataFound = true; |
|
205 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
203 | + $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
204 | + $dataFound = true; |
|
205 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
206 | 206 | } |
207 | 207 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
208 | 208 | } |
209 | 209 | |
210 | - } else if ($globalDebug && $timediff > 20) { |
|
210 | + } else if ($globalDebug && $timediff > 20) { |
|
211 | 211 | $this->tmd = $this->tmd + 1; |
212 | 212 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
213 | 213 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
214 | 214 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
215 | 215 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
216 | - } |
|
216 | + } |
|
217 | 217 | } |
218 | 218 | if (isset($line['last_update']) && $line['last_update'] != '') { |
219 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
220 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
219 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
220 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
221 | 221 | } |
222 | 222 | if (isset($line['format_source']) && $line['format_source'] != '') { |
223 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
223 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
224 | 224 | } |
225 | 225 | if (isset($line['source_name']) && $line['source_name'] != '') { |
226 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
226 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
227 | 227 | } |
228 | 228 | if (isset($line['comment']) && $line['comment'] != '') { |
229 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment'])); |
|
230 | - //$dataFound = true; |
|
229 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment'])); |
|
230 | + //$dataFound = true; |
|
231 | 231 | } |
232 | 232 | if (isset($line['type']) && $line['type'] != '') { |
233 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
234 | - //$dataFound = true; |
|
233 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
234 | + //$dataFound = true; |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | if (isset($line['altitude']) && $line['altitude'] != '') { |
238 | - //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
238 | + //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
239 | 239 | if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true; |
240 | 240 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => round($line['altitude']/100))); |
241 | 241 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude'])); |
242 | 242 | //$dataFound = true; |
243 | - //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
243 | + //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
247 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
247 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | if (isset($line['heading']) && $line['heading'] != '') { |
251 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
252 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
253 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
254 | - //$dataFound = true; |
|
251 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
252 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
253 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
254 | + //$dataFound = true; |
|
255 | 255 | } 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']) { |
256 | - $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']); |
|
257 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
258 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
259 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
256 | + $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']); |
|
257 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
258 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
259 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
260 | 260 | } |
261 | 261 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
262 | 262 | |
263 | 263 | if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) { |
264 | - $this->all_tracked[$id]['lastupdate'] = time(); |
|
265 | - if ($this->all_tracked[$id]['addedTracker'] == 0) { |
|
266 | - 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'])) { |
|
267 | - if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
264 | + $this->all_tracked[$id]['lastupdate'] = time(); |
|
265 | + if ($this->all_tracked[$id]['addedTracker'] == 0) { |
|
266 | + 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'])) { |
|
267 | + if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
268 | 268 | if ($globalDebug) echo "Check if aircraft is already in DB..."; |
269 | 269 | $timeelapsed = microtime(true); |
270 | 270 | $TrackerLive = new TrackerLive($this->db); |
271 | 271 | if (isset($line['id'])) { |
272 | - $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
|
273 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
272 | + $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
|
273 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
274 | 274 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
275 | - $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
|
276 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
275 | + $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
|
276 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
277 | 277 | } else $recent_ident = ''; |
278 | 278 | $TrackerLive->db=null; |
279 | 279 | |
280 | 280 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
281 | 281 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
282 | - } else { |
|
282 | + } else { |
|
283 | 283 | $recent_ident = ''; |
284 | 284 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
285 | - } |
|
286 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
287 | - if($recent_ident == "") |
|
288 | - { |
|
285 | + } |
|
286 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
287 | + if($recent_ident == "") |
|
288 | + { |
|
289 | 289 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
290 | 290 | //adds the spotter data for the archive |
291 | - $highlight = ''; |
|
292 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
293 | - $timeelapsed = microtime(true); |
|
294 | - $Tracker = new Tracker($this->db); |
|
295 | - $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
296 | - $Tracker->db = null; |
|
297 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
298 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
291 | + $highlight = ''; |
|
292 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
293 | + $timeelapsed = microtime(true); |
|
294 | + $Tracker = new Tracker($this->db); |
|
295 | + $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
296 | + $Tracker->db = null; |
|
297 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
298 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
299 | 299 | |
300 | - /* |
|
300 | + /* |
|
301 | 301 | // Add source stat in DB |
302 | 302 | $Stats = new Stats($this->db); |
303 | 303 | if (!empty($this->stats)) { |
@@ -324,20 +324,20 @@ discard block |
||
324 | 324 | } |
325 | 325 | $Stats->db = null; |
326 | 326 | */ |
327 | - $this->del(); |
|
327 | + $this->del(); |
|
328 | 328 | //$ignoreImport = false; |
329 | 329 | $this->all_tracked[$id]['addedTracker'] = 1; |
330 | 330 | //print_r($this->all_tracked[$id]); |
331 | 331 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
332 | - if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
333 | - //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
334 | - $TrackerLive = new TrackerLive($this->db); |
|
335 | - $TrackerLive->deleteLiveTrackerData(); |
|
336 | - $TrackerLive->db=null; |
|
337 | - if ($globalDebug) echo " Done\n"; |
|
338 | - $this->last_delete = time(); |
|
332 | + if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
333 | + //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
334 | + $TrackerLive = new TrackerLive($this->db); |
|
335 | + $TrackerLive->deleteLiveTrackerData(); |
|
336 | + $TrackerLive->db=null; |
|
337 | + if ($globalDebug) echo " Done\n"; |
|
338 | + $this->last_delete = time(); |
|
339 | 339 | } |
340 | - } else { |
|
340 | + } else { |
|
341 | 341 | $this->all_tracked[$id]['id'] = $recent_ident; |
342 | 342 | $this->all_tracked[$id]['addedTracker'] = 1; |
343 | 343 | if (isset($globalDaemon) && !$globalDaemon) { |
@@ -346,16 +346,16 @@ discard block |
||
346 | 346 | $Tracker->db = null; |
347 | 347 | } |
348 | 348 | |
349 | - } |
|
349 | + } |
|
350 | + } |
|
350 | 351 | } |
351 | - } |
|
352 | - //adds the spotter LIVE data |
|
353 | - if ($globalDebug) { |
|
352 | + //adds the spotter LIVE data |
|
353 | + if ($globalDebug) { |
|
354 | 354 | 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'].' - Altitude : '.$this->all_tracked[$id]['altitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n"; |
355 | - } |
|
356 | - $ignoreImport = false; |
|
355 | + } |
|
356 | + $ignoreImport = false; |
|
357 | 357 | |
358 | - if (!$ignoreImport) { |
|
358 | + if (!$ignoreImport) { |
|
359 | 359 | 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'])) { |
360 | 360 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
361 | 361 | $timeelapsed = microtime(true); |
@@ -427,22 +427,22 @@ discard block |
||
427 | 427 | |
428 | 428 | |
429 | 429 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
430 | - if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
431 | - $TrackerLive = new TrackerLive($this->db); |
|
432 | - $TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
433 | - $TrackerLive->db = null; |
|
434 | - //TrackerLive->deleteLiveTrackerData(); |
|
435 | - if ($globalDebug) echo " Done\n"; |
|
436 | - $this->last_delete_hourly = time(); |
|
430 | + if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
431 | + $TrackerLive = new TrackerLive($this->db); |
|
432 | + $TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
433 | + $TrackerLive->db = null; |
|
434 | + //TrackerLive->deleteLiveTrackerData(); |
|
435 | + if ($globalDebug) echo " Done\n"; |
|
436 | + $this->last_delete_hourly = time(); |
|
437 | 437 | } |
438 | 438 | |
439 | - } |
|
440 | - //$ignoreImport = false; |
|
439 | + } |
|
440 | + //$ignoreImport = false; |
|
441 | 441 | } |
442 | 442 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
443 | 443 | if ($send) return $this->all_tracked[$id]; |
444 | - } |
|
444 | + } |
|
445 | + } |
|
445 | 446 | } |
446 | - } |
|
447 | 447 | } |
448 | 448 | ?> |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | return ($dec); |
58 | 58 | } |
59 | 59 | |
60 | - /* |
|
60 | + /* |
|
61 | 61 | $ais_map64 = array( |
62 | 62 | '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', // 48 |
63 | 63 | ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', |
@@ -97,13 +97,13 @@ discard block |
||
97 | 97 | // ' ' --- '?', // 0x20 - 0x3F |
98 | 98 | // '@' --- '_', // 0x40 - 0x5F |
99 | 99 | $ais_chars = array( |
100 | - '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', |
|
101 | - 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', |
|
102 | - 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', |
|
103 | - '^', '_', ' ', '!', '\"', '#', '$', '%', '&', '\'', |
|
104 | - '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', |
|
105 | - '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', |
|
106 | - '<', '=', '>', '?' |
|
100 | + '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', |
|
101 | + 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', |
|
102 | + 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', |
|
103 | + '^', '_', ' ', '!', '\"', '#', '$', '%', '&', '\'', |
|
104 | + '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', |
|
105 | + '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', |
|
106 | + '<', '=', '>', '?' |
|
107 | 107 | ); |
108 | 108 | // " |
109 | 109 | $rv = ''; |
@@ -419,8 +419,8 @@ discard block |
||
419 | 419 | } |
420 | 420 | if ($num_seq > 1) { // for multipart messages |
421 | 421 | if ($cmsg_sid != $msg_sid // different msg_sid |
422 | - || $msg_sid == -1 // invalid initial msg_sid |
|
423 | - || ($seq - $pseq) != 1 // not insequence |
|
422 | + || $msg_sid == -1 // invalid initial msg_sid |
|
423 | + || ($seq - $pseq) != 1 // not insequence |
|
424 | 424 | ) { // invalid for multipart message |
425 | 425 | $msg_sid = -1; |
426 | 426 | $cmsg_sid = -1; |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | $itu = $itu.$pcs[5]; // get itu message |
434 | 434 | $filler += (int)$pcs[6][0]; // get filler |
435 | 435 | if ($num_seq == 1 // valid single message |
436 | - || $num_seq == $pseq // valid multi-part message |
|
436 | + || $num_seq == $pseq // valid multi-part message |
|
437 | 437 | ) { |
438 | 438 | if ($num_seq != 1) { // test |
439 | 439 | //echo $rawdata; |
@@ -516,13 +516,13 @@ discard block |
||
516 | 516 | else $pad = ''; |
517 | 517 | $rv = ''; |
518 | 518 | $ais_chars = array( |
519 | - '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9, |
|
520 | - 'J'=>10, 'K'=>11, 'L'=>12, 'M'=>13, 'N'=>14, 'O'=>15, 'P'=>16, 'Q'=>17, 'R'=>18, 'S'=>19, |
|
521 | - 'T'=>20, 'U'=>21, 'V'=>22, 'W'=>23, 'X'=>24, 'Y'=>25, 'Z'=>26, '['=>27, '\\'=>28, ']'=>29, |
|
522 | - '^'=>30, '_'=>31, ' '=>32, '!'=>33, '\"'=>34, '#'=>35, '$'=>36, '%'=>37, '&'=>38, '\''=>39, |
|
523 | - '('=>40, ')'=>41, '*'=>42, '+'=>43, ','=>44, '-'=>45, '.'=>46, '/'=>47, '0'=>48, '1'=>49, |
|
524 | - '2'=>50, '3'=>51, '4'=>52, '5'=>53, '6'=>54, '7'=>55, '8'=>56, '9'=>57, ':'=>58, ';'=>59, |
|
525 | - '<'=>60, '='=>61, '>'=>62, '?'=>63 |
|
519 | + '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9, |
|
520 | + 'J'=>10, 'K'=>11, 'L'=>12, 'M'=>13, 'N'=>14, 'O'=>15, 'P'=>16, 'Q'=>17, 'R'=>18, 'S'=>19, |
|
521 | + 'T'=>20, 'U'=>21, 'V'=>22, 'W'=>23, 'X'=>24, 'Y'=>25, 'Z'=>26, '['=>27, '\\'=>28, ']'=>29, |
|
522 | + '^'=>30, '_'=>31, ' '=>32, '!'=>33, '\"'=>34, '#'=>35, '$'=>36, '%'=>37, '&'=>38, '\''=>39, |
|
523 | + '('=>40, ')'=>41, '*'=>42, '+'=>43, ','=>44, '-'=>45, '.'=>46, '/'=>47, '0'=>48, '1'=>49, |
|
524 | + '2'=>50, '3'=>51, '4'=>52, '5'=>53, '6'=>54, '7'=>55, '8'=>56, '9'=>57, ':'=>58, ';'=>59, |
|
525 | + '<'=>60, '='=>61, '>'=>62, '?'=>63 |
|
526 | 526 | ); |
527 | 527 | // " |
528 | 528 | $_a = str_split($name); |
@@ -10,16 +10,16 @@ discard block |
||
10 | 10 | require_once(dirname(__FILE__).'/class.Source.php'); |
11 | 11 | |
12 | 12 | class MarineImport { |
13 | - private $all_tracked = array(); |
|
14 | - private $last_delete_hourly = 0; |
|
15 | - private $last_delete = 0; |
|
16 | - private $stats = array(); |
|
17 | - private $tmd = 0; |
|
18 | - private $source_location = array(); |
|
19 | - public $db = null; |
|
20 | - public $nb = 0; |
|
13 | + private $all_tracked = array(); |
|
14 | + private $last_delete_hourly = 0; |
|
15 | + private $last_delete = 0; |
|
16 | + private $stats = array(); |
|
17 | + private $tmd = 0; |
|
18 | + private $source_location = array(); |
|
19 | + public $db = null; |
|
20 | + public $nb = 0; |
|
21 | 21 | |
22 | - public function __construct($dbc = null) { |
|
22 | + public function __construct($dbc = null) { |
|
23 | 23 | global $globalBeta; |
24 | 24 | $Connection = new Connection($dbc); |
25 | 25 | $this->db = $Connection->db(); |
@@ -41,50 +41,50 @@ discard block |
||
41 | 41 | } |
42 | 42 | } |
43 | 43 | */ |
44 | - } |
|
44 | + } |
|
45 | 45 | |
46 | - public function checkAll() { |
|
46 | + public function checkAll() { |
|
47 | 47 | global $globalDebug; |
48 | 48 | if ($globalDebug) echo "Update last seen tracked data...\n"; |
49 | 49 | foreach ($this->all_tracked as $key => $flight) { |
50 | - if (isset($this->all_tracked[$key]['id'])) { |
|
50 | + if (isset($this->all_tracked[$key]['id'])) { |
|
51 | 51 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
52 | - $Marine = new Marine($this->db); |
|
53 | - $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']); |
|
54 | - } |
|
52 | + $Marine = new Marine($this->db); |
|
53 | + $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']); |
|
54 | + } |
|
55 | + } |
|
55 | 56 | } |
56 | - } |
|
57 | 57 | |
58 | - public function del() { |
|
58 | + public function del() { |
|
59 | 59 | global $globalDebug; |
60 | 60 | // Delete old infos |
61 | 61 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
62 | 62 | foreach ($this->all_tracked as $key => $flight) { |
63 | - if (isset($flight['lastupdate'])) { |
|
64 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
65 | - if (isset($this->all_tracked[$key]['id'])) { |
|
66 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
63 | + if (isset($flight['lastupdate'])) { |
|
64 | + if ($flight['lastupdate'] < (time()-3000)) { |
|
65 | + if (isset($this->all_tracked[$key]['id'])) { |
|
66 | + if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
67 | 67 | /* |
68 | 68 | $MarineLive = new MarineLive(); |
69 | 69 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
70 | 70 | $MarineLive->db = null; |
71 | 71 | */ |
72 | - //$real_arrival = $this->arrival($key); |
|
73 | - $Marine = new Marine($this->db); |
|
74 | - if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
72 | + //$real_arrival = $this->arrival($key); |
|
73 | + $Marine = new Marine($this->db); |
|
74 | + if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
75 | 75 | $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']); |
76 | 76 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
77 | 77 | } |
78 | 78 | // Put in archive |
79 | 79 | // $Marine->db = null; |
80 | - } |
|
81 | - unset($this->all_tracked[$key]); |
|
82 | - } |
|
83 | - } |
|
84 | - } |
|
85 | - } |
|
80 | + } |
|
81 | + unset($this->all_tracked[$key]); |
|
82 | + } |
|
83 | + } |
|
84 | + } |
|
85 | + } |
|
86 | 86 | |
87 | - public function add($line) { |
|
87 | + public function add($line) { |
|
88 | 88 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked; |
89 | 89 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
90 | 90 | date_default_timezone_set('UTC'); |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | |
94 | 94 | // SBS format is CSV format |
95 | 95 | if(is_array($line) && isset($line['mmsi'])) { |
96 | - //print_r($line); |
|
97 | - if (isset($line['mmsi'])) { |
|
96 | + //print_r($line); |
|
97 | + if (isset($line['mmsi'])) { |
|
98 | 98 | |
99 | 99 | /* |
100 | 100 | // Increment message number |
@@ -111,87 +111,87 @@ discard block |
||
111 | 111 | |
112 | 112 | $Common = new Common(); |
113 | 113 | $AIS = new AIS(); |
114 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
115 | - else $id = trim($line['id']); |
|
114 | + if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
115 | + else $id = trim($line['id']); |
|
116 | 116 | |
117 | 117 | if (!isset($this->all_tracked[$id])) { |
118 | - $this->all_tracked[$id] = array(); |
|
119 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
120 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '')); |
|
121 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
122 | - if (!isset($line['id'])) { |
|
118 | + $this->all_tracked[$id] = array(); |
|
119 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
120 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '')); |
|
121 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
122 | + if (!isset($line['id'])) { |
|
123 | 123 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
124 | 124 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
125 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
126 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
125 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
126 | + if ($globalAllTracked !== FALSE) $dataFound = true; |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
130 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
131 | - $Marine = new Marine($this->db); |
|
132 | - $identity = $Marine->getIdentity($line['mmsi']); |
|
133 | - if (!empty($identity)) { |
|
130 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
131 | + $Marine = new Marine($this->db); |
|
132 | + $identity = $Marine->getIdentity($line['mmsi']); |
|
133 | + if (!empty($identity)) { |
|
134 | 134 | $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
135 | 135 | $this->all_tracked[$id]['type'] = $identity['type']; |
136 | - } |
|
137 | - //print_r($identity); |
|
138 | - unset($Marine); |
|
139 | - //$dataFound = true; |
|
136 | + } |
|
137 | + //print_r($identity); |
|
138 | + unset($Marine); |
|
139 | + //$dataFound = true; |
|
140 | 140 | } |
141 | 141 | if (isset($line['type_id']) && $line['type_id'] != '') { |
142 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
142 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
143 | 143 | } |
144 | 144 | if (isset($line['type']) && $line['type'] != '') { |
145 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
145 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
146 | 146 | } |
147 | 147 | if (isset($line['imo']) && $line['imo'] != '') { |
148 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
148 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
149 | 149 | } |
150 | 150 | if (isset($line['callsign']) && $line['callsign'] != '') { |
151 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
151 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
152 | 152 | } |
153 | 153 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
154 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
154 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
155 | 155 | } |
156 | 156 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
157 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
157 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | |
161 | 161 | //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'])) { |
162 | 162 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
163 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
164 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
163 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
164 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
165 | 165 | $timeelapsed = microtime(true); |
166 | - $Marine = new Marine($this->db); |
|
167 | - $fromsource = NULL; |
|
168 | - $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
166 | + $Marine = new Marine($this->db); |
|
167 | + $fromsource = NULL; |
|
168 | + $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
169 | 169 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
170 | 170 | $Marine->db = null; |
171 | 171 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
172 | - } |
|
173 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
172 | + } |
|
173 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | if (isset($line['speed']) && $line['speed'] != '') { |
177 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
178 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
177 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
178 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
179 | 179 | } 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'])) { |
180 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
181 | - if ($distance > 1000 && $distance < 10000) { |
|
180 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
181 | + if ($distance > 1000 && $distance < 10000) { |
|
182 | 182 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
183 | 183 | $speed = $speed*3.6; |
184 | 184 | if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
185 | 185 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
186 | - } |
|
186 | + } |
|
187 | 187 | } |
188 | 188 | |
189 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
190 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
191 | - else unset($timediff); |
|
192 | - 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')))) { |
|
189 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
190 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
191 | + else unset($timediff); |
|
192 | + 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')))) { |
|
193 | 193 | 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'])) { |
194 | - 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'])) { |
|
194 | + 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'])) { |
|
195 | 195 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
196 | 196 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
197 | 197 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -205,76 +205,76 @@ discard block |
||
205 | 205 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
206 | 206 | $this->tmd = 0; |
207 | 207 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
208 | - } |
|
208 | + } |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
212 | 212 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
213 | 213 | 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') { |
214 | - $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
215 | - $dataFound = true; |
|
216 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
214 | + $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
215 | + $dataFound = true; |
|
216 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
217 | 217 | } |
218 | 218 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
219 | 219 | } |
220 | 220 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
221 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
221 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
222 | 222 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
223 | 223 | 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') { |
224 | - $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
225 | - $dataFound = true; |
|
226 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
224 | + $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
225 | + $dataFound = true; |
|
226 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
227 | 227 | } |
228 | 228 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
229 | 229 | } |
230 | 230 | |
231 | - } else if ($globalDebug && $timediff > 20) { |
|
231 | + } else if ($globalDebug && $timediff > 20) { |
|
232 | 232 | $this->tmd = $this->tmd + 1; |
233 | 233 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
234 | 234 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
235 | 235 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
236 | 236 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
237 | - } |
|
237 | + } |
|
238 | 238 | } |
239 | 239 | if (isset($line['last_update']) && $line['last_update'] != '') { |
240 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
241 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
240 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
241 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
242 | 242 | } |
243 | 243 | if (isset($line['format_source']) && $line['format_source'] != '') { |
244 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
244 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
245 | 245 | } |
246 | 246 | if (isset($line['source_name']) && $line['source_name'] != '') { |
247 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
247 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
248 | 248 | } |
249 | 249 | if (isset($line['status']) && $line['status'] != '') { |
250 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
250 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
254 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
254 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | if (isset($line['heading']) && $line['heading'] != '') { |
258 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
259 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
260 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
261 | - //$dataFound = true; |
|
258 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
259 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
260 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
261 | + //$dataFound = true; |
|
262 | 262 | } 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']) { |
263 | - $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']); |
|
264 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
265 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
266 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
263 | + $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']); |
|
264 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
265 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
266 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
267 | 267 | } |
268 | 268 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
269 | 269 | |
270 | 270 | if (isset($line['datetime'])) { |
271 | - if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
271 | + if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
272 | 272 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
273 | - } else { |
|
273 | + } else { |
|
274 | 274 | 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"; |
275 | 275 | 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"; |
276 | 276 | return ''; |
277 | - } |
|
277 | + } |
|
278 | 278 | } else { |
279 | 279 | date_default_timezone_set('UTC'); |
280 | 280 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
@@ -282,45 +282,45 @@ discard block |
||
282 | 282 | |
283 | 283 | |
284 | 284 | if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) { |
285 | - $this->all_tracked[$id]['lastupdate'] = time(); |
|
286 | - if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
287 | - 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'])) { |
|
288 | - if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
285 | + $this->all_tracked[$id]['lastupdate'] = time(); |
|
286 | + if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
287 | + 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'])) { |
|
288 | + if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
289 | 289 | if ($globalDebug) echo "Check if aircraft is already in DB..."; |
290 | 290 | $timeelapsed = microtime(true); |
291 | 291 | $MarineLive = new MarineLive($this->db); |
292 | 292 | if (isset($line['id'])) { |
293 | - $recent_ident = $MarineLive->checkIdRecent($line['id']); |
|
294 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
293 | + $recent_ident = $MarineLive->checkIdRecent($line['id']); |
|
294 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
295 | 295 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
296 | - $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
|
297 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
296 | + $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
|
297 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
298 | 298 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
299 | - $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
|
300 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
299 | + $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
|
300 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
301 | 301 | } else $recent_ident = ''; |
302 | 302 | $MarineLive->db=null; |
303 | 303 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
304 | 304 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
305 | - } else { |
|
305 | + } else { |
|
306 | 306 | $recent_ident = ''; |
307 | 307 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
308 | - } |
|
309 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
310 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
311 | - { |
|
308 | + } |
|
309 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
310 | + if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
311 | + { |
|
312 | 312 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
313 | 313 | //adds the spotter data for the archive |
314 | - $highlight = ''; |
|
315 | - 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'))); |
|
316 | - $timeelapsed = microtime(true); |
|
317 | - $Marine = new Marine($this->db); |
|
318 | - $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]['format_source'],$this->all_tracked[$id]['source_name']); |
|
319 | - $Marine->db = null; |
|
320 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
321 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
314 | + $highlight = ''; |
|
315 | + 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'))); |
|
316 | + $timeelapsed = microtime(true); |
|
317 | + $Marine = new Marine($this->db); |
|
318 | + $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]['format_source'],$this->all_tracked[$id]['source_name']); |
|
319 | + $Marine->db = null; |
|
320 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
321 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
322 | 322 | |
323 | - /* |
|
323 | + /* |
|
324 | 324 | // Add source stat in DB |
325 | 325 | $Stats = new Stats($this->db); |
326 | 326 | if (!empty($this->stats)) { |
@@ -347,20 +347,20 @@ discard block |
||
347 | 347 | } |
348 | 348 | $Stats->db = null; |
349 | 349 | */ |
350 | - $this->del(); |
|
350 | + $this->del(); |
|
351 | 351 | //$ignoreImport = false; |
352 | 352 | $this->all_tracked[$id]['addedMarine'] = 1; |
353 | 353 | //print_r($this->all_tracked[$id]); |
354 | 354 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
355 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
356 | - //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
357 | - $MarineLive = new MarineLive($this->db); |
|
358 | - $MarineLive->deleteLiveMarineData(); |
|
359 | - $MarineLive->db=null; |
|
360 | - if ($globalDebug) echo " Done\n"; |
|
361 | - $this->last_delete = time(); |
|
355 | + if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
356 | + //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
357 | + $MarineLive = new MarineLive($this->db); |
|
358 | + $MarineLive->deleteLiveMarineData(); |
|
359 | + $MarineLive->db=null; |
|
360 | + if ($globalDebug) echo " Done\n"; |
|
361 | + $this->last_delete = time(); |
|
362 | 362 | } |
363 | - } elseif ($recent_ident != '') { |
|
363 | + } elseif ($recent_ident != '') { |
|
364 | 364 | $this->all_tracked[$id]['id'] = $recent_ident; |
365 | 365 | $this->all_tracked[$id]['addedMarine'] = 1; |
366 | 366 | if (isset($globalDaemon) && !$globalDaemon) { |
@@ -369,16 +369,16 @@ discard block |
||
369 | 369 | $Marine->db = null; |
370 | 370 | } |
371 | 371 | |
372 | - } |
|
372 | + } |
|
373 | + } |
|
373 | 374 | } |
374 | - } |
|
375 | - //adds the spotter LIVE data |
|
376 | - if ($globalDebug) { |
|
375 | + //adds the spotter LIVE data |
|
376 | + if ($globalDebug) { |
|
377 | 377 | 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"; |
378 | - } |
|
379 | - $ignoreImport = false; |
|
378 | + } |
|
379 | + $ignoreImport = false; |
|
380 | 380 | |
381 | - if (!$ignoreImport) { |
|
381 | + if (!$ignoreImport) { |
|
382 | 382 | 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'])) { |
383 | 383 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
384 | 384 | $timeelapsed = microtime(true); |
@@ -450,22 +450,22 @@ discard block |
||
450 | 450 | |
451 | 451 | |
452 | 452 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
453 | - if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
454 | - $MarineLive = new MarineLive($this->db); |
|
455 | - $MarineLive->deleteLiveMarineDataNotUpdated(); |
|
456 | - $MarineLive->db = null; |
|
457 | - //MarineLive->deleteLiveMarineData(); |
|
458 | - if ($globalDebug) echo " Done\n"; |
|
459 | - $this->last_delete_hourly = time(); |
|
453 | + if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
454 | + $MarineLive = new MarineLive($this->db); |
|
455 | + $MarineLive->deleteLiveMarineDataNotUpdated(); |
|
456 | + $MarineLive->db = null; |
|
457 | + //MarineLive->deleteLiveMarineData(); |
|
458 | + if ($globalDebug) echo " Done\n"; |
|
459 | + $this->last_delete_hourly = time(); |
|
460 | 460 | } |
461 | 461 | |
462 | - } |
|
463 | - //$ignoreImport = false; |
|
462 | + } |
|
463 | + //$ignoreImport = false; |
|
464 | 464 | } |
465 | 465 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
466 | 466 | if ($send) return $this->all_tracked[$id]; |
467 | - } |
|
467 | + } |
|
468 | + } |
|
468 | 469 | } |
469 | - } |
|
470 | 470 | } |
471 | 471 | ?> |
@@ -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(); |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
89 | - * Gets all the spotter information based on the latest data entry |
|
90 | - * |
|
91 | - * @return Array the spotter information |
|
92 | - * |
|
93 | - */ |
|
89 | + * Gets all the spotter information based on the latest data entry |
|
90 | + * |
|
91 | + * @return Array the spotter information |
|
92 | + * |
|
93 | + */ |
|
94 | 94 | public function getLiveMarineData($limit = '', $sort = '', $filter = array()) |
95 | 95 | { |
96 | 96 | global $globalDBdriver, $globalLiveInterval; |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
135 | - * Gets Minimal Live Spotter data |
|
136 | - * |
|
137 | - * @return Array the spotter information |
|
138 | - * |
|
139 | - */ |
|
135 | + * Gets Minimal Live Spotter data |
|
136 | + * |
|
137 | + * @return Array the spotter information |
|
138 | + * |
|
139 | + */ |
|
140 | 140 | public function getMinLiveMarineData($filter = array()) |
141 | 141 | { |
142 | 142 | global $globalDBdriver, $globalLiveInterval; |
@@ -166,11 +166,11 @@ discard block |
||
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
169 | - * Gets Minimal Live Spotter data since xx seconds |
|
170 | - * |
|
171 | - * @return Array the spotter information |
|
172 | - * |
|
173 | - */ |
|
169 | + * Gets Minimal Live Spotter data since xx seconds |
|
170 | + * |
|
171 | + * @return Array the spotter information |
|
172 | + * |
|
173 | + */ |
|
174 | 174 | public function getMinLastLiveMarineData($filter = array()) |
175 | 175 | { |
176 | 176 | global $globalDBdriver, $globalLiveInterval; |
@@ -183,13 +183,13 @@ discard block |
||
183 | 183 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
184 | 184 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
185 | 185 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
186 | - } else { |
|
186 | + } else { |
|
187 | 187 | $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
188 | 188 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
189 | 189 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
190 | 190 | } |
191 | 191 | |
192 | - try { |
|
192 | + try { |
|
193 | 193 | $sth = $this->db->prepare($query); |
194 | 194 | $sth->execute(); |
195 | 195 | } catch(PDOException $e) { |
@@ -201,11 +201,11 @@ discard block |
||
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
204 | - * Gets number of latest data entry |
|
205 | - * |
|
206 | - * @return String number of entry |
|
207 | - * |
|
208 | - */ |
|
204 | + * Gets number of latest data entry |
|
205 | + * |
|
206 | + * @return String number of entry |
|
207 | + * |
|
208 | + */ |
|
209 | 209 | public function getLiveMarineCount($filter = array()) |
210 | 210 | { |
211 | 211 | global $globalDBdriver, $globalLiveInterval; |
@@ -230,11 +230,11 @@ discard block |
||
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
233 | - * Gets all the spotter information based on the latest data entry and coord |
|
234 | - * |
|
235 | - * @return Array the spotter information |
|
236 | - * |
|
237 | - */ |
|
233 | + * Gets all the spotter information based on the latest data entry and coord |
|
234 | + * |
|
235 | + * @return Array the spotter information |
|
236 | + * |
|
237 | + */ |
|
238 | 238 | public function getLiveMarineDatabyCoord($coord, $filter = array()) |
239 | 239 | { |
240 | 240 | global $globalDBdriver, $globalLiveInterval; |
@@ -258,11 +258,11 @@ discard block |
||
258 | 258 | } |
259 | 259 | |
260 | 260 | /** |
261 | - * Gets all the spotter information based on a user's latitude and longitude |
|
262 | - * |
|
263 | - * @return Array the spotter information |
|
264 | - * |
|
265 | - */ |
|
261 | + * Gets all the spotter information based on a user's latitude and longitude |
|
262 | + * |
|
263 | + * @return Array the spotter information |
|
264 | + * |
|
265 | + */ |
|
266 | 266 | public function getLatestMarineForLayar($lat, $lng, $radius, $interval) |
267 | 267 | { |
268 | 268 | $Marine = new Marine($this->db); |
@@ -275,134 +275,134 @@ discard block |
||
275 | 275 | if ($lng != '') |
276 | 276 | { |
277 | 277 | if (!is_numeric($lng)) |
278 | - { |
|
279 | - return false; |
|
280 | - } |
|
281 | - } |
|
282 | - |
|
283 | - if ($radius != '') |
|
284 | - { |
|
285 | - if (!is_numeric($radius)) |
|
286 | - { |
|
287 | - return false; |
|
288 | - } |
|
289 | - } |
|
278 | + { |
|
279 | + return false; |
|
280 | + } |
|
281 | + } |
|
282 | + |
|
283 | + if ($radius != '') |
|
284 | + { |
|
285 | + if (!is_numeric($radius)) |
|
286 | + { |
|
287 | + return false; |
|
288 | + } |
|
289 | + } |
|
290 | 290 | $additional_query = ''; |
291 | 291 | if ($interval != '') |
292 | - { |
|
293 | - if (!is_string($interval)) |
|
294 | - { |
|
295 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
296 | - return false; |
|
297 | - } else { |
|
298 | - if ($interval == '1m') |
|
299 | - { |
|
300 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
301 | - } else if ($interval == '15m'){ |
|
302 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
303 | - } |
|
304 | - } |
|
305 | - } else { |
|
306 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
307 | - } |
|
308 | - |
|
309 | - $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
292 | + { |
|
293 | + if (!is_string($interval)) |
|
294 | + { |
|
295 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
296 | + return false; |
|
297 | + } else { |
|
298 | + if ($interval == '1m') |
|
299 | + { |
|
300 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
301 | + } else if ($interval == '15m'){ |
|
302 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
303 | + } |
|
304 | + } |
|
305 | + } else { |
|
306 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
307 | + } |
|
308 | + |
|
309 | + $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
310 | 310 | WHERE marine_live.latitude <> '' |
311 | 311 | AND marine_live.longitude <> '' |
312 | 312 | ".$additional_query." |
313 | 313 | HAVING distance < :radius |
314 | 314 | ORDER BY distance"; |
315 | 315 | |
316 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
316 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
317 | 317 | |
318 | - return $spotter_array; |
|
319 | - } |
|
318 | + return $spotter_array; |
|
319 | + } |
|
320 | 320 | |
321 | 321 | |
322 | - /** |
|
323 | - * Gets all the spotter information based on a particular callsign |
|
324 | - * |
|
325 | - * @return Array the spotter information |
|
326 | - * |
|
327 | - */ |
|
322 | + /** |
|
323 | + * Gets all the spotter information based on a particular callsign |
|
324 | + * |
|
325 | + * @return Array the spotter information |
|
326 | + * |
|
327 | + */ |
|
328 | 328 | public function getLastLiveMarineDataByIdent($ident) |
329 | 329 | { |
330 | 330 | $Marine = new Marine($this->db); |
331 | 331 | date_default_timezone_set('UTC'); |
332 | 332 | |
333 | 333 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
334 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
334 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
335 | 335 | |
336 | 336 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
337 | 337 | |
338 | 338 | return $spotter_array; |
339 | 339 | } |
340 | 340 | |
341 | - /** |
|
342 | - * Gets all the spotter information based on a particular callsign |
|
343 | - * |
|
344 | - * @return Array the spotter information |
|
345 | - * |
|
346 | - */ |
|
341 | + /** |
|
342 | + * Gets all the spotter information based on a particular callsign |
|
343 | + * |
|
344 | + * @return Array the spotter information |
|
345 | + * |
|
346 | + */ |
|
347 | 347 | public function getDateLiveMarineDataByIdent($ident,$date) |
348 | 348 | { |
349 | 349 | $Marine = new Marine($this->db); |
350 | 350 | date_default_timezone_set('UTC'); |
351 | 351 | |
352 | 352 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
353 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
353 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
354 | 354 | |
355 | - $date = date('c',$date); |
|
355 | + $date = date('c',$date); |
|
356 | 356 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
357 | 357 | |
358 | 358 | return $spotter_array; |
359 | 359 | } |
360 | 360 | |
361 | - /** |
|
362 | - * Gets last spotter information based on a particular callsign |
|
363 | - * |
|
364 | - * @return Array the spotter information |
|
365 | - * |
|
366 | - */ |
|
361 | + /** |
|
362 | + * Gets last spotter information based on a particular callsign |
|
363 | + * |
|
364 | + * @return Array the spotter information |
|
365 | + * |
|
366 | + */ |
|
367 | 367 | public function getLastLiveMarineDataById($id) |
368 | 368 | { |
369 | 369 | $Marine = new Marine($this->db); |
370 | 370 | date_default_timezone_set('UTC'); |
371 | 371 | |
372 | 372 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
373 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
373 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
374 | 374 | |
375 | 375 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
376 | 376 | |
377 | 377 | return $spotter_array; |
378 | 378 | } |
379 | 379 | |
380 | - /** |
|
381 | - * Gets last spotter information based on a particular callsign |
|
382 | - * |
|
383 | - * @return Array the spotter information |
|
384 | - * |
|
385 | - */ |
|
380 | + /** |
|
381 | + * Gets last spotter information based on a particular callsign |
|
382 | + * |
|
383 | + * @return Array the spotter information |
|
384 | + * |
|
385 | + */ |
|
386 | 386 | public function getDateLiveMarineDataById($id,$date) |
387 | 387 | { |
388 | 388 | $Marine = new Marine($this->db); |
389 | 389 | date_default_timezone_set('UTC'); |
390 | 390 | |
391 | 391 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
392 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
393 | - $date = date('c',$date); |
|
392 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
393 | + $date = date('c',$date); |
|
394 | 394 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
395 | 395 | |
396 | 396 | return $spotter_array; |
397 | 397 | } |
398 | 398 | |
399 | 399 | |
400 | - /** |
|
401 | - * Gets all the spotter information based on a particular id |
|
402 | - * |
|
403 | - * @return Array the spotter information |
|
404 | - * |
|
405 | - */ |
|
400 | + /** |
|
401 | + * Gets all the spotter information based on a particular id |
|
402 | + * |
|
403 | + * @return Array the spotter information |
|
404 | + * |
|
405 | + */ |
|
406 | 406 | public function getAllLiveMarineDataById($id,$liveinterval = false) |
407 | 407 | { |
408 | 408 | global $globalDBdriver, $globalLiveInterval; |
@@ -430,18 +430,18 @@ discard block |
||
430 | 430 | return $spotter_array; |
431 | 431 | } |
432 | 432 | |
433 | - /** |
|
434 | - * Gets all the spotter information based on a particular ident |
|
435 | - * |
|
436 | - * @return Array the spotter information |
|
437 | - * |
|
438 | - */ |
|
433 | + /** |
|
434 | + * Gets all the spotter information based on a particular ident |
|
435 | + * |
|
436 | + * @return Array the spotter information |
|
437 | + * |
|
438 | + */ |
|
439 | 439 | public function getAllLiveMarineDataByIdent($ident) |
440 | 440 | { |
441 | 441 | date_default_timezone_set('UTC'); |
442 | 442 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
443 | 443 | $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
444 | - try { |
|
444 | + try { |
|
445 | 445 | |
446 | 446 | $sth = $this->db->prepare($query); |
447 | 447 | $sth->execute(array(':ident' => $ident)); |
@@ -455,23 +455,23 @@ discard block |
||
455 | 455 | |
456 | 456 | |
457 | 457 | /** |
458 | - * Deletes all info in the table |
|
459 | - * |
|
460 | - * @return String success or false |
|
461 | - * |
|
462 | - */ |
|
458 | + * Deletes all info in the table |
|
459 | + * |
|
460 | + * @return String success or false |
|
461 | + * |
|
462 | + */ |
|
463 | 463 | public function deleteLiveMarineData() |
464 | 464 | { |
465 | 465 | global $globalDBdriver; |
466 | 466 | if ($globalDBdriver == 'mysql') { |
467 | 467 | //$query = "DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= marine_live.date"; |
468 | 468 | $query = 'DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= marine_live.date'; |
469 | - //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)"; |
|
469 | + //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)"; |
|
470 | 470 | } else { |
471 | 471 | $query = "DELETE FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date"; |
472 | 472 | } |
473 | 473 | |
474 | - try { |
|
474 | + try { |
|
475 | 475 | |
476 | 476 | $sth = $this->db->prepare($query); |
477 | 477 | $sth->execute(); |
@@ -483,18 +483,18 @@ discard block |
||
483 | 483 | } |
484 | 484 | |
485 | 485 | /** |
486 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
487 | - * |
|
488 | - * @return String success or false |
|
489 | - * |
|
490 | - */ |
|
486 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
487 | + * |
|
488 | + * @return String success or false |
|
489 | + * |
|
490 | + */ |
|
491 | 491 | public function deleteLiveMarineDataNotUpdated() |
492 | 492 | { |
493 | 493 | global $globalDBdriver, $globalDebug; |
494 | 494 | if ($globalDBdriver == 'mysql') { |
495 | 495 | //$query = 'SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < marine_live.date) LIMIT 800 OFFSET 0'; |
496 | - $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
497 | - try { |
|
496 | + $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
497 | + try { |
|
498 | 498 | |
499 | 499 | $sth = $this->db->prepare($query); |
500 | 500 | $sth->execute(); |
@@ -502,8 +502,8 @@ discard block |
||
502 | 502 | return "error"; |
503 | 503 | } |
504 | 504 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
505 | - $i = 0; |
|
506 | - $j =0; |
|
505 | + $i = 0; |
|
506 | + $j =0; |
|
507 | 507 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
508 | 508 | foreach($all as $row) |
509 | 509 | { |
@@ -511,20 +511,20 @@ discard block |
||
511 | 511 | $j++; |
512 | 512 | if ($j == 30) { |
513 | 513 | if ($globalDebug) echo "."; |
514 | - try { |
|
514 | + try { |
|
515 | 515 | |
516 | 516 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
517 | 517 | $sth->execute(); |
518 | 518 | } catch(PDOException $e) { |
519 | 519 | return "error"; |
520 | 520 | } |
521 | - $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
522 | - $j = 0; |
|
521 | + $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
522 | + $j = 0; |
|
523 | 523 | } |
524 | 524 | $query_delete .= "'".$row['fammarine_id']."',"; |
525 | 525 | } |
526 | 526 | if ($i > 0) { |
527 | - try { |
|
527 | + try { |
|
528 | 528 | |
529 | 529 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
530 | 530 | $sth->execute(); |
@@ -535,9 +535,9 @@ discard block |
||
535 | 535 | return "success"; |
536 | 536 | } elseif ($globalDBdriver == 'pgsql') { |
537 | 537 | //$query = "SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < marine_live.date) LIMIT 800 OFFSET 0"; |
538 | - //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
539 | - $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
540 | - try { |
|
538 | + //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
539 | + $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
540 | + try { |
|
541 | 541 | |
542 | 542 | $sth = $this->db->prepare($query); |
543 | 543 | $sth->execute(); |
@@ -581,17 +581,17 @@ discard block |
||
581 | 581 | } |
582 | 582 | |
583 | 583 | /** |
584 | - * Deletes all info in the table for an ident |
|
585 | - * |
|
586 | - * @return String success or false |
|
587 | - * |
|
588 | - */ |
|
584 | + * Deletes all info in the table for an ident |
|
585 | + * |
|
586 | + * @return String success or false |
|
587 | + * |
|
588 | + */ |
|
589 | 589 | public function deleteLiveMarineDataByIdent($ident) |
590 | 590 | { |
591 | 591 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
592 | 592 | $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
593 | 593 | |
594 | - try { |
|
594 | + try { |
|
595 | 595 | |
596 | 596 | $sth = $this->db->prepare($query); |
597 | 597 | $sth->execute(array(':ident' => $ident)); |
@@ -603,17 +603,17 @@ discard block |
||
603 | 603 | } |
604 | 604 | |
605 | 605 | /** |
606 | - * Deletes all info in the table for an id |
|
607 | - * |
|
608 | - * @return String success or false |
|
609 | - * |
|
610 | - */ |
|
606 | + * Deletes all info in the table for an id |
|
607 | + * |
|
608 | + * @return String success or false |
|
609 | + * |
|
610 | + */ |
|
611 | 611 | public function deleteLiveMarineDataById($id) |
612 | 612 | { |
613 | 613 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
614 | 614 | $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
615 | 615 | |
616 | - try { |
|
616 | + try { |
|
617 | 617 | |
618 | 618 | $sth = $this->db->prepare($query); |
619 | 619 | $sth->execute(array(':id' => $id)); |
@@ -626,11 +626,11 @@ discard block |
||
626 | 626 | |
627 | 627 | |
628 | 628 | /** |
629 | - * Gets the aircraft ident within the last hour |
|
630 | - * |
|
631 | - * @return String the ident |
|
632 | - * |
|
633 | - */ |
|
629 | + * Gets the aircraft ident within the last hour |
|
630 | + * |
|
631 | + * @return String the ident |
|
632 | + * |
|
633 | + */ |
|
634 | 634 | public function getIdentFromLastHour($ident) |
635 | 635 | { |
636 | 636 | global $globalDBdriver, $globalTimezone; |
@@ -656,14 +656,14 @@ discard block |
||
656 | 656 | $ident_result = $row['ident']; |
657 | 657 | } |
658 | 658 | return $ident_result; |
659 | - } |
|
659 | + } |
|
660 | 660 | |
661 | 661 | /** |
662 | - * Check recent aircraft |
|
663 | - * |
|
664 | - * @return String the ident |
|
665 | - * |
|
666 | - */ |
|
662 | + * Check recent aircraft |
|
663 | + * |
|
664 | + * @return String the ident |
|
665 | + * |
|
666 | + */ |
|
667 | 667 | public function checkIdentRecent($ident) |
668 | 668 | { |
669 | 669 | global $globalDBdriver, $globalTimezone; |
@@ -689,14 +689,14 @@ discard block |
||
689 | 689 | $ident_result = $row['fammarine_id']; |
690 | 690 | } |
691 | 691 | return $ident_result; |
692 | - } |
|
692 | + } |
|
693 | 693 | |
694 | 694 | /** |
695 | - * Check recent aircraft by id |
|
696 | - * |
|
697 | - * @return String the ident |
|
698 | - * |
|
699 | - */ |
|
695 | + * Check recent aircraft by id |
|
696 | + * |
|
697 | + * @return String the ident |
|
698 | + * |
|
699 | + */ |
|
700 | 700 | public function checkIdRecent($id) |
701 | 701 | { |
702 | 702 | global $globalDBdriver, $globalTimezone; |
@@ -722,14 +722,14 @@ discard block |
||
722 | 722 | $ident_result = $row['fammarine_id']; |
723 | 723 | } |
724 | 724 | return $ident_result; |
725 | - } |
|
725 | + } |
|
726 | 726 | |
727 | 727 | /** |
728 | - * Check recent aircraft by mmsi |
|
729 | - * |
|
730 | - * @return String the ident |
|
731 | - * |
|
732 | - */ |
|
728 | + * Check recent aircraft by mmsi |
|
729 | + * |
|
730 | + * @return String the ident |
|
731 | + * |
|
732 | + */ |
|
733 | 733 | public function checkMMSIRecent($mmsi) |
734 | 734 | { |
735 | 735 | global $globalDBdriver, $globalTimezone; |
@@ -755,19 +755,19 @@ discard block |
||
755 | 755 | $ident_result = $row['fammarine_id']; |
756 | 756 | } |
757 | 757 | return $ident_result; |
758 | - } |
|
758 | + } |
|
759 | 759 | |
760 | 760 | /** |
761 | - * Adds a new spotter data |
|
762 | - * |
|
763 | - * @param String $fammarine_id the ID from flightaware |
|
764 | - * @param String $ident the flight ident |
|
765 | - * @param String $aircraft_icao the aircraft type |
|
766 | - * @param String $departure_airport_icao the departure airport |
|
767 | - * @param String $arrival_airport_icao the arrival airport |
|
768 | - * @return String success or false |
|
769 | - * |
|
770 | - */ |
|
761 | + * Adds a new spotter data |
|
762 | + * |
|
763 | + * @param String $fammarine_id the ID from flightaware |
|
764 | + * @param String $ident the flight ident |
|
765 | + * @param String $aircraft_icao the aircraft type |
|
766 | + * @param String $departure_airport_icao the departure airport |
|
767 | + * @param String $arrival_airport_icao the arrival airport |
|
768 | + * @return String success or false |
|
769 | + * |
|
770 | + */ |
|
771 | 771 | public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
772 | 772 | { |
773 | 773 | global $globalURL, $globalArchive, $globalDebug; |
@@ -838,9 +838,9 @@ discard block |
||
838 | 838 | $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
839 | 839 | |
840 | 840 | |
841 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
842 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
843 | - if ($arrival_date == '') $arrival_date = NULL; |
|
841 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
842 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
843 | + if ($arrival_date == '') $arrival_date = NULL; |
|
844 | 844 | $query = 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
845 | 845 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)'; |
846 | 846 | |
@@ -849,9 +849,9 @@ discard block |
||
849 | 849 | |
850 | 850 | $sth = $this->db->prepare($query); |
851 | 851 | $sth->execute($query_values); |
852 | - } catch(PDOException $e) { |
|
853 | - return "error : ".$e->getMessage(); |
|
854 | - } |
|
852 | + } catch(PDOException $e) { |
|
853 | + return "error : ".$e->getMessage(); |
|
854 | + } |
|
855 | 855 | /* |
856 | 856 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
857 | 857 | if ($globalDebug) echo '(Add to SBS archive : '; |
@@ -7,13 +7,13 @@ discard block |
||
7 | 7 | //protected $cookies = array(); |
8 | 8 | |
9 | 9 | /** |
10 | - * Get data from form result |
|
11 | - * @param String $url form URL |
|
12 | - * @param String $type type of submit form method (get or post) |
|
13 | - * @param String|Array $data values form post method |
|
14 | - * @param Array $headers header to submit with the form |
|
15 | - * @return String the result |
|
16 | - */ |
|
10 | + * Get data from form result |
|
11 | + * @param String $url form URL |
|
12 | + * @param String $type type of submit form method (get or post) |
|
13 | + * @param String|Array $data values form post method |
|
14 | + * @param Array $headers header to submit with the form |
|
15 | + * @return String the result |
|
16 | + */ |
|
17 | 17 | public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '') { |
18 | 18 | global $globalProxy, $globalForceIPv4; |
19 | 19 | $ch = curl_init(); |
@@ -107,10 +107,10 @@ discard block |
||
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
110 | - * Convert a HTML table to an array |
|
111 | - * @param String $data HTML page |
|
112 | - * @return Array array of the tables in HTML page |
|
113 | - */ |
|
110 | + * Convert a HTML table to an array |
|
111 | + * @param String $data HTML page |
|
112 | + * @return Array array of the tables in HTML page |
|
113 | + */ |
|
114 | 114 | public function table2array($data) { |
115 | 115 | if (!is_string($data)) return array(); |
116 | 116 | if ($data == '') return array(); |
@@ -144,10 +144,10 @@ discard block |
||
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
147 | - * Convert <p> part of a HTML page to an array |
|
148 | - * @param String $data HTML page |
|
149 | - * @return Array array of the <p> in HTML page |
|
150 | - */ |
|
147 | + * Convert <p> part of a HTML page to an array |
|
148 | + * @param String $data HTML page |
|
149 | + * @return Array array of the <p> in HTML page |
|
150 | + */ |
|
151 | 151 | public function text2array($data) { |
152 | 152 | $html = str_get_html($data); |
153 | 153 | if ($html === false) return array(); |
@@ -162,14 +162,14 @@ discard block |
||
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
165 | - * Give distance between 2 coordonnates |
|
166 | - * @param Float $lat latitude of first point |
|
167 | - * @param Float $lon longitude of first point |
|
168 | - * @param Float $latc latitude of second point |
|
169 | - * @param Float $lonc longitude of second point |
|
170 | - * @param String $unit km else no unit used |
|
171 | - * @return Float Distance in $unit |
|
172 | - */ |
|
165 | + * Give distance between 2 coordonnates |
|
166 | + * @param Float $lat latitude of first point |
|
167 | + * @param Float $lon longitude of first point |
|
168 | + * @param Float $latc latitude of second point |
|
169 | + * @param Float $lonc longitude of second point |
|
170 | + * @param String $unit km else no unit used |
|
171 | + * @return Float Distance in $unit |
|
172 | + */ |
|
173 | 173 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
174 | 174 | if ($lat == $latc && $lon == $lonc) return 0; |
175 | 175 | $dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515; |
@@ -187,11 +187,11 @@ discard block |
||
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
190 | - * Check is distance realistic |
|
191 | - * @param int $timeDifference the time between the reception of both messages |
|
192 | - * @param float $distance distance covered |
|
193 | - * @return whether distance is realistic |
|
194 | - */ |
|
190 | + * Check is distance realistic |
|
191 | + * @param int $timeDifference the time between the reception of both messages |
|
192 | + * @param float $distance distance covered |
|
193 | + * @return whether distance is realistic |
|
194 | + */ |
|
195 | 195 | public function withinThreshold ($timeDifference, $distance) { |
196 | 196 | $x = abs($timeDifference); |
197 | 197 | $d = abs($distance); |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | } |
210 | 210 | |
211 | 211 | public function isInteger($input){ |
212 | - return(ctype_digit(strval($input))); |
|
212 | + return(ctype_digit(strval($input))); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | |
@@ -240,11 +240,11 @@ discard block |
||
240 | 240 | } |
241 | 241 | |
242 | 242 | /** |
243 | - * Copy folder contents |
|
244 | - * @param string $source Source path |
|
245 | - * @param string $dest Destination path |
|
246 | - * @return bool Returns true on success, false on failure |
|
247 | - */ |
|
243 | + * Copy folder contents |
|
244 | + * @param string $source Source path |
|
245 | + * @param string $dest Destination path |
|
246 | + * @return bool Returns true on success, false on failure |
|
247 | + */ |
|
248 | 248 | public function xcopy($source, $dest) |
249 | 249 | { |
250 | 250 | $files = glob($source.'*.*'); |
@@ -256,20 +256,20 @@ discard block |
||
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
259 | - * Check if an url exist |
|
260 | - * @param String $url url to check |
|
261 | - * @return bool Return true on succes false on failure |
|
262 | - */ |
|
259 | + * Check if an url exist |
|
260 | + * @param String $url url to check |
|
261 | + * @return bool Return true on succes false on failure |
|
262 | + */ |
|
263 | 263 | public function urlexist($url){ |
264 | 264 | $headers=get_headers($url); |
265 | 265 | return stripos($headers[0],"200 OK")?true:false; |
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
269 | - * Convert hexa to string |
|
270 | - * @param String $hex data in hexa |
|
271 | - * @return String Return result |
|
272 | - */ |
|
269 | + * Convert hexa to string |
|
270 | + * @param String $hex data in hexa |
|
271 | + * @return String Return result |
|
272 | + */ |
|
273 | 273 | public function hex2str($hex) { |
274 | 274 | $str = ''; |
275 | 275 | $hexln = strlen($hex); |
@@ -350,9 +350,9 @@ discard block |
||
350 | 350 | } |
351 | 351 | |
352 | 352 | /** |
353 | - * Returns list of available locales |
|
354 | - * |
|
355 | - * @return array |
|
353 | + * Returns list of available locales |
|
354 | + * |
|
355 | + * @return array |
|
356 | 356 | */ |
357 | 357 | public function listLocaleDir() |
358 | 358 | { |
@@ -447,100 +447,100 @@ discard block |
||
447 | 447 | public function remove_accents($string) { |
448 | 448 | if ( !preg_match('/[\x80-\xff]/', $string) ) return $string; |
449 | 449 | $chars = array( |
450 | - // Decompositions for Latin-1 Supplement |
|
451 | - chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', |
|
452 | - chr(195).chr(130) => 'A', chr(195).chr(131) => 'A', |
|
453 | - chr(195).chr(132) => 'A', chr(195).chr(133) => 'A', |
|
454 | - chr(195).chr(135) => 'C', chr(195).chr(136) => 'E', |
|
455 | - chr(195).chr(137) => 'E', chr(195).chr(138) => 'E', |
|
456 | - chr(195).chr(139) => 'E', chr(195).chr(140) => 'I', |
|
457 | - chr(195).chr(141) => 'I', chr(195).chr(142) => 'I', |
|
458 | - chr(195).chr(143) => 'I', chr(195).chr(145) => 'N', |
|
459 | - chr(195).chr(146) => 'O', chr(195).chr(147) => 'O', |
|
460 | - chr(195).chr(148) => 'O', chr(195).chr(149) => 'O', |
|
461 | - chr(195).chr(150) => 'O', chr(195).chr(153) => 'U', |
|
462 | - chr(195).chr(154) => 'U', chr(195).chr(155) => 'U', |
|
463 | - chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y', |
|
464 | - chr(195).chr(159) => 's', chr(195).chr(160) => 'a', |
|
465 | - chr(195).chr(161) => 'a', chr(195).chr(162) => 'a', |
|
466 | - chr(195).chr(163) => 'a', chr(195).chr(164) => 'a', |
|
467 | - chr(195).chr(165) => 'a', chr(195).chr(167) => 'c', |
|
468 | - chr(195).chr(168) => 'e', chr(195).chr(169) => 'e', |
|
469 | - chr(195).chr(170) => 'e', chr(195).chr(171) => 'e', |
|
470 | - chr(195).chr(172) => 'i', chr(195).chr(173) => 'i', |
|
471 | - chr(195).chr(174) => 'i', chr(195).chr(175) => 'i', |
|
472 | - chr(195).chr(177) => 'n', chr(195).chr(178) => 'o', |
|
473 | - chr(195).chr(179) => 'o', chr(195).chr(180) => 'o', |
|
474 | - chr(195).chr(181) => 'o', chr(195).chr(182) => 'o', |
|
475 | - chr(195).chr(182) => 'o', chr(195).chr(185) => 'u', |
|
476 | - chr(195).chr(186) => 'u', chr(195).chr(187) => 'u', |
|
477 | - chr(195).chr(188) => 'u', chr(195).chr(189) => 'y', |
|
478 | - chr(195).chr(191) => 'y', |
|
479 | - // Decompositions for Latin Extended-A |
|
480 | - chr(196).chr(128) => 'A', chr(196).chr(129) => 'a', |
|
481 | - chr(196).chr(130) => 'A', chr(196).chr(131) => 'a', |
|
482 | - chr(196).chr(132) => 'A', chr(196).chr(133) => 'a', |
|
483 | - chr(196).chr(134) => 'C', chr(196).chr(135) => 'c', |
|
484 | - chr(196).chr(136) => 'C', chr(196).chr(137) => 'c', |
|
485 | - chr(196).chr(138) => 'C', chr(196).chr(139) => 'c', |
|
486 | - chr(196).chr(140) => 'C', chr(196).chr(141) => 'c', |
|
487 | - chr(196).chr(142) => 'D', chr(196).chr(143) => 'd', |
|
488 | - chr(196).chr(144) => 'D', chr(196).chr(145) => 'd', |
|
489 | - chr(196).chr(146) => 'E', chr(196).chr(147) => 'e', |
|
490 | - chr(196).chr(148) => 'E', chr(196).chr(149) => 'e', |
|
491 | - chr(196).chr(150) => 'E', chr(196).chr(151) => 'e', |
|
492 | - chr(196).chr(152) => 'E', chr(196).chr(153) => 'e', |
|
493 | - chr(196).chr(154) => 'E', chr(196).chr(155) => 'e', |
|
494 | - chr(196).chr(156) => 'G', chr(196).chr(157) => 'g', |
|
495 | - chr(196).chr(158) => 'G', chr(196).chr(159) => 'g', |
|
496 | - chr(196).chr(160) => 'G', chr(196).chr(161) => 'g', |
|
497 | - chr(196).chr(162) => 'G', chr(196).chr(163) => 'g', |
|
498 | - chr(196).chr(164) => 'H', chr(196).chr(165) => 'h', |
|
499 | - chr(196).chr(166) => 'H', chr(196).chr(167) => 'h', |
|
500 | - chr(196).chr(168) => 'I', chr(196).chr(169) => 'i', |
|
501 | - chr(196).chr(170) => 'I', chr(196).chr(171) => 'i', |
|
502 | - chr(196).chr(172) => 'I', chr(196).chr(173) => 'i', |
|
503 | - chr(196).chr(174) => 'I', chr(196).chr(175) => 'i', |
|
504 | - chr(196).chr(176) => 'I', chr(196).chr(177) => 'i', |
|
505 | - chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij', |
|
506 | - chr(196).chr(180) => 'J', chr(196).chr(181) => 'j', |
|
507 | - chr(196).chr(182) => 'K', chr(196).chr(183) => 'k', |
|
508 | - chr(196).chr(184) => 'k', chr(196).chr(185) => 'L', |
|
509 | - chr(196).chr(186) => 'l', chr(196).chr(187) => 'L', |
|
510 | - chr(196).chr(188) => 'l', chr(196).chr(189) => 'L', |
|
511 | - chr(196).chr(190) => 'l', chr(196).chr(191) => 'L', |
|
512 | - chr(197).chr(128) => 'l', chr(197).chr(129) => 'L', |
|
513 | - chr(197).chr(130) => 'l', chr(197).chr(131) => 'N', |
|
514 | - chr(197).chr(132) => 'n', chr(197).chr(133) => 'N', |
|
515 | - chr(197).chr(134) => 'n', chr(197).chr(135) => 'N', |
|
516 | - chr(197).chr(136) => 'n', chr(197).chr(137) => 'N', |
|
517 | - chr(197).chr(138) => 'n', chr(197).chr(139) => 'N', |
|
518 | - chr(197).chr(140) => 'O', chr(197).chr(141) => 'o', |
|
519 | - chr(197).chr(142) => 'O', chr(197).chr(143) => 'o', |
|
520 | - chr(197).chr(144) => 'O', chr(197).chr(145) => 'o', |
|
521 | - chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe', |
|
522 | - chr(197).chr(148) => 'R',chr(197).chr(149) => 'r', |
|
523 | - chr(197).chr(150) => 'R',chr(197).chr(151) => 'r', |
|
524 | - chr(197).chr(152) => 'R',chr(197).chr(153) => 'r', |
|
525 | - chr(197).chr(154) => 'S',chr(197).chr(155) => 's', |
|
526 | - chr(197).chr(156) => 'S',chr(197).chr(157) => 's', |
|
527 | - chr(197).chr(158) => 'S',chr(197).chr(159) => 's', |
|
528 | - chr(197).chr(160) => 'S', chr(197).chr(161) => 's', |
|
529 | - chr(197).chr(162) => 'T', chr(197).chr(163) => 't', |
|
530 | - chr(197).chr(164) => 'T', chr(197).chr(165) => 't', |
|
531 | - chr(197).chr(166) => 'T', chr(197).chr(167) => 't', |
|
532 | - chr(197).chr(168) => 'U', chr(197).chr(169) => 'u', |
|
533 | - chr(197).chr(170) => 'U', chr(197).chr(171) => 'u', |
|
534 | - chr(197).chr(172) => 'U', chr(197).chr(173) => 'u', |
|
535 | - chr(197).chr(174) => 'U', chr(197).chr(175) => 'u', |
|
536 | - chr(197).chr(176) => 'U', chr(197).chr(177) => 'u', |
|
537 | - chr(197).chr(178) => 'U', chr(197).chr(179) => 'u', |
|
538 | - chr(197).chr(180) => 'W', chr(197).chr(181) => 'w', |
|
539 | - chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y', |
|
540 | - chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z', |
|
541 | - chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z', |
|
542 | - chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z', |
|
543 | - chr(197).chr(190) => 'z', chr(197).chr(191) => 's' |
|
450 | + // Decompositions for Latin-1 Supplement |
|
451 | + chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', |
|
452 | + chr(195).chr(130) => 'A', chr(195).chr(131) => 'A', |
|
453 | + chr(195).chr(132) => 'A', chr(195).chr(133) => 'A', |
|
454 | + chr(195).chr(135) => 'C', chr(195).chr(136) => 'E', |
|
455 | + chr(195).chr(137) => 'E', chr(195).chr(138) => 'E', |
|
456 | + chr(195).chr(139) => 'E', chr(195).chr(140) => 'I', |
|
457 | + chr(195).chr(141) => 'I', chr(195).chr(142) => 'I', |
|
458 | + chr(195).chr(143) => 'I', chr(195).chr(145) => 'N', |
|
459 | + chr(195).chr(146) => 'O', chr(195).chr(147) => 'O', |
|
460 | + chr(195).chr(148) => 'O', chr(195).chr(149) => 'O', |
|
461 | + chr(195).chr(150) => 'O', chr(195).chr(153) => 'U', |
|
462 | + chr(195).chr(154) => 'U', chr(195).chr(155) => 'U', |
|
463 | + chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y', |
|
464 | + chr(195).chr(159) => 's', chr(195).chr(160) => 'a', |
|
465 | + chr(195).chr(161) => 'a', chr(195).chr(162) => 'a', |
|
466 | + chr(195).chr(163) => 'a', chr(195).chr(164) => 'a', |
|
467 | + chr(195).chr(165) => 'a', chr(195).chr(167) => 'c', |
|
468 | + chr(195).chr(168) => 'e', chr(195).chr(169) => 'e', |
|
469 | + chr(195).chr(170) => 'e', chr(195).chr(171) => 'e', |
|
470 | + chr(195).chr(172) => 'i', chr(195).chr(173) => 'i', |
|
471 | + chr(195).chr(174) => 'i', chr(195).chr(175) => 'i', |
|
472 | + chr(195).chr(177) => 'n', chr(195).chr(178) => 'o', |
|
473 | + chr(195).chr(179) => 'o', chr(195).chr(180) => 'o', |
|
474 | + chr(195).chr(181) => 'o', chr(195).chr(182) => 'o', |
|
475 | + chr(195).chr(182) => 'o', chr(195).chr(185) => 'u', |
|
476 | + chr(195).chr(186) => 'u', chr(195).chr(187) => 'u', |
|
477 | + chr(195).chr(188) => 'u', chr(195).chr(189) => 'y', |
|
478 | + chr(195).chr(191) => 'y', |
|
479 | + // Decompositions for Latin Extended-A |
|
480 | + chr(196).chr(128) => 'A', chr(196).chr(129) => 'a', |
|
481 | + chr(196).chr(130) => 'A', chr(196).chr(131) => 'a', |
|
482 | + chr(196).chr(132) => 'A', chr(196).chr(133) => 'a', |
|
483 | + chr(196).chr(134) => 'C', chr(196).chr(135) => 'c', |
|
484 | + chr(196).chr(136) => 'C', chr(196).chr(137) => 'c', |
|
485 | + chr(196).chr(138) => 'C', chr(196).chr(139) => 'c', |
|
486 | + chr(196).chr(140) => 'C', chr(196).chr(141) => 'c', |
|
487 | + chr(196).chr(142) => 'D', chr(196).chr(143) => 'd', |
|
488 | + chr(196).chr(144) => 'D', chr(196).chr(145) => 'd', |
|
489 | + chr(196).chr(146) => 'E', chr(196).chr(147) => 'e', |
|
490 | + chr(196).chr(148) => 'E', chr(196).chr(149) => 'e', |
|
491 | + chr(196).chr(150) => 'E', chr(196).chr(151) => 'e', |
|
492 | + chr(196).chr(152) => 'E', chr(196).chr(153) => 'e', |
|
493 | + chr(196).chr(154) => 'E', chr(196).chr(155) => 'e', |
|
494 | + chr(196).chr(156) => 'G', chr(196).chr(157) => 'g', |
|
495 | + chr(196).chr(158) => 'G', chr(196).chr(159) => 'g', |
|
496 | + chr(196).chr(160) => 'G', chr(196).chr(161) => 'g', |
|
497 | + chr(196).chr(162) => 'G', chr(196).chr(163) => 'g', |
|
498 | + chr(196).chr(164) => 'H', chr(196).chr(165) => 'h', |
|
499 | + chr(196).chr(166) => 'H', chr(196).chr(167) => 'h', |
|
500 | + chr(196).chr(168) => 'I', chr(196).chr(169) => 'i', |
|
501 | + chr(196).chr(170) => 'I', chr(196).chr(171) => 'i', |
|
502 | + chr(196).chr(172) => 'I', chr(196).chr(173) => 'i', |
|
503 | + chr(196).chr(174) => 'I', chr(196).chr(175) => 'i', |
|
504 | + chr(196).chr(176) => 'I', chr(196).chr(177) => 'i', |
|
505 | + chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij', |
|
506 | + chr(196).chr(180) => 'J', chr(196).chr(181) => 'j', |
|
507 | + chr(196).chr(182) => 'K', chr(196).chr(183) => 'k', |
|
508 | + chr(196).chr(184) => 'k', chr(196).chr(185) => 'L', |
|
509 | + chr(196).chr(186) => 'l', chr(196).chr(187) => 'L', |
|
510 | + chr(196).chr(188) => 'l', chr(196).chr(189) => 'L', |
|
511 | + chr(196).chr(190) => 'l', chr(196).chr(191) => 'L', |
|
512 | + chr(197).chr(128) => 'l', chr(197).chr(129) => 'L', |
|
513 | + chr(197).chr(130) => 'l', chr(197).chr(131) => 'N', |
|
514 | + chr(197).chr(132) => 'n', chr(197).chr(133) => 'N', |
|
515 | + chr(197).chr(134) => 'n', chr(197).chr(135) => 'N', |
|
516 | + chr(197).chr(136) => 'n', chr(197).chr(137) => 'N', |
|
517 | + chr(197).chr(138) => 'n', chr(197).chr(139) => 'N', |
|
518 | + chr(197).chr(140) => 'O', chr(197).chr(141) => 'o', |
|
519 | + chr(197).chr(142) => 'O', chr(197).chr(143) => 'o', |
|
520 | + chr(197).chr(144) => 'O', chr(197).chr(145) => 'o', |
|
521 | + chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe', |
|
522 | + chr(197).chr(148) => 'R',chr(197).chr(149) => 'r', |
|
523 | + chr(197).chr(150) => 'R',chr(197).chr(151) => 'r', |
|
524 | + chr(197).chr(152) => 'R',chr(197).chr(153) => 'r', |
|
525 | + chr(197).chr(154) => 'S',chr(197).chr(155) => 's', |
|
526 | + chr(197).chr(156) => 'S',chr(197).chr(157) => 's', |
|
527 | + chr(197).chr(158) => 'S',chr(197).chr(159) => 's', |
|
528 | + chr(197).chr(160) => 'S', chr(197).chr(161) => 's', |
|
529 | + chr(197).chr(162) => 'T', chr(197).chr(163) => 't', |
|
530 | + chr(197).chr(164) => 'T', chr(197).chr(165) => 't', |
|
531 | + chr(197).chr(166) => 'T', chr(197).chr(167) => 't', |
|
532 | + chr(197).chr(168) => 'U', chr(197).chr(169) => 'u', |
|
533 | + chr(197).chr(170) => 'U', chr(197).chr(171) => 'u', |
|
534 | + chr(197).chr(172) => 'U', chr(197).chr(173) => 'u', |
|
535 | + chr(197).chr(174) => 'U', chr(197).chr(175) => 'u', |
|
536 | + chr(197).chr(176) => 'U', chr(197).chr(177) => 'u', |
|
537 | + chr(197).chr(178) => 'U', chr(197).chr(179) => 'u', |
|
538 | + chr(197).chr(180) => 'W', chr(197).chr(181) => 'w', |
|
539 | + chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y', |
|
540 | + chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z', |
|
541 | + chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z', |
|
542 | + chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z', |
|
543 | + chr(197).chr(190) => 'z', chr(197).chr(191) => 's' |
|
544 | 544 | ); |
545 | 545 | $string = strtr($string, $chars); |
546 | 546 | return $string; |
@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | } |
14 | 14 | |
15 | 15 | /** |
16 | - * Get SQL query part for filter used |
|
17 | - * @param Array $filter the filter |
|
18 | - * @return Array the SQL part |
|
19 | - */ |
|
16 | + * Get SQL query part for filter used |
|
17 | + * @param Array $filter the filter |
|
18 | + * @return Array the SQL part |
|
19 | + */ |
|
20 | 20 | |
21 | 21 | public function getFilter($filter = array(),$where = false,$and = false) { |
22 | 22 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
@@ -80,14 +80,14 @@ discard block |
||
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
83 | - * Executes the SQL statements to get the spotter information |
|
84 | - * |
|
85 | - * @param String $query the SQL query |
|
86 | - * @param Array $params parameter of the query |
|
87 | - * @param String $limitQuery the limit query |
|
88 | - * @return Array the spotter information |
|
89 | - * |
|
90 | - */ |
|
83 | + * Executes the SQL statements to get the spotter information |
|
84 | + * |
|
85 | + * @param String $query the SQL query |
|
86 | + * @param Array $params parameter of the query |
|
87 | + * @param String $limitQuery the limit query |
|
88 | + * @return Array the spotter information |
|
89 | + * |
|
90 | + */ |
|
91 | 91 | public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
92 | 92 | { |
93 | 93 | date_default_timezone_set('UTC'); |
@@ -199,11 +199,11 @@ discard block |
||
199 | 199 | |
200 | 200 | |
201 | 201 | /** |
202 | - * Gets all the spotter information based on the latest data entry |
|
203 | - * |
|
204 | - * @return Array the spotter information |
|
205 | - * |
|
206 | - */ |
|
202 | + * Gets all the spotter information based on the latest data entry |
|
203 | + * |
|
204 | + * @return Array the spotter information |
|
205 | + * |
|
206 | + */ |
|
207 | 207 | public function getLatestMarineData($limit = '', $sort = '', $filter = array()) |
208 | 208 | { |
209 | 209 | global $global_query; |
@@ -261,11 +261,11 @@ discard block |
||
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
264 | - * Gets all the spotter information based on the callsign |
|
265 | - * |
|
266 | - * @return Array the spotter information |
|
267 | - * |
|
268 | - */ |
|
264 | + * Gets all the spotter information based on the callsign |
|
265 | + * |
|
266 | + * @return Array the spotter information |
|
267 | + * |
|
268 | + */ |
|
269 | 269 | public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array()) |
270 | 270 | { |
271 | 271 | global $global_query; |
@@ -376,12 +376,12 @@ discard block |
||
376 | 376 | |
377 | 377 | |
378 | 378 | /** |
379 | - * Gets all source name |
|
380 | - * |
|
381 | - * @param String type format of source |
|
382 | - * @return Array list of source name |
|
383 | - * |
|
384 | - */ |
|
379 | + * Gets all source name |
|
380 | + * |
|
381 | + * @param String type format of source |
|
382 | + * @return Array list of source name |
|
383 | + * |
|
384 | + */ |
|
385 | 385 | public function getAllSourceName($type = '',$filters = array()) |
386 | 386 | { |
387 | 387 | $filter_query = $this->getFilter($filters,true,true); |
@@ -411,11 +411,11 @@ discard block |
||
411 | 411 | |
412 | 412 | |
413 | 413 | /** |
414 | - * Gets a list of all idents/callsigns |
|
415 | - * |
|
416 | - * @return Array list of ident/callsign names |
|
417 | - * |
|
418 | - */ |
|
414 | + * Gets a list of all idents/callsigns |
|
415 | + * |
|
416 | + * @return Array list of ident/callsign names |
|
417 | + * |
|
418 | + */ |
|
419 | 419 | public function getAllIdents($filters = array()) |
420 | 420 | { |
421 | 421 | $filter_query = $this->getFilter($filters,true,true); |
@@ -439,11 +439,11 @@ discard block |
||
439 | 439 | } |
440 | 440 | |
441 | 441 | /** |
442 | - * Gets all info from a mmsi |
|
443 | - * |
|
444 | - * @return Array list of mmsi info |
|
445 | - * |
|
446 | - */ |
|
442 | + * Gets all info from a mmsi |
|
443 | + * |
|
444 | + * @return Array list of mmsi info |
|
445 | + * |
|
446 | + */ |
|
447 | 447 | public function getIdentity($mmsi) |
448 | 448 | { |
449 | 449 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
@@ -500,18 +500,18 @@ discard block |
||
500 | 500 | |
501 | 501 | |
502 | 502 | /** |
503 | - * Update ident tracker data |
|
504 | - * |
|
505 | - * @param String $fammarine_id the ID |
|
506 | - * @param String $ident the marine ident |
|
507 | - * @return String success or false |
|
508 | - * |
|
509 | - */ |
|
503 | + * Update ident tracker data |
|
504 | + * |
|
505 | + * @param String $fammarine_id the ID |
|
506 | + * @param String $ident the marine ident |
|
507 | + * @return String success or false |
|
508 | + * |
|
509 | + */ |
|
510 | 510 | public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
511 | 511 | { |
512 | 512 | |
513 | 513 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
514 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
514 | + $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
515 | 515 | |
516 | 516 | try { |
517 | 517 | $sth = $this->db->prepare($query); |
@@ -524,17 +524,17 @@ discard block |
||
524 | 524 | |
525 | 525 | } |
526 | 526 | /** |
527 | - * Update latest marine data |
|
528 | - * |
|
529 | - * @param String $fammarine_id the ID |
|
530 | - * @param String $ident the marine ident |
|
531 | - * @return String success or false |
|
532 | - * |
|
533 | - */ |
|
527 | + * Update latest marine data |
|
528 | + * |
|
529 | + * @param String $fammarine_id the ID |
|
530 | + * @param String $ident the marine ident |
|
531 | + * @return String success or false |
|
532 | + * |
|
533 | + */ |
|
534 | 534 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
535 | 535 | { |
536 | 536 | $query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id'; |
537 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
537 | + $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
538 | 538 | |
539 | 539 | try { |
540 | 540 | $sth = $this->db->prepare($query); |
@@ -548,30 +548,30 @@ discard block |
||
548 | 548 | } |
549 | 549 | |
550 | 550 | /** |
551 | - * Adds a new spotter data |
|
552 | - * |
|
553 | - * @param String $fammarine_id the ID |
|
554 | - * @param String $ident the marine ident |
|
555 | - * @param String $departure_airport_icao the departure airport |
|
556 | - * @param String $arrival_airport_icao the arrival airport |
|
557 | - * @param String $latitude latitude of flight |
|
558 | - * @param String $longitude latitude of flight |
|
559 | - * @param String $waypoints waypoints of flight |
|
560 | - * @param String $heading heading of flight |
|
561 | - * @param String $groundspeed speed of flight |
|
562 | - * @param String $date date of flight |
|
563 | - * @param String $departure_airport_time departure time of flight |
|
564 | - * @param String $arrival_airport_time arrival time of flight |
|
565 | - * @param String $squawk squawk code of flight |
|
566 | - * @param String $route_stop route stop of flight |
|
567 | - * @param String $highlight highlight or not |
|
568 | - * @param String $ModeS ModesS code of flight |
|
569 | - * @param String $registration registration code of flight |
|
570 | - * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
571 | - * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
572 | - * @param String $verticalrate vertival rate of flight |
|
573 | - * @return String success or false |
|
574 | - */ |
|
551 | + * Adds a new spotter data |
|
552 | + * |
|
553 | + * @param String $fammarine_id the ID |
|
554 | + * @param String $ident the marine ident |
|
555 | + * @param String $departure_airport_icao the departure airport |
|
556 | + * @param String $arrival_airport_icao the arrival airport |
|
557 | + * @param String $latitude latitude of flight |
|
558 | + * @param String $longitude latitude of flight |
|
559 | + * @param String $waypoints waypoints of flight |
|
560 | + * @param String $heading heading of flight |
|
561 | + * @param String $groundspeed speed of flight |
|
562 | + * @param String $date date of flight |
|
563 | + * @param String $departure_airport_time departure time of flight |
|
564 | + * @param String $arrival_airport_time arrival time of flight |
|
565 | + * @param String $squawk squawk code of flight |
|
566 | + * @param String $route_stop route stop of flight |
|
567 | + * @param String $highlight highlight or not |
|
568 | + * @param String $ModeS ModesS code of flight |
|
569 | + * @param String $registration registration code of flight |
|
570 | + * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
571 | + * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
572 | + * @param String $verticalrate vertival rate of flight |
|
573 | + * @return String success or false |
|
574 | + */ |
|
575 | 575 | public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$format_source = '', $source_name = '') |
576 | 576 | { |
577 | 577 | global $globalURL; |
@@ -659,13 +659,13 @@ discard block |
||
659 | 659 | $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
660 | 660 | $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
661 | 661 | |
662 | - if ($latitude == '' && $longitude == '') { |
|
663 | - $latitude = 0; |
|
664 | - $longitude = 0; |
|
665 | - } |
|
666 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
667 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
668 | - if ($arrival_date == '') $arrival_date = NULL; |
|
662 | + if ($latitude == '' && $longitude == '') { |
|
663 | + $latitude = 0; |
|
664 | + $longitude = 0; |
|
665 | + } |
|
666 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
667 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
668 | + if ($arrival_date == '') $arrival_date = NULL; |
|
669 | 669 | $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) |
670 | 670 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
671 | 671 | |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | $sth->execute($query_values); |
677 | 677 | $this->db = null; |
678 | 678 | } catch (PDOException $e) { |
679 | - return "error : ".$e->getMessage(); |
|
679 | + return "error : ".$e->getMessage(); |
|
680 | 680 | } |
681 | 681 | |
682 | 682 | return "success"; |
@@ -685,11 +685,11 @@ discard block |
||
685 | 685 | |
686 | 686 | |
687 | 687 | /** |
688 | - * Gets the aircraft ident within the last hour |
|
689 | - * |
|
690 | - * @return String the ident |
|
691 | - * |
|
692 | - */ |
|
688 | + * Gets the aircraft ident within the last hour |
|
689 | + * |
|
690 | + * @return String the ident |
|
691 | + * |
|
692 | + */ |
|
693 | 693 | public function getIdentFromLastHour($ident) |
694 | 694 | { |
695 | 695 | global $globalDBdriver, $globalTimezone; |
@@ -705,11 +705,11 @@ discard block |
||
705 | 705 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
706 | 706 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
707 | 707 | $query_data = array(':ident' => $ident); |
708 | - } |
|
708 | + } |
|
709 | 709 | |
710 | 710 | $sth = $this->db->prepare($query); |
711 | 711 | $sth->execute($query_data); |
712 | - $ident_result=''; |
|
712 | + $ident_result=''; |
|
713 | 713 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
714 | 714 | { |
715 | 715 | $ident_result = $row['ident']; |
@@ -720,11 +720,11 @@ discard block |
||
720 | 720 | |
721 | 721 | |
722 | 722 | /** |
723 | - * Gets the aircraft data from the last 20 seconds |
|
724 | - * |
|
725 | - * @return Array the spotter data |
|
726 | - * |
|
727 | - */ |
|
723 | + * Gets the aircraft data from the last 20 seconds |
|
724 | + * |
|
725 | + * @return Array the spotter data |
|
726 | + * |
|
727 | + */ |
|
728 | 728 | public function getRealTimeData($q = '') |
729 | 729 | { |
730 | 730 | global $globalDBdriver; |
@@ -762,11 +762,11 @@ discard block |
||
762 | 762 | |
763 | 763 | |
764 | 764 | /** |
765 | - * Gets all number of flight over countries |
|
766 | - * |
|
767 | - * @return Array the airline country list |
|
768 | - * |
|
769 | - */ |
|
765 | + * Gets all number of flight over countries |
|
766 | + * |
|
767 | + * @return Array the airline country list |
|
768 | + * |
|
769 | + */ |
|
770 | 770 | /* |
771 | 771 | public function countAllTrackedOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
772 | 772 | { |
@@ -817,11 +817,11 @@ discard block |
||
817 | 817 | |
818 | 818 | |
819 | 819 | /** |
820 | - * Gets all callsigns that have flown over |
|
821 | - * |
|
822 | - * @return Array the callsign list |
|
823 | - * |
|
824 | - */ |
|
820 | + * Gets all callsigns that have flown over |
|
821 | + * |
|
822 | + * @return Array the callsign list |
|
823 | + * |
|
824 | + */ |
|
825 | 825 | public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
826 | 826 | { |
827 | 827 | global $globalDBdriver; |
@@ -888,11 +888,11 @@ discard block |
||
888 | 888 | |
889 | 889 | |
890 | 890 | /** |
891 | - * Counts all dates |
|
892 | - * |
|
893 | - * @return Array the date list |
|
894 | - * |
|
895 | - */ |
|
891 | + * Counts all dates |
|
892 | + * |
|
893 | + * @return Array the date list |
|
894 | + * |
|
895 | + */ |
|
896 | 896 | public function countAllDates($filters = array()) |
897 | 897 | { |
898 | 898 | global $globalTimezone, $globalDBdriver; |
@@ -938,11 +938,11 @@ discard block |
||
938 | 938 | |
939 | 939 | |
940 | 940 | /** |
941 | - * Counts all dates during the last 7 days |
|
942 | - * |
|
943 | - * @return Array the date list |
|
944 | - * |
|
945 | - */ |
|
941 | + * Counts all dates during the last 7 days |
|
942 | + * |
|
943 | + * @return Array the date list |
|
944 | + * |
|
945 | + */ |
|
946 | 946 | public function countAllDatesLast7Days($filters = array()) |
947 | 947 | { |
948 | 948 | global $globalTimezone, $globalDBdriver; |
@@ -964,7 +964,7 @@ discard block |
||
964 | 964 | $query .= " GROUP BY date_name |
965 | 965 | ORDER BY date_name ASC"; |
966 | 966 | $query_data = array(':offset' => $offset); |
967 | - } |
|
967 | + } |
|
968 | 968 | |
969 | 969 | $sth = $this->db->prepare($query); |
970 | 970 | $sth->execute($query_data); |
@@ -984,11 +984,11 @@ discard block |
||
984 | 984 | } |
985 | 985 | |
986 | 986 | /** |
987 | - * Counts all dates during the last month |
|
988 | - * |
|
989 | - * @return Array the date list |
|
990 | - * |
|
991 | - */ |
|
987 | + * Counts all dates during the last month |
|
988 | + * |
|
989 | + * @return Array the date list |
|
990 | + * |
|
991 | + */ |
|
992 | 992 | public function countAllDatesLastMonth($filters = array()) |
993 | 993 | { |
994 | 994 | global $globalTimezone, $globalDBdriver; |
@@ -1010,7 +1010,7 @@ discard block |
||
1010 | 1010 | $query .= " GROUP BY date_name |
1011 | 1011 | ORDER BY date_name ASC"; |
1012 | 1012 | $query_data = array(':offset' => $offset); |
1013 | - } |
|
1013 | + } |
|
1014 | 1014 | |
1015 | 1015 | $sth = $this->db->prepare($query); |
1016 | 1016 | $sth->execute($query_data); |
@@ -1032,11 +1032,11 @@ discard block |
||
1032 | 1032 | |
1033 | 1033 | |
1034 | 1034 | /** |
1035 | - * Counts all month |
|
1036 | - * |
|
1037 | - * @return Array the month list |
|
1038 | - * |
|
1039 | - */ |
|
1035 | + * Counts all month |
|
1036 | + * |
|
1037 | + * @return Array the month list |
|
1038 | + * |
|
1039 | + */ |
|
1040 | 1040 | public function countAllMonths($filters = array()) |
1041 | 1041 | { |
1042 | 1042 | global $globalTimezone, $globalDBdriver; |
@@ -1081,11 +1081,11 @@ discard block |
||
1081 | 1081 | |
1082 | 1082 | |
1083 | 1083 | /** |
1084 | - * Counts all dates during the last year |
|
1085 | - * |
|
1086 | - * @return Array the date list |
|
1087 | - * |
|
1088 | - */ |
|
1084 | + * Counts all dates during the last year |
|
1085 | + * |
|
1086 | + * @return Array the date list |
|
1087 | + * |
|
1088 | + */ |
|
1089 | 1089 | public function countAllMonthsLastYear($filters) |
1090 | 1090 | { |
1091 | 1091 | global $globalTimezone, $globalDBdriver; |
@@ -1107,7 +1107,7 @@ discard block |
||
1107 | 1107 | $query .= " GROUP BY year_name, month_name |
1108 | 1108 | ORDER BY year_name, month_name ASC"; |
1109 | 1109 | $query_data = array(':offset' => $offset); |
1110 | - } |
|
1110 | + } |
|
1111 | 1111 | |
1112 | 1112 | $sth = $this->db->prepare($query); |
1113 | 1113 | $sth->execute($query_data); |
@@ -1130,11 +1130,11 @@ discard block |
||
1130 | 1130 | |
1131 | 1131 | |
1132 | 1132 | /** |
1133 | - * Counts all hours |
|
1134 | - * |
|
1135 | - * @return Array the hour list |
|
1136 | - * |
|
1137 | - */ |
|
1133 | + * Counts all hours |
|
1134 | + * |
|
1135 | + * @return Array the hour list |
|
1136 | + * |
|
1137 | + */ |
|
1138 | 1138 | public function countAllHours($orderby,$filters = array()) |
1139 | 1139 | { |
1140 | 1140 | global $globalTimezone, $globalDBdriver; |
@@ -1197,11 +1197,11 @@ discard block |
||
1197 | 1197 | |
1198 | 1198 | |
1199 | 1199 | /** |
1200 | - * Counts all hours by date |
|
1201 | - * |
|
1202 | - * @return Array the hour list |
|
1203 | - * |
|
1204 | - */ |
|
1200 | + * Counts all hours by date |
|
1201 | + * |
|
1202 | + * @return Array the hour list |
|
1203 | + * |
|
1204 | + */ |
|
1205 | 1205 | public function countAllHoursByDate($date, $filters = array()) |
1206 | 1206 | { |
1207 | 1207 | global $globalTimezone, $globalDBdriver; |
@@ -1245,11 +1245,11 @@ discard block |
||
1245 | 1245 | |
1246 | 1246 | |
1247 | 1247 | /** |
1248 | - * Counts all hours by a ident/callsign |
|
1249 | - * |
|
1250 | - * @return Array the hour list |
|
1251 | - * |
|
1252 | - */ |
|
1248 | + * Counts all hours by a ident/callsign |
|
1249 | + * |
|
1250 | + * @return Array the hour list |
|
1251 | + * |
|
1252 | + */ |
|
1253 | 1253 | public function countAllHoursByIdent($ident, $filters = array()) |
1254 | 1254 | { |
1255 | 1255 | global $globalTimezone, $globalDBdriver; |
@@ -1294,11 +1294,11 @@ discard block |
||
1294 | 1294 | |
1295 | 1295 | |
1296 | 1296 | /** |
1297 | - * Counts all flights that have flown over |
|
1298 | - * |
|
1299 | - * @return Integer the number of flights |
|
1300 | - * |
|
1301 | - */ |
|
1297 | + * Counts all flights that have flown over |
|
1298 | + * |
|
1299 | + * @return Integer the number of flights |
|
1300 | + * |
|
1301 | + */ |
|
1302 | 1302 | public function countOverallTracked($filters = array(),$year = '',$month = '') |
1303 | 1303 | { |
1304 | 1304 | global $globalDBdriver; |
@@ -1333,11 +1333,11 @@ discard block |
||
1333 | 1333 | |
1334 | 1334 | |
1335 | 1335 | /** |
1336 | - * Counts all hours of today |
|
1337 | - * |
|
1338 | - * @return Array the hour list |
|
1339 | - * |
|
1340 | - */ |
|
1336 | + * Counts all hours of today |
|
1337 | + * |
|
1338 | + * @return Array the hour list |
|
1339 | + * |
|
1340 | + */ |
|
1341 | 1341 | public function countAllHoursFromToday($filters = array()) |
1342 | 1342 | { |
1343 | 1343 | global $globalTimezone, $globalDBdriver; |
@@ -1377,12 +1377,12 @@ discard block |
||
1377 | 1377 | } |
1378 | 1378 | |
1379 | 1379 | |
1380 | - /** |
|
1381 | - * Gets the Barrie Spotter ID based on the FlightAware ID |
|
1382 | - * |
|
1383 | - * @return Integer the Barrie Spotter ID |
|
1380 | + /** |
|
1381 | + * Gets the Barrie Spotter ID based on the FlightAware ID |
|
1382 | + * |
|
1383 | + * @return Integer the Barrie Spotter ID |
|
1384 | 1384 | q * |
1385 | - */ |
|
1385 | + */ |
|
1386 | 1386 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
1387 | 1387 | { |
1388 | 1388 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
@@ -1403,13 +1403,13 @@ discard block |
||
1403 | 1403 | |
1404 | 1404 | |
1405 | 1405 | /** |
1406 | - * Parses a date string |
|
1407 | - * |
|
1408 | - * @param String $dateString the date string |
|
1409 | - * @param String $timezone the timezone of a user |
|
1410 | - * @return Array the time information |
|
1411 | - * |
|
1412 | - */ |
|
1406 | + * Parses a date string |
|
1407 | + * |
|
1408 | + * @param String $dateString the date string |
|
1409 | + * @param String $timezone the timezone of a user |
|
1410 | + * @return Array the time information |
|
1411 | + * |
|
1412 | + */ |
|
1413 | 1413 | public function parseDateString($dateString, $timezone = '') |
1414 | 1414 | { |
1415 | 1415 | $time_array = array(); |
@@ -1442,12 +1442,12 @@ discard block |
||
1442 | 1442 | } |
1443 | 1443 | |
1444 | 1444 | /** |
1445 | - * Parses the direction degrees to working |
|
1446 | - * |
|
1447 | - * @param Float $direction the direction in degrees |
|
1448 | - * @return Array the direction information |
|
1449 | - * |
|
1450 | - */ |
|
1445 | + * Parses the direction degrees to working |
|
1446 | + * |
|
1447 | + * @param Float $direction the direction in degrees |
|
1448 | + * @return Array the direction information |
|
1449 | + * |
|
1450 | + */ |
|
1451 | 1451 | public function parseDirection($direction = 0) |
1452 | 1452 | { |
1453 | 1453 | if ($direction == '') $direction = 0; |
@@ -1526,12 +1526,12 @@ discard block |
||
1526 | 1526 | |
1527 | 1527 | |
1528 | 1528 | /** |
1529 | - * Gets Country from latitude/longitude |
|
1530 | - * |
|
1531 | - * @param Float $latitude latitute of the flight |
|
1532 | - * @param Float $longitude longitute of the flight |
|
1533 | - * @return String the countrie |
|
1534 | - */ |
|
1529 | + * Gets Country from latitude/longitude |
|
1530 | + * |
|
1531 | + * @param Float $latitude latitute of the flight |
|
1532 | + * @param Float $longitude longitute of the flight |
|
1533 | + * @return String the countrie |
|
1534 | + */ |
|
1535 | 1535 | public function getCountryFromLatitudeLongitude($latitude,$longitude) |
1536 | 1536 | { |
1537 | 1537 | global $globalDBdriver, $globalDebug; |
@@ -1568,11 +1568,11 @@ discard block |
||
1568 | 1568 | } |
1569 | 1569 | |
1570 | 1570 | /** |
1571 | - * Gets Country from iso2 |
|
1572 | - * |
|
1573 | - * @param String $iso2 ISO2 country code |
|
1574 | - * @return String the countrie |
|
1575 | - */ |
|
1571 | + * Gets Country from iso2 |
|
1572 | + * |
|
1573 | + * @param String $iso2 ISO2 country code |
|
1574 | + * @return String the countrie |
|
1575 | + */ |
|
1576 | 1576 | public function getCountryFromISO2($iso2) |
1577 | 1577 | { |
1578 | 1578 | global $globalDBdriver, $globalDebug; |
@@ -1601,12 +1601,12 @@ discard block |
||
1601 | 1601 | |
1602 | 1602 | |
1603 | 1603 | /** |
1604 | - * Gets the short url from bit.ly |
|
1605 | - * |
|
1606 | - * @param String $url the full url |
|
1607 | - * @return String the bit.ly url |
|
1608 | - * |
|
1609 | - */ |
|
1604 | + * Gets the short url from bit.ly |
|
1605 | + * |
|
1606 | + * @param String $url the full url |
|
1607 | + * @return String the bit.ly url |
|
1608 | + * |
|
1609 | + */ |
|
1610 | 1610 | public function getBitlyURL($url) |
1611 | 1611 | { |
1612 | 1612 | global $globalBitlyAccessToken; |