@@ -20,10 +20,10 @@ discard block |
||
20 | 20 | |
21 | 21 | |
22 | 22 | /** |
23 | - * Get SQL query part for filter used |
|
24 | - * @param Array $filter the filter |
|
25 | - * @return Array the SQL part |
|
26 | - */ |
|
23 | + * Get SQL query part for filter used |
|
24 | + * @param Array $filter the filter |
|
25 | + * @return Array the SQL part |
|
26 | + */ |
|
27 | 27 | public function getFilter($filter = array(),$where = false,$and = false) { |
28 | 28 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
29 | 29 | $filters = array(); |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
106 | - * Gets all the spotter information based on the latest data entry |
|
107 | - * |
|
108 | - * @return Array the spotter information |
|
109 | - * |
|
110 | - */ |
|
106 | + * Gets all the spotter information based on the latest data entry |
|
107 | + * |
|
108 | + * @return Array the spotter information |
|
109 | + * |
|
110 | + */ |
|
111 | 111 | public function getLiveMarineData($limit = '', $sort = '', $filter = array()) |
112 | 112 | { |
113 | 113 | global $globalDBdriver, $globalLiveInterval; |
@@ -150,11 +150,11 @@ discard block |
||
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
153 | - * Gets Minimal Live Spotter data |
|
154 | - * |
|
155 | - * @return Array the spotter information |
|
156 | - * |
|
157 | - */ |
|
153 | + * Gets Minimal Live Spotter data |
|
154 | + * |
|
155 | + * @return Array the spotter information |
|
156 | + * |
|
157 | + */ |
|
158 | 158 | public function getMinLiveMarineData($filter = array()) |
159 | 159 | { |
160 | 160 | global $globalDBdriver, $globalLiveInterval; |
@@ -184,11 +184,11 @@ discard block |
||
184 | 184 | } |
185 | 185 | |
186 | 186 | /** |
187 | - * Gets Minimal Live Spotter data since xx seconds |
|
188 | - * |
|
189 | - * @return Array the spotter information |
|
190 | - * |
|
191 | - */ |
|
187 | + * Gets Minimal Live Spotter data since xx seconds |
|
188 | + * |
|
189 | + * @return Array the spotter information |
|
190 | + * |
|
191 | + */ |
|
192 | 192 | public function getMinLastLiveMarineData($coord = array(),$filter = array(), $limit = false, $id = '') |
193 | 193 | { |
194 | 194 | global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive; |
@@ -268,11 +268,11 @@ discard block |
||
268 | 268 | } |
269 | 269 | |
270 | 270 | /** |
271 | - * Gets Minimal Live Spotter data since xx seconds |
|
272 | - * |
|
273 | - * @return Array the spotter information |
|
274 | - * |
|
275 | - */ |
|
271 | + * Gets Minimal Live Spotter data since xx seconds |
|
272 | + * |
|
273 | + * @return Array the spotter information |
|
274 | + * |
|
275 | + */ |
|
276 | 276 | public function getMinLastLiveMarineDataByID($id = '',$filter = array(), $limit = false) |
277 | 277 | { |
278 | 278 | global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive; |
@@ -332,11 +332,11 @@ discard block |
||
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
335 | - * Gets number of latest data entry |
|
336 | - * |
|
337 | - * @return String number of entry |
|
338 | - * |
|
339 | - */ |
|
335 | + * Gets number of latest data entry |
|
336 | + * |
|
337 | + * @return String number of entry |
|
338 | + * |
|
339 | + */ |
|
340 | 340 | public function getLiveMarineCount($filter = array()) |
341 | 341 | { |
342 | 342 | global $globalDBdriver, $globalLiveInterval; |
@@ -361,11 +361,11 @@ discard block |
||
361 | 361 | } |
362 | 362 | |
363 | 363 | /** |
364 | - * Gets all the spotter information based on the latest data entry and coord |
|
365 | - * |
|
366 | - * @return Array the spotter information |
|
367 | - * |
|
368 | - */ |
|
364 | + * Gets all the spotter information based on the latest data entry and coord |
|
365 | + * |
|
366 | + * @return Array the spotter information |
|
367 | + * |
|
368 | + */ |
|
369 | 369 | public function getLiveMarineDatabyCoord($coord, $filter = array()) |
370 | 370 | { |
371 | 371 | global $globalDBdriver, $globalLiveInterval; |
@@ -389,11 +389,11 @@ discard block |
||
389 | 389 | } |
390 | 390 | |
391 | 391 | /** |
392 | - * Gets all the spotter information based on the latest data entry and coord |
|
393 | - * |
|
394 | - * @return Array the spotter information |
|
395 | - * |
|
396 | - */ |
|
392 | + * Gets all the spotter information based on the latest data entry and coord |
|
393 | + * |
|
394 | + * @return Array the spotter information |
|
395 | + * |
|
396 | + */ |
|
397 | 397 | public function getMinLiveMarineDatabyCoord($coord, $filter = array()) |
398 | 398 | { |
399 | 399 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -462,11 +462,11 @@ discard block |
||
462 | 462 | } |
463 | 463 | |
464 | 464 | /** |
465 | - * Gets all the spotter information based on a user's latitude and longitude |
|
466 | - * |
|
467 | - * @return Array the spotter information |
|
468 | - * |
|
469 | - */ |
|
465 | + * Gets all the spotter information based on a user's latitude and longitude |
|
466 | + * |
|
467 | + * @return Array the spotter information |
|
468 | + * |
|
469 | + */ |
|
470 | 470 | public function getLatestMarineForLayar($lat, $lng, $radius, $interval) |
471 | 471 | { |
472 | 472 | $Marine = new Marine($this->db); |
@@ -479,75 +479,75 @@ discard block |
||
479 | 479 | if ($lng != '') |
480 | 480 | { |
481 | 481 | if (!is_numeric($lng)) |
482 | - { |
|
483 | - return false; |
|
484 | - } |
|
485 | - } |
|
486 | - |
|
487 | - if ($radius != '') |
|
488 | - { |
|
489 | - if (!is_numeric($radius)) |
|
490 | - { |
|
491 | - return false; |
|
492 | - } |
|
493 | - } |
|
482 | + { |
|
483 | + return false; |
|
484 | + } |
|
485 | + } |
|
486 | + |
|
487 | + if ($radius != '') |
|
488 | + { |
|
489 | + if (!is_numeric($radius)) |
|
490 | + { |
|
491 | + return false; |
|
492 | + } |
|
493 | + } |
|
494 | 494 | $additional_query = ''; |
495 | 495 | if ($interval != '') |
496 | - { |
|
497 | - if (!is_string($interval)) |
|
498 | - { |
|
499 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
500 | - return false; |
|
501 | - } else { |
|
502 | - if ($interval == '1m') |
|
503 | - { |
|
504 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
505 | - } else if ($interval == '15m'){ |
|
506 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
507 | - } |
|
508 | - } |
|
509 | - } else { |
|
510 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
511 | - } |
|
512 | - |
|
513 | - $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
496 | + { |
|
497 | + if (!is_string($interval)) |
|
498 | + { |
|
499 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
500 | + return false; |
|
501 | + } else { |
|
502 | + if ($interval == '1m') |
|
503 | + { |
|
504 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
505 | + } else if ($interval == '15m'){ |
|
506 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
507 | + } |
|
508 | + } |
|
509 | + } else { |
|
510 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
511 | + } |
|
512 | + |
|
513 | + $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
514 | 514 | WHERE marine_live.latitude <> '' |
515 | 515 | AND marine_live.longitude <> '' |
516 | 516 | ".$additional_query." |
517 | 517 | HAVING distance < :radius |
518 | 518 | ORDER BY distance"; |
519 | 519 | |
520 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
520 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
521 | 521 | |
522 | - return $spotter_array; |
|
523 | - } |
|
522 | + return $spotter_array; |
|
523 | + } |
|
524 | 524 | |
525 | 525 | |
526 | - /** |
|
527 | - * Gets all the spotter information based on a particular callsign |
|
528 | - * |
|
529 | - * @return Array the spotter information |
|
530 | - * |
|
531 | - */ |
|
526 | + /** |
|
527 | + * Gets all the spotter information based on a particular callsign |
|
528 | + * |
|
529 | + * @return Array the spotter information |
|
530 | + * |
|
531 | + */ |
|
532 | 532 | public function getLastLiveMarineDataByIdent($ident) |
533 | 533 | { |
534 | 534 | $Marine = new Marine($this->db); |
535 | 535 | date_default_timezone_set('UTC'); |
536 | 536 | |
537 | 537 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
538 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
538 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
539 | 539 | |
540 | 540 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
541 | 541 | |
542 | 542 | return $spotter_array; |
543 | 543 | } |
544 | 544 | |
545 | - /** |
|
546 | - * Gets all the spotter information based on a particular callsign |
|
547 | - * |
|
548 | - * @return Array the spotter information |
|
549 | - * |
|
550 | - */ |
|
545 | + /** |
|
546 | + * Gets all the spotter information based on a particular callsign |
|
547 | + * |
|
548 | + * @return Array the spotter information |
|
549 | + * |
|
550 | + */ |
|
551 | 551 | public function getDateLiveMarineDataByIdent($ident,$date) |
552 | 552 | { |
553 | 553 | $Marine = new Marine($this->db); |
@@ -560,11 +560,11 @@ discard block |
||
560 | 560 | } |
561 | 561 | |
562 | 562 | /** |
563 | - * Gets all the spotter information based on a particular MMSI |
|
564 | - * |
|
565 | - * @return Array the spotter information |
|
566 | - * |
|
567 | - */ |
|
563 | + * Gets all the spotter information based on a particular MMSI |
|
564 | + * |
|
565 | + * @return Array the spotter information |
|
566 | + * |
|
567 | + */ |
|
568 | 568 | public function getDateLiveMarineDataByMMSI($mmsi,$date) |
569 | 569 | { |
570 | 570 | $Marine = new Marine($this->db); |
@@ -576,51 +576,51 @@ discard block |
||
576 | 576 | return $spotter_array; |
577 | 577 | } |
578 | 578 | |
579 | - /** |
|
580 | - * Gets last spotter information based on a particular callsign |
|
581 | - * |
|
582 | - * @return Array the spotter information |
|
583 | - * |
|
584 | - */ |
|
579 | + /** |
|
580 | + * Gets last spotter information based on a particular callsign |
|
581 | + * |
|
582 | + * @return Array the spotter information |
|
583 | + * |
|
584 | + */ |
|
585 | 585 | public function getLastLiveMarineDataById($id) |
586 | 586 | { |
587 | 587 | $Marine = new Marine($this->db); |
588 | 588 | date_default_timezone_set('UTC'); |
589 | 589 | |
590 | 590 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
591 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
591 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
592 | 592 | |
593 | 593 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
594 | 594 | |
595 | 595 | return $spotter_array; |
596 | 596 | } |
597 | 597 | |
598 | - /** |
|
599 | - * Gets last spotter information based on a particular callsign |
|
600 | - * |
|
601 | - * @return Array the spotter information |
|
602 | - * |
|
603 | - */ |
|
598 | + /** |
|
599 | + * Gets last spotter information based on a particular callsign |
|
600 | + * |
|
601 | + * @return Array the spotter information |
|
602 | + * |
|
603 | + */ |
|
604 | 604 | public function getDateLiveMarineDataById($id,$date) |
605 | 605 | { |
606 | 606 | $Marine = new Marine($this->db); |
607 | 607 | date_default_timezone_set('UTC'); |
608 | 608 | |
609 | 609 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
610 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
611 | - $date = date('c',$date); |
|
610 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
611 | + $date = date('c',$date); |
|
612 | 612 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
613 | 613 | |
614 | 614 | return $spotter_array; |
615 | 615 | } |
616 | 616 | |
617 | 617 | |
618 | - /** |
|
619 | - * Gets all the spotter information based on a particular id |
|
620 | - * |
|
621 | - * @return Array the spotter information |
|
622 | - * |
|
623 | - */ |
|
618 | + /** |
|
619 | + * Gets all the spotter information based on a particular id |
|
620 | + * |
|
621 | + * @return Array the spotter information |
|
622 | + * |
|
623 | + */ |
|
624 | 624 | public function getAllLiveMarineDataById($id,$liveinterval = false) |
625 | 625 | { |
626 | 626 | global $globalDBdriver, $globalLiveInterval; |
@@ -648,18 +648,18 @@ discard block |
||
648 | 648 | return $spotter_array; |
649 | 649 | } |
650 | 650 | |
651 | - /** |
|
652 | - * Gets all the spotter information based on a particular ident |
|
653 | - * |
|
654 | - * @return Array the spotter information |
|
655 | - * |
|
656 | - */ |
|
651 | + /** |
|
652 | + * Gets all the spotter information based on a particular ident |
|
653 | + * |
|
654 | + * @return Array the spotter information |
|
655 | + * |
|
656 | + */ |
|
657 | 657 | public function getAllLiveMarineDataByIdent($ident) |
658 | 658 | { |
659 | 659 | date_default_timezone_set('UTC'); |
660 | 660 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
661 | 661 | $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
662 | - try { |
|
662 | + try { |
|
663 | 663 | |
664 | 664 | $sth = $this->db->prepare($query); |
665 | 665 | $sth->execute(array(':ident' => $ident)); |
@@ -673,23 +673,23 @@ discard block |
||
673 | 673 | |
674 | 674 | |
675 | 675 | /** |
676 | - * Deletes all info in the table |
|
677 | - * |
|
678 | - * @return String success or false |
|
679 | - * |
|
680 | - */ |
|
676 | + * Deletes all info in the table |
|
677 | + * |
|
678 | + * @return String success or false |
|
679 | + * |
|
680 | + */ |
|
681 | 681 | public function deleteLiveMarineData() |
682 | 682 | { |
683 | 683 | global $globalDBdriver; |
684 | 684 | if ($globalDBdriver == 'mysql') { |
685 | 685 | //$query = "DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= marine_live.date"; |
686 | 686 | $query = 'DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= marine_live.date'; |
687 | - //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)"; |
|
687 | + //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)"; |
|
688 | 688 | } else { |
689 | 689 | $query = "DELETE FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date"; |
690 | 690 | } |
691 | 691 | |
692 | - try { |
|
692 | + try { |
|
693 | 693 | |
694 | 694 | $sth = $this->db->prepare($query); |
695 | 695 | $sth->execute(); |
@@ -701,18 +701,18 @@ discard block |
||
701 | 701 | } |
702 | 702 | |
703 | 703 | /** |
704 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
705 | - * |
|
706 | - * @return String success or false |
|
707 | - * |
|
708 | - */ |
|
704 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
705 | + * |
|
706 | + * @return String success or false |
|
707 | + * |
|
708 | + */ |
|
709 | 709 | public function deleteLiveMarineDataNotUpdated() |
710 | 710 | { |
711 | 711 | global $globalDBdriver, $globalDebug; |
712 | 712 | if ($globalDBdriver == 'mysql') { |
713 | 713 | //$query = 'SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < marine_live.date) LIMIT 800 OFFSET 0'; |
714 | - $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
715 | - try { |
|
714 | + $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
715 | + try { |
|
716 | 716 | |
717 | 717 | $sth = $this->db->prepare($query); |
718 | 718 | $sth->execute(); |
@@ -720,8 +720,8 @@ discard block |
||
720 | 720 | return "error"; |
721 | 721 | } |
722 | 722 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
723 | - $i = 0; |
|
724 | - $j =0; |
|
723 | + $i = 0; |
|
724 | + $j =0; |
|
725 | 725 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
726 | 726 | foreach($all as $row) |
727 | 727 | { |
@@ -729,20 +729,20 @@ discard block |
||
729 | 729 | $j++; |
730 | 730 | if ($j == 30) { |
731 | 731 | if ($globalDebug) echo "."; |
732 | - try { |
|
732 | + try { |
|
733 | 733 | |
734 | 734 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
735 | 735 | $sth->execute(); |
736 | 736 | } catch(PDOException $e) { |
737 | 737 | return "error"; |
738 | 738 | } |
739 | - $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
740 | - $j = 0; |
|
739 | + $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
740 | + $j = 0; |
|
741 | 741 | } |
742 | 742 | $query_delete .= "'".$row['fammarine_id']."',"; |
743 | 743 | } |
744 | 744 | if ($i > 0) { |
745 | - try { |
|
745 | + try { |
|
746 | 746 | |
747 | 747 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
748 | 748 | $sth->execute(); |
@@ -753,9 +753,9 @@ discard block |
||
753 | 753 | return "success"; |
754 | 754 | } elseif ($globalDBdriver == 'pgsql') { |
755 | 755 | //$query = "SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < marine_live.date) LIMIT 800 OFFSET 0"; |
756 | - //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
757 | - $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
758 | - try { |
|
756 | + //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
757 | + $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
758 | + try { |
|
759 | 759 | |
760 | 760 | $sth = $this->db->prepare($query); |
761 | 761 | $sth->execute(); |
@@ -799,17 +799,17 @@ discard block |
||
799 | 799 | } |
800 | 800 | |
801 | 801 | /** |
802 | - * Deletes all info in the table for an ident |
|
803 | - * |
|
804 | - * @return String success or false |
|
805 | - * |
|
806 | - */ |
|
802 | + * Deletes all info in the table for an ident |
|
803 | + * |
|
804 | + * @return String success or false |
|
805 | + * |
|
806 | + */ |
|
807 | 807 | public function deleteLiveMarineDataByIdent($ident) |
808 | 808 | { |
809 | 809 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
810 | 810 | $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
811 | 811 | |
812 | - try { |
|
812 | + try { |
|
813 | 813 | |
814 | 814 | $sth = $this->db->prepare($query); |
815 | 815 | $sth->execute(array(':ident' => $ident)); |
@@ -821,17 +821,17 @@ discard block |
||
821 | 821 | } |
822 | 822 | |
823 | 823 | /** |
824 | - * Deletes all info in the table for an id |
|
825 | - * |
|
826 | - * @return String success or false |
|
827 | - * |
|
828 | - */ |
|
824 | + * Deletes all info in the table for an id |
|
825 | + * |
|
826 | + * @return String success or false |
|
827 | + * |
|
828 | + */ |
|
829 | 829 | public function deleteLiveMarineDataById($id) |
830 | 830 | { |
831 | 831 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
832 | 832 | $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
833 | 833 | |
834 | - try { |
|
834 | + try { |
|
835 | 835 | |
836 | 836 | $sth = $this->db->prepare($query); |
837 | 837 | $sth->execute(array(':id' => $id)); |
@@ -844,11 +844,11 @@ discard block |
||
844 | 844 | |
845 | 845 | |
846 | 846 | /** |
847 | - * Gets the marine races |
|
848 | - * |
|
849 | - * @return Array all races |
|
850 | - * |
|
851 | - */ |
|
847 | + * Gets the marine races |
|
848 | + * |
|
849 | + * @return Array all races |
|
850 | + * |
|
851 | + */ |
|
852 | 852 | public function getAllRaces() |
853 | 853 | { |
854 | 854 | $query = 'SELECT DISTINCT marine_live.race_id, marine_live.race_name FROM marine_live ORDER BY marine_live.race_name'; |
@@ -858,11 +858,11 @@ discard block |
||
858 | 858 | } |
859 | 859 | |
860 | 860 | /** |
861 | - * Gets the aircraft ident within the last hour |
|
862 | - * |
|
863 | - * @return String the ident |
|
864 | - * |
|
865 | - */ |
|
861 | + * Gets the aircraft ident within the last hour |
|
862 | + * |
|
863 | + * @return String the ident |
|
864 | + * |
|
865 | + */ |
|
866 | 866 | public function getIdentFromLastHour($ident) |
867 | 867 | { |
868 | 868 | global $globalDBdriver, $globalTimezone; |
@@ -888,14 +888,14 @@ discard block |
||
888 | 888 | $ident_result = $row['ident']; |
889 | 889 | } |
890 | 890 | return $ident_result; |
891 | - } |
|
891 | + } |
|
892 | 892 | |
893 | 893 | /** |
894 | - * Check recent aircraft |
|
895 | - * |
|
896 | - * @return String the ident |
|
897 | - * |
|
898 | - */ |
|
894 | + * Check recent aircraft |
|
895 | + * |
|
896 | + * @return String the ident |
|
897 | + * |
|
898 | + */ |
|
899 | 899 | public function checkIdentRecent($ident) |
900 | 900 | { |
901 | 901 | global $globalDBdriver, $globalTimezone; |
@@ -921,14 +921,14 @@ discard block |
||
921 | 921 | $ident_result = $row['fammarine_id']; |
922 | 922 | } |
923 | 923 | return $ident_result; |
924 | - } |
|
924 | + } |
|
925 | 925 | |
926 | 926 | /** |
927 | - * Check recent aircraft by id |
|
928 | - * |
|
929 | - * @return String the ident |
|
930 | - * |
|
931 | - */ |
|
927 | + * Check recent aircraft by id |
|
928 | + * |
|
929 | + * @return String the ident |
|
930 | + * |
|
931 | + */ |
|
932 | 932 | public function checkIdRecent($id) |
933 | 933 | { |
934 | 934 | global $globalDBdriver, $globalTimezone; |
@@ -954,14 +954,14 @@ discard block |
||
954 | 954 | $ident_result = $row['fammarine_id']; |
955 | 955 | } |
956 | 956 | return $ident_result; |
957 | - } |
|
957 | + } |
|
958 | 958 | |
959 | 959 | /** |
960 | - * Check recent aircraft by mmsi |
|
961 | - * |
|
962 | - * @return String the ident |
|
963 | - * |
|
964 | - */ |
|
960 | + * Check recent aircraft by mmsi |
|
961 | + * |
|
962 | + * @return String the ident |
|
963 | + * |
|
964 | + */ |
|
965 | 965 | public function checkMMSIRecent($mmsi) |
966 | 966 | { |
967 | 967 | global $globalDBdriver, $globalTimezone; |
@@ -987,19 +987,19 @@ discard block |
||
987 | 987 | $ident_result = $row['fammarine_id']; |
988 | 988 | } |
989 | 989 | return $ident_result; |
990 | - } |
|
990 | + } |
|
991 | 991 | |
992 | 992 | /** |
993 | - * Adds a new spotter data |
|
994 | - * |
|
995 | - * @param String $fammarine_id the ID from flightaware |
|
996 | - * @param String $ident the flight ident |
|
997 | - * @param String $aircraft_icao the aircraft type |
|
998 | - * @param String $departure_airport_icao the departure airport |
|
999 | - * @param String $arrival_airport_icao the arrival airport |
|
1000 | - * @return String success or false |
|
1001 | - * |
|
1002 | - */ |
|
993 | + * Adds a new spotter data |
|
994 | + * |
|
995 | + * @param String $fammarine_id the ID from flightaware |
|
996 | + * @param String $ident the flight ident |
|
997 | + * @param String $aircraft_icao the aircraft type |
|
998 | + * @param String $departure_airport_icao the departure airport |
|
999 | + * @param String $arrival_airport_icao the arrival airport |
|
1000 | + * @return String success or false |
|
1001 | + * |
|
1002 | + */ |
|
1003 | 1003 | public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '',$captain_id = '',$captain_name = '',$race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '') |
1004 | 1004 | { |
1005 | 1005 | global $globalURL, $globalArchive, $globalDebug; |
@@ -1081,10 +1081,10 @@ discard block |
||
1081 | 1081 | if ($statusid == '') $statusid = NULL; |
1082 | 1082 | if ($distance == '') $distance = NULL; |
1083 | 1083 | |
1084 | - //if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1085 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1086 | - if ($arrival_date == '') $arrival_date = NULL; |
|
1087 | - $query = ''; |
|
1084 | + //if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1085 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1086 | + if ($arrival_date == '') $arrival_date = NULL; |
|
1087 | + $query = ''; |
|
1088 | 1088 | if ($globalArchive) { |
1089 | 1089 | if ($globalDebug) echo '-- Delete previous data -- '; |
1090 | 1090 | $query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;'; |