@@ -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 | { |
@@ -557,8 +562,6 @@ discard block |
||
| 557 | 562 | * Update arrival marine data |
| 558 | 563 | * |
| 559 | 564 | * @param String $fammarine_id the ID |
| 560 | - * @param String $ident the marine ident |
|
| 561 | - * @return String success or false |
|
| 562 | 565 | * |
| 563 | 566 | */ |
| 564 | 567 | public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL) |
@@ -628,25 +631,6 @@ discard block |
||
| 628 | 631 | * |
| 629 | 632 | * @param String $fammarine_id the ID |
| 630 | 633 | * @param String $ident the marine ident |
| 631 | - * @param String $departure_airport_icao the departure airport |
|
| 632 | - * @param String $arrival_airport_icao the arrival airport |
|
| 633 | - * @param String $latitude latitude of flight |
|
| 634 | - * @param String $longitude latitude of flight |
|
| 635 | - * @param String $waypoints waypoints of flight |
|
| 636 | - * @param String $heading heading of flight |
|
| 637 | - * @param String $groundspeed speed of flight |
|
| 638 | - * @param String $date date of flight |
|
| 639 | - * @param String $departure_airport_time departure time of flight |
|
| 640 | - * @param String $arrival_airport_time arrival time of flight |
|
| 641 | - * @param String $squawk squawk code of flight |
|
| 642 | - * @param String $route_stop route stop of flight |
|
| 643 | - * @param String $highlight highlight or not |
|
| 644 | - * @param String $ModeS ModesS code of flight |
|
| 645 | - * @param String $registration registration code of flight |
|
| 646 | - * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
| 647 | - * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
| 648 | - * @param String $verticalrate vertival rate of flight |
|
| 649 | - * @return String success or false |
|
| 650 | 634 | */ |
| 651 | 635 | 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 = '') |
| 652 | 636 | { |
@@ -1236,6 +1220,7 @@ discard block |
||
| 1236 | 1220 | /** |
| 1237 | 1221 | * Counts all hours |
| 1238 | 1222 | * |
| 1223 | + * @param string $orderby |
|
| 1239 | 1224 | * @return Array the hour list |
| 1240 | 1225 | * |
| 1241 | 1226 | */ |
@@ -1587,7 +1572,7 @@ discard block |
||
| 1587 | 1572 | /** |
| 1588 | 1573 | * Parses the direction degrees to working |
| 1589 | 1574 | * |
| 1590 | - * @param Float $direction the direction in degrees |
|
| 1575 | + * @param integer $direction the direction in degrees |
|
| 1591 | 1576 | * @return Array the direction information |
| 1592 | 1577 | * |
| 1593 | 1578 | */ |
@@ -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 ident |
|
| 454 | - * |
|
| 455 | - */ |
|
| 451 | + * Gets all info from a mmsi |
|
| 452 | + * |
|
| 453 | + * @return Array ident |
|
| 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); |
@@ -533,13 +533,13 @@ discard block |
||
| 533 | 533 | } |
| 534 | 534 | |
| 535 | 535 | /** |
| 536 | - * Update ident tracker data |
|
| 537 | - * |
|
| 538 | - * @param String $fammarine_id the ID |
|
| 539 | - * @param String $ident the marine ident |
|
| 540 | - * @return String success or false |
|
| 541 | - * |
|
| 542 | - */ |
|
| 536 | + * Update ident tracker data |
|
| 537 | + * |
|
| 538 | + * @param String $fammarine_id the ID |
|
| 539 | + * @param String $ident the marine ident |
|
| 540 | + * @return String success or false |
|
| 541 | + * |
|
| 542 | + */ |
|
| 543 | 543 | public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
| 544 | 544 | { |
| 545 | 545 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
@@ -554,13 +554,13 @@ discard block |
||
| 554 | 554 | } |
| 555 | 555 | |
| 556 | 556 | /** |
| 557 | - * Update arrival marine data |
|
| 558 | - * |
|
| 559 | - * @param String $fammarine_id the ID |
|
| 560 | - * @param String $ident the marine ident |
|
| 561 | - * @return String success or false |
|
| 562 | - * |
|
| 563 | - */ |
|
| 557 | + * Update arrival marine data |
|
| 558 | + * |
|
| 559 | + * @param String $fammarine_id the ID |
|
| 560 | + * @param String $ident the marine ident |
|
| 561 | + * @return String success or false |
|
| 562 | + * |
|
| 563 | + */ |
|
| 564 | 564 | public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL) |
| 565 | 565 | { |
| 566 | 566 | $query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id'; |
@@ -575,19 +575,19 @@ discard block |
||
| 575 | 575 | } |
| 576 | 576 | |
| 577 | 577 | /** |
| 578 | - * Update Status data |
|
| 579 | - * |
|
| 580 | - * @param String $fammarine_id the ID |
|
| 581 | - * @param String $status_id the marine status id |
|
| 582 | - * @param String $status the marine status |
|
| 583 | - * @return String success or false |
|
| 584 | - * |
|
| 585 | - */ |
|
| 578 | + * Update Status data |
|
| 579 | + * |
|
| 580 | + * @param String $fammarine_id the ID |
|
| 581 | + * @param String $status_id the marine status id |
|
| 582 | + * @param String $status the marine status |
|
| 583 | + * @return String success or false |
|
| 584 | + * |
|
| 585 | + */ |
|
| 586 | 586 | public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') |
| 587 | 587 | { |
| 588 | 588 | |
| 589 | 589 | $query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; |
| 590 | - $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
| 590 | + $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
| 591 | 591 | |
| 592 | 592 | try { |
| 593 | 593 | $sth = $this->db->prepare($query); |
@@ -600,17 +600,17 @@ discard block |
||
| 600 | 600 | |
| 601 | 601 | } |
| 602 | 602 | /** |
| 603 | - * Update latest marine data |
|
| 604 | - * |
|
| 605 | - * @param String $fammarine_id the ID |
|
| 606 | - * @param String $ident the marine ident |
|
| 607 | - * @return String success or false |
|
| 608 | - * |
|
| 609 | - */ |
|
| 603 | + * Update latest marine data |
|
| 604 | + * |
|
| 605 | + * @param String $fammarine_id the ID |
|
| 606 | + * @param String $ident the marine ident |
|
| 607 | + * @return String success or false |
|
| 608 | + * |
|
| 609 | + */ |
|
| 610 | 610 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
| 611 | 611 | { |
| 612 | 612 | $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'; |
| 613 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
| 613 | + $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
| 614 | 614 | |
| 615 | 615 | try { |
| 616 | 616 | $sth = $this->db->prepare($query); |
@@ -624,30 +624,30 @@ discard block |
||
| 624 | 624 | } |
| 625 | 625 | |
| 626 | 626 | /** |
| 627 | - * Adds a new spotter data |
|
| 628 | - * |
|
| 629 | - * @param String $fammarine_id the ID |
|
| 630 | - * @param String $ident the marine ident |
|
| 631 | - * @param String $departure_airport_icao the departure airport |
|
| 632 | - * @param String $arrival_airport_icao the arrival airport |
|
| 633 | - * @param String $latitude latitude of flight |
|
| 634 | - * @param String $longitude latitude of flight |
|
| 635 | - * @param String $waypoints waypoints of flight |
|
| 636 | - * @param String $heading heading of flight |
|
| 637 | - * @param String $groundspeed speed of flight |
|
| 638 | - * @param String $date date of flight |
|
| 639 | - * @param String $departure_airport_time departure time of flight |
|
| 640 | - * @param String $arrival_airport_time arrival time of flight |
|
| 641 | - * @param String $squawk squawk code of flight |
|
| 642 | - * @param String $route_stop route stop of flight |
|
| 643 | - * @param String $highlight highlight or not |
|
| 644 | - * @param String $ModeS ModesS code of flight |
|
| 645 | - * @param String $registration registration code of flight |
|
| 646 | - * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
| 647 | - * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
| 648 | - * @param String $verticalrate vertival rate of flight |
|
| 649 | - * @return String success or false |
|
| 650 | - */ |
|
| 627 | + * Adds a new spotter data |
|
| 628 | + * |
|
| 629 | + * @param String $fammarine_id the ID |
|
| 630 | + * @param String $ident the marine ident |
|
| 631 | + * @param String $departure_airport_icao the departure airport |
|
| 632 | + * @param String $arrival_airport_icao the arrival airport |
|
| 633 | + * @param String $latitude latitude of flight |
|
| 634 | + * @param String $longitude latitude of flight |
|
| 635 | + * @param String $waypoints waypoints of flight |
|
| 636 | + * @param String $heading heading of flight |
|
| 637 | + * @param String $groundspeed speed of flight |
|
| 638 | + * @param String $date date of flight |
|
| 639 | + * @param String $departure_airport_time departure time of flight |
|
| 640 | + * @param String $arrival_airport_time arrival time of flight |
|
| 641 | + * @param String $squawk squawk code of flight |
|
| 642 | + * @param String $route_stop route stop of flight |
|
| 643 | + * @param String $highlight highlight or not |
|
| 644 | + * @param String $ModeS ModesS code of flight |
|
| 645 | + * @param String $registration registration code of flight |
|
| 646 | + * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
| 647 | + * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
| 648 | + * @param String $verticalrate vertival rate of flight |
|
| 649 | + * @return String success or false |
|
| 650 | + */ |
|
| 651 | 651 | 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 = '') |
| 652 | 652 | { |
| 653 | 653 | global $globalURL, $globalMarineImageFetch; |
@@ -758,7 +758,7 @@ discard block |
||
| 758 | 758 | $sth->execute($query_values); |
| 759 | 759 | $this->db = null; |
| 760 | 760 | } catch (PDOException $e) { |
| 761 | - return "error : ".$e->getMessage(); |
|
| 761 | + return "error : ".$e->getMessage(); |
|
| 762 | 762 | } |
| 763 | 763 | |
| 764 | 764 | return "success"; |
@@ -767,11 +767,11 @@ discard block |
||
| 767 | 767 | |
| 768 | 768 | |
| 769 | 769 | /** |
| 770 | - * Gets the aircraft ident within the last hour |
|
| 771 | - * |
|
| 772 | - * @return String the ident |
|
| 773 | - * |
|
| 774 | - */ |
|
| 770 | + * Gets the aircraft ident within the last hour |
|
| 771 | + * |
|
| 772 | + * @return String the ident |
|
| 773 | + * |
|
| 774 | + */ |
|
| 775 | 775 | public function getIdentFromLastHour($ident) |
| 776 | 776 | { |
| 777 | 777 | global $globalDBdriver, $globalTimezone; |
@@ -787,11 +787,11 @@ discard block |
||
| 787 | 787 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 788 | 788 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
| 789 | 789 | $query_data = array(':ident' => $ident); |
| 790 | - } |
|
| 790 | + } |
|
| 791 | 791 | |
| 792 | 792 | $sth = $this->db->prepare($query); |
| 793 | 793 | $sth->execute($query_data); |
| 794 | - $ident_result=''; |
|
| 794 | + $ident_result=''; |
|
| 795 | 795 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 796 | 796 | { |
| 797 | 797 | $ident_result = $row['ident']; |
@@ -802,11 +802,11 @@ discard block |
||
| 802 | 802 | |
| 803 | 803 | |
| 804 | 804 | /** |
| 805 | - * Gets the aircraft data from the last 20 seconds |
|
| 806 | - * |
|
| 807 | - * @return Array the spotter data |
|
| 808 | - * |
|
| 809 | - */ |
|
| 805 | + * Gets the aircraft data from the last 20 seconds |
|
| 806 | + * |
|
| 807 | + * @return Array the spotter data |
|
| 808 | + * |
|
| 809 | + */ |
|
| 810 | 810 | public function getRealTimeData($q = '') |
| 811 | 811 | { |
| 812 | 812 | global $globalDBdriver; |
@@ -844,11 +844,11 @@ discard block |
||
| 844 | 844 | |
| 845 | 845 | |
| 846 | 846 | /** |
| 847 | - * Gets all number of flight over countries |
|
| 848 | - * |
|
| 849 | - * @return Array the airline country list |
|
| 850 | - * |
|
| 851 | - */ |
|
| 847 | + * Gets all number of flight over countries |
|
| 848 | + * |
|
| 849 | + * @return Array the airline country list |
|
| 850 | + * |
|
| 851 | + */ |
|
| 852 | 852 | |
| 853 | 853 | public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
| 854 | 854 | { |
@@ -921,11 +921,11 @@ discard block |
||
| 921 | 921 | |
| 922 | 922 | |
| 923 | 923 | /** |
| 924 | - * Gets all callsigns that have flown over |
|
| 925 | - * |
|
| 926 | - * @return Array the callsign list |
|
| 927 | - * |
|
| 928 | - */ |
|
| 924 | + * Gets all callsigns that have flown over |
|
| 925 | + * |
|
| 926 | + * @return Array the callsign list |
|
| 927 | + * |
|
| 928 | + */ |
|
| 929 | 929 | public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
| 930 | 930 | { |
| 931 | 931 | global $globalDBdriver; |
@@ -992,11 +992,11 @@ discard block |
||
| 992 | 992 | |
| 993 | 993 | |
| 994 | 994 | /** |
| 995 | - * Counts all dates |
|
| 996 | - * |
|
| 997 | - * @return Array the date list |
|
| 998 | - * |
|
| 999 | - */ |
|
| 995 | + * Counts all dates |
|
| 996 | + * |
|
| 997 | + * @return Array the date list |
|
| 998 | + * |
|
| 999 | + */ |
|
| 1000 | 1000 | public function countAllDates($filters = array()) |
| 1001 | 1001 | { |
| 1002 | 1002 | global $globalTimezone, $globalDBdriver; |
@@ -1042,11 +1042,11 @@ discard block |
||
| 1042 | 1042 | |
| 1043 | 1043 | |
| 1044 | 1044 | /** |
| 1045 | - * Counts all dates during the last 7 days |
|
| 1046 | - * |
|
| 1047 | - * @return Array the date list |
|
| 1048 | - * |
|
| 1049 | - */ |
|
| 1045 | + * Counts all dates during the last 7 days |
|
| 1046 | + * |
|
| 1047 | + * @return Array the date list |
|
| 1048 | + * |
|
| 1049 | + */ |
|
| 1050 | 1050 | public function countAllDatesLast7Days($filters = array()) |
| 1051 | 1051 | { |
| 1052 | 1052 | global $globalTimezone, $globalDBdriver; |
@@ -1068,7 +1068,7 @@ discard block |
||
| 1068 | 1068 | $query .= " GROUP BY date_name |
| 1069 | 1069 | ORDER BY date_name ASC"; |
| 1070 | 1070 | $query_data = array(':offset' => $offset); |
| 1071 | - } |
|
| 1071 | + } |
|
| 1072 | 1072 | |
| 1073 | 1073 | $sth = $this->db->prepare($query); |
| 1074 | 1074 | $sth->execute($query_data); |
@@ -1088,11 +1088,11 @@ discard block |
||
| 1088 | 1088 | } |
| 1089 | 1089 | |
| 1090 | 1090 | /** |
| 1091 | - * Counts all dates during the last month |
|
| 1092 | - * |
|
| 1093 | - * @return Array the date list |
|
| 1094 | - * |
|
| 1095 | - */ |
|
| 1091 | + * Counts all dates during the last month |
|
| 1092 | + * |
|
| 1093 | + * @return Array the date list |
|
| 1094 | + * |
|
| 1095 | + */ |
|
| 1096 | 1096 | public function countAllDatesLastMonth($filters = array()) |
| 1097 | 1097 | { |
| 1098 | 1098 | global $globalTimezone, $globalDBdriver; |
@@ -1114,7 +1114,7 @@ discard block |
||
| 1114 | 1114 | $query .= " GROUP BY date_name |
| 1115 | 1115 | ORDER BY date_name ASC"; |
| 1116 | 1116 | $query_data = array(':offset' => $offset); |
| 1117 | - } |
|
| 1117 | + } |
|
| 1118 | 1118 | |
| 1119 | 1119 | $sth = $this->db->prepare($query); |
| 1120 | 1120 | $sth->execute($query_data); |
@@ -1136,11 +1136,11 @@ discard block |
||
| 1136 | 1136 | |
| 1137 | 1137 | |
| 1138 | 1138 | /** |
| 1139 | - * Counts all month |
|
| 1140 | - * |
|
| 1141 | - * @return Array the month list |
|
| 1142 | - * |
|
| 1143 | - */ |
|
| 1139 | + * Counts all month |
|
| 1140 | + * |
|
| 1141 | + * @return Array the month list |
|
| 1142 | + * |
|
| 1143 | + */ |
|
| 1144 | 1144 | public function countAllMonths($filters = array()) |
| 1145 | 1145 | { |
| 1146 | 1146 | global $globalTimezone, $globalDBdriver; |
@@ -1185,11 +1185,11 @@ discard block |
||
| 1185 | 1185 | |
| 1186 | 1186 | |
| 1187 | 1187 | /** |
| 1188 | - * Counts all dates during the last year |
|
| 1189 | - * |
|
| 1190 | - * @return Array the date list |
|
| 1191 | - * |
|
| 1192 | - */ |
|
| 1188 | + * Counts all dates during the last year |
|
| 1189 | + * |
|
| 1190 | + * @return Array the date list |
|
| 1191 | + * |
|
| 1192 | + */ |
|
| 1193 | 1193 | public function countAllMonthsLastYear($filters) |
| 1194 | 1194 | { |
| 1195 | 1195 | global $globalTimezone, $globalDBdriver; |
@@ -1211,7 +1211,7 @@ discard block |
||
| 1211 | 1211 | $query .= " GROUP BY year_name, month_name |
| 1212 | 1212 | ORDER BY year_name, month_name ASC"; |
| 1213 | 1213 | $query_data = array(':offset' => $offset); |
| 1214 | - } |
|
| 1214 | + } |
|
| 1215 | 1215 | |
| 1216 | 1216 | $sth = $this->db->prepare($query); |
| 1217 | 1217 | $sth->execute($query_data); |
@@ -1234,11 +1234,11 @@ discard block |
||
| 1234 | 1234 | |
| 1235 | 1235 | |
| 1236 | 1236 | /** |
| 1237 | - * Counts all hours |
|
| 1238 | - * |
|
| 1239 | - * @return Array the hour list |
|
| 1240 | - * |
|
| 1241 | - */ |
|
| 1237 | + * Counts all hours |
|
| 1238 | + * |
|
| 1239 | + * @return Array the hour list |
|
| 1240 | + * |
|
| 1241 | + */ |
|
| 1242 | 1242 | public function countAllHours($orderby,$filters = array()) |
| 1243 | 1243 | { |
| 1244 | 1244 | global $globalTimezone, $globalDBdriver; |
@@ -1301,11 +1301,11 @@ discard block |
||
| 1301 | 1301 | |
| 1302 | 1302 | |
| 1303 | 1303 | /** |
| 1304 | - * Counts all hours by date |
|
| 1305 | - * |
|
| 1306 | - * @return Array the hour list |
|
| 1307 | - * |
|
| 1308 | - */ |
|
| 1304 | + * Counts all hours by date |
|
| 1305 | + * |
|
| 1306 | + * @return Array the hour list |
|
| 1307 | + * |
|
| 1308 | + */ |
|
| 1309 | 1309 | public function countAllHoursByDate($date, $filters = array()) |
| 1310 | 1310 | { |
| 1311 | 1311 | global $globalTimezone, $globalDBdriver; |
@@ -1349,11 +1349,11 @@ discard block |
||
| 1349 | 1349 | |
| 1350 | 1350 | |
| 1351 | 1351 | /** |
| 1352 | - * Counts all hours by a ident/callsign |
|
| 1353 | - * |
|
| 1354 | - * @return Array the hour list |
|
| 1355 | - * |
|
| 1356 | - */ |
|
| 1352 | + * Counts all hours by a ident/callsign |
|
| 1353 | + * |
|
| 1354 | + * @return Array the hour list |
|
| 1355 | + * |
|
| 1356 | + */ |
|
| 1357 | 1357 | public function countAllHoursByIdent($ident, $filters = array()) |
| 1358 | 1358 | { |
| 1359 | 1359 | global $globalTimezone, $globalDBdriver; |
@@ -1398,11 +1398,11 @@ discard block |
||
| 1398 | 1398 | |
| 1399 | 1399 | |
| 1400 | 1400 | /** |
| 1401 | - * Counts all vessels |
|
| 1402 | - * |
|
| 1403 | - * @return Integer the number of vessels |
|
| 1404 | - * |
|
| 1405 | - */ |
|
| 1401 | + * Counts all vessels |
|
| 1402 | + * |
|
| 1403 | + * @return Integer the number of vessels |
|
| 1404 | + * |
|
| 1405 | + */ |
|
| 1406 | 1406 | public function countOverallMarine($filters = array(),$year = '',$month = '') |
| 1407 | 1407 | { |
| 1408 | 1408 | global $globalDBdriver; |
@@ -1437,11 +1437,11 @@ discard block |
||
| 1437 | 1437 | } |
| 1438 | 1438 | |
| 1439 | 1439 | /** |
| 1440 | - * Counts all vessel type |
|
| 1441 | - * |
|
| 1442 | - * @return Integer the number of vessels |
|
| 1443 | - * |
|
| 1444 | - */ |
|
| 1440 | + * Counts all vessel type |
|
| 1441 | + * |
|
| 1442 | + * @return Integer the number of vessels |
|
| 1443 | + * |
|
| 1444 | + */ |
|
| 1445 | 1445 | public function countOverallMarineTypes($filters = array(),$year = '',$month = '') |
| 1446 | 1446 | { |
| 1447 | 1447 | global $globalDBdriver; |
@@ -1476,11 +1476,11 @@ discard block |
||
| 1476 | 1476 | |
| 1477 | 1477 | |
| 1478 | 1478 | /** |
| 1479 | - * Counts all hours of today |
|
| 1480 | - * |
|
| 1481 | - * @return Array the hour list |
|
| 1482 | - * |
|
| 1483 | - */ |
|
| 1479 | + * Counts all hours of today |
|
| 1480 | + * |
|
| 1481 | + * @return Array the hour list |
|
| 1482 | + * |
|
| 1483 | + */ |
|
| 1484 | 1484 | public function countAllHoursFromToday($filters = array()) |
| 1485 | 1485 | { |
| 1486 | 1486 | global $globalTimezone, $globalDBdriver; |
@@ -1520,12 +1520,12 @@ discard block |
||
| 1520 | 1520 | } |
| 1521 | 1521 | |
| 1522 | 1522 | |
| 1523 | - /** |
|
| 1524 | - * Gets the Barrie Spotter ID based on the FlightAware ID |
|
| 1525 | - * |
|
| 1526 | - * @return Integer the Barrie Spotter ID |
|
| 1523 | + /** |
|
| 1524 | + * Gets the Barrie Spotter ID based on the FlightAware ID |
|
| 1525 | + * |
|
| 1526 | + * @return Integer the Barrie Spotter ID |
|
| 1527 | 1527 | q * |
| 1528 | - */ |
|
| 1528 | + */ |
|
| 1529 | 1529 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
| 1530 | 1530 | { |
| 1531 | 1531 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
@@ -1546,13 +1546,13 @@ discard block |
||
| 1546 | 1546 | |
| 1547 | 1547 | |
| 1548 | 1548 | /** |
| 1549 | - * Parses a date string |
|
| 1550 | - * |
|
| 1551 | - * @param String $dateString the date string |
|
| 1552 | - * @param String $timezone the timezone of a user |
|
| 1553 | - * @return Array the time information |
|
| 1554 | - * |
|
| 1555 | - */ |
|
| 1549 | + * Parses a date string |
|
| 1550 | + * |
|
| 1551 | + * @param String $dateString the date string |
|
| 1552 | + * @param String $timezone the timezone of a user |
|
| 1553 | + * @return Array the time information |
|
| 1554 | + * |
|
| 1555 | + */ |
|
| 1556 | 1556 | public function parseDateString($dateString, $timezone = '') |
| 1557 | 1557 | { |
| 1558 | 1558 | $time_array = array(); |
@@ -1585,12 +1585,12 @@ discard block |
||
| 1585 | 1585 | } |
| 1586 | 1586 | |
| 1587 | 1587 | /** |
| 1588 | - * Parses the direction degrees to working |
|
| 1589 | - * |
|
| 1590 | - * @param Float $direction the direction in degrees |
|
| 1591 | - * @return Array the direction information |
|
| 1592 | - * |
|
| 1593 | - */ |
|
| 1588 | + * Parses the direction degrees to working |
|
| 1589 | + * |
|
| 1590 | + * @param Float $direction the direction in degrees |
|
| 1591 | + * @return Array the direction information |
|
| 1592 | + * |
|
| 1593 | + */ |
|
| 1594 | 1594 | public function parseDirection($direction = 0) |
| 1595 | 1595 | { |
| 1596 | 1596 | if ($direction == '') $direction = 0; |
@@ -1669,12 +1669,12 @@ discard block |
||
| 1669 | 1669 | |
| 1670 | 1670 | |
| 1671 | 1671 | /** |
| 1672 | - * Gets Country from latitude/longitude |
|
| 1673 | - * |
|
| 1674 | - * @param Float $latitude latitute of the flight |
|
| 1675 | - * @param Float $longitude longitute of the flight |
|
| 1676 | - * @return String the countrie |
|
| 1677 | - */ |
|
| 1672 | + * Gets Country from latitude/longitude |
|
| 1673 | + * |
|
| 1674 | + * @param Float $latitude latitute of the flight |
|
| 1675 | + * @param Float $longitude longitute of the flight |
|
| 1676 | + * @return String the countrie |
|
| 1677 | + */ |
|
| 1678 | 1678 | public function getCountryFromLatitudeLongitude($latitude,$longitude) |
| 1679 | 1679 | { |
| 1680 | 1680 | global $globalDBdriver, $globalDebug; |
@@ -1711,11 +1711,11 @@ discard block |
||
| 1711 | 1711 | } |
| 1712 | 1712 | |
| 1713 | 1713 | /** |
| 1714 | - * Gets Country from iso2 |
|
| 1715 | - * |
|
| 1716 | - * @param String $iso2 ISO2 country code |
|
| 1717 | - * @return String the countrie |
|
| 1718 | - */ |
|
| 1714 | + * Gets Country from iso2 |
|
| 1715 | + * |
|
| 1716 | + * @param String $iso2 ISO2 country code |
|
| 1717 | + * @return String the countrie |
|
| 1718 | + */ |
|
| 1719 | 1719 | public function getCountryFromISO2($iso2) |
| 1720 | 1720 | { |
| 1721 | 1721 | global $globalDBdriver, $globalDebug; |
@@ -1744,12 +1744,12 @@ discard block |
||
| 1744 | 1744 | |
| 1745 | 1745 | |
| 1746 | 1746 | /** |
| 1747 | - * Gets the short url from bit.ly |
|
| 1748 | - * |
|
| 1749 | - * @param String $url the full url |
|
| 1750 | - * @return String the bit.ly url |
|
| 1751 | - * |
|
| 1752 | - */ |
|
| 1747 | + * Gets the short url from bit.ly |
|
| 1748 | + * |
|
| 1749 | + * @param String $url the full url |
|
| 1750 | + * @return String the bit.ly url |
|
| 1751 | + * |
|
| 1752 | + */ |
|
| 1753 | 1753 | public function getBitlyURL($url) |
| 1754 | 1754 | { |
| 1755 | 1755 | global $globalBitlyAccessToken; |
@@ -1776,11 +1776,11 @@ discard block |
||
| 1776 | 1776 | |
| 1777 | 1777 | |
| 1778 | 1778 | /** |
| 1779 | - * Gets all vessels types that have flown over |
|
| 1780 | - * |
|
| 1781 | - * @return Array the vessel type list |
|
| 1782 | - * |
|
| 1783 | - */ |
|
| 1779 | + * Gets all vessels types that have flown over |
|
| 1780 | + * |
|
| 1781 | + * @return Array the vessel type list |
|
| 1782 | + * |
|
| 1783 | + */ |
|
| 1784 | 1784 | public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
| 1785 | 1785 | { |
| 1786 | 1786 | global $globalDBdriver; |
@@ -1845,11 +1845,11 @@ discard block |
||
| 1845 | 1845 | } |
| 1846 | 1846 | |
| 1847 | 1847 | /** |
| 1848 | - * Gets all the tracker information |
|
| 1849 | - * |
|
| 1850 | - * @return Array the tracker information |
|
| 1851 | - * |
|
| 1852 | - */ |
|
| 1848 | + * Gets all the tracker information |
|
| 1849 | + * |
|
| 1850 | + * @return Array the tracker information |
|
| 1851 | + * |
|
| 1852 | + */ |
|
| 1853 | 1853 | public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array()) |
| 1854 | 1854 | { |
| 1855 | 1855 | 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,23 +468,23 @@ 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); |
|
| 473 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
| 474 | 474 | if ($mmsi != '') { |
| 475 | - $imo = filter_var($imo,FILTER_SANITIZE_NUMBER_INT); |
|
| 476 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 477 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 478 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
| 475 | + $imo = filter_var($imo, FILTER_SANITIZE_NUMBER_INT); |
|
| 476 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 477 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 478 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
| 479 | 479 | $identinfo = $this->getIdentity($mmsi); |
| 480 | 480 | if (empty($identinfo)) { |
| 481 | - $query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)"; |
|
| 481 | + $query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)"; |
|
| 482 | 482 | $sth = $this->db->prepare($query); |
| 483 | - $sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':call_sign' => $callsign,':ship_name' => $ident,':type' => $type)); |
|
| 483 | + $sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':call_sign' => $callsign, ':ship_name' => $ident, ':type' => $type)); |
|
| 484 | 484 | } elseif ($ident != '' && $identinfo['ship_name'] != $ident) { |
| 485 | - $query = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi"; |
|
| 485 | + $query = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi"; |
|
| 486 | 486 | $sth = $this->db->prepare($query); |
| 487 | - $sth->execute(array(':mmsi' => $mmsi,':ship_name' => $ident,':type' => $type)); |
|
| 487 | + $sth->execute(array(':mmsi' => $mmsi, ':ship_name' => $ident, ':type' => $type)); |
|
| 488 | 488 | } |
| 489 | 489 | } |
| 490 | 490 | } |
@@ -505,12 +505,12 @@ discard block |
||
| 505 | 505 | } else $offset = '+00:00'; |
| 506 | 506 | |
| 507 | 507 | if ($globalDBdriver == 'mysql') { |
| 508 | - $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
| 508 | + $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
| 509 | 509 | FROM marine_output |
| 510 | 510 | WHERE marine_output.date <> '' |
| 511 | 511 | ORDER BY marine_output.date ASC LIMIT 0,100"; |
| 512 | 512 | } else { |
| 513 | - $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
| 513 | + $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
| 514 | 514 | FROM marine_output |
| 515 | 515 | WHERE marine_output.date <> '' |
| 516 | 516 | ORDER BY marine_output.date ASC LIMIT 0,100"; |
@@ -522,7 +522,7 @@ discard block |
||
| 522 | 522 | $date_array = array(); |
| 523 | 523 | $temp_array = array(); |
| 524 | 524 | |
| 525 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 525 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 526 | 526 | { |
| 527 | 527 | $temp_array['date'] = $row['date']; |
| 528 | 528 | |
@@ -540,10 +540,10 @@ discard block |
||
| 540 | 540 | * @return String success or false |
| 541 | 541 | * |
| 542 | 542 | */ |
| 543 | - public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
|
| 543 | + public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL) |
|
| 544 | 544 | { |
| 545 | 545 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
| 546 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
| 546 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident); |
|
| 547 | 547 | try { |
| 548 | 548 | $sth = $this->db->prepare($query); |
| 549 | 549 | $sth->execute($query_values); |
@@ -561,10 +561,10 @@ discard block |
||
| 561 | 561 | * @return String success or false |
| 562 | 562 | * |
| 563 | 563 | */ |
| 564 | - public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL) |
|
| 564 | + public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '', $fromsource = NULL) |
|
| 565 | 565 | { |
| 566 | 566 | $query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id'; |
| 567 | - $query_values = array(':fammarine_id' => $fammarine_id,':arrival_code' => $arrival_code); |
|
| 567 | + $query_values = array(':fammarine_id' => $fammarine_id, ':arrival_code' => $arrival_code); |
|
| 568 | 568 | try { |
| 569 | 569 | $sth = $this->db->prepare($query); |
| 570 | 570 | $sth->execute($query_values); |
@@ -583,11 +583,11 @@ discard block |
||
| 583 | 583 | * @return String success or false |
| 584 | 584 | * |
| 585 | 585 | */ |
| 586 | - public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') |
|
| 586 | + public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '') |
|
| 587 | 587 | { |
| 588 | 588 | |
| 589 | 589 | $query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; |
| 590 | - $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
| 590 | + $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id); |
|
| 591 | 591 | |
| 592 | 592 | try { |
| 593 | 593 | $sth = $this->db->prepare($query); |
@@ -610,7 +610,7 @@ discard block |
||
| 610 | 610 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
| 611 | 611 | { |
| 612 | 612 | $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'; |
| 613 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
| 613 | + $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident); |
|
| 614 | 614 | |
| 615 | 615 | try { |
| 616 | 616 | $sth = $this->db->prepare($query); |
@@ -648,7 +648,7 @@ discard block |
||
| 648 | 648 | * @param String $verticalrate vertival rate of flight |
| 649 | 649 | * @return String success or false |
| 650 | 650 | */ |
| 651 | - 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 = '') |
|
| 651 | + 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 = '') |
|
| 652 | 652 | { |
| 653 | 653 | global $globalURL, $globalMarineImageFetch; |
| 654 | 654 | |
@@ -715,30 +715,30 @@ discard block |
||
| 715 | 715 | } |
| 716 | 716 | |
| 717 | 717 | |
| 718 | - if ($date == "" || strtotime($date) < time()-20*60) |
|
| 718 | + if ($date == "" || strtotime($date) < time() - 20*60) |
|
| 719 | 719 | { |
| 720 | 720 | $date = date("Y-m-d H:i:s", time()); |
| 721 | 721 | } |
| 722 | 722 | |
| 723 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
| 724 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 725 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 726 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 727 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 728 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 729 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 730 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
| 731 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
| 732 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
| 733 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 734 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 735 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
| 736 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
| 723 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
| 724 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 725 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 726 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 727 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 728 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 729 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 730 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
| 731 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
| 732 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
| 733 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 734 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 735 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
| 736 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
| 737 | 737 | if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) { |
| 738 | 738 | $Image = new Image($this->db); |
| 739 | - $image_array = $Image->getMarineImage($mmsi,$imo,$ident); |
|
| 739 | + $image_array = $Image->getMarineImage($mmsi, $imo, $ident); |
|
| 740 | 740 | if (!isset($image_array[0]['mmsi'])) { |
| 741 | - $Image->addMarineImage($mmsi,$imo,$ident); |
|
| 741 | + $Image->addMarineImage($mmsi, $imo, $ident); |
|
| 742 | 742 | } |
| 743 | 743 | unset($Image); |
| 744 | 744 | } |
@@ -749,10 +749,10 @@ discard block |
||
| 749 | 749 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
| 750 | 750 | if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
| 751 | 751 | if ($arrival_date == '') $arrival_date = NULL; |
| 752 | - $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) |
|
| 752 | + $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) |
|
| 753 | 753 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
| 754 | 754 | |
| 755 | - $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); |
|
| 755 | + $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); |
|
| 756 | 756 | try { |
| 757 | 757 | $sth = $this->db->prepare($query); |
| 758 | 758 | $sth->execute($query_values); |
@@ -776,13 +776,13 @@ discard block |
||
| 776 | 776 | { |
| 777 | 777 | global $globalDBdriver, $globalTimezone; |
| 778 | 778 | if ($globalDBdriver == 'mysql') { |
| 779 | - $query = "SELECT marine_output.ident FROM marine_output |
|
| 779 | + $query = "SELECT marine_output.ident FROM marine_output |
|
| 780 | 780 | WHERE marine_output.ident = :ident |
| 781 | 781 | AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 782 | 782 | AND marine_output.date < UTC_TIMESTAMP()"; |
| 783 | 783 | $query_data = array(':ident' => $ident); |
| 784 | 784 | } else { |
| 785 | - $query = "SELECT marine_output.ident FROM marine_output |
|
| 785 | + $query = "SELECT marine_output.ident FROM marine_output |
|
| 786 | 786 | WHERE marine_output.ident = :ident |
| 787 | 787 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 788 | 788 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
@@ -791,8 +791,8 @@ discard block |
||
| 791 | 791 | |
| 792 | 792 | $sth = $this->db->prepare($query); |
| 793 | 793 | $sth->execute($query_data); |
| 794 | - $ident_result=''; |
|
| 795 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 794 | + $ident_result = ''; |
|
| 795 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 796 | 796 | { |
| 797 | 797 | $ident_result = $row['ident']; |
| 798 | 798 | } |
@@ -818,8 +818,8 @@ discard block |
||
| 818 | 818 | return false; |
| 819 | 819 | } else { |
| 820 | 820 | $q_array = explode(" ", $q); |
| 821 | - foreach ($q_array as $q_item){ |
|
| 822 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
| 821 | + foreach ($q_array as $q_item) { |
|
| 822 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
| 823 | 823 | $additional_query .= " AND ("; |
| 824 | 824 | $additional_query .= "(marine_output.ident like '%".$q_item."%')"; |
| 825 | 825 | $additional_query .= ")"; |
@@ -827,11 +827,11 @@ discard block |
||
| 827 | 827 | } |
| 828 | 828 | } |
| 829 | 829 | if ($globalDBdriver == 'mysql') { |
| 830 | - $query = "SELECT marine_output.* FROM marine_output |
|
| 830 | + $query = "SELECT marine_output.* FROM marine_output |
|
| 831 | 831 | WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
| 832 | 832 | AND marine_output.date < UTC_TIMESTAMP()"; |
| 833 | 833 | } else { |
| 834 | - $query = "SELECT marine_output.* FROM marine_output |
|
| 834 | + $query = "SELECT marine_output.* FROM marine_output |
|
| 835 | 835 | WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
| 836 | 836 | AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
| 837 | 837 | } |
@@ -850,16 +850,16 @@ discard block |
||
| 850 | 850 | * |
| 851 | 851 | */ |
| 852 | 852 | |
| 853 | - public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
| 853 | + public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
| 854 | 854 | { |
| 855 | 855 | global $globalDBdriver, $globalArchive; |
| 856 | 856 | //$filter_query = $this->getFilter($filters,true,true); |
| 857 | - $Connection= new Connection($this->db); |
|
| 857 | + $Connection = new Connection($this->db); |
|
| 858 | 858 | if (!$Connection->tableExists('countries')) return array(); |
| 859 | 859 | require_once('class.SpotterLive.php'); |
| 860 | 860 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
| 861 | 861 | $MarineLive = new MarineLive($this->db); |
| 862 | - $filter_query = $MarineLive->getFilter($filters,true,true); |
|
| 862 | + $filter_query = $MarineLive->getFilter($filters, true, true); |
|
| 863 | 863 | $filter_query .= " over_country IS NOT NULL AND over_country <> ''"; |
| 864 | 864 | if ($olderthanmonths > 0) { |
| 865 | 865 | if ($globalDBdriver == 'mysql') { |
@@ -879,7 +879,7 @@ discard block |
||
| 879 | 879 | } else { |
| 880 | 880 | require_once(dirname(__FILE__)."/class.MarineArchive.php"); |
| 881 | 881 | $MarineArchive = new MarineArchive($this->db); |
| 882 | - $filter_query = $MarineArchive->getFilter($filters,true,true); |
|
| 882 | + $filter_query = $MarineArchive->getFilter($filters, true, true); |
|
| 883 | 883 | $filter_query .= " over_country <> ''"; |
| 884 | 884 | if ($olderthanmonths > 0) { |
| 885 | 885 | if ($globalDBdriver == 'mysql') { |
@@ -907,7 +907,7 @@ discard block |
||
| 907 | 907 | $flight_array = array(); |
| 908 | 908 | $temp_array = array(); |
| 909 | 909 | |
| 910 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 910 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 911 | 911 | { |
| 912 | 912 | $temp_array['marine_count'] = $row['nb']; |
| 913 | 913 | $temp_array['marine_country'] = $row['name']; |
@@ -926,11 +926,11 @@ discard block |
||
| 926 | 926 | * @return Array the callsign list |
| 927 | 927 | * |
| 928 | 928 | */ |
| 929 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
| 929 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 930 | 930 | { |
| 931 | 931 | global $globalDBdriver; |
| 932 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 933 | - $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
| 932 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 933 | + $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
| 934 | 934 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
| 935 | 935 | if ($olderthanmonths > 0) { |
| 936 | 936 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -944,28 +944,28 @@ discard block |
||
| 944 | 944 | if ($year != '') { |
| 945 | 945 | if ($globalDBdriver == 'mysql') { |
| 946 | 946 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 947 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 947 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 948 | 948 | } else { |
| 949 | 949 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 950 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 950 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 951 | 951 | } |
| 952 | 952 | } |
| 953 | 953 | if ($month != '') { |
| 954 | 954 | if ($globalDBdriver == 'mysql') { |
| 955 | 955 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 956 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 956 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 957 | 957 | } else { |
| 958 | 958 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 959 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 959 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 960 | 960 | } |
| 961 | 961 | } |
| 962 | 962 | if ($day != '') { |
| 963 | 963 | if ($globalDBdriver == 'mysql') { |
| 964 | 964 | $query .= " AND DAY(marine_output.date) = :day"; |
| 965 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 965 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 966 | 966 | } else { |
| 967 | 967 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 968 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 968 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 969 | 969 | } |
| 970 | 970 | } |
| 971 | 971 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
@@ -977,7 +977,7 @@ discard block |
||
| 977 | 977 | $callsign_array = array(); |
| 978 | 978 | $temp_array = array(); |
| 979 | 979 | |
| 980 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 980 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 981 | 981 | { |
| 982 | 982 | $temp_array['callsign_icao'] = $row['ident']; |
| 983 | 983 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -1029,7 +1029,7 @@ discard block |
||
| 1029 | 1029 | $date_array = array(); |
| 1030 | 1030 | $temp_array = array(); |
| 1031 | 1031 | |
| 1032 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1032 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1033 | 1033 | { |
| 1034 | 1034 | $temp_array['date_name'] = $row['date_name']; |
| 1035 | 1035 | $temp_array['date_count'] = $row['date_count']; |
@@ -1055,7 +1055,7 @@ discard block |
||
| 1055 | 1055 | $datetime = new DateTime(); |
| 1056 | 1056 | $offset = $datetime->format('P'); |
| 1057 | 1057 | } else $offset = '+00:00'; |
| 1058 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1058 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1059 | 1059 | if ($globalDBdriver == 'mysql') { |
| 1060 | 1060 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
| 1061 | 1061 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -1076,7 +1076,7 @@ discard block |
||
| 1076 | 1076 | $date_array = array(); |
| 1077 | 1077 | $temp_array = array(); |
| 1078 | 1078 | |
| 1079 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1079 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1080 | 1080 | { |
| 1081 | 1081 | $temp_array['date_name'] = $row['date_name']; |
| 1082 | 1082 | $temp_array['date_count'] = $row['date_count']; |
@@ -1101,7 +1101,7 @@ discard block |
||
| 1101 | 1101 | $datetime = new DateTime(); |
| 1102 | 1102 | $offset = $datetime->format('P'); |
| 1103 | 1103 | } else $offset = '+00:00'; |
| 1104 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1104 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1105 | 1105 | if ($globalDBdriver == 'mysql') { |
| 1106 | 1106 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
| 1107 | 1107 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -1122,7 +1122,7 @@ discard block |
||
| 1122 | 1122 | $date_array = array(); |
| 1123 | 1123 | $temp_array = array(); |
| 1124 | 1124 | |
| 1125 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1125 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1126 | 1126 | { |
| 1127 | 1127 | $temp_array['date_name'] = $row['date_name']; |
| 1128 | 1128 | $temp_array['date_count'] = $row['date_count']; |
@@ -1169,7 +1169,7 @@ discard block |
||
| 1169 | 1169 | $date_array = array(); |
| 1170 | 1170 | $temp_array = array(); |
| 1171 | 1171 | |
| 1172 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1172 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1173 | 1173 | { |
| 1174 | 1174 | $temp_array['month_name'] = $row['month_name']; |
| 1175 | 1175 | $temp_array['year_name'] = $row['year_name']; |
@@ -1198,7 +1198,7 @@ discard block |
||
| 1198 | 1198 | $datetime = new DateTime(); |
| 1199 | 1199 | $offset = $datetime->format('P'); |
| 1200 | 1200 | } else $offset = '+00:00'; |
| 1201 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1201 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1202 | 1202 | if ($globalDBdriver == 'mysql') { |
| 1203 | 1203 | $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 |
| 1204 | 1204 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -1219,7 +1219,7 @@ discard block |
||
| 1219 | 1219 | $date_array = array(); |
| 1220 | 1220 | $temp_array = array(); |
| 1221 | 1221 | |
| 1222 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1222 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1223 | 1223 | { |
| 1224 | 1224 | $temp_array['year_name'] = $row['year_name']; |
| 1225 | 1225 | $temp_array['month_name'] = $row['month_name']; |
@@ -1239,7 +1239,7 @@ discard block |
||
| 1239 | 1239 | * @return Array the hour list |
| 1240 | 1240 | * |
| 1241 | 1241 | */ |
| 1242 | - public function countAllHours($orderby,$filters = array()) |
|
| 1242 | + public function countAllHours($orderby, $filters = array()) |
|
| 1243 | 1243 | { |
| 1244 | 1244 | global $globalTimezone, $globalDBdriver; |
| 1245 | 1245 | if ($globalTimezone != '') { |
@@ -1287,7 +1287,7 @@ discard block |
||
| 1287 | 1287 | $hour_array = array(); |
| 1288 | 1288 | $temp_array = array(); |
| 1289 | 1289 | |
| 1290 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1290 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1291 | 1291 | { |
| 1292 | 1292 | $temp_array['hour_name'] = $row['hour_name']; |
| 1293 | 1293 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1309,8 +1309,8 @@ discard block |
||
| 1309 | 1309 | public function countAllHoursByDate($date, $filters = array()) |
| 1310 | 1310 | { |
| 1311 | 1311 | global $globalTimezone, $globalDBdriver; |
| 1312 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1313 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
| 1312 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1313 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
| 1314 | 1314 | if ($globalTimezone != '') { |
| 1315 | 1315 | date_default_timezone_set($globalTimezone); |
| 1316 | 1316 | $datetime = new DateTime($date); |
@@ -1318,12 +1318,12 @@ discard block |
||
| 1318 | 1318 | } else $offset = '+00:00'; |
| 1319 | 1319 | |
| 1320 | 1320 | if ($globalDBdriver == 'mysql') { |
| 1321 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1321 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1322 | 1322 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date |
| 1323 | 1323 | GROUP BY hour_name |
| 1324 | 1324 | ORDER BY hour_name ASC"; |
| 1325 | 1325 | } else { |
| 1326 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1326 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1327 | 1327 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
| 1328 | 1328 | GROUP BY hour_name |
| 1329 | 1329 | ORDER BY hour_name ASC"; |
@@ -1335,7 +1335,7 @@ discard block |
||
| 1335 | 1335 | $hour_array = array(); |
| 1336 | 1336 | $temp_array = array(); |
| 1337 | 1337 | |
| 1338 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1338 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1339 | 1339 | { |
| 1340 | 1340 | $temp_array['hour_name'] = $row['hour_name']; |
| 1341 | 1341 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1357,8 +1357,8 @@ discard block |
||
| 1357 | 1357 | public function countAllHoursByIdent($ident, $filters = array()) |
| 1358 | 1358 | { |
| 1359 | 1359 | global $globalTimezone, $globalDBdriver; |
| 1360 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1361 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 1360 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1361 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 1362 | 1362 | if ($globalTimezone != '') { |
| 1363 | 1363 | date_default_timezone_set($globalTimezone); |
| 1364 | 1364 | $datetime = new DateTime(); |
@@ -1366,12 +1366,12 @@ discard block |
||
| 1366 | 1366 | } else $offset = '+00:00'; |
| 1367 | 1367 | |
| 1368 | 1368 | if ($globalDBdriver == 'mysql') { |
| 1369 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1369 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1370 | 1370 | FROM marine_output".$filter_query." marine_output.ident = :ident |
| 1371 | 1371 | GROUP BY hour_name |
| 1372 | 1372 | ORDER BY hour_name ASC"; |
| 1373 | 1373 | } else { |
| 1374 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1374 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1375 | 1375 | FROM marine_output".$filter_query." marine_output.ident = :ident |
| 1376 | 1376 | GROUP BY hour_name |
| 1377 | 1377 | ORDER BY hour_name ASC"; |
@@ -1379,12 +1379,12 @@ discard block |
||
| 1379 | 1379 | |
| 1380 | 1380 | |
| 1381 | 1381 | $sth = $this->db->prepare($query); |
| 1382 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
| 1382 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
| 1383 | 1383 | |
| 1384 | 1384 | $hour_array = array(); |
| 1385 | 1385 | $temp_array = array(); |
| 1386 | 1386 | |
| 1387 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1387 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1388 | 1388 | { |
| 1389 | 1389 | $temp_array['hour_name'] = $row['hour_name']; |
| 1390 | 1390 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1403,33 +1403,33 @@ discard block |
||
| 1403 | 1403 | * @return Integer the number of vessels |
| 1404 | 1404 | * |
| 1405 | 1405 | */ |
| 1406 | - public function countOverallMarine($filters = array(),$year = '',$month = '') |
|
| 1406 | + public function countOverallMarine($filters = array(), $year = '', $month = '') |
|
| 1407 | 1407 | { |
| 1408 | 1408 | global $globalDBdriver; |
| 1409 | 1409 | //$queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; |
| 1410 | - $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
| 1410 | + $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
| 1411 | 1411 | $query_values = array(); |
| 1412 | 1412 | $query = ''; |
| 1413 | 1413 | if ($year != '') { |
| 1414 | 1414 | if ($globalDBdriver == 'mysql') { |
| 1415 | 1415 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 1416 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1416 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1417 | 1417 | } else { |
| 1418 | 1418 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 1419 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1419 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1420 | 1420 | } |
| 1421 | 1421 | } |
| 1422 | 1422 | if ($month != '') { |
| 1423 | 1423 | if ($globalDBdriver == 'mysql') { |
| 1424 | 1424 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 1425 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1425 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1426 | 1426 | } else { |
| 1427 | 1427 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 1428 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1428 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1429 | 1429 | } |
| 1430 | 1430 | } |
| 1431 | 1431 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
| 1432 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1432 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
| 1433 | 1433 | |
| 1434 | 1434 | $sth = $this->db->prepare($queryi); |
| 1435 | 1435 | $sth->execute($query_values); |
@@ -1442,32 +1442,32 @@ discard block |
||
| 1442 | 1442 | * @return Integer the number of vessels |
| 1443 | 1443 | * |
| 1444 | 1444 | */ |
| 1445 | - public function countOverallMarineTypes($filters = array(),$year = '',$month = '') |
|
| 1445 | + public function countOverallMarineTypes($filters = array(), $year = '', $month = '') |
|
| 1446 | 1446 | { |
| 1447 | 1447 | global $globalDBdriver; |
| 1448 | - $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
| 1448 | + $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
| 1449 | 1449 | $query_values = array(); |
| 1450 | 1450 | $query = ''; |
| 1451 | 1451 | if ($year != '') { |
| 1452 | 1452 | if ($globalDBdriver == 'mysql') { |
| 1453 | 1453 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 1454 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1454 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1455 | 1455 | } else { |
| 1456 | 1456 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 1457 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1457 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1458 | 1458 | } |
| 1459 | 1459 | } |
| 1460 | 1460 | if ($month != '') { |
| 1461 | 1461 | if ($globalDBdriver == 'mysql') { |
| 1462 | 1462 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 1463 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1463 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1464 | 1464 | } else { |
| 1465 | 1465 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 1466 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1466 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1467 | 1467 | } |
| 1468 | 1468 | } |
| 1469 | 1469 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
| 1470 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1470 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
| 1471 | 1471 | |
| 1472 | 1472 | $sth = $this->db->prepare($queryi); |
| 1473 | 1473 | $sth->execute($query_values); |
@@ -1484,7 +1484,7 @@ discard block |
||
| 1484 | 1484 | public function countAllHoursFromToday($filters = array()) |
| 1485 | 1485 | { |
| 1486 | 1486 | global $globalTimezone, $globalDBdriver; |
| 1487 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1487 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1488 | 1488 | if ($globalTimezone != '') { |
| 1489 | 1489 | date_default_timezone_set($globalTimezone); |
| 1490 | 1490 | $datetime = new DateTime(); |
@@ -1492,12 +1492,12 @@ discard block |
||
| 1492 | 1492 | } else $offset = '+00:00'; |
| 1493 | 1493 | |
| 1494 | 1494 | if ($globalDBdriver == 'mysql') { |
| 1495 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1495 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1496 | 1496 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE() |
| 1497 | 1497 | GROUP BY hour_name |
| 1498 | 1498 | ORDER BY hour_name ASC"; |
| 1499 | 1499 | } else { |
| 1500 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1500 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1501 | 1501 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
| 1502 | 1502 | GROUP BY hour_name |
| 1503 | 1503 | ORDER BY hour_name ASC"; |
@@ -1509,7 +1509,7 @@ discard block |
||
| 1509 | 1509 | $hour_array = array(); |
| 1510 | 1510 | $temp_array = array(); |
| 1511 | 1511 | |
| 1512 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1512 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1513 | 1513 | { |
| 1514 | 1514 | $temp_array['hour_name'] = $row['hour_name']; |
| 1515 | 1515 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1528,9 +1528,9 @@ discard block |
||
| 1528 | 1528 | */ |
| 1529 | 1529 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
| 1530 | 1530 | { |
| 1531 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
| 1531 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
| 1532 | 1532 | |
| 1533 | - $query = "SELECT marine_output.marine_id |
|
| 1533 | + $query = "SELECT marine_output.marine_id |
|
| 1534 | 1534 | FROM marine_output |
| 1535 | 1535 | WHERE marine_output.fammarine_id = '".$fammarine_id."'"; |
| 1536 | 1536 | |
@@ -1538,7 +1538,7 @@ discard block |
||
| 1538 | 1538 | $sth = $this->db->prepare($query); |
| 1539 | 1539 | $sth->execute(); |
| 1540 | 1540 | |
| 1541 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1541 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1542 | 1542 | { |
| 1543 | 1543 | return $row['marine_id']; |
| 1544 | 1544 | } |
@@ -1563,23 +1563,23 @@ discard block |
||
| 1563 | 1563 | } |
| 1564 | 1564 | |
| 1565 | 1565 | $current_date = date("Y-m-d H:i:s"); |
| 1566 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
| 1566 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
| 1567 | 1567 | |
| 1568 | 1568 | $diff = abs(strtotime($current_date) - strtotime($date)); |
| 1569 | 1569 | |
| 1570 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
| 1570 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
| 1571 | 1571 | $years = $time_array['years']; |
| 1572 | 1572 | |
| 1573 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
| 1573 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
| 1574 | 1574 | $months = $time_array['months']; |
| 1575 | 1575 | |
| 1576 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
| 1576 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
| 1577 | 1577 | $days = $time_array['days']; |
| 1578 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
| 1578 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
| 1579 | 1579 | $hours = $time_array['hours']; |
| 1580 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
| 1580 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
| 1581 | 1581 | $minutes = $time_array['minutes']; |
| 1582 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
| 1582 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
| 1583 | 1583 | |
| 1584 | 1584 | return $time_array; |
| 1585 | 1585 | } |
@@ -1602,63 +1602,63 @@ discard block |
||
| 1602 | 1602 | $temp_array['direction_degree'] = $direction; |
| 1603 | 1603 | $temp_array['direction_shortname'] = "N"; |
| 1604 | 1604 | $temp_array['direction_fullname'] = "North"; |
| 1605 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
| 1605 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
| 1606 | 1606 | $temp_array['direction_degree'] = $direction; |
| 1607 | 1607 | $temp_array['direction_shortname'] = "NNE"; |
| 1608 | 1608 | $temp_array['direction_fullname'] = "North-Northeast"; |
| 1609 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
| 1609 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
| 1610 | 1610 | $temp_array['direction_degree'] = $direction; |
| 1611 | 1611 | $temp_array['direction_shortname'] = "NE"; |
| 1612 | 1612 | $temp_array['direction_fullname'] = "Northeast"; |
| 1613 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
| 1613 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
| 1614 | 1614 | $temp_array['direction_degree'] = $direction; |
| 1615 | 1615 | $temp_array['direction_shortname'] = "ENE"; |
| 1616 | 1616 | $temp_array['direction_fullname'] = "East-Northeast"; |
| 1617 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
| 1617 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
| 1618 | 1618 | $temp_array['direction_degree'] = $direction; |
| 1619 | 1619 | $temp_array['direction_shortname'] = "E"; |
| 1620 | 1620 | $temp_array['direction_fullname'] = "East"; |
| 1621 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
| 1621 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
| 1622 | 1622 | $temp_array['direction_degree'] = $direction; |
| 1623 | 1623 | $temp_array['direction_shortname'] = "ESE"; |
| 1624 | 1624 | $temp_array['direction_fullname'] = "East-Southeast"; |
| 1625 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
| 1625 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
| 1626 | 1626 | $temp_array['direction_degree'] = $direction; |
| 1627 | 1627 | $temp_array['direction_shortname'] = "SE"; |
| 1628 | 1628 | $temp_array['direction_fullname'] = "Southeast"; |
| 1629 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
| 1629 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
| 1630 | 1630 | $temp_array['direction_degree'] = $direction; |
| 1631 | 1631 | $temp_array['direction_shortname'] = "SSE"; |
| 1632 | 1632 | $temp_array['direction_fullname'] = "South-Southeast"; |
| 1633 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
| 1633 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
| 1634 | 1634 | $temp_array['direction_degree'] = $direction; |
| 1635 | 1635 | $temp_array['direction_shortname'] = "S"; |
| 1636 | 1636 | $temp_array['direction_fullname'] = "South"; |
| 1637 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
| 1637 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
| 1638 | 1638 | $temp_array['direction_degree'] = $direction; |
| 1639 | 1639 | $temp_array['direction_shortname'] = "SSW"; |
| 1640 | 1640 | $temp_array['direction_fullname'] = "South-Southwest"; |
| 1641 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
| 1641 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
| 1642 | 1642 | $temp_array['direction_degree'] = $direction; |
| 1643 | 1643 | $temp_array['direction_shortname'] = "SW"; |
| 1644 | 1644 | $temp_array['direction_fullname'] = "Southwest"; |
| 1645 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
| 1645 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
| 1646 | 1646 | $temp_array['direction_degree'] = $direction; |
| 1647 | 1647 | $temp_array['direction_shortname'] = "WSW"; |
| 1648 | 1648 | $temp_array['direction_fullname'] = "West-Southwest"; |
| 1649 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
| 1649 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
| 1650 | 1650 | $temp_array['direction_degree'] = $direction; |
| 1651 | 1651 | $temp_array['direction_shortname'] = "W"; |
| 1652 | 1652 | $temp_array['direction_fullname'] = "West"; |
| 1653 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
| 1653 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
| 1654 | 1654 | $temp_array['direction_degree'] = $direction; |
| 1655 | 1655 | $temp_array['direction_shortname'] = "WNW"; |
| 1656 | 1656 | $temp_array['direction_fullname'] = "West-Northwest"; |
| 1657 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
| 1657 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
| 1658 | 1658 | $temp_array['direction_degree'] = $direction; |
| 1659 | 1659 | $temp_array['direction_shortname'] = "NW"; |
| 1660 | 1660 | $temp_array['direction_fullname'] = "Northwest"; |
| 1661 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
| 1661 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
| 1662 | 1662 | $temp_array['direction_degree'] = $direction; |
| 1663 | 1663 | $temp_array['direction_shortname'] = "NNW"; |
| 1664 | 1664 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -1675,11 +1675,11 @@ discard block |
||
| 1675 | 1675 | * @param Float $longitude longitute of the flight |
| 1676 | 1676 | * @return String the countrie |
| 1677 | 1677 | */ |
| 1678 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
| 1678 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
| 1679 | 1679 | { |
| 1680 | 1680 | global $globalDBdriver, $globalDebug; |
| 1681 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1682 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1681 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1682 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1683 | 1683 | |
| 1684 | 1684 | $Connection = new Connection($this->db); |
| 1685 | 1685 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1719,7 +1719,7 @@ discard block |
||
| 1719 | 1719 | public function getCountryFromISO2($iso2) |
| 1720 | 1720 | { |
| 1721 | 1721 | global $globalDBdriver, $globalDebug; |
| 1722 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
| 1722 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
| 1723 | 1723 | |
| 1724 | 1724 | $Connection = new Connection($this->db); |
| 1725 | 1725 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1767,7 +1767,7 @@ discard block |
||
| 1767 | 1767 | |
| 1768 | 1768 | $bitly_data = json_decode($bitly_data); |
| 1769 | 1769 | $bitly_url = ''; |
| 1770 | - if ($bitly_data->status_txt = "OK"){ |
|
| 1770 | + if ($bitly_data->status_txt = "OK") { |
|
| 1771 | 1771 | $bitly_url = $bitly_data->data->url; |
| 1772 | 1772 | } |
| 1773 | 1773 | |
@@ -1781,11 +1781,11 @@ discard block |
||
| 1781 | 1781 | * @return Array the vessel type list |
| 1782 | 1782 | * |
| 1783 | 1783 | */ |
| 1784 | - public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
|
| 1784 | + public function countAllMarineTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 1785 | 1785 | { |
| 1786 | 1786 | global $globalDBdriver; |
| 1787 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1788 | - $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count |
|
| 1787 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1788 | + $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count |
|
| 1789 | 1789 | FROM marine_output ".$filter_query." marine_output.type <> ''"; |
| 1790 | 1790 | if ($olderthanmonths > 0) { |
| 1791 | 1791 | if ($globalDBdriver == 'mysql') { |
@@ -1805,28 +1805,28 @@ discard block |
||
| 1805 | 1805 | if ($year != '') { |
| 1806 | 1806 | if ($globalDBdriver == 'mysql') { |
| 1807 | 1807 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 1808 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1808 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1809 | 1809 | } else { |
| 1810 | 1810 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 1811 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1811 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1812 | 1812 | } |
| 1813 | 1813 | } |
| 1814 | 1814 | if ($month != '') { |
| 1815 | 1815 | if ($globalDBdriver == 'mysql') { |
| 1816 | 1816 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 1817 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1817 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1818 | 1818 | } else { |
| 1819 | 1819 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 1820 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1820 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1821 | 1821 | } |
| 1822 | 1822 | } |
| 1823 | 1823 | if ($day != '') { |
| 1824 | 1824 | if ($globalDBdriver == 'mysql') { |
| 1825 | 1825 | $query .= " AND DAY(marine_output.date) = :day"; |
| 1826 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 1826 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 1827 | 1827 | } else { |
| 1828 | 1828 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 1829 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 1829 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 1830 | 1830 | } |
| 1831 | 1831 | } |
| 1832 | 1832 | $query .= " GROUP BY marine_output.type ORDER BY marine_type_count DESC"; |
@@ -1835,7 +1835,7 @@ discard block |
||
| 1835 | 1835 | $sth->execute($query_values); |
| 1836 | 1836 | $marine_array = array(); |
| 1837 | 1837 | $temp_array = array(); |
| 1838 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1838 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1839 | 1839 | { |
| 1840 | 1840 | $temp_array['marine_type'] = $row['marine_type']; |
| 1841 | 1841 | $temp_array['marine_type_count'] = $row['marine_type_count']; |
@@ -1850,13 +1850,13 @@ discard block |
||
| 1850 | 1850 | * @return Array the tracker information |
| 1851 | 1851 | * |
| 1852 | 1852 | */ |
| 1853 | - public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array()) |
|
| 1853 | + public function searchMarineData($q = '', $callsign = '', $mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
| 1854 | 1854 | { |
| 1855 | 1855 | global $globalTimezone, $globalDBdriver; |
| 1856 | 1856 | date_default_timezone_set('UTC'); |
| 1857 | 1857 | $query_values = array(); |
| 1858 | 1858 | $additional_query = ''; |
| 1859 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1859 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1860 | 1860 | if ($q != "") |
| 1861 | 1861 | { |
| 1862 | 1862 | if (!is_string($q)) |
@@ -1864,8 +1864,8 @@ discard block |
||
| 1864 | 1864 | return false; |
| 1865 | 1865 | } else { |
| 1866 | 1866 | $q_array = explode(" ", $q); |
| 1867 | - foreach ($q_array as $q_item){ |
|
| 1868 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
| 1867 | + foreach ($q_array as $q_item) { |
|
| 1868 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
| 1869 | 1869 | $additional_query .= " AND ("; |
| 1870 | 1870 | if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; |
| 1871 | 1871 | if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; |
@@ -1877,42 +1877,42 @@ discard block |
||
| 1877 | 1877 | } |
| 1878 | 1878 | if ($callsign != "") |
| 1879 | 1879 | { |
| 1880 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 1880 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 1881 | 1881 | if (!is_string($callsign)) |
| 1882 | 1882 | { |
| 1883 | 1883 | return false; |
| 1884 | 1884 | } else { |
| 1885 | 1885 | $additional_query .= " AND marine_output.ident = :callsign"; |
| 1886 | - $query_values = array_merge($query_values,array(':callsign' => $callsign)); |
|
| 1886 | + $query_values = array_merge($query_values, array(':callsign' => $callsign)); |
|
| 1887 | 1887 | } |
| 1888 | 1888 | } |
| 1889 | 1889 | if ($mmsi != "") |
| 1890 | 1890 | { |
| 1891 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
| 1891 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
| 1892 | 1892 | if (!is_numeric($mmsi)) |
| 1893 | 1893 | { |
| 1894 | 1894 | return false; |
| 1895 | 1895 | } else { |
| 1896 | 1896 | $additional_query .= " AND marine_output.mmsi = :mmsi"; |
| 1897 | - $query_values = array_merge($query_values,array(':mmsi' => $mmsi)); |
|
| 1897 | + $query_values = array_merge($query_values, array(':mmsi' => $mmsi)); |
|
| 1898 | 1898 | } |
| 1899 | 1899 | } |
| 1900 | 1900 | if ($imo != "") |
| 1901 | 1901 | { |
| 1902 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 1902 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 1903 | 1903 | if (!is_numeric($imo)) |
| 1904 | 1904 | { |
| 1905 | 1905 | return false; |
| 1906 | 1906 | } else { |
| 1907 | 1907 | $additional_query .= " AND marine_output.imo = :imo"; |
| 1908 | - $query_values = array_merge($query_values,array(':imo' => $imo)); |
|
| 1908 | + $query_values = array_merge($query_values, array(':imo' => $imo)); |
|
| 1909 | 1909 | } |
| 1910 | 1910 | } |
| 1911 | 1911 | if ($date_posted != "") |
| 1912 | 1912 | { |
| 1913 | 1913 | $date_array = explode(",", $date_posted); |
| 1914 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 1915 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 1914 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
| 1915 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
| 1916 | 1916 | if ($globalTimezone != '') { |
| 1917 | 1917 | date_default_timezone_set($globalTimezone); |
| 1918 | 1918 | $datetime = new DateTime(); |
@@ -1939,8 +1939,8 @@ discard block |
||
| 1939 | 1939 | if ($limit != "") |
| 1940 | 1940 | { |
| 1941 | 1941 | $limit_array = explode(",", $limit); |
| 1942 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1943 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1942 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1943 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1944 | 1944 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1945 | 1945 | { |
| 1946 | 1946 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -1958,28 +1958,28 @@ discard block |
||
| 1958 | 1958 | } |
| 1959 | 1959 | } |
| 1960 | 1960 | if ($origLat != "" && $origLon != "" && $dist != "") { |
| 1961 | - $dist = number_format($dist*0.621371,2,'.',''); // convert km to mile |
|
| 1961 | + $dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile |
|
| 1962 | 1962 | if ($globalDBdriver == 'mysql') { |
| 1963 | - $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 |
|
| 1963 | + $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 |
|
| 1964 | 1964 | 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)) |
| 1965 | 1965 | 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; |
| 1966 | 1966 | } else { |
| 1967 | - $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 |
|
| 1967 | + $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 |
|
| 1968 | 1968 | 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)) |
| 1969 | 1969 | 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; |
| 1970 | 1970 | } |
| 1971 | 1971 | } else { |
| 1972 | - $query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' |
|
| 1972 | + $query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' |
|
| 1973 | 1973 | ".$additional_query." |
| 1974 | 1974 | ".$orderby_query; |
| 1975 | 1975 | } |
| 1976 | - $marine_array = $this->getDataFromDB($query, $query_values,$limit_query); |
|
| 1976 | + $marine_array = $this->getDataFromDB($query, $query_values, $limit_query); |
|
| 1977 | 1977 | return $marine_array; |
| 1978 | 1978 | } |
| 1979 | 1979 | |
| 1980 | 1980 | public function getOrderBy() |
| 1981 | 1981 | { |
| 1982 | - $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")); |
|
| 1982 | + $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")); |
|
| 1983 | 1983 | |
| 1984 | 1984 | return $orderby; |
| 1985 | 1985 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | return ($dec); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - /* |
|
| 60 | + /* |
|
| 61 | 61 | $ais_map64 = array( |
| 62 | 62 | '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', // 48 |
| 63 | 63 | ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', |
@@ -97,13 +97,13 @@ discard block |
||
| 97 | 97 | // ' ' --- '?', // 0x20 - 0x3F |
| 98 | 98 | // '@' --- '_', // 0x40 - 0x5F |
| 99 | 99 | $ais_chars = array( |
| 100 | - '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', |
|
| 101 | - 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', |
|
| 102 | - 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', |
|
| 103 | - '^', '_', ' ', '!', '\"', '#', '$', '%', '&', '\'', |
|
| 104 | - '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', |
|
| 105 | - '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', |
|
| 106 | - '<', '=', '>', '?' |
|
| 100 | + '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', |
|
| 101 | + 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', |
|
| 102 | + 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', |
|
| 103 | + '^', '_', ' ', '!', '\"', '#', '$', '%', '&', '\'', |
|
| 104 | + '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', |
|
| 105 | + '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', |
|
| 106 | + '<', '=', '>', '?' |
|
| 107 | 107 | ); |
| 108 | 108 | // " |
| 109 | 109 | $rv = ''; |
@@ -421,8 +421,8 @@ discard block |
||
| 421 | 421 | } |
| 422 | 422 | if ($num_seq > 1) { // for multipart messages |
| 423 | 423 | if ($cmsg_sid != $msg_sid // different msg_sid |
| 424 | - || $msg_sid == -1 // invalid initial msg_sid |
|
| 425 | - || ($seq - $pseq) != 1 // not insequence |
|
| 424 | + || $msg_sid == -1 // invalid initial msg_sid |
|
| 425 | + || ($seq - $pseq) != 1 // not insequence |
|
| 426 | 426 | ) { // invalid for multipart message |
| 427 | 427 | $msg_sid = -1; |
| 428 | 428 | $cmsg_sid = -1; |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | $itu = $itu.$pcs[5]; // get itu message |
| 436 | 436 | $filler += (int)$pcs[6][0]; // get filler |
| 437 | 437 | if ($num_seq == 1 // valid single message |
| 438 | - || $num_seq == $pseq // valid multi-part message |
|
| 438 | + || $num_seq == $pseq // valid multi-part message |
|
| 439 | 439 | ) { |
| 440 | 440 | /* |
| 441 | 441 | if ($num_seq != 1) { // test |
@@ -520,13 +520,13 @@ discard block |
||
| 520 | 520 | else $pad = ''; |
| 521 | 521 | $rv = ''; |
| 522 | 522 | $ais_chars = array( |
| 523 | - '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9, |
|
| 524 | - 'J'=>10, 'K'=>11, 'L'=>12, 'M'=>13, 'N'=>14, 'O'=>15, 'P'=>16, 'Q'=>17, 'R'=>18, 'S'=>19, |
|
| 525 | - 'T'=>20, 'U'=>21, 'V'=>22, 'W'=>23, 'X'=>24, 'Y'=>25, 'Z'=>26, '['=>27, '\\'=>28, ']'=>29, |
|
| 526 | - '^'=>30, '_'=>31, ' '=>32, '!'=>33, '\"'=>34, '#'=>35, '$'=>36, '%'=>37, '&'=>38, '\''=>39, |
|
| 527 | - '('=>40, ')'=>41, '*'=>42, '+'=>43, ','=>44, '-'=>45, '.'=>46, '/'=>47, '0'=>48, '1'=>49, |
|
| 528 | - '2'=>50, '3'=>51, '4'=>52, '5'=>53, '6'=>54, '7'=>55, '8'=>56, '9'=>57, ':'=>58, ';'=>59, |
|
| 529 | - '<'=>60, '='=>61, '>'=>62, '?'=>63 |
|
| 523 | + '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9, |
|
| 524 | + 'J'=>10, 'K'=>11, 'L'=>12, 'M'=>13, 'N'=>14, 'O'=>15, 'P'=>16, 'Q'=>17, 'R'=>18, 'S'=>19, |
|
| 525 | + 'T'=>20, 'U'=>21, 'V'=>22, 'W'=>23, 'X'=>24, 'Y'=>25, 'Z'=>26, '['=>27, '\\'=>28, ']'=>29, |
|
| 526 | + '^'=>30, '_'=>31, ' '=>32, '!'=>33, '\"'=>34, '#'=>35, '$'=>36, '%'=>37, '&'=>38, '\''=>39, |
|
| 527 | + '('=>40, ')'=>41, '*'=>42, '+'=>43, ','=>44, '-'=>45, '.'=>46, '/'=>47, '0'=>48, '1'=>49, |
|
| 528 | + '2'=>50, '3'=>51, '4'=>52, '5'=>53, '6'=>54, '7'=>55, '8'=>56, '9'=>57, ':'=>58, ';'=>59, |
|
| 529 | + '<'=>60, '='=>61, '>'=>62, '?'=>63 |
|
| 530 | 530 | ); |
| 531 | 531 | // " |
| 532 | 532 | $_a = str_split($name); |
@@ -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,102 +105,102 @@ 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 | - if (!isset($this->all_tracked[$id]['arrival_code'])) { |
|
| 173 | + if (!isset($this->all_tracked[$id]['arrival_code'])) { |
|
| 174 | 174 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
| 175 | 175 | if ($this->all_tracked[$id]['addedMarine'] != 0) { |
| 176 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
| 176 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
| 177 | 177 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 178 | - $Marine = new Marine($this->db); |
|
| 179 | - $fromsource = NULL; |
|
| 180 | - $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource); |
|
| 181 | - $Marine->db = null; |
|
| 178 | + $Marine = new Marine($this->db); |
|
| 179 | + $fromsource = NULL; |
|
| 180 | + $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource); |
|
| 181 | + $Marine->db = null; |
|
| 182 | + } |
|
| 182 | 183 | } |
| 183 | - } |
|
| 184 | 184 | } |
| 185 | - } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) { |
|
| 185 | + } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) { |
|
| 186 | 186 | $this->all_tracked[$id]['arrival_code'] = $line['arrival_code']; |
| 187 | 187 | if (!isset($line['id'])) { |
| 188 | 188 | $this->all_tracked[$id]['id'] = $id.'-'.date('YmdHi'); |
| 189 | 189 | $this->all_tracked[$id]['forcenew'] = 1; |
| 190 | 190 | $this->all_tracked[$id]['addedMarine'] = 0; |
| 191 | 191 | } |
| 192 | - } |
|
| 192 | + } |
|
| 193 | 193 | } |
| 194 | 194 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
| 195 | - if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
| 195 | + if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | //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'])) { |
| 199 | 199 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
| 200 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
| 201 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
| 200 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
| 201 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
| 202 | 202 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 203 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 203 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 204 | 204 | $timeelapsed = microtime(true); |
| 205 | 205 | $Marine = new Marine($this->db); |
| 206 | 206 | $fromsource = NULL; |
@@ -209,20 +209,20 @@ discard block |
||
| 209 | 209 | $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']); |
| 210 | 210 | $Marine->db = null; |
| 211 | 211 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 212 | - } |
|
| 212 | + } |
|
| 213 | + } |
|
| 213 | 214 | } |
| 214 | - } |
|
| 215 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 215 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
| 219 | - if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
| 219 | + if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
| 220 | 220 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
| 221 | - } else { |
|
| 221 | + } else { |
|
| 222 | 222 | 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"; |
| 223 | 223 | 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"; |
| 224 | 224 | return ''; |
| 225 | - } |
|
| 225 | + } |
|
| 226 | 226 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
| 227 | 227 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
| 228 | 228 | return ''; |
@@ -239,24 +239,24 @@ discard block |
||
| 239 | 239 | |
| 240 | 240 | |
| 241 | 241 | if (isset($line['speed'])) { |
| 242 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
| 243 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
| 242 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
| 243 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
| 244 | 244 | } 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'])) { |
| 245 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
| 246 | - if ($distance > 1000 && $distance < 10000) { |
|
| 245 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
| 246 | + if ($distance > 1000 && $distance < 10000) { |
|
| 247 | 247 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
| 248 | 248 | $speed = $speed*3.6; |
| 249 | 249 | if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
| 250 | 250 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
| 251 | - } |
|
| 251 | + } |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
| 255 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 256 | - else unset($timediff); |
|
| 257 | - 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')))) { |
|
| 254 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
| 255 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 256 | + else unset($timediff); |
|
| 257 | + 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')))) { |
|
| 258 | 258 | 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'])) { |
| 259 | - 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'])) { |
|
| 259 | + 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'])) { |
|
| 260 | 260 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 261 | 261 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 262 | 262 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -264,211 +264,211 @@ discard block |
||
| 264 | 264 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
| 265 | 265 | $timeelapsed = microtime(true); |
| 266 | 266 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 267 | - $Marine = new Marine($this->db); |
|
| 268 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
| 269 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 270 | - $Marine->db = null; |
|
| 271 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 267 | + $Marine = new Marine($this->db); |
|
| 268 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
| 269 | + if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 270 | + $Marine->db = null; |
|
| 271 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 272 | 272 | } |
| 273 | 273 | $this->tmd = 0; |
| 274 | 274 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
| 275 | - } |
|
| 275 | + } |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 279 | 279 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 280 | 280 | 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') { |
| 281 | - $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
| 282 | - $dataFound = true; |
|
| 283 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 281 | + $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
| 282 | + $dataFound = true; |
|
| 283 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 284 | 284 | } |
| 285 | 285 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
| 286 | 286 | } |
| 287 | 287 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 288 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 288 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 289 | 289 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 290 | 290 | 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') { |
| 291 | - $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
| 292 | - $dataFound = true; |
|
| 293 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 291 | + $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
| 292 | + $dataFound = true; |
|
| 293 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
| 294 | 294 | } |
| 295 | 295 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | - } else if ($globalDebug && $timediff > 20) { |
|
| 298 | + } else if ($globalDebug && $timediff > 20) { |
|
| 299 | 299 | $this->tmd = $this->tmd + 1; |
| 300 | 300 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
| 301 | 301 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
| 302 | 302 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
| 303 | 303 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
| 304 | - } |
|
| 304 | + } |
|
| 305 | 305 | } |
| 306 | 306 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 307 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 308 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
| 307 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 308 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
| 309 | 309 | } |
| 310 | 310 | if (isset($line['format_source']) && $line['format_source'] != '') { |
| 311 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
| 311 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
| 312 | 312 | } |
| 313 | 313 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 314 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
| 314 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
| 315 | 315 | } |
| 316 | 316 | if (isset($line['status']) && $line['status'] != '') { |
| 317 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
| 317 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
| 318 | 318 | } |
| 319 | 319 | if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) { |
| 320 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
| 321 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
| 320 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
| 321 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
| 322 | 322 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 323 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 323 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 324 | 324 | $Marine = new Marine($this->db); |
| 325 | 325 | $Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']); |
| 326 | 326 | unset($Marine); |
| 327 | - } |
|
| 327 | + } |
|
| 328 | + } |
|
| 328 | 329 | } |
| 329 | - } |
|
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
| 333 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
| 333 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | if (isset($line['heading']) && $line['heading'] != '') { |
| 337 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 338 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
| 339 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
| 340 | - //$dataFound = true; |
|
| 337 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 338 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
| 339 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
| 340 | + //$dataFound = true; |
|
| 341 | 341 | } 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']) { |
| 342 | - $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']); |
|
| 343 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
| 344 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 345 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 342 | + $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']); |
|
| 343 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
| 344 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 345 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 346 | 346 | } |
| 347 | 347 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
| 348 | 348 | |
| 349 | 349 | |
| 350 | 350 | |
| 351 | 351 | if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) { |
| 352 | - $this->all_tracked[$id]['lastupdate'] = time(); |
|
| 353 | - if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
| 354 | - 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'])) { |
|
| 355 | - if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
| 352 | + $this->all_tracked[$id]['lastupdate'] = time(); |
|
| 353 | + if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
| 354 | + 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'])) { |
|
| 355 | + if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
| 356 | 356 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 357 | - if ($globalDebug) echo "Check if vessel is already in DB..."; |
|
| 358 | - $timeelapsed = microtime(true); |
|
| 359 | - $MarineLive = new MarineLive($this->db); |
|
| 360 | - if (isset($line['id'])) { |
|
| 357 | + if ($globalDebug) echo "Check if vessel is already in DB..."; |
|
| 358 | + $timeelapsed = microtime(true); |
|
| 359 | + $MarineLive = new MarineLive($this->db); |
|
| 360 | + if (isset($line['id'])) { |
|
| 361 | 361 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
| 362 | 362 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 363 | - } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
| 363 | + } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
| 364 | 364 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
| 365 | 365 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 366 | - } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
| 366 | + } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
| 367 | 367 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
| 368 | 368 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 369 | - } else $recent_ident = ''; |
|
| 370 | - $MarineLive->db=null; |
|
| 371 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 372 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 369 | + } else $recent_ident = ''; |
|
| 370 | + $MarineLive->db=null; |
|
| 371 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 372 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 373 | 373 | } else $recent_ident = ''; |
| 374 | - } else { |
|
| 374 | + } else { |
|
| 375 | 375 | $recent_ident = ''; |
| 376 | 376 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
| 377 | - } |
|
| 378 | - //if there was no vessel with the same callsign within the last hour and go post it into the archive |
|
| 379 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
| 380 | - { |
|
| 377 | + } |
|
| 378 | + //if there was no vessel with the same callsign within the last hour and go post it into the archive |
|
| 379 | + if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
| 380 | + { |
|
| 381 | 381 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
| 382 | 382 | //adds the spotter data for the archive |
| 383 | - $highlight = ''; |
|
| 384 | - 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'))); |
|
| 385 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
| 383 | + $highlight = ''; |
|
| 384 | + 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'))); |
|
| 385 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
| 386 | 386 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 387 | - $timeelapsed = microtime(true); |
|
| 388 | - $Marine = new Marine($this->db); |
|
| 389 | - $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']); |
|
| 390 | - $Marine->db = null; |
|
| 391 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 392 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 387 | + $timeelapsed = microtime(true); |
|
| 388 | + $Marine = new Marine($this->db); |
|
| 389 | + $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']); |
|
| 390 | + $Marine->db = null; |
|
| 391 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 392 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 393 | 393 | } |
| 394 | - } |
|
| 395 | - if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
|
| 394 | + } |
|
| 395 | + if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
|
| 396 | 396 | // Add source stat in DB |
| 397 | 397 | $Stats = new Stats($this->db); |
| 398 | 398 | if (!empty($this->stats)) { |
| 399 | - if ($globalDebug) echo 'Add source stats : '; |
|
| 400 | - foreach($this->stats as $date => $data) { |
|
| 399 | + if ($globalDebug) echo 'Add source stats : '; |
|
| 400 | + foreach($this->stats as $date => $data) { |
|
| 401 | 401 | foreach($data as $source => $sourced) { |
| 402 | - //print_r($sourced); |
|
| 403 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
| 404 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
| 405 | - if (isset($sourced['msg'])) { |
|
| 406 | - if (time() - $sourced['msg']['date'] > 10) { |
|
| 407 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
| 408 | - echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
| 409 | - unset($this->stats[$date][$source]['msg']); |
|
| 410 | - } |
|
| 411 | - } |
|
| 412 | - } |
|
| 413 | - if ($date != date('Y-m-d')) { |
|
| 414 | - unset($this->stats[$date]); |
|
| 415 | - } |
|
| 416 | - } |
|
| 417 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 402 | + //print_r($sourced); |
|
| 403 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
| 404 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
| 405 | + if (isset($sourced['msg'])) { |
|
| 406 | + if (time() - $sourced['msg']['date'] > 10) { |
|
| 407 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
| 408 | + echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
| 409 | + unset($this->stats[$date][$source]['msg']); |
|
| 410 | + } |
|
| 411 | + } |
|
| 412 | + } |
|
| 413 | + if ($date != date('Y-m-d')) { |
|
| 414 | + unset($this->stats[$date]); |
|
| 415 | + } |
|
| 416 | + } |
|
| 417 | + if ($globalDebug) echo 'Done'."\n"; |
|
| 418 | 418 | } |
| 419 | 419 | $Stats->db = null; |
| 420 | - } |
|
| 420 | + } |
|
| 421 | 421 | |
| 422 | - $this->del(); |
|
| 422 | + $this->del(); |
|
| 423 | 423 | //$ignoreImport = false; |
| 424 | 424 | $this->all_tracked[$id]['addedMarine'] = 1; |
| 425 | 425 | //print_r($this->all_tracked[$id]); |
| 426 | 426 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 427 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
| 428 | - //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
| 429 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 427 | + if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
| 428 | + //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
| 429 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 430 | 430 | $MarineLive = new MarineLive($this->db); |
| 431 | 431 | $MarineLive->deleteLiveMarineData(); |
| 432 | 432 | $MarineLive->db=null; |
| 433 | 433 | if ($globalDebug) echo " Done\n"; |
| 434 | - } |
|
| 435 | - $this->last_delete = time(); |
|
| 434 | + } |
|
| 435 | + $this->last_delete = time(); |
|
| 436 | 436 | } |
| 437 | - } elseif ($recent_ident != '') { |
|
| 437 | + } elseif ($recent_ident != '') { |
|
| 438 | 438 | $this->all_tracked[$id]['id'] = $recent_ident; |
| 439 | 439 | $this->all_tracked[$id]['addedMarine'] = 1; |
| 440 | 440 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 441 | - if (isset($globalDaemon) && !$globalDaemon) { |
|
| 441 | + if (isset($globalDaemon) && !$globalDaemon) { |
|
| 442 | 442 | $Marine = new Marine($this->db); |
| 443 | 443 | $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']); |
| 444 | 444 | $Marine->db = null; |
| 445 | - } |
|
| 445 | + } |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | - } |
|
| 448 | + } |
|
| 449 | + } |
|
| 449 | 450 | } |
| 450 | - } |
|
| 451 | - //adds the spotter LIVE data |
|
| 452 | - if ($globalDebug) { |
|
| 451 | + //adds the spotter LIVE data |
|
| 452 | + if ($globalDebug) { |
|
| 453 | 453 | 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"; |
| 454 | - } |
|
| 455 | - $ignoreImport = false; |
|
| 454 | + } |
|
| 455 | + $ignoreImport = false; |
|
| 456 | 456 | |
| 457 | - if (!$ignoreImport) { |
|
| 457 | + if (!$ignoreImport) { |
|
| 458 | 458 | 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'])) { |
| 459 | 459 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
| 460 | 460 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 461 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 461 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 462 | 462 | $timeelapsed = microtime(true); |
| 463 | 463 | $MarineLive = new MarineLive($this->db); |
| 464 | 464 | $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']); |
| 465 | 465 | $MarineLive->db = null; |
| 466 | 466 | if ($globalDebug) echo $result."\n"; |
| 467 | 467 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 468 | - } |
|
| 468 | + } |
|
| 469 | 469 | } |
| 470 | 470 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
| 471 | - $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']); |
|
| 471 | + $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']); |
|
| 472 | 472 | } |
| 473 | 473 | $this->all_tracked[$id]['putinarchive'] = false; |
| 474 | 474 | |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | if ($stats_heading == 16) $stats_heading = 0; |
| 501 | 501 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 502 | 502 | for ($i=0;$i<=15;$i++) { |
| 503 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
| 503 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
| 504 | 504 | } |
| 505 | 505 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
| 506 | 506 | } else { |
@@ -513,11 +513,11 @@ discard block |
||
| 513 | 513 | //var_dump($this->stats); |
| 514 | 514 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
| 515 | 515 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 516 | - end($this->stats[$current_date][$source]['hist']); |
|
| 517 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
| 516 | + end($this->stats[$current_date][$source]['hist']); |
|
| 517 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
| 518 | 518 | } else $mini = 0; |
| 519 | 519 | for ($i=$mini;$i<=$distance;$i+=10) { |
| 520 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
| 520 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
| 521 | 521 | } |
| 522 | 522 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
| 523 | 523 | } else { |
@@ -533,24 +533,24 @@ discard block |
||
| 533 | 533 | |
| 534 | 534 | |
| 535 | 535 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 536 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 536 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
| 537 | 537 | if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
| 538 | 538 | $MarineLive = new MarineLive($this->db); |
| 539 | 539 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
| 540 | 540 | $MarineLive->db = null; |
| 541 | 541 | //MarineLive->deleteLiveMarineData(); |
| 542 | 542 | if ($globalDebug) echo " Done\n"; |
| 543 | - } |
|
| 544 | - $this->last_delete_hourly = time(); |
|
| 543 | + } |
|
| 544 | + $this->last_delete_hourly = time(); |
|
| 545 | 545 | } |
| 546 | 546 | |
| 547 | - } |
|
| 548 | - //$ignoreImport = false; |
|
| 547 | + } |
|
| 548 | + //$ignoreImport = false; |
|
| 549 | 549 | } |
| 550 | 550 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 551 | 551 | if ($send) return $this->all_tracked[$id]; |
| 552 | - } |
|
| 552 | + } |
|
| 553 | + } |
|
| 553 | 554 | } |
| 554 | - } |
|
| 555 | 555 | } |
| 556 | 556 | ?> |
@@ -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,30 +154,30 @@ 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 | 173 | if (!isset($this->all_tracked[$id]['arrival_code'])) { |
| 174 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
| 174 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_code' => $line['arrival_code'])); |
|
| 175 | 175 | if ($this->all_tracked[$id]['addedMarine'] != 0) { |
| 176 | 176 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 177 | 177 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 178 | 178 | $Marine = new Marine($this->db); |
| 179 | 179 | $fromsource = NULL; |
| 180 | - $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource); |
|
| 180 | + $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['arrival_code'], $fromsource); |
|
| 181 | 181 | $Marine->db = null; |
| 182 | 182 | } |
| 183 | 183 | } |
@@ -192,46 +192,46 @@ discard block |
||
| 192 | 192 | } |
| 193 | 193 | } |
| 194 | 194 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
| 195 | - if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
| 195 | + if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_date' => $line['arrival_date'])); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | //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'])) { |
| 199 | 199 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
| 200 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
| 200 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident']))); |
|
| 201 | 201 | if ($this->all_tracked[$id]['addedMarine'] == 1) { |
| 202 | 202 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 203 | 203 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 204 | 204 | $timeelapsed = microtime(true); |
| 205 | 205 | $Marine = new Marine($this->db); |
| 206 | 206 | $fromsource = NULL; |
| 207 | - $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
| 207 | + $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource); |
|
| 208 | 208 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 209 | - $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']); |
|
| 209 | + $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']); |
|
| 210 | 210 | $Marine->db = null; |
| 211 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 211 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 212 | 212 | } |
| 213 | 213 | } |
| 214 | 214 | } |
| 215 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 215 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'])); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
|
| 218 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 30*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
| 219 | 219 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
| 220 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
|
| 220 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime'])); |
|
| 221 | 221 | } else { |
| 222 | 222 | 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"; |
| 223 | 223 | 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"; |
| 224 | 224 | return ''; |
| 225 | 225 | } |
| 226 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
|
| 226 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time() - 30*60) { |
|
| 227 | 227 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
| 228 | 228 | return ''; |
| 229 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) { |
|
| 229 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time() + 20*60) { |
|
| 230 | 230 | if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
| 231 | 231 | return ''; |
| 232 | 232 | } elseif (!isset($line['datetime'])) { |
| 233 | 233 | date_default_timezone_set('UTC'); |
| 234 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 234 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
| 235 | 235 | } else { |
| 236 | 236 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!"; |
| 237 | 237 | return ''; |
@@ -239,24 +239,24 @@ discard block |
||
| 239 | 239 | |
| 240 | 240 | |
| 241 | 241 | if (isset($line['speed'])) { |
| 242 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
| 243 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
| 242 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed']))); |
|
| 243 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true)); |
|
| 244 | 244 | } 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'])) { |
| 245 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
| 245 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm'); |
|
| 246 | 246 | if ($distance > 1000 && $distance < 10000) { |
| 247 | 247 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
| 248 | 248 | $speed = $speed*3.6; |
| 249 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
| 249 | + if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed))); |
|
| 250 | 250 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
| 251 | 251 | } |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
| 255 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 255 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']); |
|
| 256 | 256 | else unset($timediff); |
| 257 | - 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')))) { |
|
| 257 | + 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')))) { |
|
| 258 | 258 | 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'])) { |
| 259 | - 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'])) { |
|
| 259 | + 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'])) { |
|
| 260 | 260 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 261 | 261 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 262 | 262 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -265,10 +265,10 @@ discard block |
||
| 265 | 265 | $timeelapsed = microtime(true); |
| 266 | 266 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 267 | 267 | $Marine = new Marine($this->db); |
| 268 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
| 268 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
| 269 | 269 | if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
| 270 | 270 | $Marine->db = null; |
| 271 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 271 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 272 | 272 | } |
| 273 | 273 | $this->tmd = 0; |
| 274 | 274 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
@@ -277,52 +277,52 @@ discard block |
||
| 277 | 277 | |
| 278 | 278 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 279 | 279 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 280 | - 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') { |
|
| 280 | + 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') { |
|
| 281 | 281 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
| 282 | 282 | $dataFound = true; |
| 283 | 283 | $this->all_tracked[$id]['time_last_coord'] = time(); |
| 284 | 284 | } |
| 285 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
|
| 285 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude'])); |
|
| 286 | 286 | } |
| 287 | 287 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 288 | 288 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
| 289 | 289 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 290 | - 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') { |
|
| 290 | + 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') { |
|
| 291 | 291 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
| 292 | 292 | $dataFound = true; |
| 293 | 293 | $this->all_tracked[$id]['time_last_coord'] = time(); |
| 294 | 294 | } |
| 295 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
|
| 295 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude'])); |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | } else if ($globalDebug && $timediff > 20) { |
| 299 | 299 | $this->tmd = $this->tmd + 1; |
| 300 | 300 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
| 301 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
|
| 302 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
| 301 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -"; |
|
| 302 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
| 303 | 303 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
| 304 | 304 | } |
| 305 | 305 | } |
| 306 | 306 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 307 | 307 | if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
| 308 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
| 308 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update'])); |
|
| 309 | 309 | } |
| 310 | 310 | if (isset($line['format_source']) && $line['format_source'] != '') { |
| 311 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
| 311 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source'])); |
|
| 312 | 312 | } |
| 313 | 313 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 314 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
| 314 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name'])); |
|
| 315 | 315 | } |
| 316 | 316 | if (isset($line['status']) && $line['status'] != '') { |
| 317 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
| 317 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status' => $line['status'])); |
|
| 318 | 318 | } |
| 319 | 319 | if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) { |
| 320 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
| 320 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status_id' => $line['status_id'])); |
|
| 321 | 321 | if ($this->all_tracked[$id]['addedMarine'] == 1) { |
| 322 | 322 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 323 | 323 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 324 | 324 | $Marine = new Marine($this->db); |
| 325 | - $Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']); |
|
| 325 | + $Marine->updateStatusMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['status']); |
|
| 326 | 326 | unset($Marine); |
| 327 | 327 | } |
| 328 | 328 | } |
@@ -330,18 +330,18 @@ discard block |
||
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
| 333 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
| 333 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true)); |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | if (isset($line['heading']) && $line['heading'] != '') { |
| 337 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 338 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
| 339 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
| 337 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 338 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading']))); |
|
| 339 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true)); |
|
| 340 | 340 | //$dataFound = true; |
| 341 | 341 | } 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']) { |
| 342 | - $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']); |
|
| 343 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
| 344 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 342 | + $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']); |
|
| 343 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading))); |
|
| 344 | + if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 345 | 345 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
| 346 | 346 | } |
| 347 | 347 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) { |
| 352 | 352 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 353 | 353 | if ($this->all_tracked[$id]['addedMarine'] == 0) { |
| 354 | - 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'])) { |
|
| 354 | + 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'])) { |
|
| 355 | 355 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
| 356 | 356 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 357 | 357 | if ($globalDebug) echo "Check if vessel is already in DB..."; |
@@ -359,37 +359,37 @@ discard block |
||
| 359 | 359 | $MarineLive = new MarineLive($this->db); |
| 360 | 360 | if (isset($line['id'])) { |
| 361 | 361 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
| 362 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 362 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 363 | 363 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
| 364 | 364 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
| 365 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 365 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 366 | 366 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
| 367 | 367 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
| 368 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 368 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 369 | 369 | } else $recent_ident = ''; |
| 370 | - $MarineLive->db=null; |
|
| 370 | + $MarineLive->db = null; |
|
| 371 | 371 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
| 372 | 372 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
| 373 | 373 | } else $recent_ident = ''; |
| 374 | 374 | } else { |
| 375 | 375 | $recent_ident = ''; |
| 376 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
|
| 376 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0)); |
|
| 377 | 377 | } |
| 378 | 378 | //if there was no vessel with the same callsign within the last hour and go post it into the archive |
| 379 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
| 379 | + if ($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
| 380 | 380 | { |
| 381 | 381 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
| 382 | 382 | //adds the spotter data for the archive |
| 383 | 383 | $highlight = ''; |
| 384 | - 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'))); |
|
| 384 | + 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'))); |
|
| 385 | 385 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 386 | 386 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 387 | 387 | $timeelapsed = microtime(true); |
| 388 | 388 | $Marine = new Marine($this->db); |
| 389 | - $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']); |
|
| 389 | + $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']); |
|
| 390 | 390 | $Marine->db = null; |
| 391 | 391 | if ($globalDebug && isset($result)) echo $result."\n"; |
| 392 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 392 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 393 | 393 | } |
| 394 | 394 | } |
| 395 | 395 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
@@ -397,15 +397,15 @@ discard block |
||
| 397 | 397 | $Stats = new Stats($this->db); |
| 398 | 398 | if (!empty($this->stats)) { |
| 399 | 399 | if ($globalDebug) echo 'Add source stats : '; |
| 400 | - foreach($this->stats as $date => $data) { |
|
| 401 | - foreach($data as $source => $sourced) { |
|
| 400 | + foreach ($this->stats as $date => $data) { |
|
| 401 | + foreach ($data as $source => $sourced) { |
|
| 402 | 402 | //print_r($sourced); |
| 403 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
| 404 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
| 403 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar_marine', $date); |
|
| 404 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist_marine', $date); |
|
| 405 | 405 | if (isset($sourced['msg'])) { |
| 406 | 406 | if (time() - $sourced['msg']['date'] > 10) { |
| 407 | 407 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
| 408 | - echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
| 408 | + echo $Stats->addStatSource($nbmsg, $source, 'msg_marine', $date); |
|
| 409 | 409 | unset($this->stats[$date][$source]['msg']); |
| 410 | 410 | } |
| 411 | 411 | } |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 430 | 430 | $MarineLive = new MarineLive($this->db); |
| 431 | 431 | $MarineLive->deleteLiveMarineData(); |
| 432 | - $MarineLive->db=null; |
|
| 432 | + $MarineLive->db = null; |
|
| 433 | 433 | if ($globalDebug) echo " Done\n"; |
| 434 | 434 | } |
| 435 | 435 | $this->last_delete = time(); |
@@ -440,7 +440,7 @@ discard block |
||
| 440 | 440 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 441 | 441 | if (isset($globalDaemon) && !$globalDaemon) { |
| 442 | 442 | $Marine = new Marine($this->db); |
| 443 | - $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']); |
|
| 443 | + $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']); |
|
| 444 | 444 | $Marine->db = null; |
| 445 | 445 | } |
| 446 | 446 | } |
@@ -455,20 +455,20 @@ discard block |
||
| 455 | 455 | $ignoreImport = false; |
| 456 | 456 | |
| 457 | 457 | if (!$ignoreImport) { |
| 458 | - 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'])) { |
|
| 458 | + 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'])) { |
|
| 459 | 459 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
| 460 | 460 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 461 | 461 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 462 | 462 | $timeelapsed = microtime(true); |
| 463 | 463 | $MarineLive = new MarineLive($this->db); |
| 464 | - $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']); |
|
| 464 | + $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']); |
|
| 465 | 465 | $MarineLive->db = null; |
| 466 | 466 | if ($globalDebug) echo $result."\n"; |
| 467 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 467 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 468 | 468 | } |
| 469 | 469 | } |
| 470 | 470 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
| 471 | - $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']); |
|
| 471 | + $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']); |
|
| 472 | 472 | } |
| 473 | 473 | $this->all_tracked[$id]['putinarchive'] = false; |
| 474 | 474 | |
@@ -487,19 +487,19 @@ discard block |
||
| 487 | 487 | $latitude = $globalCenterLatitude; |
| 488 | 488 | $longitude = $globalCenterLongitude; |
| 489 | 489 | } |
| 490 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
| 490 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
| 491 | 491 | } else { |
| 492 | 492 | $latitude = $this->source_location[$source]['latitude']; |
| 493 | 493 | $longitude = $this->source_location[$source]['longitude']; |
| 494 | 494 | } |
| 495 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
| 495 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
| 496 | 496 | //$stats_heading = $stats_heading%22.5; |
| 497 | 497 | $stats_heading = round($stats_heading/22.5); |
| 498 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
| 498 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
| 499 | 499 | $current_date = date('Y-m-d'); |
| 500 | 500 | if ($stats_heading == 16) $stats_heading = 0; |
| 501 | 501 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 502 | - for ($i=0;$i<=15;$i++) { |
|
| 502 | + for ($i = 0; $i <= 15; $i++) { |
|
| 503 | 503 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
| 504 | 504 | } |
| 505 | 505 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -514,9 +514,9 @@ discard block |
||
| 514 | 514 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
| 515 | 515 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 516 | 516 | end($this->stats[$current_date][$source]['hist']); |
| 517 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
| 517 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
| 518 | 518 | } else $mini = 0; |
| 519 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
| 519 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
| 520 | 520 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
| 521 | 521 | } |
| 522 | 522 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -528,7 +528,7 @@ discard block |
||
| 528 | 528 | |
| 529 | 529 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 530 | 530 | if ($this->all_tracked[$id]['putinarchive']) $send = true; |
| 531 | - } 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"; |
|
| 531 | + } 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"; |
|
| 532 | 532 | //$this->del(); |
| 533 | 533 | |
| 534 | 534 | |
@@ -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']) { |
@@ -192,7 +218,9 @@ discard block |
||
| 192 | 218 | } |
| 193 | 219 | } |
| 194 | 220 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
| 195 | - if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
| 221 | + if (strtotime($line['arrival_date']) > time()) { |
|
| 222 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
| 223 | + } |
|
| 196 | 224 | } |
| 197 | 225 | |
| 198 | 226 | //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'])) { |
@@ -205,35 +233,50 @@ discard block |
||
| 205 | 233 | $Marine = new Marine($this->db); |
| 206 | 234 | $fromsource = NULL; |
| 207 | 235 | $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
| 208 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 236 | + if ($globalDebug && $result != 'success') { |
|
| 237 | + echo '!!! ERROR : '.$result."\n"; |
|
| 238 | + } |
|
| 209 | 239 | $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']); |
| 210 | 240 | $Marine->db = null; |
| 211 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 241 | + if ($globalDebugTimeElapsed) { |
|
| 242 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 243 | + } |
|
| 212 | 244 | } |
| 213 | 245 | } |
| 214 | 246 | } |
| 215 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 247 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
| 248 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 249 | + } |
|
| 216 | 250 | } |
| 217 | 251 | |
| 218 | 252 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
| 219 | 253 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
| 220 | 254 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
| 221 | 255 | } else { |
| 222 | - 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"; |
|
| 223 | - 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"; |
|
| 256 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
| 257 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
| 258 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
| 259 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 260 | + } |
|
| 224 | 261 | return ''; |
| 225 | 262 | } |
| 226 | 263 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
| 227 | - if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
| 264 | + if ($globalDebug) { |
|
| 265 | + echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
| 266 | + } |
|
| 228 | 267 | return ''; |
| 229 | 268 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) { |
| 230 | - if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
| 269 | + if ($globalDebug) { |
|
| 270 | + echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
| 271 | + } |
|
| 231 | 272 | return ''; |
| 232 | 273 | } elseif (!isset($line['datetime'])) { |
| 233 | 274 | date_default_timezone_set('UTC'); |
| 234 | 275 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
| 235 | 276 | } else { |
| 236 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!"; |
|
| 277 | + if ($globalDebug) { |
|
| 278 | + echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!"; |
|
| 279 | + } |
|
| 237 | 280 | return ''; |
| 238 | 281 | } |
| 239 | 282 | |
@@ -246,14 +289,21 @@ discard block |
||
| 246 | 289 | if ($distance > 1000 && $distance < 10000) { |
| 247 | 290 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
| 248 | 291 | $speed = $speed*3.6; |
| 249 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
| 250 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
| 292 | + if ($speed < 1000) { |
|
| 293 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
| 294 | + } |
|
| 295 | + if ($globalDebug) { |
|
| 296 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
| 297 | + } |
|
| 251 | 298 | } |
| 252 | 299 | } |
| 253 | 300 | |
| 254 | 301 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
| 255 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 256 | - else unset($timediff); |
|
| 302 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
| 303 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 304 | + } else { |
|
| 305 | + unset($timediff); |
|
| 306 | + } |
|
| 257 | 307 | 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')))) { |
| 258 | 308 | 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'])) { |
| 259 | 309 | 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'])) { |
@@ -261,22 +311,32 @@ discard block |
||
| 261 | 311 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 262 | 312 | $this->all_tracked[$id]['putinarchive'] = true; |
| 263 | 313 | |
| 264 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 314 | + if ($globalDebug) { |
|
| 315 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 316 | + } |
|
| 265 | 317 | $timeelapsed = microtime(true); |
| 266 | 318 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 267 | 319 | $Marine = new Marine($this->db); |
| 268 | 320 | $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
| 269 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 321 | + if (!empty($all_country)) { |
|
| 322 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 323 | + } |
|
| 270 | 324 | $Marine->db = null; |
| 271 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 325 | + if ($globalDebugTimeElapsed) { |
|
| 326 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 327 | + } |
|
| 272 | 328 | } |
| 273 | 329 | $this->tmd = 0; |
| 274 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
| 330 | + if ($globalDebug) { |
|
| 331 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
| 332 | + } |
|
| 275 | 333 | } |
| 276 | 334 | } |
| 277 | 335 | |
| 278 | 336 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 279 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
| 337 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
| 338 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
| 339 | + } |
|
| 280 | 340 | 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') { |
| 281 | 341 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
| 282 | 342 | $dataFound = true; |
@@ -285,8 +345,12 @@ discard block |
||
| 285 | 345 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
| 286 | 346 | } |
| 287 | 347 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 288 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 289 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
| 348 | + if ($line['longitude'] > 180) { |
|
| 349 | + $line['longitude'] = $line['longitude'] - 360; |
|
| 350 | + } |
|
| 351 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
| 352 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
| 353 | + } |
|
| 290 | 354 | 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') { |
| 291 | 355 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
| 292 | 356 | $dataFound = true; |
@@ -304,7 +368,9 @@ discard block |
||
| 304 | 368 | } |
| 305 | 369 | } |
| 306 | 370 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 307 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 371 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
| 372 | + $dataFound = true; |
|
| 373 | + } |
|
| 308 | 374 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
| 309 | 375 | } |
| 310 | 376 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -334,15 +400,21 @@ discard block |
||
| 334 | 400 | } |
| 335 | 401 | |
| 336 | 402 | if (isset($line['heading']) && $line['heading'] != '') { |
| 337 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 403 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
| 404 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 405 | + } |
|
| 338 | 406 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
| 339 | 407 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
| 340 | 408 | //$dataFound = true; |
| 341 | 409 | } 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']) { |
| 342 | 410 | $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']); |
| 343 | 411 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
| 344 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 345 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 412 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
| 413 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 414 | + } |
|
| 415 | + if ($globalDebug) { |
|
| 416 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 417 | + } |
|
| 346 | 418 | } |
| 347 | 419 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
| 348 | 420 | |
@@ -354,23 +426,38 @@ discard block |
||
| 354 | 426 | 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'])) { |
| 355 | 427 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
| 356 | 428 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 357 | - if ($globalDebug) echo "Check if vessel is already in DB..."; |
|
| 429 | + if ($globalDebug) { |
|
| 430 | + echo "Check if vessel is already in DB..."; |
|
| 431 | + } |
|
| 358 | 432 | $timeelapsed = microtime(true); |
| 359 | 433 | $MarineLive = new MarineLive($this->db); |
| 360 | 434 | if (isset($line['id'])) { |
| 361 | 435 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
| 362 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 436 | + if ($globalDebugTimeElapsed) { |
|
| 437 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 438 | + } |
|
| 363 | 439 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
| 364 | 440 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
| 365 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 441 | + if ($globalDebugTimeElapsed) { |
|
| 442 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 443 | + } |
|
| 366 | 444 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
| 367 | 445 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
| 368 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 369 | - } else $recent_ident = ''; |
|
| 446 | + if ($globalDebugTimeElapsed) { |
|
| 447 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 448 | + } |
|
| 449 | + } else { |
|
| 450 | + $recent_ident = ''; |
|
| 451 | + } |
|
| 370 | 452 | $MarineLive->db=null; |
| 371 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 372 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 373 | - } else $recent_ident = ''; |
|
| 453 | + if ($globalDebug && $recent_ident == '') { |
|
| 454 | + echo " Not in DB.\n"; |
|
| 455 | + } elseif ($globalDebug && $recent_ident != '') { |
|
| 456 | + echo " Already in DB.\n"; |
|
| 457 | + } |
|
| 458 | + } else { |
|
| 459 | + $recent_ident = ''; |
|
| 460 | + } |
|
| 374 | 461 | } else { |
| 375 | 462 | $recent_ident = ''; |
| 376 | 463 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -378,30 +465,44 @@ discard block |
||
| 378 | 465 | //if there was no vessel with the same callsign within the last hour and go post it into the archive |
| 379 | 466 | if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
| 380 | 467 | { |
| 381 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
| 468 | + if ($globalDebug) { |
|
| 469 | + echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
| 470 | + } |
|
| 382 | 471 | //adds the spotter data for the archive |
| 383 | 472 | $highlight = ''; |
| 384 | - 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'))); |
|
| 473 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
| 474 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
| 475 | + } |
|
| 385 | 476 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 386 | 477 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 387 | 478 | $timeelapsed = microtime(true); |
| 388 | 479 | $Marine = new Marine($this->db); |
| 389 | 480 | $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']); |
| 390 | 481 | $Marine->db = null; |
| 391 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 392 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 482 | + if ($globalDebug && isset($result)) { |
|
| 483 | + echo $result."\n"; |
|
| 484 | + } |
|
| 485 | + if ($globalDebugTimeElapsed) { |
|
| 486 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 487 | + } |
|
| 393 | 488 | } |
| 394 | 489 | } |
| 395 | 490 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
| 396 | 491 | // Add source stat in DB |
| 397 | 492 | $Stats = new Stats($this->db); |
| 398 | 493 | if (!empty($this->stats)) { |
| 399 | - if ($globalDebug) echo 'Add source stats : '; |
|
| 494 | + if ($globalDebug) { |
|
| 495 | + echo 'Add source stats : '; |
|
| 496 | + } |
|
| 400 | 497 | foreach($this->stats as $date => $data) { |
| 401 | 498 | foreach($data as $source => $sourced) { |
| 402 | 499 | //print_r($sourced); |
| 403 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
| 404 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
| 500 | + if (isset($sourced['polar'])) { |
|
| 501 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
| 502 | + } |
|
| 503 | + if (isset($sourced['hist'])) { |
|
| 504 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
| 505 | + } |
|
| 405 | 506 | if (isset($sourced['msg'])) { |
| 406 | 507 | if (time() - $sourced['msg']['date'] > 10) { |
| 407 | 508 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -414,7 +515,9 @@ discard block |
||
| 414 | 515 | unset($this->stats[$date]); |
| 415 | 516 | } |
| 416 | 517 | } |
| 417 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 518 | + if ($globalDebug) { |
|
| 519 | + echo 'Done'."\n"; |
|
| 520 | + } |
|
| 418 | 521 | } |
| 419 | 522 | $Stats->db = null; |
| 420 | 523 | } |
@@ -424,13 +527,17 @@ discard block |
||
| 424 | 527 | $this->all_tracked[$id]['addedMarine'] = 1; |
| 425 | 528 | //print_r($this->all_tracked[$id]); |
| 426 | 529 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 427 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
| 530 | + if ($globalDebug) { |
|
| 531 | + echo "---- Deleting Live Marine data older than 9 hours..."; |
|
| 532 | + } |
|
| 428 | 533 | //MarineLive->deleteLiveMarineDataNotUpdated(); |
| 429 | 534 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 430 | 535 | $MarineLive = new MarineLive($this->db); |
| 431 | 536 | $MarineLive->deleteLiveMarineData(); |
| 432 | 537 | $MarineLive->db=null; |
| 433 | - if ($globalDebug) echo " Done\n"; |
|
| 538 | + if ($globalDebug) { |
|
| 539 | + echo " Done\n"; |
|
| 540 | + } |
|
| 434 | 541 | } |
| 435 | 542 | $this->last_delete = time(); |
| 436 | 543 | } |
@@ -456,15 +563,21 @@ discard block |
||
| 456 | 563 | |
| 457 | 564 | if (!$ignoreImport) { |
| 458 | 565 | 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'])) { |
| 459 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
| 566 | + if ($globalDebug) { |
|
| 567 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
| 568 | + } |
|
| 460 | 569 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 461 | 570 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 462 | 571 | $timeelapsed = microtime(true); |
| 463 | 572 | $MarineLive = new MarineLive($this->db); |
| 464 | 573 | $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']); |
| 465 | 574 | $MarineLive->db = null; |
| 466 | - if ($globalDebug) echo $result."\n"; |
|
| 467 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 575 | + if ($globalDebug) { |
|
| 576 | + echo $result."\n"; |
|
| 577 | + } |
|
| 578 | + if ($globalDebugTimeElapsed) { |
|
| 579 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 580 | + } |
|
| 468 | 581 | } |
| 469 | 582 | } |
| 470 | 583 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
@@ -476,7 +589,9 @@ discard block |
||
| 476 | 589 | |
| 477 | 590 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
| 478 | 591 | $source = $this->all_tracked[$id]['source_name']; |
| 479 | - if ($source == '') $source = $this->all_tracked[$id]['format_source']; |
|
| 592 | + if ($source == '') { |
|
| 593 | + $source = $this->all_tracked[$id]['format_source']; |
|
| 594 | + } |
|
| 480 | 595 | if (!isset($this->source_location[$source])) { |
| 481 | 596 | $Location = new Source($this->db); |
| 482 | 597 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -497,7 +612,9 @@ discard block |
||
| 497 | 612 | $stats_heading = round($stats_heading/22.5); |
| 498 | 613 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
| 499 | 614 | $current_date = date('Y-m-d'); |
| 500 | - if ($stats_heading == 16) $stats_heading = 0; |
|
| 615 | + if ($stats_heading == 16) { |
|
| 616 | + $stats_heading = 0; |
|
| 617 | + } |
|
| 501 | 618 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 502 | 619 | for ($i=0;$i<=15;$i++) { |
| 503 | 620 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -515,7 +632,9 @@ discard block |
||
| 515 | 632 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 516 | 633 | end($this->stats[$current_date][$source]['hist']); |
| 517 | 634 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
| 518 | - } else $mini = 0; |
|
| 635 | + } else { |
|
| 636 | + $mini = 0; |
|
| 637 | + } |
|
| 519 | 638 | for ($i=$mini;$i<=$distance;$i+=10) { |
| 520 | 639 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
| 521 | 640 | } |
@@ -527,19 +646,27 @@ discard block |
||
| 527 | 646 | |
| 528 | 647 | |
| 529 | 648 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 530 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
| 531 | - } 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"; |
|
| 649 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
| 650 | + $send = true; |
|
| 651 | + } |
|
| 652 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
| 653 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 654 | + } |
|
| 532 | 655 | //$this->del(); |
| 533 | 656 | |
| 534 | 657 | |
| 535 | 658 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 536 | 659 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 537 | - if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
| 660 | + if ($globalDebug) { |
|
| 661 | + echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
| 662 | + } |
|
| 538 | 663 | $MarineLive = new MarineLive($this->db); |
| 539 | 664 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
| 540 | 665 | $MarineLive->db = null; |
| 541 | 666 | //MarineLive->deleteLiveMarineData(); |
| 542 | - if ($globalDebug) echo " Done\n"; |
|
| 667 | + if ($globalDebug) { |
|
| 668 | + echo " Done\n"; |
|
| 669 | + } |
|
| 543 | 670 | } |
| 544 | 671 | $this->last_delete_hourly = time(); |
| 545 | 672 | } |
@@ -548,7 +675,9 @@ discard block |
||
| 548 | 675 | //$ignoreImport = false; |
| 549 | 676 | } |
| 550 | 677 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 551 | - if ($send) return $this->all_tracked[$id]; |
|
| 678 | + if ($send) { |
|
| 679 | + return $this->all_tracked[$id]; |
|
| 680 | + } |
|
| 552 | 681 | } |
| 553 | 682 | } |
| 554 | 683 | } |