@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * Get SQL query part for filter used |
16 | 16 | * @param Array $filter the filter |
17 | - * @return Array the SQL part |
|
17 | + * @return string the SQL part |
|
18 | 18 | */ |
19 | 19 | |
20 | 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
@@ -467,6 +467,11 @@ discard block |
||
467 | 467 | /** |
468 | 468 | * Add identity |
469 | 469 | * |
470 | + * @param string $mmsi |
|
471 | + * @param string $imo |
|
472 | + * @param string $ident |
|
473 | + * @param string $callsign |
|
474 | + * @param string $type |
|
470 | 475 | */ |
471 | 476 | public function addIdentity($mmsi,$imo,$ident,$callsign,$type) |
472 | 477 | { |
@@ -600,25 +605,6 @@ discard block |
||
600 | 605 | * |
601 | 606 | * @param String $fammarine_id the ID |
602 | 607 | * @param String $ident the marine ident |
603 | - * @param String $departure_airport_icao the departure airport |
|
604 | - * @param String $arrival_airport_icao the arrival airport |
|
605 | - * @param String $latitude latitude of flight |
|
606 | - * @param String $longitude latitude of flight |
|
607 | - * @param String $waypoints waypoints of flight |
|
608 | - * @param String $heading heading of flight |
|
609 | - * @param String $groundspeed speed of flight |
|
610 | - * @param String $date date of flight |
|
611 | - * @param String $departure_airport_time departure time of flight |
|
612 | - * @param String $arrival_airport_time arrival time of flight |
|
613 | - * @param String $squawk squawk code of flight |
|
614 | - * @param String $route_stop route stop of flight |
|
615 | - * @param String $highlight highlight or not |
|
616 | - * @param String $ModeS ModesS code of flight |
|
617 | - * @param String $registration registration code of flight |
|
618 | - * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
619 | - * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
620 | - * @param String $verticalrate vertival rate of flight |
|
621 | - * @return String success or false |
|
622 | 608 | */ |
623 | 609 | public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '') |
624 | 610 | { |
@@ -1211,6 +1197,7 @@ discard block |
||
1211 | 1197 | /** |
1212 | 1198 | * Counts all hours |
1213 | 1199 | * |
1200 | + * @param string $orderby |
|
1214 | 1201 | * @return Array the hour list |
1215 | 1202 | * |
1216 | 1203 | */ |
@@ -1562,7 +1549,7 @@ discard block |
||
1562 | 1549 | /** |
1563 | 1550 | * Parses the direction degrees to working |
1564 | 1551 | * |
1565 | - * @param Float $direction the direction in degrees |
|
1552 | + * @param integer $direction the direction in degrees |
|
1566 | 1553 | * @return Array the direction information |
1567 | 1554 | * |
1568 | 1555 | */ |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | } |
13 | 13 | |
14 | 14 | /** |
15 | - * Get SQL query part for filter used |
|
16 | - * @param Array $filter the filter |
|
17 | - * @return Array the SQL part |
|
18 | - */ |
|
15 | + * Get SQL query part for filter used |
|
16 | + * @param Array $filter the filter |
|
17 | + * @return Array the SQL part |
|
18 | + */ |
|
19 | 19 | |
20 | 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
@@ -82,14 +82,14 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
85 | - * Executes the SQL statements to get the spotter information |
|
86 | - * |
|
87 | - * @param String $query the SQL query |
|
88 | - * @param Array $params parameter of the query |
|
89 | - * @param String $limitQuery the limit query |
|
90 | - * @return Array the spotter information |
|
91 | - * |
|
92 | - */ |
|
85 | + * Executes the SQL statements to get the spotter information |
|
86 | + * |
|
87 | + * @param String $query the SQL query |
|
88 | + * @param Array $params parameter of the query |
|
89 | + * @param String $limitQuery the limit query |
|
90 | + * @return Array the spotter information |
|
91 | + * |
|
92 | + */ |
|
93 | 93 | public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
94 | 94 | { |
95 | 95 | date_default_timezone_set('UTC'); |
@@ -217,11 +217,11 @@ discard block |
||
217 | 217 | |
218 | 218 | |
219 | 219 | /** |
220 | - * Gets all the spotter information based on the latest data entry |
|
221 | - * |
|
222 | - * @return Array the spotter information |
|
223 | - * |
|
224 | - */ |
|
220 | + * Gets all the spotter information based on the latest data entry |
|
221 | + * |
|
222 | + * @return Array the spotter information |
|
223 | + * |
|
224 | + */ |
|
225 | 225 | public function getLatestMarineData($limit = '', $sort = '', $filter = array()) |
226 | 226 | { |
227 | 227 | global $global_query; |
@@ -270,11 +270,11 @@ discard block |
||
270 | 270 | } |
271 | 271 | |
272 | 272 | /** |
273 | - * Gets all the spotter information based on the callsign |
|
274 | - * |
|
275 | - * @return Array the spotter information |
|
276 | - * |
|
277 | - */ |
|
273 | + * Gets all the spotter information based on the callsign |
|
274 | + * |
|
275 | + * @return Array the spotter information |
|
276 | + * |
|
277 | + */ |
|
278 | 278 | public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array()) |
279 | 279 | { |
280 | 280 | global $global_query; |
@@ -385,12 +385,12 @@ discard block |
||
385 | 385 | |
386 | 386 | |
387 | 387 | /** |
388 | - * Gets all source name |
|
389 | - * |
|
390 | - * @param String type format of source |
|
391 | - * @return Array list of source name |
|
392 | - * |
|
393 | - */ |
|
388 | + * Gets all source name |
|
389 | + * |
|
390 | + * @param String type format of source |
|
391 | + * @return Array list of source name |
|
392 | + * |
|
393 | + */ |
|
394 | 394 | public function getAllSourceName($type = '',$filters = array()) |
395 | 395 | { |
396 | 396 | $filter_query = $this->getFilter($filters,true,true); |
@@ -420,11 +420,11 @@ discard block |
||
420 | 420 | |
421 | 421 | |
422 | 422 | /** |
423 | - * Gets a list of all idents/callsigns |
|
424 | - * |
|
425 | - * @return Array list of ident/callsign names |
|
426 | - * |
|
427 | - */ |
|
423 | + * Gets a list of all idents/callsigns |
|
424 | + * |
|
425 | + * @return Array list of ident/callsign names |
|
426 | + * |
|
427 | + */ |
|
428 | 428 | public function getAllIdents($filters = array()) |
429 | 429 | { |
430 | 430 | $filter_query = $this->getFilter($filters,true,true); |
@@ -448,11 +448,11 @@ discard block |
||
448 | 448 | } |
449 | 449 | |
450 | 450 | /** |
451 | - * Gets all info from a mmsi |
|
452 | - * |
|
453 | - * @return Array list of mmsi info |
|
454 | - * |
|
455 | - */ |
|
451 | + * Gets all info from a mmsi |
|
452 | + * |
|
453 | + * @return Array list of mmsi info |
|
454 | + * |
|
455 | + */ |
|
456 | 456 | public function getIdentity($mmsi) |
457 | 457 | { |
458 | 458 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
@@ -465,9 +465,9 @@ discard block |
||
465 | 465 | } |
466 | 466 | |
467 | 467 | /** |
468 | - * Add identity |
|
469 | - * |
|
470 | - */ |
|
468 | + * Add identity |
|
469 | + * |
|
470 | + */ |
|
471 | 471 | public function addIdentity($mmsi,$imo,$ident,$callsign,$type) |
472 | 472 | { |
473 | 473 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
@@ -526,13 +526,13 @@ discard block |
||
526 | 526 | } |
527 | 527 | |
528 | 528 | /** |
529 | - * Update ident tracker data |
|
530 | - * |
|
531 | - * @param String $fammarine_id the ID |
|
532 | - * @param String $ident the marine ident |
|
533 | - * @return String success or false |
|
534 | - * |
|
535 | - */ |
|
529 | + * Update ident tracker data |
|
530 | + * |
|
531 | + * @param String $fammarine_id the ID |
|
532 | + * @param String $ident the marine ident |
|
533 | + * @return String success or false |
|
534 | + * |
|
535 | + */ |
|
536 | 536 | public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
537 | 537 | { |
538 | 538 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
@@ -547,19 +547,19 @@ discard block |
||
547 | 547 | } |
548 | 548 | |
549 | 549 | /** |
550 | - * Update Status data |
|
551 | - * |
|
552 | - * @param String $fammarine_id the ID |
|
553 | - * @param String $status_id the marine status id |
|
554 | - * @param String $status the marine status |
|
555 | - * @return String success or false |
|
556 | - * |
|
557 | - */ |
|
550 | + * Update Status data |
|
551 | + * |
|
552 | + * @param String $fammarine_id the ID |
|
553 | + * @param String $status_id the marine status id |
|
554 | + * @param String $status the marine status |
|
555 | + * @return String success or false |
|
556 | + * |
|
557 | + */ |
|
558 | 558 | public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') |
559 | 559 | { |
560 | 560 | |
561 | 561 | $query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; |
562 | - $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
562 | + $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
563 | 563 | |
564 | 564 | try { |
565 | 565 | $sth = $this->db->prepare($query); |
@@ -572,17 +572,17 @@ discard block |
||
572 | 572 | |
573 | 573 | } |
574 | 574 | /** |
575 | - * Update latest marine data |
|
576 | - * |
|
577 | - * @param String $fammarine_id the ID |
|
578 | - * @param String $ident the marine ident |
|
579 | - * @return String success or false |
|
580 | - * |
|
581 | - */ |
|
575 | + * Update latest marine data |
|
576 | + * |
|
577 | + * @param String $fammarine_id the ID |
|
578 | + * @param String $ident the marine ident |
|
579 | + * @return String success or false |
|
580 | + * |
|
581 | + */ |
|
582 | 582 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
583 | 583 | { |
584 | 584 | $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'; |
585 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
585 | + $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
586 | 586 | |
587 | 587 | try { |
588 | 588 | $sth = $this->db->prepare($query); |
@@ -596,30 +596,30 @@ discard block |
||
596 | 596 | } |
597 | 597 | |
598 | 598 | /** |
599 | - * Adds a new spotter data |
|
600 | - * |
|
601 | - * @param String $fammarine_id the ID |
|
602 | - * @param String $ident the marine ident |
|
603 | - * @param String $departure_airport_icao the departure airport |
|
604 | - * @param String $arrival_airport_icao the arrival airport |
|
605 | - * @param String $latitude latitude of flight |
|
606 | - * @param String $longitude latitude of flight |
|
607 | - * @param String $waypoints waypoints of flight |
|
608 | - * @param String $heading heading of flight |
|
609 | - * @param String $groundspeed speed of flight |
|
610 | - * @param String $date date of flight |
|
611 | - * @param String $departure_airport_time departure time of flight |
|
612 | - * @param String $arrival_airport_time arrival time of flight |
|
613 | - * @param String $squawk squawk code of flight |
|
614 | - * @param String $route_stop route stop of flight |
|
615 | - * @param String $highlight highlight or not |
|
616 | - * @param String $ModeS ModesS code of flight |
|
617 | - * @param String $registration registration code of flight |
|
618 | - * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
619 | - * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
620 | - * @param String $verticalrate vertival rate of flight |
|
621 | - * @return String success or false |
|
622 | - */ |
|
599 | + * Adds a new spotter data |
|
600 | + * |
|
601 | + * @param String $fammarine_id the ID |
|
602 | + * @param String $ident the marine ident |
|
603 | + * @param String $departure_airport_icao the departure airport |
|
604 | + * @param String $arrival_airport_icao the arrival airport |
|
605 | + * @param String $latitude latitude of flight |
|
606 | + * @param String $longitude latitude of flight |
|
607 | + * @param String $waypoints waypoints of flight |
|
608 | + * @param String $heading heading of flight |
|
609 | + * @param String $groundspeed speed of flight |
|
610 | + * @param String $date date of flight |
|
611 | + * @param String $departure_airport_time departure time of flight |
|
612 | + * @param String $arrival_airport_time arrival time of flight |
|
613 | + * @param String $squawk squawk code of flight |
|
614 | + * @param String $route_stop route stop of flight |
|
615 | + * @param String $highlight highlight or not |
|
616 | + * @param String $ModeS ModesS code of flight |
|
617 | + * @param String $registration registration code of flight |
|
618 | + * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
619 | + * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
620 | + * @param String $verticalrate vertival rate of flight |
|
621 | + * @return String success or false |
|
622 | + */ |
|
623 | 623 | public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '') |
624 | 624 | { |
625 | 625 | global $globalURL, $globalMarineImageFetch; |
@@ -716,13 +716,13 @@ discard block |
||
716 | 716 | unset($Image); |
717 | 717 | } |
718 | 718 | |
719 | - if ($latitude == '' && $longitude == '') { |
|
720 | - $latitude = 0; |
|
721 | - $longitude = 0; |
|
722 | - } |
|
723 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
724 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
725 | - if ($arrival_date == '') $arrival_date = NULL; |
|
719 | + if ($latitude == '' && $longitude == '') { |
|
720 | + $latitude = 0; |
|
721 | + $longitude = 0; |
|
722 | + } |
|
723 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
724 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
725 | + if ($arrival_date == '') $arrival_date = NULL; |
|
726 | 726 | $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) |
727 | 727 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
728 | 728 | |
@@ -733,7 +733,7 @@ discard block |
||
733 | 733 | $sth->execute($query_values); |
734 | 734 | $this->db = null; |
735 | 735 | } catch (PDOException $e) { |
736 | - return "error : ".$e->getMessage(); |
|
736 | + return "error : ".$e->getMessage(); |
|
737 | 737 | } |
738 | 738 | |
739 | 739 | return "success"; |
@@ -742,11 +742,11 @@ discard block |
||
742 | 742 | |
743 | 743 | |
744 | 744 | /** |
745 | - * Gets the aircraft ident within the last hour |
|
746 | - * |
|
747 | - * @return String the ident |
|
748 | - * |
|
749 | - */ |
|
745 | + * Gets the aircraft ident within the last hour |
|
746 | + * |
|
747 | + * @return String the ident |
|
748 | + * |
|
749 | + */ |
|
750 | 750 | public function getIdentFromLastHour($ident) |
751 | 751 | { |
752 | 752 | global $globalDBdriver, $globalTimezone; |
@@ -762,11 +762,11 @@ discard block |
||
762 | 762 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
763 | 763 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
764 | 764 | $query_data = array(':ident' => $ident); |
765 | - } |
|
765 | + } |
|
766 | 766 | |
767 | 767 | $sth = $this->db->prepare($query); |
768 | 768 | $sth->execute($query_data); |
769 | - $ident_result=''; |
|
769 | + $ident_result=''; |
|
770 | 770 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
771 | 771 | { |
772 | 772 | $ident_result = $row['ident']; |
@@ -777,11 +777,11 @@ discard block |
||
777 | 777 | |
778 | 778 | |
779 | 779 | /** |
780 | - * Gets the aircraft data from the last 20 seconds |
|
781 | - * |
|
782 | - * @return Array the spotter data |
|
783 | - * |
|
784 | - */ |
|
780 | + * Gets the aircraft data from the last 20 seconds |
|
781 | + * |
|
782 | + * @return Array the spotter data |
|
783 | + * |
|
784 | + */ |
|
785 | 785 | public function getRealTimeData($q = '') |
786 | 786 | { |
787 | 787 | global $globalDBdriver; |
@@ -819,11 +819,11 @@ discard block |
||
819 | 819 | |
820 | 820 | |
821 | 821 | /** |
822 | - * Gets all number of flight over countries |
|
823 | - * |
|
824 | - * @return Array the airline country list |
|
825 | - * |
|
826 | - */ |
|
822 | + * Gets all number of flight over countries |
|
823 | + * |
|
824 | + * @return Array the airline country list |
|
825 | + * |
|
826 | + */ |
|
827 | 827 | |
828 | 828 | public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
829 | 829 | { |
@@ -896,11 +896,11 @@ discard block |
||
896 | 896 | |
897 | 897 | |
898 | 898 | /** |
899 | - * Gets all callsigns that have flown over |
|
900 | - * |
|
901 | - * @return Array the callsign list |
|
902 | - * |
|
903 | - */ |
|
899 | + * Gets all callsigns that have flown over |
|
900 | + * |
|
901 | + * @return Array the callsign list |
|
902 | + * |
|
903 | + */ |
|
904 | 904 | public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
905 | 905 | { |
906 | 906 | global $globalDBdriver; |
@@ -967,11 +967,11 @@ discard block |
||
967 | 967 | |
968 | 968 | |
969 | 969 | /** |
970 | - * Counts all dates |
|
971 | - * |
|
972 | - * @return Array the date list |
|
973 | - * |
|
974 | - */ |
|
970 | + * Counts all dates |
|
971 | + * |
|
972 | + * @return Array the date list |
|
973 | + * |
|
974 | + */ |
|
975 | 975 | public function countAllDates($filters = array()) |
976 | 976 | { |
977 | 977 | global $globalTimezone, $globalDBdriver; |
@@ -1017,11 +1017,11 @@ discard block |
||
1017 | 1017 | |
1018 | 1018 | |
1019 | 1019 | /** |
1020 | - * Counts all dates during the last 7 days |
|
1021 | - * |
|
1022 | - * @return Array the date list |
|
1023 | - * |
|
1024 | - */ |
|
1020 | + * Counts all dates during the last 7 days |
|
1021 | + * |
|
1022 | + * @return Array the date list |
|
1023 | + * |
|
1024 | + */ |
|
1025 | 1025 | public function countAllDatesLast7Days($filters = array()) |
1026 | 1026 | { |
1027 | 1027 | global $globalTimezone, $globalDBdriver; |
@@ -1043,7 +1043,7 @@ discard block |
||
1043 | 1043 | $query .= " GROUP BY date_name |
1044 | 1044 | ORDER BY date_name ASC"; |
1045 | 1045 | $query_data = array(':offset' => $offset); |
1046 | - } |
|
1046 | + } |
|
1047 | 1047 | |
1048 | 1048 | $sth = $this->db->prepare($query); |
1049 | 1049 | $sth->execute($query_data); |
@@ -1063,11 +1063,11 @@ discard block |
||
1063 | 1063 | } |
1064 | 1064 | |
1065 | 1065 | /** |
1066 | - * Counts all dates during the last month |
|
1067 | - * |
|
1068 | - * @return Array the date list |
|
1069 | - * |
|
1070 | - */ |
|
1066 | + * Counts all dates during the last month |
|
1067 | + * |
|
1068 | + * @return Array the date list |
|
1069 | + * |
|
1070 | + */ |
|
1071 | 1071 | public function countAllDatesLastMonth($filters = array()) |
1072 | 1072 | { |
1073 | 1073 | global $globalTimezone, $globalDBdriver; |
@@ -1089,7 +1089,7 @@ discard block |
||
1089 | 1089 | $query .= " GROUP BY date_name |
1090 | 1090 | ORDER BY date_name ASC"; |
1091 | 1091 | $query_data = array(':offset' => $offset); |
1092 | - } |
|
1092 | + } |
|
1093 | 1093 | |
1094 | 1094 | $sth = $this->db->prepare($query); |
1095 | 1095 | $sth->execute($query_data); |
@@ -1111,11 +1111,11 @@ discard block |
||
1111 | 1111 | |
1112 | 1112 | |
1113 | 1113 | /** |
1114 | - * Counts all month |
|
1115 | - * |
|
1116 | - * @return Array the month list |
|
1117 | - * |
|
1118 | - */ |
|
1114 | + * Counts all month |
|
1115 | + * |
|
1116 | + * @return Array the month list |
|
1117 | + * |
|
1118 | + */ |
|
1119 | 1119 | public function countAllMonths($filters = array()) |
1120 | 1120 | { |
1121 | 1121 | global $globalTimezone, $globalDBdriver; |
@@ -1160,11 +1160,11 @@ discard block |
||
1160 | 1160 | |
1161 | 1161 | |
1162 | 1162 | /** |
1163 | - * Counts all dates during the last year |
|
1164 | - * |
|
1165 | - * @return Array the date list |
|
1166 | - * |
|
1167 | - */ |
|
1163 | + * Counts all dates during the last year |
|
1164 | + * |
|
1165 | + * @return Array the date list |
|
1166 | + * |
|
1167 | + */ |
|
1168 | 1168 | public function countAllMonthsLastYear($filters) |
1169 | 1169 | { |
1170 | 1170 | global $globalTimezone, $globalDBdriver; |
@@ -1186,7 +1186,7 @@ discard block |
||
1186 | 1186 | $query .= " GROUP BY year_name, month_name |
1187 | 1187 | ORDER BY year_name, month_name ASC"; |
1188 | 1188 | $query_data = array(':offset' => $offset); |
1189 | - } |
|
1189 | + } |
|
1190 | 1190 | |
1191 | 1191 | $sth = $this->db->prepare($query); |
1192 | 1192 | $sth->execute($query_data); |
@@ -1209,11 +1209,11 @@ discard block |
||
1209 | 1209 | |
1210 | 1210 | |
1211 | 1211 | /** |
1212 | - * Counts all hours |
|
1213 | - * |
|
1214 | - * @return Array the hour list |
|
1215 | - * |
|
1216 | - */ |
|
1212 | + * Counts all hours |
|
1213 | + * |
|
1214 | + * @return Array the hour list |
|
1215 | + * |
|
1216 | + */ |
|
1217 | 1217 | public function countAllHours($orderby,$filters = array()) |
1218 | 1218 | { |
1219 | 1219 | global $globalTimezone, $globalDBdriver; |
@@ -1276,11 +1276,11 @@ discard block |
||
1276 | 1276 | |
1277 | 1277 | |
1278 | 1278 | /** |
1279 | - * Counts all hours by date |
|
1280 | - * |
|
1281 | - * @return Array the hour list |
|
1282 | - * |
|
1283 | - */ |
|
1279 | + * Counts all hours by date |
|
1280 | + * |
|
1281 | + * @return Array the hour list |
|
1282 | + * |
|
1283 | + */ |
|
1284 | 1284 | public function countAllHoursByDate($date, $filters = array()) |
1285 | 1285 | { |
1286 | 1286 | global $globalTimezone, $globalDBdriver; |
@@ -1324,11 +1324,11 @@ discard block |
||
1324 | 1324 | |
1325 | 1325 | |
1326 | 1326 | /** |
1327 | - * Counts all hours by a ident/callsign |
|
1328 | - * |
|
1329 | - * @return Array the hour list |
|
1330 | - * |
|
1331 | - */ |
|
1327 | + * Counts all hours by a ident/callsign |
|
1328 | + * |
|
1329 | + * @return Array the hour list |
|
1330 | + * |
|
1331 | + */ |
|
1332 | 1332 | public function countAllHoursByIdent($ident, $filters = array()) |
1333 | 1333 | { |
1334 | 1334 | global $globalTimezone, $globalDBdriver; |
@@ -1373,11 +1373,11 @@ discard block |
||
1373 | 1373 | |
1374 | 1374 | |
1375 | 1375 | /** |
1376 | - * Counts all vessels |
|
1377 | - * |
|
1378 | - * @return Integer the number of vessels |
|
1379 | - * |
|
1380 | - */ |
|
1376 | + * Counts all vessels |
|
1377 | + * |
|
1378 | + * @return Integer the number of vessels |
|
1379 | + * |
|
1380 | + */ |
|
1381 | 1381 | public function countOverallMarine($filters = array(),$year = '',$month = '') |
1382 | 1382 | { |
1383 | 1383 | global $globalDBdriver; |
@@ -1412,11 +1412,11 @@ discard block |
||
1412 | 1412 | } |
1413 | 1413 | |
1414 | 1414 | /** |
1415 | - * Counts all vessel type |
|
1416 | - * |
|
1417 | - * @return Integer the number of vessels |
|
1418 | - * |
|
1419 | - */ |
|
1415 | + * Counts all vessel type |
|
1416 | + * |
|
1417 | + * @return Integer the number of vessels |
|
1418 | + * |
|
1419 | + */ |
|
1420 | 1420 | public function countOverallMarineTypes($filters = array(),$year = '',$month = '') |
1421 | 1421 | { |
1422 | 1422 | global $globalDBdriver; |
@@ -1451,11 +1451,11 @@ discard block |
||
1451 | 1451 | |
1452 | 1452 | |
1453 | 1453 | /** |
1454 | - * Counts all hours of today |
|
1455 | - * |
|
1456 | - * @return Array the hour list |
|
1457 | - * |
|
1458 | - */ |
|
1454 | + * Counts all hours of today |
|
1455 | + * |
|
1456 | + * @return Array the hour list |
|
1457 | + * |
|
1458 | + */ |
|
1459 | 1459 | public function countAllHoursFromToday($filters = array()) |
1460 | 1460 | { |
1461 | 1461 | global $globalTimezone, $globalDBdriver; |
@@ -1495,12 +1495,12 @@ discard block |
||
1495 | 1495 | } |
1496 | 1496 | |
1497 | 1497 | |
1498 | - /** |
|
1499 | - * Gets the Barrie Spotter ID based on the FlightAware ID |
|
1500 | - * |
|
1501 | - * @return Integer the Barrie Spotter ID |
|
1498 | + /** |
|
1499 | + * Gets the Barrie Spotter ID based on the FlightAware ID |
|
1500 | + * |
|
1501 | + * @return Integer the Barrie Spotter ID |
|
1502 | 1502 | q * |
1503 | - */ |
|
1503 | + */ |
|
1504 | 1504 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
1505 | 1505 | { |
1506 | 1506 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
@@ -1521,13 +1521,13 @@ discard block |
||
1521 | 1521 | |
1522 | 1522 | |
1523 | 1523 | /** |
1524 | - * Parses a date string |
|
1525 | - * |
|
1526 | - * @param String $dateString the date string |
|
1527 | - * @param String $timezone the timezone of a user |
|
1528 | - * @return Array the time information |
|
1529 | - * |
|
1530 | - */ |
|
1524 | + * Parses a date string |
|
1525 | + * |
|
1526 | + * @param String $dateString the date string |
|
1527 | + * @param String $timezone the timezone of a user |
|
1528 | + * @return Array the time information |
|
1529 | + * |
|
1530 | + */ |
|
1531 | 1531 | public function parseDateString($dateString, $timezone = '') |
1532 | 1532 | { |
1533 | 1533 | $time_array = array(); |
@@ -1560,12 +1560,12 @@ discard block |
||
1560 | 1560 | } |
1561 | 1561 | |
1562 | 1562 | /** |
1563 | - * Parses the direction degrees to working |
|
1564 | - * |
|
1565 | - * @param Float $direction the direction in degrees |
|
1566 | - * @return Array the direction information |
|
1567 | - * |
|
1568 | - */ |
|
1563 | + * Parses the direction degrees to working |
|
1564 | + * |
|
1565 | + * @param Float $direction the direction in degrees |
|
1566 | + * @return Array the direction information |
|
1567 | + * |
|
1568 | + */ |
|
1569 | 1569 | public function parseDirection($direction = 0) |
1570 | 1570 | { |
1571 | 1571 | if ($direction == '') $direction = 0; |
@@ -1644,12 +1644,12 @@ discard block |
||
1644 | 1644 | |
1645 | 1645 | |
1646 | 1646 | /** |
1647 | - * Gets Country from latitude/longitude |
|
1648 | - * |
|
1649 | - * @param Float $latitude latitute of the flight |
|
1650 | - * @param Float $longitude longitute of the flight |
|
1651 | - * @return String the countrie |
|
1652 | - */ |
|
1647 | + * Gets Country from latitude/longitude |
|
1648 | + * |
|
1649 | + * @param Float $latitude latitute of the flight |
|
1650 | + * @param Float $longitude longitute of the flight |
|
1651 | + * @return String the countrie |
|
1652 | + */ |
|
1653 | 1653 | public function getCountryFromLatitudeLongitude($latitude,$longitude) |
1654 | 1654 | { |
1655 | 1655 | global $globalDBdriver, $globalDebug; |
@@ -1686,11 +1686,11 @@ discard block |
||
1686 | 1686 | } |
1687 | 1687 | |
1688 | 1688 | /** |
1689 | - * Gets Country from iso2 |
|
1690 | - * |
|
1691 | - * @param String $iso2 ISO2 country code |
|
1692 | - * @return String the countrie |
|
1693 | - */ |
|
1689 | + * Gets Country from iso2 |
|
1690 | + * |
|
1691 | + * @param String $iso2 ISO2 country code |
|
1692 | + * @return String the countrie |
|
1693 | + */ |
|
1694 | 1694 | public function getCountryFromISO2($iso2) |
1695 | 1695 | { |
1696 | 1696 | global $globalDBdriver, $globalDebug; |
@@ -1719,12 +1719,12 @@ discard block |
||
1719 | 1719 | |
1720 | 1720 | |
1721 | 1721 | /** |
1722 | - * Gets the short url from bit.ly |
|
1723 | - * |
|
1724 | - * @param String $url the full url |
|
1725 | - * @return String the bit.ly url |
|
1726 | - * |
|
1727 | - */ |
|
1722 | + * Gets the short url from bit.ly |
|
1723 | + * |
|
1724 | + * @param String $url the full url |
|
1725 | + * @return String the bit.ly url |
|
1726 | + * |
|
1727 | + */ |
|
1728 | 1728 | public function getBitlyURL($url) |
1729 | 1729 | { |
1730 | 1730 | global $globalBitlyAccessToken; |
@@ -1751,11 +1751,11 @@ discard block |
||
1751 | 1751 | |
1752 | 1752 | |
1753 | 1753 | /** |
1754 | - * Gets all vessels types that have flown over |
|
1755 | - * |
|
1756 | - * @return Array the vessel type list |
|
1757 | - * |
|
1758 | - */ |
|
1754 | + * Gets all vessels types that have flown over |
|
1755 | + * |
|
1756 | + * @return Array the vessel type list |
|
1757 | + * |
|
1758 | + */ |
|
1759 | 1759 | public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
1760 | 1760 | { |
1761 | 1761 | global $globalDBdriver; |
@@ -1820,11 +1820,11 @@ discard block |
||
1820 | 1820 | } |
1821 | 1821 | |
1822 | 1822 | /** |
1823 | - * Gets all the tracker information |
|
1824 | - * |
|
1825 | - * @return Array the tracker information |
|
1826 | - * |
|
1827 | - */ |
|
1823 | + * Gets all the tracker information |
|
1824 | + * |
|
1825 | + * @return Array the tracker information |
|
1826 | + * |
|
1827 | + */ |
|
1828 | 1828 | public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array()) |
1829 | 1829 | { |
1830 | 1830 | global $globalTimezone, $globalDBdriver; |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | require_once(dirname(__FILE__).'/class.Image.php'); |
3 | 3 | $global_query = "SELECT marine_output.* FROM marine_output"; |
4 | 4 | |
5 | -class Marine{ |
|
5 | +class Marine { |
|
6 | 6 | public $db; |
7 | 7 | |
8 | 8 | public function __construct($dbc = null) { |
@@ -17,33 +17,33 @@ discard block |
||
17 | 17 | * @return Array the SQL part |
18 | 18 | */ |
19 | 19 | |
20 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
20 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
22 | 22 | $filters = array(); |
23 | 23 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
24 | 24 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
25 | 25 | $filters = $globalStatsFilters[$globalFilterName]; |
26 | 26 | } else { |
27 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
27 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
28 | 28 | } |
29 | 29 | } |
30 | 30 | if (isset($filter[0]['source'])) { |
31 | - $filters = array_merge($filters,$filter); |
|
31 | + $filters = array_merge($filters, $filter); |
|
32 | 32 | } |
33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
33 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
34 | 34 | $filter_query_join = ''; |
35 | 35 | $filter_query_where = ''; |
36 | - foreach($filters as $flt) { |
|
36 | + foreach ($filters as $flt) { |
|
37 | 37 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
38 | 38 | if (isset($flt['source'])) { |
39 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
39 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
40 | 40 | } else { |
41 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
41 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | } |
45 | 45 | if (isset($filter['source']) && !empty($filter['source'])) { |
46 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
46 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
47 | 47 | } |
48 | 48 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
49 | 49 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
76 | 76 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
77 | 77 | if ($filter_query_where != '') { |
78 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
78 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
79 | 79 | } |
80 | 80 | $filter_query = $filter_query_join.$filter_query_where; |
81 | 81 | return $filter_query; |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @return Array the spotter information |
91 | 91 | * |
92 | 92 | */ |
93 | - public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
|
93 | + public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false) |
|
94 | 94 | { |
95 | 95 | date_default_timezone_set('UTC'); |
96 | 96 | if (!is_string($query)) |
@@ -110,13 +110,13 @@ discard block |
||
110 | 110 | $sth = $this->db->prepare($query.$limitQuery); |
111 | 111 | $sth->execute($params); |
112 | 112 | } catch (PDOException $e) { |
113 | - printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); |
|
113 | + printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery); |
|
114 | 114 | exit(); |
115 | 115 | } |
116 | 116 | |
117 | 117 | $num_rows = 0; |
118 | 118 | $spotter_array = array(); |
119 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
119 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
120 | 120 | { |
121 | 121 | $num_rows++; |
122 | 122 | $temp_array = array(); |
@@ -148,10 +148,10 @@ discard block |
||
148 | 148 | } |
149 | 149 | if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
150 | 150 | |
151 | - if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
|
151 | + if (isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
|
152 | 152 | { |
153 | 153 | $Image = new Image($this->db); |
154 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
154 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']); |
|
155 | 155 | else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
156 | 156 | unset($Image); |
157 | 157 | if (count($image_array) > 0) { |
@@ -187,17 +187,17 @@ discard block |
||
187 | 187 | { |
188 | 188 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
189 | 189 | } else { |
190 | - $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
|
190 | + $temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC")); |
|
191 | 191 | } |
192 | 192 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
193 | - $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
|
194 | - $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
|
193 | + $temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC")); |
|
194 | + $temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC")); |
|
195 | 195 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
196 | 196 | if (isset($row['last_seen']) && $row['last_seen'] != '') { |
197 | 197 | if (strtotime($row['last_seen']) > strtotime($row['date'])) { |
198 | 198 | $temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']); |
199 | - $temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC")); |
|
200 | - $temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC")); |
|
199 | + $temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC")); |
|
200 | + $temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC")); |
|
201 | 201 | $temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC"); |
202 | 202 | } |
203 | 203 | } |
@@ -230,8 +230,8 @@ discard block |
||
230 | 230 | if ($limit != "") |
231 | 231 | { |
232 | 232 | $limit_array = explode(",", $limit); |
233 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
234 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
233 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
234 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
235 | 235 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
236 | 236 | { |
237 | 237 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -245,8 +245,8 @@ discard block |
||
245 | 245 | } else { |
246 | 246 | $orderby_query = " ORDER BY marine_output.date DESC"; |
247 | 247 | } |
248 | - $query = $global_query.$filter_query." ".$orderby_query; |
|
249 | - $spotter_array = $this->getDataFromDB($query, array(),$limit_query,true); |
|
248 | + $query = $global_query.$filter_query." ".$orderby_query; |
|
249 | + $spotter_array = $this->getDataFromDB($query, array(), $limit_query, true); |
|
250 | 250 | return $spotter_array; |
251 | 251 | } |
252 | 252 | |
@@ -264,8 +264,8 @@ discard block |
||
264 | 264 | if ($id == '') return array(); |
265 | 265 | $additional_query = "marine_output.fammarine_id = :id"; |
266 | 266 | $query_values = array(':id' => $id); |
267 | - $query = $global_query." WHERE ".$additional_query." "; |
|
268 | - $spotter_array = $this->getDataFromDB($query,$query_values); |
|
267 | + $query = $global_query." WHERE ".$additional_query." "; |
|
268 | + $spotter_array = $this->getDataFromDB($query, $query_values); |
|
269 | 269 | return $spotter_array; |
270 | 270 | } |
271 | 271 | |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | $query_values = array(); |
285 | 285 | $limit_query = ''; |
286 | 286 | $additional_query = ''; |
287 | - $filter_query = $this->getFilter($filter,true,true); |
|
287 | + $filter_query = $this->getFilter($filter, true, true); |
|
288 | 288 | if ($ident != "") |
289 | 289 | { |
290 | 290 | if (!is_string($ident)) |
@@ -300,8 +300,8 @@ discard block |
||
300 | 300 | { |
301 | 301 | $limit_array = explode(",", $limit); |
302 | 302 | |
303 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
304 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
303 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
304 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
305 | 305 | |
306 | 306 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
307 | 307 | { |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | return $spotter_array; |
326 | 326 | } |
327 | 327 | |
328 | - public function getMarineDataByDate($date = '', $limit = '', $sort = '',$filter = array()) |
|
328 | + public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array()) |
|
329 | 329 | { |
330 | 330 | global $global_query, $globalTimezone, $globalDBdriver; |
331 | 331 | |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | $limit_query = ''; |
334 | 334 | $additional_query = ''; |
335 | 335 | |
336 | - $filter_query = $this->getFilter($filter,true,true); |
|
336 | + $filter_query = $this->getFilter($filter, true, true); |
|
337 | 337 | |
338 | 338 | if ($date != "") |
339 | 339 | { |
@@ -359,8 +359,8 @@ discard block |
||
359 | 359 | { |
360 | 360 | $limit_array = explode(",", $limit); |
361 | 361 | |
362 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
363 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
362 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
363 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
364 | 364 | |
365 | 365 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
366 | 366 | { |
@@ -391,11 +391,11 @@ discard block |
||
391 | 391 | * @return Array list of source name |
392 | 392 | * |
393 | 393 | */ |
394 | - public function getAllSourceName($type = '',$filters = array()) |
|
394 | + public function getAllSourceName($type = '', $filters = array()) |
|
395 | 395 | { |
396 | - $filter_query = $this->getFilter($filters,true,true); |
|
396 | + $filter_query = $this->getFilter($filters, true, true); |
|
397 | 397 | $query_values = array(); |
398 | - $query = "SELECT DISTINCT marine_output.source_name |
|
398 | + $query = "SELECT DISTINCT marine_output.source_name |
|
399 | 399 | FROM marine_output".$filter_query." marine_output.source_name <> ''"; |
400 | 400 | if ($type != '') { |
401 | 401 | $query_values = array(':type' => $type); |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | $source_array = array(); |
411 | 411 | $temp_array = array(); |
412 | 412 | |
413 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
413 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
414 | 414 | { |
415 | 415 | $temp_array['source_name'] = $row['source_name']; |
416 | 416 | $source_array[] = $temp_array; |
@@ -427,8 +427,8 @@ discard block |
||
427 | 427 | */ |
428 | 428 | public function getAllIdents($filters = array()) |
429 | 429 | { |
430 | - $filter_query = $this->getFilter($filters,true,true); |
|
431 | - $query = "SELECT DISTINCT marine_output.ident |
|
430 | + $filter_query = $this->getFilter($filters, true, true); |
|
431 | + $query = "SELECT DISTINCT marine_output.ident |
|
432 | 432 | FROM marine_output".$filter_query." marine_output.ident <> '' |
433 | 433 | ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0"; |
434 | 434 | |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | $ident_array = array(); |
439 | 439 | $temp_array = array(); |
440 | 440 | |
441 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
441 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
442 | 442 | { |
443 | 443 | $temp_array['ident'] = $row['ident']; |
444 | 444 | $ident_array[] = $temp_array; |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | */ |
456 | 456 | public function getIdentity($mmsi) |
457 | 457 | { |
458 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
458 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
459 | 459 | $query = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1"; |
460 | 460 | $sth = $this->db->prepare($query); |
461 | 461 | $sth->execute(array(':mmsi' => $mmsi)); |
@@ -468,17 +468,17 @@ discard block |
||
468 | 468 | * Add identity |
469 | 469 | * |
470 | 470 | */ |
471 | - public function addIdentity($mmsi,$imo,$ident,$callsign,$type) |
|
471 | + public function addIdentity($mmsi, $imo, $ident, $callsign, $type) |
|
472 | 472 | { |
473 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
474 | - $imo = filter_var($imo,FILTER_SANITIZE_NUMBER_INT); |
|
475 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
476 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
477 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
473 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
474 | + $imo = filter_var($imo, FILTER_SANITIZE_NUMBER_INT); |
|
475 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
476 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
477 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
478 | 478 | if (empty($this->getIdentity)) { |
479 | - $query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)"; |
|
479 | + $query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)"; |
|
480 | 480 | $sth = $this->db->prepare($query); |
481 | - $sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':call_sign' => $callsign,':ship_name' => $ident,':type' => $type)); |
|
481 | + $sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':call_sign' => $callsign, ':ship_name' => $ident, ':type' => $type)); |
|
482 | 482 | } |
483 | 483 | } |
484 | 484 | |
@@ -498,12 +498,12 @@ discard block |
||
498 | 498 | } else $offset = '+00:00'; |
499 | 499 | |
500 | 500 | if ($globalDBdriver == 'mysql') { |
501 | - $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
501 | + $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
502 | 502 | FROM marine_output |
503 | 503 | WHERE marine_output.date <> '' |
504 | 504 | ORDER BY marine_output.date ASC LIMIT 0,100"; |
505 | 505 | } else { |
506 | - $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
506 | + $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
507 | 507 | FROM marine_output |
508 | 508 | WHERE marine_output.date <> '' |
509 | 509 | ORDER BY marine_output.date ASC LIMIT 0,100"; |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | $date_array = array(); |
516 | 516 | $temp_array = array(); |
517 | 517 | |
518 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
518 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
519 | 519 | { |
520 | 520 | $temp_array['date'] = $row['date']; |
521 | 521 | |
@@ -533,10 +533,10 @@ discard block |
||
533 | 533 | * @return String success or false |
534 | 534 | * |
535 | 535 | */ |
536 | - public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
|
536 | + public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL) |
|
537 | 537 | { |
538 | 538 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
539 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
539 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident); |
|
540 | 540 | try { |
541 | 541 | $sth = $this->db->prepare($query); |
542 | 542 | $sth->execute($query_values); |
@@ -555,11 +555,11 @@ discard block |
||
555 | 555 | * @return String success or false |
556 | 556 | * |
557 | 557 | */ |
558 | - public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') |
|
558 | + public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '') |
|
559 | 559 | { |
560 | 560 | |
561 | 561 | $query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; |
562 | - $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
562 | + $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id); |
|
563 | 563 | |
564 | 564 | try { |
565 | 565 | $sth = $this->db->prepare($query); |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
583 | 583 | { |
584 | 584 | $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'; |
585 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
585 | + $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident); |
|
586 | 586 | |
587 | 587 | try { |
588 | 588 | $sth = $this->db->prepare($query); |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | * @param String $verticalrate vertival rate of flight |
621 | 621 | * @return String success or false |
622 | 622 | */ |
623 | - public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '') |
|
623 | + public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $format_source = '', $source_name = '') |
|
624 | 624 | { |
625 | 625 | global $globalURL, $globalMarineImageFetch; |
626 | 626 | |
@@ -687,31 +687,31 @@ discard block |
||
687 | 687 | } |
688 | 688 | |
689 | 689 | |
690 | - if ($date == "" || strtotime($date) < time()-20*60) |
|
690 | + if ($date == "" || strtotime($date) < time() - 20*60) |
|
691 | 691 | { |
692 | 692 | $date = date("Y-m-d H:i:s", time()); |
693 | 693 | } |
694 | 694 | |
695 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
696 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
697 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
698 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
699 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
700 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
701 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
702 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
703 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
704 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
705 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
706 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
707 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
708 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
695 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
696 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
697 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
698 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
699 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
700 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
701 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
702 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
703 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
704 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
705 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
706 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
707 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
708 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
709 | 709 | |
710 | 710 | if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) { |
711 | 711 | $Image = new Image($this->db); |
712 | - $image_array = $Image->getMarineImage($mmsi,$imo,$ident); |
|
712 | + $image_array = $Image->getMarineImage($mmsi, $imo, $ident); |
|
713 | 713 | if (!isset($image_array[0]['mmsi'])) { |
714 | - $Image->addMarineImage($mmsi,$imo,$ident); |
|
714 | + $Image->addMarineImage($mmsi, $imo, $ident); |
|
715 | 715 | } |
716 | 716 | unset($Image); |
717 | 717 | } |
@@ -723,10 +723,10 @@ discard block |
||
723 | 723 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
724 | 724 | if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
725 | 725 | if ($arrival_date == '') $arrival_date = NULL; |
726 | - $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) |
|
726 | + $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) |
|
727 | 727 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
728 | 728 | |
729 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); |
|
729 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); |
|
730 | 730 | try { |
731 | 731 | |
732 | 732 | $sth = $this->db->prepare($query); |
@@ -751,13 +751,13 @@ discard block |
||
751 | 751 | { |
752 | 752 | global $globalDBdriver, $globalTimezone; |
753 | 753 | if ($globalDBdriver == 'mysql') { |
754 | - $query = "SELECT marine_output.ident FROM marine_output |
|
754 | + $query = "SELECT marine_output.ident FROM marine_output |
|
755 | 755 | WHERE marine_output.ident = :ident |
756 | 756 | AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
757 | 757 | AND marine_output.date < UTC_TIMESTAMP()"; |
758 | 758 | $query_data = array(':ident' => $ident); |
759 | 759 | } else { |
760 | - $query = "SELECT marine_output.ident FROM marine_output |
|
760 | + $query = "SELECT marine_output.ident FROM marine_output |
|
761 | 761 | WHERE marine_output.ident = :ident |
762 | 762 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
763 | 763 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
@@ -766,8 +766,8 @@ discard block |
||
766 | 766 | |
767 | 767 | $sth = $this->db->prepare($query); |
768 | 768 | $sth->execute($query_data); |
769 | - $ident_result=''; |
|
770 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
769 | + $ident_result = ''; |
|
770 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
771 | 771 | { |
772 | 772 | $ident_result = $row['ident']; |
773 | 773 | } |
@@ -793,8 +793,8 @@ discard block |
||
793 | 793 | return false; |
794 | 794 | } else { |
795 | 795 | $q_array = explode(" ", $q); |
796 | - foreach ($q_array as $q_item){ |
|
797 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
796 | + foreach ($q_array as $q_item) { |
|
797 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
798 | 798 | $additional_query .= " AND ("; |
799 | 799 | $additional_query .= "(marine_output.ident like '%".$q_item."%')"; |
800 | 800 | $additional_query .= ")"; |
@@ -802,11 +802,11 @@ discard block |
||
802 | 802 | } |
803 | 803 | } |
804 | 804 | if ($globalDBdriver == 'mysql') { |
805 | - $query = "SELECT marine_output.* FROM marine_output |
|
805 | + $query = "SELECT marine_output.* FROM marine_output |
|
806 | 806 | WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
807 | 807 | AND marine_output.date < UTC_TIMESTAMP()"; |
808 | 808 | } else { |
809 | - $query = "SELECT marine_output.* FROM marine_output |
|
809 | + $query = "SELECT marine_output.* FROM marine_output |
|
810 | 810 | WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
811 | 811 | AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
812 | 812 | } |
@@ -825,16 +825,16 @@ discard block |
||
825 | 825 | * |
826 | 826 | */ |
827 | 827 | |
828 | - public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
828 | + public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
829 | 829 | { |
830 | 830 | global $globalDBdriver, $globalArchive; |
831 | 831 | //$filter_query = $this->getFilter($filters,true,true); |
832 | - $Connection= new Connection($this->db); |
|
832 | + $Connection = new Connection($this->db); |
|
833 | 833 | if (!$Connection->tableExists('countries')) return array(); |
834 | 834 | require_once('class.SpotterLive.php'); |
835 | 835 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
836 | 836 | $MarineLive = new MarineLive($this->db); |
837 | - $filter_query = $MarineLive->getFilter($filters,true,true); |
|
837 | + $filter_query = $MarineLive->getFilter($filters, true, true); |
|
838 | 838 | $filter_query .= " over_country IS NOT NULL AND over_country <> ''"; |
839 | 839 | if ($olderthanmonths > 0) { |
840 | 840 | if ($globalDBdriver == 'mysql') { |
@@ -854,7 +854,7 @@ discard block |
||
854 | 854 | } else { |
855 | 855 | require_once(dirname(__FILE__)."/class.MarineArchive.php"); |
856 | 856 | $MarineArchive = new MarineArchive($this->db); |
857 | - $filter_query = $MarineArchive->getFilter($filters,true,true); |
|
857 | + $filter_query = $MarineArchive->getFilter($filters, true, true); |
|
858 | 858 | $filter_query .= " over_country <> ''"; |
859 | 859 | if ($olderthanmonths > 0) { |
860 | 860 | if ($globalDBdriver == 'mysql') { |
@@ -882,7 +882,7 @@ discard block |
||
882 | 882 | $flight_array = array(); |
883 | 883 | $temp_array = array(); |
884 | 884 | |
885 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
885 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
886 | 886 | { |
887 | 887 | $temp_array['marine_count'] = $row['nb']; |
888 | 888 | $temp_array['marine_country'] = $row['name']; |
@@ -901,11 +901,11 @@ discard block |
||
901 | 901 | * @return Array the callsign list |
902 | 902 | * |
903 | 903 | */ |
904 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
904 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
905 | 905 | { |
906 | 906 | global $globalDBdriver; |
907 | - $filter_query = $this->getFilter($filters,true,true); |
|
908 | - $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
907 | + $filter_query = $this->getFilter($filters, true, true); |
|
908 | + $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
909 | 909 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
910 | 910 | if ($olderthanmonths > 0) { |
911 | 911 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -919,28 +919,28 @@ discard block |
||
919 | 919 | if ($year != '') { |
920 | 920 | if ($globalDBdriver == 'mysql') { |
921 | 921 | $query .= " AND YEAR(marine_output.date) = :year"; |
922 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
922 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
923 | 923 | } else { |
924 | 924 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
925 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
925 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
926 | 926 | } |
927 | 927 | } |
928 | 928 | if ($month != '') { |
929 | 929 | if ($globalDBdriver == 'mysql') { |
930 | 930 | $query .= " AND MONTH(marine_output.date) = :month"; |
931 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
931 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
932 | 932 | } else { |
933 | 933 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
934 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
934 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
935 | 935 | } |
936 | 936 | } |
937 | 937 | if ($day != '') { |
938 | 938 | if ($globalDBdriver == 'mysql') { |
939 | 939 | $query .= " AND DAY(marine_output.date) = :day"; |
940 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
940 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
941 | 941 | } else { |
942 | 942 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
943 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
943 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
944 | 944 | } |
945 | 945 | } |
946 | 946 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
@@ -952,7 +952,7 @@ discard block |
||
952 | 952 | $callsign_array = array(); |
953 | 953 | $temp_array = array(); |
954 | 954 | |
955 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
955 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
956 | 956 | { |
957 | 957 | $temp_array['callsign_icao'] = $row['ident']; |
958 | 958 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -1004,7 +1004,7 @@ discard block |
||
1004 | 1004 | $date_array = array(); |
1005 | 1005 | $temp_array = array(); |
1006 | 1006 | |
1007 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1007 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1008 | 1008 | { |
1009 | 1009 | $temp_array['date_name'] = $row['date_name']; |
1010 | 1010 | $temp_array['date_count'] = $row['date_count']; |
@@ -1030,7 +1030,7 @@ discard block |
||
1030 | 1030 | $datetime = new DateTime(); |
1031 | 1031 | $offset = $datetime->format('P'); |
1032 | 1032 | } else $offset = '+00:00'; |
1033 | - $filter_query = $this->getFilter($filters,true,true); |
|
1033 | + $filter_query = $this->getFilter($filters, true, true); |
|
1034 | 1034 | if ($globalDBdriver == 'mysql') { |
1035 | 1035 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
1036 | 1036 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -1051,7 +1051,7 @@ discard block |
||
1051 | 1051 | $date_array = array(); |
1052 | 1052 | $temp_array = array(); |
1053 | 1053 | |
1054 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1054 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1055 | 1055 | { |
1056 | 1056 | $temp_array['date_name'] = $row['date_name']; |
1057 | 1057 | $temp_array['date_count'] = $row['date_count']; |
@@ -1076,7 +1076,7 @@ discard block |
||
1076 | 1076 | $datetime = new DateTime(); |
1077 | 1077 | $offset = $datetime->format('P'); |
1078 | 1078 | } else $offset = '+00:00'; |
1079 | - $filter_query = $this->getFilter($filters,true,true); |
|
1079 | + $filter_query = $this->getFilter($filters, true, true); |
|
1080 | 1080 | if ($globalDBdriver == 'mysql') { |
1081 | 1081 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
1082 | 1082 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -1097,7 +1097,7 @@ discard block |
||
1097 | 1097 | $date_array = array(); |
1098 | 1098 | $temp_array = array(); |
1099 | 1099 | |
1100 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1100 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1101 | 1101 | { |
1102 | 1102 | $temp_array['date_name'] = $row['date_name']; |
1103 | 1103 | $temp_array['date_count'] = $row['date_count']; |
@@ -1144,7 +1144,7 @@ discard block |
||
1144 | 1144 | $date_array = array(); |
1145 | 1145 | $temp_array = array(); |
1146 | 1146 | |
1147 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1147 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1148 | 1148 | { |
1149 | 1149 | $temp_array['month_name'] = $row['month_name']; |
1150 | 1150 | $temp_array['year_name'] = $row['year_name']; |
@@ -1173,7 +1173,7 @@ discard block |
||
1173 | 1173 | $datetime = new DateTime(); |
1174 | 1174 | $offset = $datetime->format('P'); |
1175 | 1175 | } else $offset = '+00:00'; |
1176 | - $filter_query = $this->getFilter($filters,true,true); |
|
1176 | + $filter_query = $this->getFilter($filters, true, true); |
|
1177 | 1177 | if ($globalDBdriver == 'mysql') { |
1178 | 1178 | $query = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
1179 | 1179 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -1194,7 +1194,7 @@ discard block |
||
1194 | 1194 | $date_array = array(); |
1195 | 1195 | $temp_array = array(); |
1196 | 1196 | |
1197 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1197 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1198 | 1198 | { |
1199 | 1199 | $temp_array['year_name'] = $row['year_name']; |
1200 | 1200 | $temp_array['month_name'] = $row['month_name']; |
@@ -1214,7 +1214,7 @@ discard block |
||
1214 | 1214 | * @return Array the hour list |
1215 | 1215 | * |
1216 | 1216 | */ |
1217 | - public function countAllHours($orderby,$filters = array()) |
|
1217 | + public function countAllHours($orderby, $filters = array()) |
|
1218 | 1218 | { |
1219 | 1219 | global $globalTimezone, $globalDBdriver; |
1220 | 1220 | if ($globalTimezone != '') { |
@@ -1262,7 +1262,7 @@ discard block |
||
1262 | 1262 | $hour_array = array(); |
1263 | 1263 | $temp_array = array(); |
1264 | 1264 | |
1265 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1265 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1266 | 1266 | { |
1267 | 1267 | $temp_array['hour_name'] = $row['hour_name']; |
1268 | 1268 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1284,8 +1284,8 @@ discard block |
||
1284 | 1284 | public function countAllHoursByDate($date, $filters = array()) |
1285 | 1285 | { |
1286 | 1286 | global $globalTimezone, $globalDBdriver; |
1287 | - $filter_query = $this->getFilter($filters,true,true); |
|
1288 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
1287 | + $filter_query = $this->getFilter($filters, true, true); |
|
1288 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
1289 | 1289 | if ($globalTimezone != '') { |
1290 | 1290 | date_default_timezone_set($globalTimezone); |
1291 | 1291 | $datetime = new DateTime($date); |
@@ -1293,12 +1293,12 @@ discard block |
||
1293 | 1293 | } else $offset = '+00:00'; |
1294 | 1294 | |
1295 | 1295 | if ($globalDBdriver == 'mysql') { |
1296 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1296 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1297 | 1297 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date |
1298 | 1298 | GROUP BY hour_name |
1299 | 1299 | ORDER BY hour_name ASC"; |
1300 | 1300 | } else { |
1301 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1301 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1302 | 1302 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
1303 | 1303 | GROUP BY hour_name |
1304 | 1304 | ORDER BY hour_name ASC"; |
@@ -1310,7 +1310,7 @@ discard block |
||
1310 | 1310 | $hour_array = array(); |
1311 | 1311 | $temp_array = array(); |
1312 | 1312 | |
1313 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1313 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1314 | 1314 | { |
1315 | 1315 | $temp_array['hour_name'] = $row['hour_name']; |
1316 | 1316 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1332,8 +1332,8 @@ discard block |
||
1332 | 1332 | public function countAllHoursByIdent($ident, $filters = array()) |
1333 | 1333 | { |
1334 | 1334 | global $globalTimezone, $globalDBdriver; |
1335 | - $filter_query = $this->getFilter($filters,true,true); |
|
1336 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
1335 | + $filter_query = $this->getFilter($filters, true, true); |
|
1336 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
1337 | 1337 | if ($globalTimezone != '') { |
1338 | 1338 | date_default_timezone_set($globalTimezone); |
1339 | 1339 | $datetime = new DateTime(); |
@@ -1341,12 +1341,12 @@ discard block |
||
1341 | 1341 | } else $offset = '+00:00'; |
1342 | 1342 | |
1343 | 1343 | if ($globalDBdriver == 'mysql') { |
1344 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1344 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1345 | 1345 | FROM marine_output".$filter_query." marine_output.ident = :ident |
1346 | 1346 | GROUP BY hour_name |
1347 | 1347 | ORDER BY hour_name ASC"; |
1348 | 1348 | } else { |
1349 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1349 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1350 | 1350 | FROM marine_output".$filter_query." marine_output.ident = :ident |
1351 | 1351 | GROUP BY hour_name |
1352 | 1352 | ORDER BY hour_name ASC"; |
@@ -1354,12 +1354,12 @@ discard block |
||
1354 | 1354 | |
1355 | 1355 | |
1356 | 1356 | $sth = $this->db->prepare($query); |
1357 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
1357 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
1358 | 1358 | |
1359 | 1359 | $hour_array = array(); |
1360 | 1360 | $temp_array = array(); |
1361 | 1361 | |
1362 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1362 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1363 | 1363 | { |
1364 | 1364 | $temp_array['hour_name'] = $row['hour_name']; |
1365 | 1365 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1378,33 +1378,33 @@ discard block |
||
1378 | 1378 | * @return Integer the number of vessels |
1379 | 1379 | * |
1380 | 1380 | */ |
1381 | - public function countOverallMarine($filters = array(),$year = '',$month = '') |
|
1381 | + public function countOverallMarine($filters = array(), $year = '', $month = '') |
|
1382 | 1382 | { |
1383 | 1383 | global $globalDBdriver; |
1384 | 1384 | //$queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; |
1385 | - $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
1385 | + $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
1386 | 1386 | $query_values = array(); |
1387 | 1387 | $query = ''; |
1388 | 1388 | if ($year != '') { |
1389 | 1389 | if ($globalDBdriver == 'mysql') { |
1390 | 1390 | $query .= " AND YEAR(marine_output.date) = :year"; |
1391 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1391 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1392 | 1392 | } else { |
1393 | 1393 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1394 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1394 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1395 | 1395 | } |
1396 | 1396 | } |
1397 | 1397 | if ($month != '') { |
1398 | 1398 | if ($globalDBdriver == 'mysql') { |
1399 | 1399 | $query .= " AND MONTH(marine_output.date) = :month"; |
1400 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1400 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1401 | 1401 | } else { |
1402 | 1402 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1403 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1403 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1404 | 1404 | } |
1405 | 1405 | } |
1406 | 1406 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1407 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1407 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1408 | 1408 | |
1409 | 1409 | $sth = $this->db->prepare($queryi); |
1410 | 1410 | $sth->execute($query_values); |
@@ -1417,32 +1417,32 @@ discard block |
||
1417 | 1417 | * @return Integer the number of vessels |
1418 | 1418 | * |
1419 | 1419 | */ |
1420 | - public function countOverallMarineTypes($filters = array(),$year = '',$month = '') |
|
1420 | + public function countOverallMarineTypes($filters = array(), $year = '', $month = '') |
|
1421 | 1421 | { |
1422 | 1422 | global $globalDBdriver; |
1423 | - $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
1423 | + $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
1424 | 1424 | $query_values = array(); |
1425 | 1425 | $query = ''; |
1426 | 1426 | if ($year != '') { |
1427 | 1427 | if ($globalDBdriver == 'mysql') { |
1428 | 1428 | $query .= " AND YEAR(marine_output.date) = :year"; |
1429 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1429 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1430 | 1430 | } else { |
1431 | 1431 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1432 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1432 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1433 | 1433 | } |
1434 | 1434 | } |
1435 | 1435 | if ($month != '') { |
1436 | 1436 | if ($globalDBdriver == 'mysql') { |
1437 | 1437 | $query .= " AND MONTH(marine_output.date) = :month"; |
1438 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1438 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1439 | 1439 | } else { |
1440 | 1440 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1441 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1441 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1442 | 1442 | } |
1443 | 1443 | } |
1444 | 1444 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1445 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1445 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1446 | 1446 | |
1447 | 1447 | $sth = $this->db->prepare($queryi); |
1448 | 1448 | $sth->execute($query_values); |
@@ -1459,7 +1459,7 @@ discard block |
||
1459 | 1459 | public function countAllHoursFromToday($filters = array()) |
1460 | 1460 | { |
1461 | 1461 | global $globalTimezone, $globalDBdriver; |
1462 | - $filter_query = $this->getFilter($filters,true,true); |
|
1462 | + $filter_query = $this->getFilter($filters, true, true); |
|
1463 | 1463 | if ($globalTimezone != '') { |
1464 | 1464 | date_default_timezone_set($globalTimezone); |
1465 | 1465 | $datetime = new DateTime(); |
@@ -1467,12 +1467,12 @@ discard block |
||
1467 | 1467 | } else $offset = '+00:00'; |
1468 | 1468 | |
1469 | 1469 | if ($globalDBdriver == 'mysql') { |
1470 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1470 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1471 | 1471 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE() |
1472 | 1472 | GROUP BY hour_name |
1473 | 1473 | ORDER BY hour_name ASC"; |
1474 | 1474 | } else { |
1475 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1475 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1476 | 1476 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
1477 | 1477 | GROUP BY hour_name |
1478 | 1478 | ORDER BY hour_name ASC"; |
@@ -1484,7 +1484,7 @@ discard block |
||
1484 | 1484 | $hour_array = array(); |
1485 | 1485 | $temp_array = array(); |
1486 | 1486 | |
1487 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1487 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1488 | 1488 | { |
1489 | 1489 | $temp_array['hour_name'] = $row['hour_name']; |
1490 | 1490 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1503,9 +1503,9 @@ discard block |
||
1503 | 1503 | */ |
1504 | 1504 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
1505 | 1505 | { |
1506 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
1506 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
1507 | 1507 | |
1508 | - $query = "SELECT marine_output.marine_id |
|
1508 | + $query = "SELECT marine_output.marine_id |
|
1509 | 1509 | FROM marine_output |
1510 | 1510 | WHERE marine_output.fammarine_id = '".$fammarine_id."'"; |
1511 | 1511 | |
@@ -1513,7 +1513,7 @@ discard block |
||
1513 | 1513 | $sth = $this->db->prepare($query); |
1514 | 1514 | $sth->execute(); |
1515 | 1515 | |
1516 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1516 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1517 | 1517 | { |
1518 | 1518 | return $row['marine_id']; |
1519 | 1519 | } |
@@ -1538,23 +1538,23 @@ discard block |
||
1538 | 1538 | } |
1539 | 1539 | |
1540 | 1540 | $current_date = date("Y-m-d H:i:s"); |
1541 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
1541 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
1542 | 1542 | |
1543 | 1543 | $diff = abs(strtotime($current_date) - strtotime($date)); |
1544 | 1544 | |
1545 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
1545 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
1546 | 1546 | $years = $time_array['years']; |
1547 | 1547 | |
1548 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
1548 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
1549 | 1549 | $months = $time_array['months']; |
1550 | 1550 | |
1551 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
1551 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
1552 | 1552 | $days = $time_array['days']; |
1553 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
1553 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
1554 | 1554 | $hours = $time_array['hours']; |
1555 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
1555 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
1556 | 1556 | $minutes = $time_array['minutes']; |
1557 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1557 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1558 | 1558 | |
1559 | 1559 | return $time_array; |
1560 | 1560 | } |
@@ -1577,63 +1577,63 @@ discard block |
||
1577 | 1577 | $temp_array['direction_degree'] = $direction; |
1578 | 1578 | $temp_array['direction_shortname'] = "N"; |
1579 | 1579 | $temp_array['direction_fullname'] = "North"; |
1580 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
1580 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
1581 | 1581 | $temp_array['direction_degree'] = $direction; |
1582 | 1582 | $temp_array['direction_shortname'] = "NNE"; |
1583 | 1583 | $temp_array['direction_fullname'] = "North-Northeast"; |
1584 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
1584 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
1585 | 1585 | $temp_array['direction_degree'] = $direction; |
1586 | 1586 | $temp_array['direction_shortname'] = "NE"; |
1587 | 1587 | $temp_array['direction_fullname'] = "Northeast"; |
1588 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
1588 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
1589 | 1589 | $temp_array['direction_degree'] = $direction; |
1590 | 1590 | $temp_array['direction_shortname'] = "ENE"; |
1591 | 1591 | $temp_array['direction_fullname'] = "East-Northeast"; |
1592 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
1592 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
1593 | 1593 | $temp_array['direction_degree'] = $direction; |
1594 | 1594 | $temp_array['direction_shortname'] = "E"; |
1595 | 1595 | $temp_array['direction_fullname'] = "East"; |
1596 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
1596 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
1597 | 1597 | $temp_array['direction_degree'] = $direction; |
1598 | 1598 | $temp_array['direction_shortname'] = "ESE"; |
1599 | 1599 | $temp_array['direction_fullname'] = "East-Southeast"; |
1600 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
1600 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
1601 | 1601 | $temp_array['direction_degree'] = $direction; |
1602 | 1602 | $temp_array['direction_shortname'] = "SE"; |
1603 | 1603 | $temp_array['direction_fullname'] = "Southeast"; |
1604 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
1604 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
1605 | 1605 | $temp_array['direction_degree'] = $direction; |
1606 | 1606 | $temp_array['direction_shortname'] = "SSE"; |
1607 | 1607 | $temp_array['direction_fullname'] = "South-Southeast"; |
1608 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
1608 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
1609 | 1609 | $temp_array['direction_degree'] = $direction; |
1610 | 1610 | $temp_array['direction_shortname'] = "S"; |
1611 | 1611 | $temp_array['direction_fullname'] = "South"; |
1612 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
1612 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
1613 | 1613 | $temp_array['direction_degree'] = $direction; |
1614 | 1614 | $temp_array['direction_shortname'] = "SSW"; |
1615 | 1615 | $temp_array['direction_fullname'] = "South-Southwest"; |
1616 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
1616 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
1617 | 1617 | $temp_array['direction_degree'] = $direction; |
1618 | 1618 | $temp_array['direction_shortname'] = "SW"; |
1619 | 1619 | $temp_array['direction_fullname'] = "Southwest"; |
1620 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
1620 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
1621 | 1621 | $temp_array['direction_degree'] = $direction; |
1622 | 1622 | $temp_array['direction_shortname'] = "WSW"; |
1623 | 1623 | $temp_array['direction_fullname'] = "West-Southwest"; |
1624 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
1624 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
1625 | 1625 | $temp_array['direction_degree'] = $direction; |
1626 | 1626 | $temp_array['direction_shortname'] = "W"; |
1627 | 1627 | $temp_array['direction_fullname'] = "West"; |
1628 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
1628 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
1629 | 1629 | $temp_array['direction_degree'] = $direction; |
1630 | 1630 | $temp_array['direction_shortname'] = "WNW"; |
1631 | 1631 | $temp_array['direction_fullname'] = "West-Northwest"; |
1632 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
1632 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
1633 | 1633 | $temp_array['direction_degree'] = $direction; |
1634 | 1634 | $temp_array['direction_shortname'] = "NW"; |
1635 | 1635 | $temp_array['direction_fullname'] = "Northwest"; |
1636 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
1636 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
1637 | 1637 | $temp_array['direction_degree'] = $direction; |
1638 | 1638 | $temp_array['direction_shortname'] = "NNW"; |
1639 | 1639 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -1650,11 +1650,11 @@ discard block |
||
1650 | 1650 | * @param Float $longitude longitute of the flight |
1651 | 1651 | * @return String the countrie |
1652 | 1652 | */ |
1653 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
1653 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
1654 | 1654 | { |
1655 | 1655 | global $globalDBdriver, $globalDebug; |
1656 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1657 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1656 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1657 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1658 | 1658 | |
1659 | 1659 | $Connection = new Connection($this->db); |
1660 | 1660 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1694,7 +1694,7 @@ discard block |
||
1694 | 1694 | public function getCountryFromISO2($iso2) |
1695 | 1695 | { |
1696 | 1696 | global $globalDBdriver, $globalDebug; |
1697 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
1697 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
1698 | 1698 | |
1699 | 1699 | $Connection = new Connection($this->db); |
1700 | 1700 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1742,7 +1742,7 @@ discard block |
||
1742 | 1742 | |
1743 | 1743 | $bitly_data = json_decode($bitly_data); |
1744 | 1744 | $bitly_url = ''; |
1745 | - if ($bitly_data->status_txt = "OK"){ |
|
1745 | + if ($bitly_data->status_txt = "OK") { |
|
1746 | 1746 | $bitly_url = $bitly_data->data->url; |
1747 | 1747 | } |
1748 | 1748 | |
@@ -1756,11 +1756,11 @@ discard block |
||
1756 | 1756 | * @return Array the vessel type list |
1757 | 1757 | * |
1758 | 1758 | */ |
1759 | - public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
|
1759 | + public function countAllMarineTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
1760 | 1760 | { |
1761 | 1761 | global $globalDBdriver; |
1762 | - $filter_query = $this->getFilter($filters,true,true); |
|
1763 | - $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count |
|
1762 | + $filter_query = $this->getFilter($filters, true, true); |
|
1763 | + $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count |
|
1764 | 1764 | FROM marine_output ".$filter_query." marine_output.type <> ''"; |
1765 | 1765 | if ($olderthanmonths > 0) { |
1766 | 1766 | if ($globalDBdriver == 'mysql') { |
@@ -1780,28 +1780,28 @@ discard block |
||
1780 | 1780 | if ($year != '') { |
1781 | 1781 | if ($globalDBdriver == 'mysql') { |
1782 | 1782 | $query .= " AND YEAR(marine_output.date) = :year"; |
1783 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1783 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1784 | 1784 | } else { |
1785 | 1785 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1786 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1786 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1787 | 1787 | } |
1788 | 1788 | } |
1789 | 1789 | if ($month != '') { |
1790 | 1790 | if ($globalDBdriver == 'mysql') { |
1791 | 1791 | $query .= " AND MONTH(marine_output.date) = :month"; |
1792 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1792 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1793 | 1793 | } else { |
1794 | 1794 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1795 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1795 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1796 | 1796 | } |
1797 | 1797 | } |
1798 | 1798 | if ($day != '') { |
1799 | 1799 | if ($globalDBdriver == 'mysql') { |
1800 | 1800 | $query .= " AND DAY(marine_output.date) = :day"; |
1801 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1801 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1802 | 1802 | } else { |
1803 | 1803 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
1804 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1804 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1805 | 1805 | } |
1806 | 1806 | } |
1807 | 1807 | $query .= " GROUP BY marine_output.type ORDER BY marine_type_count DESC"; |
@@ -1810,7 +1810,7 @@ discard block |
||
1810 | 1810 | $sth->execute($query_values); |
1811 | 1811 | $marine_array = array(); |
1812 | 1812 | $temp_array = array(); |
1813 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1813 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1814 | 1814 | { |
1815 | 1815 | $temp_array['marine_type'] = $row['marine_type']; |
1816 | 1816 | $temp_array['marine_type_count'] = $row['marine_type_count']; |
@@ -1825,13 +1825,13 @@ discard block |
||
1825 | 1825 | * @return Array the tracker information |
1826 | 1826 | * |
1827 | 1827 | */ |
1828 | - public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array()) |
|
1828 | + public function searchMarineData($q = '', $callsign = '', $mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
1829 | 1829 | { |
1830 | 1830 | global $globalTimezone, $globalDBdriver; |
1831 | 1831 | date_default_timezone_set('UTC'); |
1832 | 1832 | $query_values = array(); |
1833 | 1833 | $additional_query = ''; |
1834 | - $filter_query = $this->getFilter($filters,true,true); |
|
1834 | + $filter_query = $this->getFilter($filters, true, true); |
|
1835 | 1835 | if ($q != "") |
1836 | 1836 | { |
1837 | 1837 | if (!is_string($q)) |
@@ -1839,8 +1839,8 @@ discard block |
||
1839 | 1839 | return false; |
1840 | 1840 | } else { |
1841 | 1841 | $q_array = explode(" ", $q); |
1842 | - foreach ($q_array as $q_item){ |
|
1843 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
1842 | + foreach ($q_array as $q_item) { |
|
1843 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
1844 | 1844 | $additional_query .= " AND ("; |
1845 | 1845 | if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
1846 | 1846 | if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
@@ -1852,42 +1852,42 @@ discard block |
||
1852 | 1852 | } |
1853 | 1853 | if ($callsign != "") |
1854 | 1854 | { |
1855 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
1855 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
1856 | 1856 | if (!is_string($callsign)) |
1857 | 1857 | { |
1858 | 1858 | return false; |
1859 | 1859 | } else { |
1860 | 1860 | $additional_query .= " AND marine_output.ident = :callsign"; |
1861 | - $query_values = array_merge($query_values,array(':callsign' => $callsign)); |
|
1861 | + $query_values = array_merge($query_values, array(':callsign' => $callsign)); |
|
1862 | 1862 | } |
1863 | 1863 | } |
1864 | 1864 | if ($mmsi != "") |
1865 | 1865 | { |
1866 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
1866 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
1867 | 1867 | if (!is_numeric($mmsi)) |
1868 | 1868 | { |
1869 | 1869 | return false; |
1870 | 1870 | } else { |
1871 | 1871 | $additional_query .= " AND marine_output.mmsi = :mmsi"; |
1872 | - $query_values = array_merge($query_values,array(':mmsi' => $mmsi)); |
|
1872 | + $query_values = array_merge($query_values, array(':mmsi' => $mmsi)); |
|
1873 | 1873 | } |
1874 | 1874 | } |
1875 | 1875 | if ($imo != "") |
1876 | 1876 | { |
1877 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
1877 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
1878 | 1878 | if (!is_numeric($imo)) |
1879 | 1879 | { |
1880 | 1880 | return false; |
1881 | 1881 | } else { |
1882 | 1882 | $additional_query .= " AND marine_output.imo = :imo"; |
1883 | - $query_values = array_merge($query_values,array(':imo' => $imo)); |
|
1883 | + $query_values = array_merge($query_values, array(':imo' => $imo)); |
|
1884 | 1884 | } |
1885 | 1885 | } |
1886 | 1886 | if ($date_posted != "") |
1887 | 1887 | { |
1888 | 1888 | $date_array = explode(",", $date_posted); |
1889 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
1890 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
1889 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
1890 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
1891 | 1891 | if ($globalTimezone != '') { |
1892 | 1892 | date_default_timezone_set($globalTimezone); |
1893 | 1893 | $datetime = new DateTime(); |
@@ -1914,8 +1914,8 @@ discard block |
||
1914 | 1914 | if ($limit != "") |
1915 | 1915 | { |
1916 | 1916 | $limit_array = explode(",", $limit); |
1917 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1918 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1917 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1918 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1919 | 1919 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1920 | 1920 | { |
1921 | 1921 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -1933,28 +1933,28 @@ discard block |
||
1933 | 1933 | } |
1934 | 1934 | } |
1935 | 1935 | if ($origLat != "" && $origLon != "" && $dist != "") { |
1936 | - $dist = number_format($dist*0.621371,2,'.',''); // convert km to mile |
|
1936 | + $dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile |
|
1937 | 1937 | if ($globalDBdriver == 'mysql') { |
1938 | - $query="SELECT marine_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2))) as distance |
|
1938 | + $query = "SELECT marine_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2))) as distance |
|
1939 | 1939 | FROM marine_archive,marine_output".$filter_query." marine_output.fammarine_id = marine_archive.fammarine_id AND marine_output.ident <> '' ".$additional_query."AND marine_archive.longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and marine_archive.latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
1940 | 1940 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2)))) < $dist".$orderby_query; |
1941 | 1941 | } else { |
1942 | - $query="SELECT marine_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
1942 | + $query = "SELECT marine_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
1943 | 1943 | FROM marine_archive,marine_output".$filter_query." marine_output.fammarine_id = marine_archive.fammarine_id AND marine_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
1944 | 1944 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query.$orderby_query; |
1945 | 1945 | } |
1946 | 1946 | } else { |
1947 | - $query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' |
|
1947 | + $query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' |
|
1948 | 1948 | ".$additional_query." |
1949 | 1949 | ".$orderby_query; |
1950 | 1950 | } |
1951 | - $marine_array = $this->getDataFromDB($query, $query_values,$limit_query); |
|
1951 | + $marine_array = $this->getDataFromDB($query, $query_values, $limit_query); |
|
1952 | 1952 | return $marine_array; |
1953 | 1953 | } |
1954 | 1954 | |
1955 | 1955 | public function getOrderBy() |
1956 | 1956 | { |
1957 | - $orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY marine_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY marine_output.type DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC")); |
|
1957 | + $orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY marine_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY marine_output.type DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC")); |
|
1958 | 1958 | |
1959 | 1959 | return $orderby; |
1960 | 1960 |
@@ -8,7 +8,9 @@ discard block |
||
8 | 8 | public function __construct($dbc = null) { |
9 | 9 | $Connection = new Connection($dbc); |
10 | 10 | $this->db = $Connection->db(); |
11 | - if ($this->db === null) die('Error: No DB connection. (Marine)'); |
|
11 | + if ($this->db === null) { |
|
12 | + die('Error: No DB connection. (Marine)'); |
|
13 | + } |
|
12 | 14 | } |
13 | 15 | |
14 | 16 | /** |
@@ -30,7 +32,9 @@ discard block |
||
30 | 32 | if (isset($filter[0]['source'])) { |
31 | 33 | $filters = array_merge($filters,$filter); |
32 | 34 | } |
33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
35 | + if (is_array($globalFilter)) { |
|
36 | + $filter = array_merge($filter,$globalFilter); |
|
37 | + } |
|
34 | 38 | $filter_query_join = ''; |
35 | 39 | $filter_query_where = ''; |
36 | 40 | foreach($filters as $flt) { |
@@ -72,8 +76,11 @@ discard block |
||
72 | 76 | $filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
73 | 77 | } |
74 | 78 | } |
75 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
76 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
79 | + if ($filter_query_where == '' && $where) { |
|
80 | + $filter_query_where = ' WHERE'; |
|
81 | + } elseif ($filter_query_where != '' && $and) { |
|
82 | + $filter_query_where .= ' AND'; |
|
83 | + } |
|
77 | 84 | if ($filter_query_where != '') { |
78 | 85 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
79 | 86 | } |
@@ -127,32 +134,54 @@ discard block |
||
127 | 134 | $temp_array['spotter_id'] = $row['spotter_archive_id']; |
128 | 135 | } elseif (isset($row['spotter_archive_output_id'])) { |
129 | 136 | $temp_array['spotter_id'] = $row['spotter_archive_output_id']; |
130 | - */} |
|
131 | - elseif (isset($row['marineid'])) { |
|
137 | + */} elseif (isset($row['marineid'])) { |
|
132 | 138 | $temp_array['marine_id'] = $row['marineid']; |
133 | 139 | } else { |
134 | 140 | $temp_array['marine_id'] = ''; |
135 | 141 | } |
136 | - if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
137 | - if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi']; |
|
138 | - if (isset($row['type'])) $temp_array['type'] = $row['type']; |
|
139 | - if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id']; |
|
140 | - if (isset($row['ident'])) $temp_array['ident'] = $row['ident']; |
|
141 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
142 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
143 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
142 | + if (isset($row['fammarine_id'])) { |
|
143 | + $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
144 | + } |
|
145 | + if (isset($row['mmsi'])) { |
|
146 | + $temp_array['mmsi'] = $row['mmsi']; |
|
147 | + } |
|
148 | + if (isset($row['type'])) { |
|
149 | + $temp_array['type'] = $row['type']; |
|
150 | + } |
|
151 | + if (isset($row['type_id'])) { |
|
152 | + $temp_array['type_id'] = $row['type_id']; |
|
153 | + } |
|
154 | + if (isset($row['ident'])) { |
|
155 | + $temp_array['ident'] = $row['ident']; |
|
156 | + } |
|
157 | + if (isset($row['latitude'])) { |
|
158 | + $temp_array['latitude'] = $row['latitude']; |
|
159 | + } |
|
160 | + if (isset($row['longitude'])) { |
|
161 | + $temp_array['longitude'] = $row['longitude']; |
|
162 | + } |
|
163 | + if (isset($row['format_source'])) { |
|
164 | + $temp_array['format_source'] = $row['format_source']; |
|
165 | + } |
|
144 | 166 | if (isset($row['heading'])) { |
145 | 167 | $temp_array['heading'] = $row['heading']; |
146 | 168 | $heading_direction = $this->parseDirection($row['heading']); |
147 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
169 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
170 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
171 | + } |
|
172 | + } |
|
173 | + if (isset($row['ground_speed'])) { |
|
174 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
148 | 175 | } |
149 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
150 | 176 | |
151 | 177 | if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") |
152 | 178 | { |
153 | 179 | $Image = new Image($this->db); |
154 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
155 | - else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
180 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') { |
|
181 | + $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
182 | + } else { |
|
183 | + $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
184 | + } |
|
156 | 185 | unset($Image); |
157 | 186 | if (count($image_array) > 0) { |
158 | 187 | $temp_array['image'] = $image_array[0]['image']; |
@@ -204,13 +233,21 @@ discard block |
||
204 | 233 | } |
205 | 234 | |
206 | 235 | $fromsource = NULL; |
207 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
208 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
209 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
236 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
237 | + $temp_array['source_name'] = $row['source_name']; |
|
238 | + } |
|
239 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
240 | + $temp_array['over_country'] = $row['over_country']; |
|
241 | + } |
|
242 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
243 | + $temp_array['distance'] = $row['distance']; |
|
244 | + } |
|
210 | 245 | $temp_array['query_number_rows'] = $num_rows; |
211 | 246 | $spotter_array[] = $temp_array; |
212 | 247 | } |
213 | - if ($num_rows == 0) return array(); |
|
248 | + if ($num_rows == 0) { |
|
249 | + return array(); |
|
250 | + } |
|
214 | 251 | $spotter_array[0]['query_number_rows'] = $num_rows; |
215 | 252 | return $spotter_array; |
216 | 253 | } |
@@ -236,8 +273,12 @@ discard block |
||
236 | 273 | { |
237 | 274 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
238 | 275 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
239 | - } else $limit_query = ""; |
|
240 | - } else $limit_query = ""; |
|
276 | + } else { |
|
277 | + $limit_query = ""; |
|
278 | + } |
|
279 | + } else { |
|
280 | + $limit_query = ""; |
|
281 | + } |
|
241 | 282 | if ($sort != "") |
242 | 283 | { |
243 | 284 | $search_orderby_array = $this->getOrderBy(); |
@@ -261,7 +302,9 @@ discard block |
||
261 | 302 | global $global_query; |
262 | 303 | |
263 | 304 | date_default_timezone_set('UTC'); |
264 | - if ($id == '') return array(); |
|
305 | + if ($id == '') { |
|
306 | + return array(); |
|
307 | + } |
|
265 | 308 | $additional_query = "marine_output.fammarine_id = :id"; |
266 | 309 | $query_values = array(':id' => $id); |
267 | 310 | $query = $global_query." WHERE ".$additional_query." "; |
@@ -404,8 +447,11 @@ discard block |
||
404 | 447 | $query .= " ORDER BY marine_output.source_name ASC"; |
405 | 448 | |
406 | 449 | $sth = $this->db->prepare($query); |
407 | - if (!empty($query_values)) $sth->execute($query_values); |
|
408 | - else $sth->execute(); |
|
450 | + if (!empty($query_values)) { |
|
451 | + $sth->execute($query_values); |
|
452 | + } else { |
|
453 | + $sth->execute(); |
|
454 | + } |
|
409 | 455 | |
410 | 456 | $source_array = array(); |
411 | 457 | $temp_array = array(); |
@@ -460,8 +506,11 @@ discard block |
||
460 | 506 | $sth = $this->db->prepare($query); |
461 | 507 | $sth->execute(array(':mmsi' => $mmsi)); |
462 | 508 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
463 | - if (isset($result[0])) return $result[0]; |
|
464 | - else return array(); |
|
509 | + if (isset($result[0])) { |
|
510 | + return $result[0]; |
|
511 | + } else { |
|
512 | + return array(); |
|
513 | + } |
|
465 | 514 | } |
466 | 515 | |
467 | 516 | /** |
@@ -495,7 +544,9 @@ discard block |
||
495 | 544 | date_default_timezone_set($globalTimezone); |
496 | 545 | $datetime = new DateTime(); |
497 | 546 | $offset = $datetime->format('P'); |
498 | - } else $offset = '+00:00'; |
|
547 | + } else { |
|
548 | + $offset = '+00:00'; |
|
549 | + } |
|
499 | 550 | |
500 | 551 | if ($globalDBdriver == 'mysql') { |
501 | 552 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
@@ -720,9 +771,15 @@ discard block |
||
720 | 771 | $latitude = 0; |
721 | 772 | $longitude = 0; |
722 | 773 | } |
723 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
724 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
725 | - if ($arrival_date == '') $arrival_date = NULL; |
|
774 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
775 | + $heading = 0; |
|
776 | + } |
|
777 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) { |
|
778 | + $groundspeed = 0; |
|
779 | + } |
|
780 | + if ($arrival_date == '') { |
|
781 | + $arrival_date = NULL; |
|
782 | + } |
|
726 | 783 | $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) |
727 | 784 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
728 | 785 | |
@@ -830,7 +887,9 @@ discard block |
||
830 | 887 | global $globalDBdriver, $globalArchive; |
831 | 888 | //$filter_query = $this->getFilter($filters,true,true); |
832 | 889 | $Connection= new Connection($this->db); |
833 | - if (!$Connection->tableExists('countries')) return array(); |
|
890 | + if (!$Connection->tableExists('countries')) { |
|
891 | + return array(); |
|
892 | + } |
|
834 | 893 | require_once('class.SpotterLive.php'); |
835 | 894 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
836 | 895 | $MarineLive = new MarineLive($this->db); |
@@ -874,7 +933,9 @@ discard block |
||
874 | 933 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT fammarine_id,over_country FROM marine_archive".$filter_query.") l ON c.iso2 = l.over_country "; |
875 | 934 | } |
876 | 935 | $query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; |
877 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
936 | + if ($limit) { |
|
937 | + $query .= " LIMIT 10 OFFSET 0"; |
|
938 | + } |
|
878 | 939 | |
879 | 940 | $sth = $this->db->prepare($query); |
880 | 941 | $sth->execute(); |
@@ -908,12 +969,18 @@ discard block |
||
908 | 969 | $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
909 | 970 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
910 | 971 | if ($olderthanmonths > 0) { |
911 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
912 | - else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
972 | + if ($globalDBdriver == 'mysql') { |
|
973 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
974 | + } else { |
|
975 | + $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
976 | + } |
|
913 | 977 | } |
914 | 978 | if ($sincedate != '') { |
915 | - if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'"; |
|
916 | - else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
979 | + if ($globalDBdriver == 'mysql') { |
|
980 | + $query .= " AND marine_output.date > '".$sincedate."'"; |
|
981 | + } else { |
|
982 | + $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
983 | + } |
|
917 | 984 | } |
918 | 985 | $query_values = array(); |
919 | 986 | if ($year != '') { |
@@ -944,7 +1011,9 @@ discard block |
||
944 | 1011 | } |
945 | 1012 | } |
946 | 1013 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
947 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
1014 | + if ($limit) { |
|
1015 | + $query .= " LIMIT 10 OFFSET 0"; |
|
1016 | + } |
|
948 | 1017 | |
949 | 1018 | $sth = $this->db->prepare($query); |
950 | 1019 | $sth->execute($query_values); |
@@ -979,7 +1048,9 @@ discard block |
||
979 | 1048 | date_default_timezone_set($globalTimezone); |
980 | 1049 | $datetime = new DateTime(); |
981 | 1050 | $offset = $datetime->format('P'); |
982 | - } else $offset = '+00:00'; |
|
1051 | + } else { |
|
1052 | + $offset = '+00:00'; |
|
1053 | + } |
|
983 | 1054 | |
984 | 1055 | if ($globalDBdriver == 'mysql') { |
985 | 1056 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1029,7 +1100,9 @@ discard block |
||
1029 | 1100 | date_default_timezone_set($globalTimezone); |
1030 | 1101 | $datetime = new DateTime(); |
1031 | 1102 | $offset = $datetime->format('P'); |
1032 | - } else $offset = '+00:00'; |
|
1103 | + } else { |
|
1104 | + $offset = '+00:00'; |
|
1105 | + } |
|
1033 | 1106 | $filter_query = $this->getFilter($filters,true,true); |
1034 | 1107 | if ($globalDBdriver == 'mysql') { |
1035 | 1108 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1075,7 +1148,9 @@ discard block |
||
1075 | 1148 | date_default_timezone_set($globalTimezone); |
1076 | 1149 | $datetime = new DateTime(); |
1077 | 1150 | $offset = $datetime->format('P'); |
1078 | - } else $offset = '+00:00'; |
|
1151 | + } else { |
|
1152 | + $offset = '+00:00'; |
|
1153 | + } |
|
1079 | 1154 | $filter_query = $this->getFilter($filters,true,true); |
1080 | 1155 | if ($globalDBdriver == 'mysql') { |
1081 | 1156 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1123,7 +1198,9 @@ discard block |
||
1123 | 1198 | date_default_timezone_set($globalTimezone); |
1124 | 1199 | $datetime = new DateTime(); |
1125 | 1200 | $offset = $datetime->format('P'); |
1126 | - } else $offset = '+00:00'; |
|
1201 | + } else { |
|
1202 | + $offset = '+00:00'; |
|
1203 | + } |
|
1127 | 1204 | |
1128 | 1205 | if ($globalDBdriver == 'mysql') { |
1129 | 1206 | $query = "SELECT YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
@@ -1172,7 +1249,9 @@ discard block |
||
1172 | 1249 | date_default_timezone_set($globalTimezone); |
1173 | 1250 | $datetime = new DateTime(); |
1174 | 1251 | $offset = $datetime->format('P'); |
1175 | - } else $offset = '+00:00'; |
|
1252 | + } else { |
|
1253 | + $offset = '+00:00'; |
|
1254 | + } |
|
1176 | 1255 | $filter_query = $this->getFilter($filters,true,true); |
1177 | 1256 | if ($globalDBdriver == 'mysql') { |
1178 | 1257 | $query = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
@@ -1221,7 +1300,9 @@ discard block |
||
1221 | 1300 | date_default_timezone_set($globalTimezone); |
1222 | 1301 | $datetime = new DateTime(); |
1223 | 1302 | $offset = $datetime->format('P'); |
1224 | - } else $offset = '+00:00'; |
|
1303 | + } else { |
|
1304 | + $offset = '+00:00'; |
|
1305 | + } |
|
1225 | 1306 | |
1226 | 1307 | $orderby_sql = ''; |
1227 | 1308 | if ($orderby == "hour") |
@@ -1290,7 +1371,9 @@ discard block |
||
1290 | 1371 | date_default_timezone_set($globalTimezone); |
1291 | 1372 | $datetime = new DateTime($date); |
1292 | 1373 | $offset = $datetime->format('P'); |
1293 | - } else $offset = '+00:00'; |
|
1374 | + } else { |
|
1375 | + $offset = '+00:00'; |
|
1376 | + } |
|
1294 | 1377 | |
1295 | 1378 | if ($globalDBdriver == 'mysql') { |
1296 | 1379 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1338,7 +1421,9 @@ discard block |
||
1338 | 1421 | date_default_timezone_set($globalTimezone); |
1339 | 1422 | $datetime = new DateTime(); |
1340 | 1423 | $offset = $datetime->format('P'); |
1341 | - } else $offset = '+00:00'; |
|
1424 | + } else { |
|
1425 | + $offset = '+00:00'; |
|
1426 | + } |
|
1342 | 1427 | |
1343 | 1428 | if ($globalDBdriver == 'mysql') { |
1344 | 1429 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1403,8 +1488,11 @@ discard block |
||
1403 | 1488 | $query_values = array_merge($query_values,array(':month' => $month)); |
1404 | 1489 | } |
1405 | 1490 | } |
1406 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1407 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1491 | + if (empty($query_values)) { |
|
1492 | + $queryi .= $this->getFilter($filters); |
|
1493 | + } else { |
|
1494 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1495 | + } |
|
1408 | 1496 | |
1409 | 1497 | $sth = $this->db->prepare($queryi); |
1410 | 1498 | $sth->execute($query_values); |
@@ -1441,8 +1529,11 @@ discard block |
||
1441 | 1529 | $query_values = array_merge($query_values,array(':month' => $month)); |
1442 | 1530 | } |
1443 | 1531 | } |
1444 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1445 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1532 | + if (empty($query_values)) { |
|
1533 | + $queryi .= $this->getFilter($filters); |
|
1534 | + } else { |
|
1535 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1536 | + } |
|
1446 | 1537 | |
1447 | 1538 | $sth = $this->db->prepare($queryi); |
1448 | 1539 | $sth->execute($query_values); |
@@ -1464,7 +1555,9 @@ discard block |
||
1464 | 1555 | date_default_timezone_set($globalTimezone); |
1465 | 1556 | $datetime = new DateTime(); |
1466 | 1557 | $offset = $datetime->format('P'); |
1467 | - } else $offset = '+00:00'; |
|
1558 | + } else { |
|
1559 | + $offset = '+00:00'; |
|
1560 | + } |
|
1468 | 1561 | |
1469 | 1562 | if ($globalDBdriver == 'mysql') { |
1470 | 1563 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1568,7 +1661,9 @@ discard block |
||
1568 | 1661 | */ |
1569 | 1662 | public function parseDirection($direction = 0) |
1570 | 1663 | { |
1571 | - if ($direction == '') $direction = 0; |
|
1664 | + if ($direction == '') { |
|
1665 | + $direction = 0; |
|
1666 | + } |
|
1572 | 1667 | $direction_array = array(); |
1573 | 1668 | $temp_array = array(); |
1574 | 1669 | |
@@ -1657,7 +1752,9 @@ discard block |
||
1657 | 1752 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1658 | 1753 | |
1659 | 1754 | $Connection = new Connection($this->db); |
1660 | - if (!$Connection->tableExists('countries')) return ''; |
|
1755 | + if (!$Connection->tableExists('countries')) { |
|
1756 | + return ''; |
|
1757 | + } |
|
1661 | 1758 | |
1662 | 1759 | try { |
1663 | 1760 | /* |
@@ -1677,9 +1774,13 @@ discard block |
||
1677 | 1774 | $sth->closeCursor(); |
1678 | 1775 | if (count($row) > 0) { |
1679 | 1776 | return $row; |
1680 | - } else return ''; |
|
1777 | + } else { |
|
1778 | + return ''; |
|
1779 | + } |
|
1681 | 1780 | } catch (PDOException $e) { |
1682 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1781 | + if (isset($globalDebug) && $globalDebug) { |
|
1782 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1783 | + } |
|
1683 | 1784 | return ''; |
1684 | 1785 | } |
1685 | 1786 | |
@@ -1697,7 +1798,9 @@ discard block |
||
1697 | 1798 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
1698 | 1799 | |
1699 | 1800 | $Connection = new Connection($this->db); |
1700 | - if (!$Connection->tableExists('countries')) return ''; |
|
1801 | + if (!$Connection->tableExists('countries')) { |
|
1802 | + return ''; |
|
1803 | + } |
|
1701 | 1804 | |
1702 | 1805 | try { |
1703 | 1806 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -1709,9 +1812,13 @@ discard block |
||
1709 | 1812 | $sth->closeCursor(); |
1710 | 1813 | if (count($row) > 0) { |
1711 | 1814 | return $row; |
1712 | - } else return ''; |
|
1815 | + } else { |
|
1816 | + return ''; |
|
1817 | + } |
|
1713 | 1818 | } catch (PDOException $e) { |
1714 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1819 | + if (isset($globalDebug) && $globalDebug) { |
|
1820 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1821 | + } |
|
1715 | 1822 | return ''; |
1716 | 1823 | } |
1717 | 1824 | |
@@ -1729,7 +1836,9 @@ discard block |
||
1729 | 1836 | { |
1730 | 1837 | global $globalBitlyAccessToken; |
1731 | 1838 | |
1732 | - if ($globalBitlyAccessToken == '') return $url; |
|
1839 | + if ($globalBitlyAccessToken == '') { |
|
1840 | + return $url; |
|
1841 | + } |
|
1733 | 1842 | |
1734 | 1843 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
1735 | 1844 | |
@@ -1805,7 +1914,9 @@ discard block |
||
1805 | 1914 | } |
1806 | 1915 | } |
1807 | 1916 | $query .= " GROUP BY marine_output.type ORDER BY marine_type_count DESC"; |
1808 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
1917 | + if ($limit) { |
|
1918 | + $query .= " LIMIT 10 OFFSET 0"; |
|
1919 | + } |
|
1809 | 1920 | $sth = $this->db->prepare($query); |
1810 | 1921 | $sth->execute($query_values); |
1811 | 1922 | $marine_array = array(); |
@@ -1842,9 +1953,15 @@ discard block |
||
1842 | 1953 | foreach ($q_array as $q_item){ |
1843 | 1954 | $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
1844 | 1955 | $additional_query .= " AND ("; |
1845 | - if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
|
1846 | - if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
|
1847 | - if (is_int($q_item)) $additional_query .= "(marine_output.imo = '".$q_item."') OR "; |
|
1956 | + if (is_int($q_item)) { |
|
1957 | + $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
|
1958 | + } |
|
1959 | + if (is_int($q_item)) { |
|
1960 | + $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
|
1961 | + } |
|
1962 | + if (is_int($q_item)) { |
|
1963 | + $additional_query .= "(marine_output.imo = '".$q_item."') OR "; |
|
1964 | + } |
|
1848 | 1965 | $additional_query .= "(marine_output.ident like '%".$q_item."%') OR "; |
1849 | 1966 | $additional_query .= ")"; |
1850 | 1967 | } |
@@ -1892,7 +2009,9 @@ discard block |
||
1892 | 2009 | date_default_timezone_set($globalTimezone); |
1893 | 2010 | $datetime = new DateTime(); |
1894 | 2011 | $offset = $datetime->format('P'); |
1895 | - } else $offset = '+00:00'; |
|
2012 | + } else { |
|
2013 | + $offset = '+00:00'; |
|
2014 | + } |
|
1896 | 2015 | if ($date_array[1] != "") |
1897 | 2016 | { |
1898 | 2017 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
@@ -1919,8 +2038,12 @@ discard block |
||
1919 | 2038 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1920 | 2039 | { |
1921 | 2040 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1922 | - } else $limit_query = ""; |
|
1923 | - } else $limit_query = ""; |
|
2041 | + } else { |
|
2042 | + $limit_query = ""; |
|
2043 | + } |
|
2044 | + } else { |
|
2045 | + $limit_query = ""; |
|
2046 | + } |
|
1924 | 2047 | if ($sort != "") |
1925 | 2048 | { |
1926 | 2049 | $search_orderby_array = $this->getOrderBy(); |
@@ -9,25 +9,25 @@ discard block |
||
9 | 9 | require_once(dirname(__FILE__).'/class.Stats.php'); |
10 | 10 | require_once(dirname(__FILE__).'/class.Source.php'); |
11 | 11 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
12 | - require_once(dirname(__FILE__).'/class.APRS.php'); |
|
12 | + require_once(dirname(__FILE__).'/class.APRS.php'); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | class MarineImport { |
16 | - private $all_tracked = array(); |
|
17 | - private $last_delete_hourly = 0; |
|
18 | - private $last_delete = 0; |
|
19 | - private $stats = array(); |
|
20 | - private $tmd = 0; |
|
21 | - private $source_location = array(); |
|
22 | - public $db = null; |
|
23 | - public $nb = 0; |
|
16 | + private $all_tracked = array(); |
|
17 | + private $last_delete_hourly = 0; |
|
18 | + private $last_delete = 0; |
|
19 | + private $stats = array(); |
|
20 | + private $tmd = 0; |
|
21 | + private $source_location = array(); |
|
22 | + public $db = null; |
|
23 | + public $nb = 0; |
|
24 | 24 | |
25 | - public function __construct($dbc = null) { |
|
25 | + public function __construct($dbc = null) { |
|
26 | 26 | global $globalBeta, $globalServerAPRS, $APRSMarine, $globalNoDB; |
27 | 27 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
28 | - $Connection = new Connection($dbc); |
|
29 | - $this->db = $Connection->db(); |
|
30 | - date_default_timezone_set('UTC'); |
|
28 | + $Connection = new Connection($dbc); |
|
29 | + $this->db = $Connection->db(); |
|
30 | + date_default_timezone_set('UTC'); |
|
31 | 31 | } |
32 | 32 | // Get previous source stats |
33 | 33 | /* |
@@ -46,57 +46,57 @@ discard block |
||
46 | 46 | } |
47 | 47 | */ |
48 | 48 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
49 | - $APRSMarine = new APRSMarine(); |
|
50 | - //$APRSSpotter->connect(); |
|
49 | + $APRSMarine = new APRSMarine(); |
|
50 | + //$APRSSpotter->connect(); |
|
51 | + } |
|
51 | 52 | } |
52 | - } |
|
53 | 53 | |
54 | - public function checkAll() { |
|
54 | + public function checkAll() { |
|
55 | 55 | global $globalDebug, $globalNoDB; |
56 | 56 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
57 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
58 | - foreach ($this->all_tracked as $key => $flight) { |
|
57 | + if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
58 | + foreach ($this->all_tracked as $key => $flight) { |
|
59 | 59 | if (isset($this->all_tracked[$key]['id'])) { |
60 | - //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
|
61 | - $Marine = new Marine($this->db); |
|
62 | - $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']); |
|
60 | + //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
|
61 | + $Marine = new Marine($this->db); |
|
62 | + $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']); |
|
63 | 63 | } |
64 | - } |
|
64 | + } |
|
65 | + } |
|
65 | 66 | } |
66 | - } |
|
67 | 67 | |
68 | - public function del() { |
|
68 | + public function del() { |
|
69 | 69 | global $globalDebug, $globalNoDB, $globalNoImport; |
70 | 70 | // Delete old infos |
71 | 71 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
72 | 72 | foreach ($this->all_tracked as $key => $flight) { |
73 | - if (isset($flight['lastupdate'])) { |
|
74 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
75 | - if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
76 | - if (isset($this->all_tracked[$key]['id'])) { |
|
77 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
78 | - /* |
|
73 | + if (isset($flight['lastupdate'])) { |
|
74 | + if ($flight['lastupdate'] < (time()-3000)) { |
|
75 | + if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
76 | + if (isset($this->all_tracked[$key]['id'])) { |
|
77 | + if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
78 | + /* |
|
79 | 79 | $MarineLive = new MarineLive(); |
80 | 80 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
81 | 81 | $MarineLive->db = null; |
82 | 82 | */ |
83 | - //$real_arrival = $this->arrival($key); |
|
84 | - $Marine = new Marine($this->db); |
|
85 | - if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
83 | + //$real_arrival = $this->arrival($key); |
|
84 | + $Marine = new Marine($this->db); |
|
85 | + if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
86 | 86 | $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
87 | 87 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
88 | - } |
|
89 | - // Put in archive |
|
88 | + } |
|
89 | + // Put in archive |
|
90 | 90 | // $Marine->db = null; |
91 | 91 | } |
92 | - } |
|
93 | - unset($this->all_tracked[$key]); |
|
94 | - } |
|
95 | - } |
|
96 | - } |
|
97 | - } |
|
92 | + } |
|
93 | + unset($this->all_tracked[$key]); |
|
94 | + } |
|
95 | + } |
|
96 | + } |
|
97 | + } |
|
98 | 98 | |
99 | - public function add($line) { |
|
99 | + public function add($line) { |
|
100 | 100 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
101 | 101 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
102 | 102 | date_default_timezone_set('UTC'); |
@@ -105,83 +105,83 @@ discard block |
||
105 | 105 | |
106 | 106 | // SBS format is CSV format |
107 | 107 | if(is_array($line) && isset($line['mmsi'])) { |
108 | - //print_r($line); |
|
109 | - if (isset($line['mmsi'])) { |
|
108 | + //print_r($line); |
|
109 | + if (isset($line['mmsi'])) { |
|
110 | 110 | |
111 | 111 | |
112 | 112 | // Increment message number |
113 | 113 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
114 | - $current_date = date('Y-m-d'); |
|
115 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
116 | - else $source = ''; |
|
117 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
118 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
119 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
120 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
121 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
114 | + $current_date = date('Y-m-d'); |
|
115 | + if (isset($line['source_name'])) $source = $line['source_name']; |
|
116 | + else $source = ''; |
|
117 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
118 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
119 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
120 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
121 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | |
125 | 125 | $Common = new Common(); |
126 | 126 | $AIS = new AIS(); |
127 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
128 | - else $id = trim($line['id']); |
|
127 | + if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
128 | + else $id = trim($line['id']); |
|
129 | 129 | |
130 | 130 | if (!isset($this->all_tracked[$id])) { |
131 | - $this->all_tracked[$id] = array(); |
|
132 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
133 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
|
134 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
135 | - if (!isset($line['id'])) { |
|
131 | + $this->all_tracked[$id] = array(); |
|
132 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
133 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
|
134 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
135 | + if (!isset($line['id'])) { |
|
136 | 136 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
137 | 137 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
138 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
139 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
138 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
139 | + if ($globalAllTracked !== FALSE) $dataFound = true; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
143 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
144 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
143 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
144 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
145 | 145 | $Marine = new Marine($this->db); |
146 | 146 | $identity = $Marine->getIdentity($line['mmsi']); |
147 | 147 | if (!empty($identity)) { |
148 | - $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
149 | - $this->all_tracked[$id]['type'] = $identity['type']; |
|
148 | + $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
149 | + $this->all_tracked[$id]['type'] = $identity['type']; |
|
150 | 150 | } |
151 | 151 | //print_r($identity); |
152 | 152 | unset($Marine); |
153 | 153 | //$dataFound = true; |
154 | - } |
|
154 | + } |
|
155 | 155 | } |
156 | 156 | if (isset($line['type_id'])) { |
157 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
158 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
157 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
158 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
159 | 159 | } |
160 | 160 | if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') { |
161 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
161 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
162 | 162 | } |
163 | 163 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
164 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
164 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
165 | 165 | } |
166 | 166 | if (isset($line['imo']) && $line['imo'] != '') { |
167 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
167 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
168 | 168 | } |
169 | 169 | if (isset($line['callsign']) && $line['callsign'] != '') { |
170 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
170 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
171 | 171 | } |
172 | 172 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
173 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
173 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
174 | 174 | } |
175 | 175 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
176 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
176 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | //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'])) { |
180 | 180 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
181 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
182 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
181 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
182 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
183 | 183 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
184 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
184 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
185 | 185 | $timeelapsed = microtime(true); |
186 | 186 | $Marine = new Marine($this->db); |
187 | 187 | $fromsource = NULL; |
@@ -190,20 +190,20 @@ discard block |
||
190 | 190 | $Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']); |
191 | 191 | $Marine->db = null; |
192 | 192 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
193 | - } |
|
193 | + } |
|
194 | 194 | } |
195 | - } |
|
196 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
195 | + } |
|
196 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
200 | - if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
200 | + if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
201 | 201 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
202 | - } else { |
|
202 | + } else { |
|
203 | 203 | 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"; |
204 | 204 | 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"; |
205 | 205 | return ''; |
206 | - } |
|
206 | + } |
|
207 | 207 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
208 | 208 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
209 | 209 | return ''; |
@@ -220,24 +220,24 @@ discard block |
||
220 | 220 | |
221 | 221 | |
222 | 222 | if (isset($line['speed'])) { |
223 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
224 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
223 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
224 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
225 | 225 | } 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'])) { |
226 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
227 | - if ($distance > 1000 && $distance < 10000) { |
|
226 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
227 | + if ($distance > 1000 && $distance < 10000) { |
|
228 | 228 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
229 | 229 | $speed = $speed*3.6; |
230 | 230 | if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
231 | 231 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
232 | - } |
|
232 | + } |
|
233 | 233 | } |
234 | 234 | |
235 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
236 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
237 | - else unset($timediff); |
|
238 | - 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')))) { |
|
235 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
236 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
237 | + else unset($timediff); |
|
238 | + 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')))) { |
|
239 | 239 | 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'])) { |
240 | - 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'])) { |
|
240 | + 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'])) { |
|
241 | 241 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
242 | 242 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
243 | 243 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -245,211 +245,211 @@ discard block |
||
245 | 245 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
246 | 246 | $timeelapsed = microtime(true); |
247 | 247 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
248 | - $Marine = new Marine($this->db); |
|
249 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
250 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
251 | - $Marine->db = null; |
|
252 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
248 | + $Marine = new Marine($this->db); |
|
249 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
250 | + if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
251 | + $Marine->db = null; |
|
252 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
253 | 253 | } |
254 | 254 | $this->tmd = 0; |
255 | 255 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
256 | - } |
|
256 | + } |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
260 | 260 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
261 | 261 | 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') { |
262 | - $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
263 | - $dataFound = true; |
|
264 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
262 | + $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
263 | + $dataFound = true; |
|
264 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
265 | 265 | } |
266 | 266 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
267 | 267 | } |
268 | 268 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
269 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
269 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
270 | 270 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
271 | 271 | 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') { |
272 | - $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
273 | - $dataFound = true; |
|
274 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
272 | + $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
273 | + $dataFound = true; |
|
274 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
275 | 275 | } |
276 | 276 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
277 | 277 | } |
278 | 278 | |
279 | - } else if ($globalDebug && $timediff > 20) { |
|
279 | + } else if ($globalDebug && $timediff > 20) { |
|
280 | 280 | $this->tmd = $this->tmd + 1; |
281 | 281 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
282 | 282 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
283 | 283 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
284 | 284 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
285 | - } |
|
285 | + } |
|
286 | 286 | } |
287 | 287 | if (isset($line['last_update']) && $line['last_update'] != '') { |
288 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
289 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
288 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
289 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
290 | 290 | } |
291 | 291 | if (isset($line['format_source']) && $line['format_source'] != '') { |
292 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
292 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
293 | 293 | } |
294 | 294 | if (isset($line['source_name']) && $line['source_name'] != '') { |
295 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
295 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
296 | 296 | } |
297 | 297 | if (isset($line['status']) && $line['status'] != '') { |
298 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
298 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
299 | 299 | } |
300 | 300 | if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) { |
301 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
302 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
301 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
302 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
303 | 303 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
304 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
304 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
305 | 305 | $Marine = new Marine($this->db); |
306 | 306 | $Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']); |
307 | 307 | unset($Marine); |
308 | - } |
|
308 | + } |
|
309 | + } |
|
309 | 310 | } |
310 | - } |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
314 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
314 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | if (isset($line['heading']) && $line['heading'] != '') { |
318 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
319 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
320 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
321 | - //$dataFound = true; |
|
318 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
319 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
320 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
321 | + //$dataFound = true; |
|
322 | 322 | } 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']) { |
323 | - $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']); |
|
324 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
325 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
326 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
323 | + $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']); |
|
324 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
325 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
326 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
327 | 327 | } |
328 | 328 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
329 | 329 | |
330 | 330 | |
331 | 331 | |
332 | 332 | if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) { |
333 | - $this->all_tracked[$id]['lastupdate'] = time(); |
|
334 | - if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
335 | - 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'])) { |
|
336 | - if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
333 | + $this->all_tracked[$id]['lastupdate'] = time(); |
|
334 | + if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
335 | + 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'])) { |
|
336 | + if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
337 | 337 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
338 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
339 | - $timeelapsed = microtime(true); |
|
340 | - $MarineLive = new MarineLive($this->db); |
|
341 | - if (isset($line['id'])) { |
|
338 | + if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
339 | + $timeelapsed = microtime(true); |
|
340 | + $MarineLive = new MarineLive($this->db); |
|
341 | + if (isset($line['id'])) { |
|
342 | 342 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
343 | 343 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
344 | - } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
344 | + } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
345 | 345 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
346 | 346 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
347 | - } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
347 | + } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
348 | 348 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
349 | 349 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
350 | - } else $recent_ident = ''; |
|
351 | - $MarineLive->db=null; |
|
352 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
353 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
350 | + } else $recent_ident = ''; |
|
351 | + $MarineLive->db=null; |
|
352 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
353 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
354 | 354 | } else $recent_ident = ''; |
355 | - } else { |
|
355 | + } else { |
|
356 | 356 | $recent_ident = ''; |
357 | 357 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
358 | - } |
|
359 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
360 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
361 | - { |
|
358 | + } |
|
359 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
360 | + if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
361 | + { |
|
362 | 362 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
363 | 363 | //adds the spotter data for the archive |
364 | - $highlight = ''; |
|
365 | - 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'))); |
|
366 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
364 | + $highlight = ''; |
|
365 | + 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'))); |
|
366 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
367 | 367 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
368 | - $timeelapsed = microtime(true); |
|
369 | - $Marine = new Marine($this->db); |
|
370 | - $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
371 | - $Marine->db = null; |
|
372 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
373 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
368 | + $timeelapsed = microtime(true); |
|
369 | + $Marine = new Marine($this->db); |
|
370 | + $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
371 | + $Marine->db = null; |
|
372 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
373 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
374 | + } |
|
374 | 375 | } |
375 | - } |
|
376 | - if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
|
376 | + if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
|
377 | 377 | // Add source stat in DB |
378 | 378 | $Stats = new Stats($this->db); |
379 | 379 | if (!empty($this->stats)) { |
380 | - if ($globalDebug) echo 'Add source stats : '; |
|
381 | - foreach($this->stats as $date => $data) { |
|
380 | + if ($globalDebug) echo 'Add source stats : '; |
|
381 | + foreach($this->stats as $date => $data) { |
|
382 | 382 | foreach($data as $source => $sourced) { |
383 | - //print_r($sourced); |
|
384 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
385 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
386 | - if (isset($sourced['msg'])) { |
|
387 | - if (time() - $sourced['msg']['date'] > 10) { |
|
388 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
389 | - echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
390 | - unset($this->stats[$date][$source]['msg']); |
|
391 | - } |
|
392 | - } |
|
393 | - } |
|
394 | - if ($date != date('Y-m-d')) { |
|
395 | - unset($this->stats[$date]); |
|
396 | - } |
|
397 | - } |
|
398 | - if ($globalDebug) echo 'Done'."\n"; |
|
383 | + //print_r($sourced); |
|
384 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
385 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
386 | + if (isset($sourced['msg'])) { |
|
387 | + if (time() - $sourced['msg']['date'] > 10) { |
|
388 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
389 | + echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
390 | + unset($this->stats[$date][$source]['msg']); |
|
391 | + } |
|
392 | + } |
|
393 | + } |
|
394 | + if ($date != date('Y-m-d')) { |
|
395 | + unset($this->stats[$date]); |
|
396 | + } |
|
397 | + } |
|
398 | + if ($globalDebug) echo 'Done'."\n"; |
|
399 | 399 | } |
400 | 400 | $Stats->db = null; |
401 | - } |
|
401 | + } |
|
402 | 402 | |
403 | - $this->del(); |
|
403 | + $this->del(); |
|
404 | 404 | //$ignoreImport = false; |
405 | 405 | $this->all_tracked[$id]['addedMarine'] = 1; |
406 | 406 | //print_r($this->all_tracked[$id]); |
407 | 407 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
408 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
409 | - //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
410 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
408 | + if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
409 | + //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
410 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
411 | 411 | $MarineLive = new MarineLive($this->db); |
412 | 412 | $MarineLive->deleteLiveMarineData(); |
413 | 413 | $MarineLive->db=null; |
414 | 414 | if ($globalDebug) echo " Done\n"; |
415 | - } |
|
416 | - $this->last_delete = time(); |
|
415 | + } |
|
416 | + $this->last_delete = time(); |
|
417 | 417 | } |
418 | - } elseif ($recent_ident != '') { |
|
418 | + } elseif ($recent_ident != '') { |
|
419 | 419 | $this->all_tracked[$id]['id'] = $recent_ident; |
420 | 420 | $this->all_tracked[$id]['addedMarine'] = 1; |
421 | 421 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
422 | - if (isset($globalDaemon) && !$globalDaemon) { |
|
422 | + if (isset($globalDaemon) && !$globalDaemon) { |
|
423 | 423 | $Marine = new Marine($this->db); |
424 | 424 | $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']); |
425 | 425 | $Marine->db = null; |
426 | - } |
|
426 | + } |
|
427 | 427 | } |
428 | 428 | |
429 | - } |
|
429 | + } |
|
430 | + } |
|
430 | 431 | } |
431 | - } |
|
432 | - //adds the spotter LIVE data |
|
433 | - if ($globalDebug) { |
|
432 | + //adds the spotter LIVE data |
|
433 | + if ($globalDebug) { |
|
434 | 434 | 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"; |
435 | - } |
|
436 | - $ignoreImport = false; |
|
435 | + } |
|
436 | + $ignoreImport = false; |
|
437 | 437 | |
438 | - if (!$ignoreImport) { |
|
438 | + if (!$ignoreImport) { |
|
439 | 439 | 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'])) { |
440 | 440 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
441 | 441 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
442 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
442 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
443 | 443 | $timeelapsed = microtime(true); |
444 | 444 | $MarineLive = new MarineLive($this->db); |
445 | 445 | $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
446 | 446 | $MarineLive->db = null; |
447 | 447 | if ($globalDebug) echo $result."\n"; |
448 | 448 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
449 | - } |
|
449 | + } |
|
450 | 450 | } |
451 | 451 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
452 | - $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
452 | + $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
453 | 453 | } |
454 | 454 | $this->all_tracked[$id]['putinarchive'] = false; |
455 | 455 | |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | if ($stats_heading == 16) $stats_heading = 0; |
482 | 482 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
483 | 483 | for ($i=0;$i<=15;$i++) { |
484 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
484 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
485 | 485 | } |
486 | 486 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
487 | 487 | } else { |
@@ -494,11 +494,11 @@ discard block |
||
494 | 494 | //var_dump($this->stats); |
495 | 495 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
496 | 496 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
497 | - end($this->stats[$current_date][$source]['hist']); |
|
498 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
497 | + end($this->stats[$current_date][$source]['hist']); |
|
498 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
499 | 499 | } else $mini = 0; |
500 | 500 | for ($i=$mini;$i<=$distance;$i+=10) { |
501 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
501 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
502 | 502 | } |
503 | 503 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
504 | 504 | } else { |
@@ -514,24 +514,24 @@ discard block |
||
514 | 514 | |
515 | 515 | |
516 | 516 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
517 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
517 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
518 | 518 | if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
519 | 519 | $MarineLive = new MarineLive($this->db); |
520 | 520 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
521 | 521 | $MarineLive->db = null; |
522 | 522 | //MarineLive->deleteLiveMarineData(); |
523 | 523 | if ($globalDebug) echo " Done\n"; |
524 | - } |
|
525 | - $this->last_delete_hourly = time(); |
|
524 | + } |
|
525 | + $this->last_delete_hourly = time(); |
|
526 | 526 | } |
527 | 527 | |
528 | - } |
|
529 | - //$ignoreImport = false; |
|
528 | + } |
|
529 | + //$ignoreImport = false; |
|
530 | 530 | } |
531 | 531 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
532 | 532 | if ($send) return $this->all_tracked[$id]; |
533 | - } |
|
533 | + } |
|
534 | + } |
|
534 | 535 | } |
535 | - } |
|
536 | 536 | } |
537 | 537 | ?> |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | if (isset($this->all_tracked[$key]['id'])) { |
60 | 60 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
61 | 61 | $Marine = new Marine($this->db); |
62 | - $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
62 | + $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']); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
72 | 72 | foreach ($this->all_tracked as $key => $flight) { |
73 | 73 | if (isset($flight['lastupdate'])) { |
74 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
74 | + if ($flight['lastupdate'] < (time() - 3000)) { |
|
75 | 75 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
76 | 76 | if (isset($this->all_tracked[$key]['id'])) { |
77 | 77 | if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | //$real_arrival = $this->arrival($key); |
84 | 84 | $Marine = new Marine($this->db); |
85 | 85 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
86 | - $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
86 | + $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']); |
|
87 | 87 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
88 | 88 | } |
89 | 89 | // Put in archive |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | } |
98 | 98 | |
99 | 99 | public function add($line) { |
100 | - global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
|
100 | + global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS, $APRSMarine; |
|
101 | 101 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
102 | 102 | date_default_timezone_set('UTC'); |
103 | 103 | $dataFound = false; |
104 | 104 | $send = false; |
105 | 105 | |
106 | 106 | // SBS format is CSV format |
107 | - if(is_array($line) && isset($line['mmsi'])) { |
|
107 | + if (is_array($line) && isset($line['mmsi'])) { |
|
108 | 108 | //print_r($line); |
109 | 109 | if (isset($line['mmsi'])) { |
110 | 110 | |
@@ -129,18 +129,18 @@ discard block |
||
129 | 129 | |
130 | 130 | if (!isset($this->all_tracked[$id])) { |
131 | 131 | $this->all_tracked[$id] = array(); |
132 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
133 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
|
134 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
132 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedMarine' => 0)); |
|
133 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'typeid' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => '', 'mmsi' => '', 'status' => '', 'status_id' => '', 'imo' => '', 'callsign' => '', 'arrival_code' => '', 'arrival_date' => '', 'mmsi_type' => '')); |
|
134 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time())); |
|
135 | 135 | if (!isset($line['id'])) { |
136 | 136 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
137 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
138 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
137 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
138 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id'])); |
|
139 | 139 | if ($globalAllTracked !== FALSE) $dataFound = true; |
140 | 140 | } |
141 | 141 | |
142 | 142 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
143 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
143 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi' => $line['mmsi'])); |
|
144 | 144 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
145 | 145 | $Marine = new Marine($this->db); |
146 | 146 | $identity = $Marine->getIdentity($line['mmsi']); |
@@ -154,65 +154,65 @@ discard block |
||
154 | 154 | } |
155 | 155 | } |
156 | 156 | if (isset($line['type_id'])) { |
157 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
158 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
157 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $AIS->getShipType($line['type_id']))); |
|
158 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('typeid' => $line['type_id'])); |
|
159 | 159 | } |
160 | 160 | if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') { |
161 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
161 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type'])); |
|
162 | 162 | } |
163 | 163 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
164 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
164 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi_type' => $line['mmsi_type'])); |
|
165 | 165 | } |
166 | 166 | if (isset($line['imo']) && $line['imo'] != '') { |
167 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
167 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('imo' => $line['imo'])); |
|
168 | 168 | } |
169 | 169 | if (isset($line['callsign']) && $line['callsign'] != '') { |
170 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
170 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('callsign' => $line['callsign'])); |
|
171 | 171 | } |
172 | 172 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
173 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
173 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_code' => $line['arrival_code'])); |
|
174 | 174 | } |
175 | 175 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
176 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
176 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_date' => $line['arrival_date'])); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | //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'])) { |
180 | 180 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
181 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
181 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident']))); |
|
182 | 182 | if ($this->all_tracked[$id]['addedMarine'] == 1) { |
183 | 183 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
184 | 184 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
185 | 185 | $timeelapsed = microtime(true); |
186 | 186 | $Marine = new Marine($this->db); |
187 | 187 | $fromsource = NULL; |
188 | - $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
188 | + $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource); |
|
189 | 189 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
190 | - $Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']); |
|
190 | + $Marine->addIdentity($this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['type']); |
|
191 | 191 | $Marine->db = null; |
192 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
192 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
193 | 193 | } |
194 | 194 | } |
195 | 195 | } |
196 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
196 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'])); |
|
197 | 197 | } |
198 | 198 | |
199 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
|
199 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 30*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
200 | 200 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
201 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
|
201 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime'])); |
|
202 | 202 | } else { |
203 | 203 | 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"; |
204 | 204 | 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"; |
205 | 205 | return ''; |
206 | 206 | } |
207 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
|
207 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time() - 30*60) { |
|
208 | 208 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
209 | 209 | return ''; |
210 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) { |
|
210 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time() + 20*60) { |
|
211 | 211 | if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
212 | 212 | return ''; |
213 | 213 | } elseif (!isset($line['datetime'])) { |
214 | 214 | date_default_timezone_set('UTC'); |
215 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
215 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
216 | 216 | } else { |
217 | 217 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!"; |
218 | 218 | return ''; |
@@ -220,24 +220,24 @@ discard block |
||
220 | 220 | |
221 | 221 | |
222 | 222 | if (isset($line['speed'])) { |
223 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
224 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
223 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed']))); |
|
224 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true)); |
|
225 | 225 | } 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'])) { |
226 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
226 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm'); |
|
227 | 227 | if ($distance > 1000 && $distance < 10000) { |
228 | 228 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
229 | 229 | $speed = $speed*3.6; |
230 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
230 | + if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed))); |
|
231 | 231 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
232 | 232 | } |
233 | 233 | } |
234 | 234 | |
235 | 235 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
236 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
236 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']); |
|
237 | 237 | else unset($timediff); |
238 | - 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')))) { |
|
238 | + 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')))) { |
|
239 | 239 | 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'])) { |
240 | - 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'])) { |
|
240 | + 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'])) { |
|
241 | 241 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
242 | 242 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
243 | 243 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -246,10 +246,10 @@ discard block |
||
246 | 246 | $timeelapsed = microtime(true); |
247 | 247 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
248 | 248 | $Marine = new Marine($this->db); |
249 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
249 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
250 | 250 | if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
251 | 251 | $Marine->db = null; |
252 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
252 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
253 | 253 | } |
254 | 254 | $this->tmd = 0; |
255 | 255 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
@@ -258,52 +258,52 @@ discard block |
||
258 | 258 | |
259 | 259 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
260 | 260 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
261 | - 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') { |
|
261 | + 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') { |
|
262 | 262 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
263 | 263 | $dataFound = true; |
264 | 264 | $this->all_tracked[$id]['time_last_coord'] = time(); |
265 | 265 | } |
266 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
|
266 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude'])); |
|
267 | 267 | } |
268 | 268 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
269 | 269 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
270 | 270 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
271 | - 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') { |
|
271 | + 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') { |
|
272 | 272 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
273 | 273 | $dataFound = true; |
274 | 274 | $this->all_tracked[$id]['time_last_coord'] = time(); |
275 | 275 | } |
276 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
|
276 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude'])); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | } else if ($globalDebug && $timediff > 20) { |
280 | 280 | $this->tmd = $this->tmd + 1; |
281 | 281 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
282 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
|
283 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
282 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -"; |
|
283 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
284 | 284 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
285 | 285 | } |
286 | 286 | } |
287 | 287 | if (isset($line['last_update']) && $line['last_update'] != '') { |
288 | 288 | if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
289 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
289 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update'])); |
|
290 | 290 | } |
291 | 291 | if (isset($line['format_source']) && $line['format_source'] != '') { |
292 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
292 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source'])); |
|
293 | 293 | } |
294 | 294 | if (isset($line['source_name']) && $line['source_name'] != '') { |
295 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
295 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name'])); |
|
296 | 296 | } |
297 | 297 | if (isset($line['status']) && $line['status'] != '') { |
298 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
298 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status' => $line['status'])); |
|
299 | 299 | } |
300 | 300 | if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) { |
301 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
301 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status_id' => $line['status_id'])); |
|
302 | 302 | if ($this->all_tracked[$id]['addedMarine'] == 1) { |
303 | 303 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
304 | 304 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
305 | 305 | $Marine = new Marine($this->db); |
306 | - $Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']); |
|
306 | + $Marine->updateStatusMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['status']); |
|
307 | 307 | unset($Marine); |
308 | 308 | } |
309 | 309 | } |
@@ -311,18 +311,18 @@ discard block |
||
311 | 311 | } |
312 | 312 | |
313 | 313 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
314 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
314 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true)); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | if (isset($line['heading']) && $line['heading'] != '') { |
318 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
319 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
320 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
318 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
319 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading']))); |
|
320 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true)); |
|
321 | 321 | //$dataFound = true; |
322 | 322 | } 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']) { |
323 | - $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']); |
|
324 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
325 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
323 | + $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']); |
|
324 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading))); |
|
325 | + if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
326 | 326 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
327 | 327 | } |
328 | 328 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) { |
333 | 333 | $this->all_tracked[$id]['lastupdate'] = time(); |
334 | 334 | if ($this->all_tracked[$id]['addedMarine'] == 0) { |
335 | - 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'])) { |
|
335 | + 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'])) { |
|
336 | 336 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
337 | 337 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
338 | 338 | if ($globalDebug) echo "Check if aircraft is already in DB..."; |
@@ -340,37 +340,37 @@ discard block |
||
340 | 340 | $MarineLive = new MarineLive($this->db); |
341 | 341 | if (isset($line['id'])) { |
342 | 342 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
343 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
343 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
344 | 344 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
345 | 345 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
346 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
346 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
347 | 347 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
348 | 348 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
349 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
349 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
350 | 350 | } else $recent_ident = ''; |
351 | - $MarineLive->db=null; |
|
351 | + $MarineLive->db = null; |
|
352 | 352 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
353 | 353 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
354 | 354 | } else $recent_ident = ''; |
355 | 355 | } else { |
356 | 356 | $recent_ident = ''; |
357 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
|
357 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0)); |
|
358 | 358 | } |
359 | 359 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
360 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
360 | + if ($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
361 | 361 | { |
362 | 362 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
363 | 363 | //adds the spotter data for the archive |
364 | 364 | $highlight = ''; |
365 | - 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'))); |
|
365 | + 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'))); |
|
366 | 366 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
367 | 367 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
368 | 368 | $timeelapsed = microtime(true); |
369 | 369 | $Marine = new Marine($this->db); |
370 | - $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
370 | + $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']); |
|
371 | 371 | $Marine->db = null; |
372 | 372 | if ($globalDebug && isset($result)) echo $result."\n"; |
373 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
373 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
374 | 374 | } |
375 | 375 | } |
376 | 376 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
@@ -378,15 +378,15 @@ discard block |
||
378 | 378 | $Stats = new Stats($this->db); |
379 | 379 | if (!empty($this->stats)) { |
380 | 380 | if ($globalDebug) echo 'Add source stats : '; |
381 | - foreach($this->stats as $date => $data) { |
|
382 | - foreach($data as $source => $sourced) { |
|
381 | + foreach ($this->stats as $date => $data) { |
|
382 | + foreach ($data as $source => $sourced) { |
|
383 | 383 | //print_r($sourced); |
384 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
385 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
384 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar_marine', $date); |
|
385 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist_marine', $date); |
|
386 | 386 | if (isset($sourced['msg'])) { |
387 | 387 | if (time() - $sourced['msg']['date'] > 10) { |
388 | 388 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
389 | - echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
389 | + echo $Stats->addStatSource($nbmsg, $source, 'msg_marine', $date); |
|
390 | 390 | unset($this->stats[$date][$source]['msg']); |
391 | 391 | } |
392 | 392 | } |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
411 | 411 | $MarineLive = new MarineLive($this->db); |
412 | 412 | $MarineLive->deleteLiveMarineData(); |
413 | - $MarineLive->db=null; |
|
413 | + $MarineLive->db = null; |
|
414 | 414 | if ($globalDebug) echo " Done\n"; |
415 | 415 | } |
416 | 416 | $this->last_delete = time(); |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
422 | 422 | if (isset($globalDaemon) && !$globalDaemon) { |
423 | 423 | $Marine = new Marine($this->db); |
424 | - $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']); |
|
424 | + $Marine->updateLatestMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']); |
|
425 | 425 | $Marine->db = null; |
426 | 426 | } |
427 | 427 | } |
@@ -436,20 +436,20 @@ discard block |
||
436 | 436 | $ignoreImport = false; |
437 | 437 | |
438 | 438 | if (!$ignoreImport) { |
439 | - 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'])) { |
|
439 | + 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'])) { |
|
440 | 440 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
441 | 441 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
442 | 442 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
443 | 443 | $timeelapsed = microtime(true); |
444 | 444 | $MarineLive = new MarineLive($this->db); |
445 | - $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
445 | + $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']); |
|
446 | 446 | $MarineLive->db = null; |
447 | 447 | if ($globalDebug) echo $result."\n"; |
448 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
448 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
449 | 449 | } |
450 | 450 | } |
451 | 451 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
452 | - $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
452 | + $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']); |
|
453 | 453 | } |
454 | 454 | $this->all_tracked[$id]['putinarchive'] = false; |
455 | 455 | |
@@ -468,19 +468,19 @@ discard block |
||
468 | 468 | $latitude = $globalCenterLatitude; |
469 | 469 | $longitude = $globalCenterLongitude; |
470 | 470 | } |
471 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
471 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
472 | 472 | } else { |
473 | 473 | $latitude = $this->source_location[$source]['latitude']; |
474 | 474 | $longitude = $this->source_location[$source]['longitude']; |
475 | 475 | } |
476 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
476 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
477 | 477 | //$stats_heading = $stats_heading%22.5; |
478 | 478 | $stats_heading = round($stats_heading/22.5); |
479 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
479 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
480 | 480 | $current_date = date('Y-m-d'); |
481 | 481 | if ($stats_heading == 16) $stats_heading = 0; |
482 | 482 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
483 | - for ($i=0;$i<=15;$i++) { |
|
483 | + for ($i = 0; $i <= 15; $i++) { |
|
484 | 484 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
485 | 485 | } |
486 | 486 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -495,9 +495,9 @@ discard block |
||
495 | 495 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
496 | 496 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
497 | 497 | end($this->stats[$current_date][$source]['hist']); |
498 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
498 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
499 | 499 | } else $mini = 0; |
500 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
500 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
501 | 501 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
502 | 502 | } |
503 | 503 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | |
510 | 510 | $this->all_tracked[$id]['lastupdate'] = time(); |
511 | 511 | if ($this->all_tracked[$id]['putinarchive']) $send = true; |
512 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
512 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
513 | 513 | //$this->del(); |
514 | 514 | |
515 | 515 |
@@ -54,7 +54,9 @@ discard block |
||
54 | 54 | public function checkAll() { |
55 | 55 | global $globalDebug, $globalNoDB; |
56 | 56 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
57 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
57 | + if ($globalDebug) { |
|
58 | + echo "Update last seen tracked data...\n"; |
|
59 | + } |
|
58 | 60 | foreach ($this->all_tracked as $key => $flight) { |
59 | 61 | if (isset($this->all_tracked[$key]['id'])) { |
60 | 62 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
@@ -68,13 +70,17 @@ discard block |
||
68 | 70 | public function del() { |
69 | 71 | global $globalDebug, $globalNoDB, $globalNoImport; |
70 | 72 | // Delete old infos |
71 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
73 | + if ($globalDebug) { |
|
74 | + echo 'Delete old values and update latest data...'."\n"; |
|
75 | + } |
|
72 | 76 | foreach ($this->all_tracked as $key => $flight) { |
73 | 77 | if (isset($flight['lastupdate'])) { |
74 | 78 | if ($flight['lastupdate'] < (time()-3000)) { |
75 | 79 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
76 | 80 | if (isset($this->all_tracked[$key]['id'])) { |
77 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
81 | + if ($globalDebug) { |
|
82 | + echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
83 | + } |
|
78 | 84 | /* |
79 | 85 | $MarineLive = new MarineLive(); |
80 | 86 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
@@ -84,7 +90,9 @@ discard block |
||
84 | 90 | $Marine = new Marine($this->db); |
85 | 91 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
86 | 92 | $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
87 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
93 | + if ($globalDebug && $result != 'success') { |
|
94 | + echo '!!! ERROR : '.$result."\n"; |
|
95 | + } |
|
88 | 96 | } |
89 | 97 | // Put in archive |
90 | 98 | // $Marine->db = null; |
@@ -98,7 +106,9 @@ discard block |
||
98 | 106 | |
99 | 107 | public function add($line) { |
100 | 108 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
101 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
109 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
110 | + $globalCoordMinChange = '0.02'; |
|
111 | + } |
|
102 | 112 | date_default_timezone_set('UTC'); |
103 | 113 | $dataFound = false; |
104 | 114 | $send = false; |
@@ -112,20 +122,30 @@ discard block |
||
112 | 122 | // Increment message number |
113 | 123 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
114 | 124 | $current_date = date('Y-m-d'); |
115 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
116 | - else $source = ''; |
|
117 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
125 | + if (isset($line['source_name'])) { |
|
126 | + $source = $line['source_name']; |
|
127 | + } else { |
|
128 | + $source = ''; |
|
129 | + } |
|
130 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
131 | + $source = $line['format_source']; |
|
132 | + } |
|
118 | 133 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
119 | 134 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
120 | 135 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
121 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
136 | + } else { |
|
137 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
138 | + } |
|
122 | 139 | } |
123 | 140 | |
124 | 141 | |
125 | 142 | $Common = new Common(); |
126 | 143 | $AIS = new AIS(); |
127 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
128 | - else $id = trim($line['id']); |
|
144 | + if (!isset($line['id'])) { |
|
145 | + $id = trim($line['mmsi']); |
|
146 | + } else { |
|
147 | + $id = trim($line['id']); |
|
148 | + } |
|
129 | 149 | |
130 | 150 | if (!isset($this->all_tracked[$id])) { |
131 | 151 | $this->all_tracked[$id] = array(); |
@@ -133,10 +153,16 @@ discard block |
||
133 | 153 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
134 | 154 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
135 | 155 | if (!isset($line['id'])) { |
136 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
156 | + if (!isset($globalDaemon)) { |
|
157 | + $globalDaemon = TRUE; |
|
158 | + } |
|
137 | 159 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
138 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
139 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
160 | + } else { |
|
161 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
162 | + } |
|
163 | + if ($globalAllTracked !== FALSE) { |
|
164 | + $dataFound = true; |
|
165 | + } |
|
140 | 166 | } |
141 | 167 | |
142 | 168 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
@@ -186,35 +212,50 @@ discard block |
||
186 | 212 | $Marine = new Marine($this->db); |
187 | 213 | $fromsource = NULL; |
188 | 214 | $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
189 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
215 | + if ($globalDebug && $result != 'success') { |
|
216 | + echo '!!! ERROR : '.$result."\n"; |
|
217 | + } |
|
190 | 218 | $Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']); |
191 | 219 | $Marine->db = null; |
192 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
220 | + if ($globalDebugTimeElapsed) { |
|
221 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
222 | + } |
|
193 | 223 | } |
194 | 224 | } |
195 | 225 | } |
196 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
226 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
227 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
228 | + } |
|
197 | 229 | } |
198 | 230 | |
199 | 231 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
200 | 232 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
201 | 233 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
202 | 234 | } else { |
203 | - 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"; |
|
204 | - 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"; |
|
235 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
236 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
237 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
238 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
239 | + } |
|
205 | 240 | return ''; |
206 | 241 | } |
207 | 242 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
208 | - if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
243 | + if ($globalDebug) { |
|
244 | + echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
245 | + } |
|
209 | 246 | return ''; |
210 | 247 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) { |
211 | - if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
248 | + if ($globalDebug) { |
|
249 | + echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
250 | + } |
|
212 | 251 | return ''; |
213 | 252 | } elseif (!isset($line['datetime'])) { |
214 | 253 | date_default_timezone_set('UTC'); |
215 | 254 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
216 | 255 | } else { |
217 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!"; |
|
256 | + if ($globalDebug) { |
|
257 | + echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!"; |
|
258 | + } |
|
218 | 259 | return ''; |
219 | 260 | } |
220 | 261 | |
@@ -227,14 +268,21 @@ discard block |
||
227 | 268 | if ($distance > 1000 && $distance < 10000) { |
228 | 269 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
229 | 270 | $speed = $speed*3.6; |
230 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
231 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
271 | + if ($speed < 1000) { |
|
272 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
273 | + } |
|
274 | + if ($globalDebug) { |
|
275 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
276 | + } |
|
232 | 277 | } |
233 | 278 | } |
234 | 279 | |
235 | 280 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
236 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
237 | - else unset($timediff); |
|
281 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
282 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
283 | + } else { |
|
284 | + unset($timediff); |
|
285 | + } |
|
238 | 286 | 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')))) { |
239 | 287 | 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'])) { |
240 | 288 | 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'])) { |
@@ -242,22 +290,32 @@ discard block |
||
242 | 290 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
243 | 291 | $this->all_tracked[$id]['putinarchive'] = true; |
244 | 292 | |
245 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
293 | + if ($globalDebug) { |
|
294 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
295 | + } |
|
246 | 296 | $timeelapsed = microtime(true); |
247 | 297 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
248 | 298 | $Marine = new Marine($this->db); |
249 | 299 | $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
250 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
300 | + if (!empty($all_country)) { |
|
301 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
302 | + } |
|
251 | 303 | $Marine->db = null; |
252 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
304 | + if ($globalDebugTimeElapsed) { |
|
305 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
306 | + } |
|
253 | 307 | } |
254 | 308 | $this->tmd = 0; |
255 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
309 | + if ($globalDebug) { |
|
310 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
311 | + } |
|
256 | 312 | } |
257 | 313 | } |
258 | 314 | |
259 | 315 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
260 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
316 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
317 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
318 | + } |
|
261 | 319 | 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') { |
262 | 320 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
263 | 321 | $dataFound = true; |
@@ -266,8 +324,12 @@ discard block |
||
266 | 324 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
267 | 325 | } |
268 | 326 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
269 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
270 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
327 | + if ($line['longitude'] > 180) { |
|
328 | + $line['longitude'] = $line['longitude'] - 360; |
|
329 | + } |
|
330 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
331 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
332 | + } |
|
271 | 333 | 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') { |
272 | 334 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
273 | 335 | $dataFound = true; |
@@ -285,7 +347,9 @@ discard block |
||
285 | 347 | } |
286 | 348 | } |
287 | 349 | if (isset($line['last_update']) && $line['last_update'] != '') { |
288 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
350 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
351 | + $dataFound = true; |
|
352 | + } |
|
289 | 353 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
290 | 354 | } |
291 | 355 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -315,15 +379,21 @@ discard block |
||
315 | 379 | } |
316 | 380 | |
317 | 381 | if (isset($line['heading']) && $line['heading'] != '') { |
318 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
382 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
383 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
384 | + } |
|
319 | 385 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
320 | 386 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
321 | 387 | //$dataFound = true; |
322 | 388 | } 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']) { |
323 | 389 | $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']); |
324 | 390 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
325 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
326 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
391 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
392 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
393 | + } |
|
394 | + if ($globalDebug) { |
|
395 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
396 | + } |
|
327 | 397 | } |
328 | 398 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
329 | 399 | |
@@ -335,23 +405,38 @@ discard block |
||
335 | 405 | 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'])) { |
336 | 406 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
337 | 407 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
338 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
408 | + if ($globalDebug) { |
|
409 | + echo "Check if aircraft is already in DB..."; |
|
410 | + } |
|
339 | 411 | $timeelapsed = microtime(true); |
340 | 412 | $MarineLive = new MarineLive($this->db); |
341 | 413 | if (isset($line['id'])) { |
342 | 414 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
343 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
415 | + if ($globalDebugTimeElapsed) { |
|
416 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
417 | + } |
|
344 | 418 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
345 | 419 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
346 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
420 | + if ($globalDebugTimeElapsed) { |
|
421 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
422 | + } |
|
347 | 423 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
348 | 424 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
349 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
350 | - } else $recent_ident = ''; |
|
425 | + if ($globalDebugTimeElapsed) { |
|
426 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
427 | + } |
|
428 | + } else { |
|
429 | + $recent_ident = ''; |
|
430 | + } |
|
351 | 431 | $MarineLive->db=null; |
352 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
353 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
354 | - } else $recent_ident = ''; |
|
432 | + if ($globalDebug && $recent_ident == '') { |
|
433 | + echo " Not in DB.\n"; |
|
434 | + } elseif ($globalDebug && $recent_ident != '') { |
|
435 | + echo " Already in DB.\n"; |
|
436 | + } |
|
437 | + } else { |
|
438 | + $recent_ident = ''; |
|
439 | + } |
|
355 | 440 | } else { |
356 | 441 | $recent_ident = ''; |
357 | 442 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -359,30 +444,44 @@ discard block |
||
359 | 444 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
360 | 445 | if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
361 | 446 | { |
362 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
447 | + if ($globalDebug) { |
|
448 | + echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
449 | + } |
|
363 | 450 | //adds the spotter data for the archive |
364 | 451 | $highlight = ''; |
365 | - 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'))); |
|
452 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
453 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
454 | + } |
|
366 | 455 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
367 | 456 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
368 | 457 | $timeelapsed = microtime(true); |
369 | 458 | $Marine = new Marine($this->db); |
370 | 459 | $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
371 | 460 | $Marine->db = null; |
372 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
373 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
461 | + if ($globalDebug && isset($result)) { |
|
462 | + echo $result."\n"; |
|
463 | + } |
|
464 | + if ($globalDebugTimeElapsed) { |
|
465 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
466 | + } |
|
374 | 467 | } |
375 | 468 | } |
376 | 469 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
377 | 470 | // Add source stat in DB |
378 | 471 | $Stats = new Stats($this->db); |
379 | 472 | if (!empty($this->stats)) { |
380 | - if ($globalDebug) echo 'Add source stats : '; |
|
473 | + if ($globalDebug) { |
|
474 | + echo 'Add source stats : '; |
|
475 | + } |
|
381 | 476 | foreach($this->stats as $date => $data) { |
382 | 477 | foreach($data as $source => $sourced) { |
383 | 478 | //print_r($sourced); |
384 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
385 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
479 | + if (isset($sourced['polar'])) { |
|
480 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
481 | + } |
|
482 | + if (isset($sourced['hist'])) { |
|
483 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
484 | + } |
|
386 | 485 | if (isset($sourced['msg'])) { |
387 | 486 | if (time() - $sourced['msg']['date'] > 10) { |
388 | 487 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -395,7 +494,9 @@ discard block |
||
395 | 494 | unset($this->stats[$date]); |
396 | 495 | } |
397 | 496 | } |
398 | - if ($globalDebug) echo 'Done'."\n"; |
|
497 | + if ($globalDebug) { |
|
498 | + echo 'Done'."\n"; |
|
499 | + } |
|
399 | 500 | } |
400 | 501 | $Stats->db = null; |
401 | 502 | } |
@@ -405,13 +506,17 @@ discard block |
||
405 | 506 | $this->all_tracked[$id]['addedMarine'] = 1; |
406 | 507 | //print_r($this->all_tracked[$id]); |
407 | 508 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
408 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
509 | + if ($globalDebug) { |
|
510 | + echo "---- Deleting Live Marine data older than 9 hours..."; |
|
511 | + } |
|
409 | 512 | //MarineLive->deleteLiveMarineDataNotUpdated(); |
410 | 513 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
411 | 514 | $MarineLive = new MarineLive($this->db); |
412 | 515 | $MarineLive->deleteLiveMarineData(); |
413 | 516 | $MarineLive->db=null; |
414 | - if ($globalDebug) echo " Done\n"; |
|
517 | + if ($globalDebug) { |
|
518 | + echo " Done\n"; |
|
519 | + } |
|
415 | 520 | } |
416 | 521 | $this->last_delete = time(); |
417 | 522 | } |
@@ -437,15 +542,21 @@ discard block |
||
437 | 542 | |
438 | 543 | if (!$ignoreImport) { |
439 | 544 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
440 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
545 | + if ($globalDebug) { |
|
546 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
547 | + } |
|
441 | 548 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
442 | 549 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
443 | 550 | $timeelapsed = microtime(true); |
444 | 551 | $MarineLive = new MarineLive($this->db); |
445 | 552 | $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
446 | 553 | $MarineLive->db = null; |
447 | - if ($globalDebug) echo $result."\n"; |
|
448 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
554 | + if ($globalDebug) { |
|
555 | + echo $result."\n"; |
|
556 | + } |
|
557 | + if ($globalDebugTimeElapsed) { |
|
558 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
559 | + } |
|
449 | 560 | } |
450 | 561 | } |
451 | 562 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
@@ -457,7 +568,9 @@ discard block |
||
457 | 568 | |
458 | 569 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
459 | 570 | $source = $this->all_tracked[$id]['source_name']; |
460 | - if ($source == '') $source = $this->all_tracked[$id]['format_source']; |
|
571 | + if ($source == '') { |
|
572 | + $source = $this->all_tracked[$id]['format_source']; |
|
573 | + } |
|
461 | 574 | if (!isset($this->source_location[$source])) { |
462 | 575 | $Location = new Source($this->db); |
463 | 576 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -478,7 +591,9 @@ discard block |
||
478 | 591 | $stats_heading = round($stats_heading/22.5); |
479 | 592 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
480 | 593 | $current_date = date('Y-m-d'); |
481 | - if ($stats_heading == 16) $stats_heading = 0; |
|
594 | + if ($stats_heading == 16) { |
|
595 | + $stats_heading = 0; |
|
596 | + } |
|
482 | 597 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
483 | 598 | for ($i=0;$i<=15;$i++) { |
484 | 599 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -496,7 +611,9 @@ discard block |
||
496 | 611 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
497 | 612 | end($this->stats[$current_date][$source]['hist']); |
498 | 613 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
499 | - } else $mini = 0; |
|
614 | + } else { |
|
615 | + $mini = 0; |
|
616 | + } |
|
500 | 617 | for ($i=$mini;$i<=$distance;$i+=10) { |
501 | 618 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
502 | 619 | } |
@@ -508,19 +625,27 @@ discard block |
||
508 | 625 | |
509 | 626 | |
510 | 627 | $this->all_tracked[$id]['lastupdate'] = time(); |
511 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
512 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
628 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
629 | + $send = true; |
|
630 | + } |
|
631 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
632 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
633 | + } |
|
513 | 634 | //$this->del(); |
514 | 635 | |
515 | 636 | |
516 | 637 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
517 | 638 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
518 | - if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
639 | + if ($globalDebug) { |
|
640 | + echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
641 | + } |
|
519 | 642 | $MarineLive = new MarineLive($this->db); |
520 | 643 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
521 | 644 | $MarineLive->db = null; |
522 | 645 | //MarineLive->deleteLiveMarineData(); |
523 | - if ($globalDebug) echo " Done\n"; |
|
646 | + if ($globalDebug) { |
|
647 | + echo " Done\n"; |
|
648 | + } |
|
524 | 649 | } |
525 | 650 | $this->last_delete_hourly = time(); |
526 | 651 | } |
@@ -529,7 +654,9 @@ discard block |
||
529 | 654 | //$ignoreImport = false; |
530 | 655 | } |
531 | 656 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
532 | - if ($send) return $this->all_tracked[$id]; |
|
657 | + if ($send) { |
|
658 | + return $this->all_tracked[$id]; |
|
659 | + } |
|
533 | 660 | } |
534 | 661 | } |
535 | 662 | } |