@@ -20,13 +20,13 @@ discard block |
||
20 | 20 | } |
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * Get SQL query part for filter used |
|
25 | - * @param array $filter the filter |
|
26 | - * @param bool $where |
|
27 | - * @param bool $and |
|
28 | - * @return string the SQL part |
|
29 | - */ |
|
23 | + /** |
|
24 | + * Get SQL query part for filter used |
|
25 | + * @param array $filter the filter |
|
26 | + * @param bool $where |
|
27 | + * @param bool $and |
|
28 | + * @return string the SQL part |
|
29 | + */ |
|
30 | 30 | public function getFilter($filter = array(),$where = false,$and = false) { |
31 | 31 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
32 | 32 | $filters = array(); |
@@ -105,14 +105,14 @@ discard block |
||
105 | 105 | return $filter_query; |
106 | 106 | } |
107 | 107 | |
108 | - /** |
|
109 | - * Gets all the spotter information based on the latest data entry |
|
110 | - * |
|
111 | - * @param string $limit |
|
112 | - * @param string $sort |
|
113 | - * @param array $filter |
|
114 | - * @return array the spotter information |
|
115 | - */ |
|
108 | + /** |
|
109 | + * Gets all the spotter information based on the latest data entry |
|
110 | + * |
|
111 | + * @param string $limit |
|
112 | + * @param string $sort |
|
113 | + * @param array $filter |
|
114 | + * @return array the spotter information |
|
115 | + */ |
|
116 | 116 | public function getLiveMarineData($limit = '', $sort = '', $filter = array()) |
117 | 117 | { |
118 | 118 | global $globalDBdriver, $globalLiveInterval; |
@@ -154,12 +154,12 @@ discard block |
||
154 | 154 | return $spotter_array; |
155 | 155 | } |
156 | 156 | |
157 | - /** |
|
158 | - * Gets Minimal Live Spotter data |
|
159 | - * |
|
160 | - * @param array $filter |
|
161 | - * @return array the spotter information |
|
162 | - */ |
|
157 | + /** |
|
158 | + * Gets Minimal Live Spotter data |
|
159 | + * |
|
160 | + * @param array $filter |
|
161 | + * @return array the spotter information |
|
162 | + */ |
|
163 | 163 | public function getMinLiveMarineData($filter = array()) |
164 | 164 | { |
165 | 165 | global $globalDBdriver, $globalLiveInterval; |
@@ -188,15 +188,15 @@ discard block |
||
188 | 188 | return $spotter_array; |
189 | 189 | } |
190 | 190 | |
191 | - /** |
|
192 | - * Gets Minimal Live Spotter data since xx seconds |
|
193 | - * |
|
194 | - * @param array $coord |
|
195 | - * @param array $filter |
|
196 | - * @param bool $limit |
|
197 | - * @param string $id |
|
198 | - * @return array the spotter information |
|
199 | - */ |
|
191 | + /** |
|
192 | + * Gets Minimal Live Spotter data since xx seconds |
|
193 | + * |
|
194 | + * @param array $coord |
|
195 | + * @param array $filter |
|
196 | + * @param bool $limit |
|
197 | + * @param string $id |
|
198 | + * @return array the spotter information |
|
199 | + */ |
|
200 | 200 | public function getMinLastLiveMarineData($coord = array(),$filter = array(), $limit = false, $id = '') |
201 | 201 | { |
202 | 202 | global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive; |
@@ -275,14 +275,14 @@ discard block |
||
275 | 275 | return $spotter_array; |
276 | 276 | } |
277 | 277 | |
278 | - /** |
|
279 | - * Gets Minimal Live Spotter data since xx seconds |
|
280 | - * |
|
281 | - * @param string $id |
|
282 | - * @param array $filter |
|
283 | - * @param bool $limit |
|
284 | - * @return array the spotter information |
|
285 | - */ |
|
278 | + /** |
|
279 | + * Gets Minimal Live Spotter data since xx seconds |
|
280 | + * |
|
281 | + * @param string $id |
|
282 | + * @param array $filter |
|
283 | + * @param bool $limit |
|
284 | + * @return array the spotter information |
|
285 | + */ |
|
286 | 286 | public function getMinLastLiveMarineDataByID($id = '',$filter = array(), $limit = false) |
287 | 287 | { |
288 | 288 | global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive; |
@@ -341,12 +341,12 @@ discard block |
||
341 | 341 | return $spotter_array; |
342 | 342 | } |
343 | 343 | |
344 | - /** |
|
345 | - * Gets number of latest data entry |
|
346 | - * |
|
347 | - * @param array $filter |
|
348 | - * @return String number of entry |
|
349 | - */ |
|
344 | + /** |
|
345 | + * Gets number of latest data entry |
|
346 | + * |
|
347 | + * @param array $filter |
|
348 | + * @return String number of entry |
|
349 | + */ |
|
350 | 350 | public function getLiveMarineCount($filter = array()) |
351 | 351 | { |
352 | 352 | global $globalDBdriver, $globalLiveInterval; |
@@ -370,13 +370,13 @@ discard block |
||
370 | 370 | return $result['nb']; |
371 | 371 | } |
372 | 372 | |
373 | - /** |
|
374 | - * Gets all the spotter information based on the latest data entry and coord |
|
375 | - * |
|
376 | - * @param $coord |
|
377 | - * @param array $filter |
|
378 | - * @return array the spotter information |
|
379 | - */ |
|
373 | + /** |
|
374 | + * Gets all the spotter information based on the latest data entry and coord |
|
375 | + * |
|
376 | + * @param $coord |
|
377 | + * @param array $filter |
|
378 | + * @return array the spotter information |
|
379 | + */ |
|
380 | 380 | public function getLiveMarineDatabyCoord($coord, $filter = array()) |
381 | 381 | { |
382 | 382 | global $globalDBdriver, $globalLiveInterval; |
@@ -399,13 +399,13 @@ discard block |
||
399 | 399 | return $spotter_array; |
400 | 400 | } |
401 | 401 | |
402 | - /** |
|
403 | - * Gets all the spotter information based on the latest data entry and coord |
|
404 | - * |
|
405 | - * @param $coord |
|
406 | - * @param array $filter |
|
407 | - * @return array the spotter information |
|
408 | - */ |
|
402 | + /** |
|
403 | + * Gets all the spotter information based on the latest data entry and coord |
|
404 | + * |
|
405 | + * @param $coord |
|
406 | + * @param array $filter |
|
407 | + * @return array the spotter information |
|
408 | + */ |
|
409 | 409 | public function getMinLiveMarineDatabyCoord($coord, $filter = array()) |
410 | 410 | { |
411 | 411 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -473,15 +473,15 @@ discard block |
||
473 | 473 | return $spotter_array; |
474 | 474 | } |
475 | 475 | |
476 | - /** |
|
477 | - * Gets all the spotter information based on a user's latitude and longitude |
|
478 | - * |
|
479 | - * @param $lat |
|
480 | - * @param $lng |
|
481 | - * @param $radius |
|
482 | - * @param $interval |
|
483 | - * @return array the spotter information |
|
484 | - */ |
|
476 | + /** |
|
477 | + * Gets all the spotter information based on a user's latitude and longitude |
|
478 | + * |
|
479 | + * @param $lat |
|
480 | + * @param $lng |
|
481 | + * @param $radius |
|
482 | + * @param $interval |
|
483 | + * @return array the spotter information |
|
484 | + */ |
|
485 | 485 | public function getLatestMarineForLayar($lat, $lng, $radius, $interval) |
486 | 486 | { |
487 | 487 | $Marine = new Marine($this->db); |
@@ -538,32 +538,32 @@ discard block |
||
538 | 538 | } |
539 | 539 | |
540 | 540 | |
541 | - /** |
|
542 | - * Gets all the spotter information based on a particular callsign |
|
543 | - * |
|
544 | - * @param $ident |
|
545 | - * @return array the spotter information |
|
546 | - */ |
|
541 | + /** |
|
542 | + * Gets all the spotter information based on a particular callsign |
|
543 | + * |
|
544 | + * @param $ident |
|
545 | + * @return array the spotter information |
|
546 | + */ |
|
547 | 547 | public function getLastLiveMarineDataByIdent($ident) |
548 | 548 | { |
549 | 549 | $Marine = new Marine($this->db); |
550 | 550 | date_default_timezone_set('UTC'); |
551 | 551 | |
552 | 552 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
553 | - $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'; |
|
553 | + $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'; |
|
554 | 554 | |
555 | 555 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
556 | 556 | |
557 | 557 | return $spotter_array; |
558 | 558 | } |
559 | 559 | |
560 | - /** |
|
561 | - * Gets all the spotter information based on a particular callsign |
|
562 | - * |
|
563 | - * @param $ident |
|
564 | - * @param $date |
|
565 | - * @return array the spotter information |
|
566 | - */ |
|
560 | + /** |
|
561 | + * Gets all the spotter information based on a particular callsign |
|
562 | + * |
|
563 | + * @param $ident |
|
564 | + * @param $date |
|
565 | + * @return array the spotter information |
|
566 | + */ |
|
567 | 567 | public function getDateLiveMarineDataByIdent($ident,$date) |
568 | 568 | { |
569 | 569 | $Marine = new Marine($this->db); |
@@ -575,13 +575,13 @@ discard block |
||
575 | 575 | return $spotter_array; |
576 | 576 | } |
577 | 577 | |
578 | - /** |
|
579 | - * Gets all the spotter information based on a particular MMSI |
|
580 | - * |
|
581 | - * @param $mmsi |
|
582 | - * @param $date |
|
583 | - * @return array the spotter information |
|
584 | - */ |
|
578 | + /** |
|
579 | + * Gets all the spotter information based on a particular MMSI |
|
580 | + * |
|
581 | + * @param $mmsi |
|
582 | + * @param $date |
|
583 | + * @return array the spotter information |
|
584 | + */ |
|
585 | 585 | public function getDateLiveMarineDataByMMSI($mmsi,$date) |
586 | 586 | { |
587 | 587 | $Marine = new Marine($this->db); |
@@ -593,53 +593,53 @@ discard block |
||
593 | 593 | return $spotter_array; |
594 | 594 | } |
595 | 595 | |
596 | - /** |
|
597 | - * Gets last spotter information based on a particular callsign |
|
598 | - * |
|
599 | - * @param $id |
|
600 | - * @return array the spotter information |
|
601 | - */ |
|
596 | + /** |
|
597 | + * Gets last spotter information based on a particular callsign |
|
598 | + * |
|
599 | + * @param $id |
|
600 | + * @return array the spotter information |
|
601 | + */ |
|
602 | 602 | public function getLastLiveMarineDataById($id) |
603 | 603 | { |
604 | 604 | $Marine = new Marine($this->db); |
605 | 605 | date_default_timezone_set('UTC'); |
606 | 606 | |
607 | 607 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
608 | - $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'; |
|
608 | + $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'; |
|
609 | 609 | |
610 | 610 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
611 | 611 | |
612 | 612 | return $spotter_array; |
613 | 613 | } |
614 | 614 | |
615 | - /** |
|
616 | - * Gets last spotter information based on a particular callsign |
|
617 | - * |
|
618 | - * @param $id |
|
619 | - * @param $date |
|
620 | - * @return array the spotter information |
|
621 | - */ |
|
615 | + /** |
|
616 | + * Gets last spotter information based on a particular callsign |
|
617 | + * |
|
618 | + * @param $id |
|
619 | + * @param $date |
|
620 | + * @return array the spotter information |
|
621 | + */ |
|
622 | 622 | public function getDateLiveMarineDataById($id,$date) |
623 | 623 | { |
624 | 624 | $Marine = new Marine($this->db); |
625 | 625 | date_default_timezone_set('UTC'); |
626 | 626 | |
627 | 627 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
628 | - $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'; |
|
629 | - $date = date('c',$date); |
|
628 | + $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'; |
|
629 | + $date = date('c',$date); |
|
630 | 630 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
631 | 631 | |
632 | 632 | return $spotter_array; |
633 | 633 | } |
634 | 634 | |
635 | 635 | |
636 | - /** |
|
637 | - * Gets all the spotter information based on a particular id |
|
638 | - * |
|
639 | - * @param $id |
|
640 | - * @param bool $liveinterval |
|
641 | - * @return array the spotter information |
|
642 | - */ |
|
636 | + /** |
|
637 | + * Gets all the spotter information based on a particular id |
|
638 | + * |
|
639 | + * @param $id |
|
640 | + * @param bool $liveinterval |
|
641 | + * @return array the spotter information |
|
642 | + */ |
|
643 | 643 | public function getAllLiveMarineDataById($id,$liveinterval = false) |
644 | 644 | { |
645 | 645 | global $globalDBdriver, $globalLiveInterval; |
@@ -667,18 +667,18 @@ discard block |
||
667 | 667 | return $spotter_array; |
668 | 668 | } |
669 | 669 | |
670 | - /** |
|
671 | - * Gets all the spotter information based on a particular ident |
|
672 | - * |
|
673 | - * @param $ident |
|
674 | - * @return array the spotter information |
|
675 | - */ |
|
670 | + /** |
|
671 | + * Gets all the spotter information based on a particular ident |
|
672 | + * |
|
673 | + * @param $ident |
|
674 | + * @return array the spotter information |
|
675 | + */ |
|
676 | 676 | public function getAllLiveMarineDataByIdent($ident) |
677 | 677 | { |
678 | 678 | date_default_timezone_set('UTC'); |
679 | 679 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
680 | 680 | $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
681 | - try { |
|
681 | + try { |
|
682 | 682 | |
683 | 683 | $sth = $this->db->prepare($query); |
684 | 684 | $sth->execute(array(':ident' => $ident)); |
@@ -692,23 +692,23 @@ discard block |
||
692 | 692 | |
693 | 693 | |
694 | 694 | /** |
695 | - * Deletes all info in the table |
|
696 | - * |
|
697 | - * @return String success or false |
|
698 | - * |
|
699 | - */ |
|
695 | + * Deletes all info in the table |
|
696 | + * |
|
697 | + * @return String success or false |
|
698 | + * |
|
699 | + */ |
|
700 | 700 | public function deleteLiveMarineData() |
701 | 701 | { |
702 | 702 | global $globalDBdriver; |
703 | 703 | if ($globalDBdriver == 'mysql') { |
704 | 704 | //$query = "DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= marine_live.date"; |
705 | 705 | $query = 'DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 HOUR) >= marine_live.date'; |
706 | - //$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)"; |
|
706 | + //$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)"; |
|
707 | 707 | } else { |
708 | 708 | $query = "DELETE FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '12 HOURS' >= marine_live.date"; |
709 | 709 | } |
710 | 710 | |
711 | - try { |
|
711 | + try { |
|
712 | 712 | |
713 | 713 | $sth = $this->db->prepare($query); |
714 | 714 | $sth->execute(); |
@@ -720,18 +720,18 @@ discard block |
||
720 | 720 | } |
721 | 721 | |
722 | 722 | /** |
723 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
724 | - * |
|
725 | - * @return String success or false |
|
726 | - * |
|
727 | - */ |
|
723 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
724 | + * |
|
725 | + * @return String success or false |
|
726 | + * |
|
727 | + */ |
|
728 | 728 | public function deleteLiveMarineDataNotUpdated() |
729 | 729 | { |
730 | 730 | global $globalDBdriver, $globalDebug; |
731 | 731 | if ($globalDBdriver == 'mysql') { |
732 | 732 | //$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'; |
733 | - $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"; |
|
734 | - try { |
|
733 | + $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"; |
|
734 | + try { |
|
735 | 735 | |
736 | 736 | $sth = $this->db->prepare($query); |
737 | 737 | $sth->execute(); |
@@ -739,8 +739,8 @@ discard block |
||
739 | 739 | return "error"; |
740 | 740 | } |
741 | 741 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
742 | - $i = 0; |
|
743 | - $j =0; |
|
742 | + $i = 0; |
|
743 | + $j =0; |
|
744 | 744 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
745 | 745 | foreach($all as $row) |
746 | 746 | { |
@@ -748,20 +748,20 @@ discard block |
||
748 | 748 | $j++; |
749 | 749 | if ($j == 30) { |
750 | 750 | if ($globalDebug) echo "."; |
751 | - try { |
|
751 | + try { |
|
752 | 752 | |
753 | 753 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
754 | 754 | $sth->execute(); |
755 | 755 | } catch(PDOException $e) { |
756 | 756 | return "error"; |
757 | 757 | } |
758 | - $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
759 | - $j = 0; |
|
758 | + $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
759 | + $j = 0; |
|
760 | 760 | } |
761 | 761 | $query_delete .= "'".$row['fammarine_id']."',"; |
762 | 762 | } |
763 | 763 | if ($i > 0) { |
764 | - try { |
|
764 | + try { |
|
765 | 765 | |
766 | 766 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
767 | 767 | $sth->execute(); |
@@ -772,9 +772,9 @@ discard block |
||
772 | 772 | return "success"; |
773 | 773 | } elseif ($globalDBdriver == 'pgsql') { |
774 | 774 | //$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"; |
775 | - //$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"; |
|
776 | - $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)"; |
|
777 | - try { |
|
775 | + //$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"; |
|
776 | + $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)"; |
|
777 | + try { |
|
778 | 778 | |
779 | 779 | $sth = $this->db->prepare($query); |
780 | 780 | $sth->execute(); |
@@ -818,18 +818,18 @@ discard block |
||
818 | 818 | return 'error'; |
819 | 819 | } |
820 | 820 | |
821 | - /** |
|
822 | - * Deletes all info in the table for an ident |
|
823 | - * |
|
824 | - * @param $ident |
|
825 | - * @return String success or false |
|
826 | - */ |
|
821 | + /** |
|
822 | + * Deletes all info in the table for an ident |
|
823 | + * |
|
824 | + * @param $ident |
|
825 | + * @return String success or false |
|
826 | + */ |
|
827 | 827 | public function deleteLiveMarineDataByIdent($ident) |
828 | 828 | { |
829 | 829 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
830 | 830 | $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
831 | 831 | |
832 | - try { |
|
832 | + try { |
|
833 | 833 | |
834 | 834 | $sth = $this->db->prepare($query); |
835 | 835 | $sth->execute(array(':ident' => $ident)); |
@@ -840,18 +840,18 @@ discard block |
||
840 | 840 | return "success"; |
841 | 841 | } |
842 | 842 | |
843 | - /** |
|
844 | - * Deletes all info in the table for an id |
|
845 | - * |
|
846 | - * @param $id |
|
847 | - * @return String success or false |
|
848 | - */ |
|
843 | + /** |
|
844 | + * Deletes all info in the table for an id |
|
845 | + * |
|
846 | + * @param $id |
|
847 | + * @return String success or false |
|
848 | + */ |
|
849 | 849 | public function deleteLiveMarineDataById($id) |
850 | 850 | { |
851 | 851 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
852 | 852 | $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
853 | 853 | |
854 | - try { |
|
854 | + try { |
|
855 | 855 | |
856 | 856 | $sth = $this->db->prepare($query); |
857 | 857 | $sth->execute(array(':id' => $id)); |
@@ -864,11 +864,11 @@ discard block |
||
864 | 864 | |
865 | 865 | |
866 | 866 | /** |
867 | - * Gets the marine races |
|
868 | - * |
|
869 | - * @return array all races |
|
870 | - * |
|
871 | - */ |
|
867 | + * Gets the marine races |
|
868 | + * |
|
869 | + * @return array all races |
|
870 | + * |
|
871 | + */ |
|
872 | 872 | public function getAllRaces() |
873 | 873 | { |
874 | 874 | $query = 'SELECT DISTINCT marine_live.race_id, marine_live.race_name FROM marine_live ORDER BY marine_live.race_name'; |
@@ -877,12 +877,12 @@ discard block |
||
877 | 877 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
878 | 878 | } |
879 | 879 | |
880 | - /** |
|
881 | - * Gets the aircraft ident within the last hour |
|
882 | - * |
|
883 | - * @param $ident |
|
884 | - * @return String the ident |
|
885 | - */ |
|
880 | + /** |
|
881 | + * Gets the aircraft ident within the last hour |
|
882 | + * |
|
883 | + * @param $ident |
|
884 | + * @return String the ident |
|
885 | + */ |
|
886 | 886 | public function getIdentFromLastHour($ident) |
887 | 887 | { |
888 | 888 | global $globalDBdriver; |
@@ -908,14 +908,14 @@ discard block |
||
908 | 908 | $ident_result = $row['ident']; |
909 | 909 | } |
910 | 910 | return $ident_result; |
911 | - } |
|
912 | - |
|
913 | - /** |
|
914 | - * Check recent aircraft |
|
915 | - * |
|
916 | - * @param $ident |
|
917 | - * @return String the ident |
|
918 | - */ |
|
911 | + } |
|
912 | + |
|
913 | + /** |
|
914 | + * Check recent aircraft |
|
915 | + * |
|
916 | + * @param $ident |
|
917 | + * @return String the ident |
|
918 | + */ |
|
919 | 919 | public function checkIdentRecent($ident) |
920 | 920 | { |
921 | 921 | global $globalDBdriver; |
@@ -941,14 +941,14 @@ discard block |
||
941 | 941 | $ident_result = $row['fammarine_id']; |
942 | 942 | } |
943 | 943 | return $ident_result; |
944 | - } |
|
945 | - |
|
946 | - /** |
|
947 | - * Check recent aircraft by id |
|
948 | - * |
|
949 | - * @param $id |
|
950 | - * @return String the ident |
|
951 | - */ |
|
944 | + } |
|
945 | + |
|
946 | + /** |
|
947 | + * Check recent aircraft by id |
|
948 | + * |
|
949 | + * @param $id |
|
950 | + * @return String the ident |
|
951 | + */ |
|
952 | 952 | public function checkIdRecent($id) |
953 | 953 | { |
954 | 954 | global $globalDBdriver; |
@@ -974,14 +974,14 @@ discard block |
||
974 | 974 | $ident_result = $row['fammarine_id']; |
975 | 975 | } |
976 | 976 | return $ident_result; |
977 | - } |
|
978 | - |
|
979 | - /** |
|
980 | - * Check recent aircraft by mmsi |
|
981 | - * |
|
982 | - * @param $mmsi |
|
983 | - * @return String the ident |
|
984 | - */ |
|
977 | + } |
|
978 | + |
|
979 | + /** |
|
980 | + * Check recent aircraft by mmsi |
|
981 | + * |
|
982 | + * @param $mmsi |
|
983 | + * @return String the ident |
|
984 | + */ |
|
985 | 985 | public function checkMMSIRecent($mmsi) |
986 | 986 | { |
987 | 987 | global $globalDBdriver; |
@@ -1007,41 +1007,41 @@ discard block |
||
1007 | 1007 | $ident_result = $row['fammarine_id']; |
1008 | 1008 | } |
1009 | 1009 | return $ident_result; |
1010 | - } |
|
1011 | - |
|
1012 | - /** |
|
1013 | - * Adds a new spotter data |
|
1014 | - * |
|
1015 | - * @param String $fammarine_id the ID from flightaware |
|
1016 | - * @param String $ident the flight ident |
|
1017 | - * @param string $latitude |
|
1018 | - * @param string $longitude |
|
1019 | - * @param string $heading |
|
1020 | - * @param string $groundspeed |
|
1021 | - * @param string $date |
|
1022 | - * @param bool $putinarchive |
|
1023 | - * @param string $mmsi |
|
1024 | - * @param string $type |
|
1025 | - * @param string $typeid |
|
1026 | - * @param string $imo |
|
1027 | - * @param string $callsign |
|
1028 | - * @param string $arrival_code |
|
1029 | - * @param string $arrival_date |
|
1030 | - * @param string $status |
|
1031 | - * @param string $statusid |
|
1032 | - * @param bool $noarchive |
|
1033 | - * @param string $format_source |
|
1034 | - * @param string $source_name |
|
1035 | - * @param string $over_country |
|
1036 | - * @param string $captain_id |
|
1037 | - * @param string $captain_name |
|
1038 | - * @param string $race_id |
|
1039 | - * @param string $race_name |
|
1040 | - * @param string $distance |
|
1041 | - * @param string $race_rank |
|
1042 | - * @param string $race_time |
|
1043 | - * @return String success or false |
|
1044 | - */ |
|
1010 | + } |
|
1011 | + |
|
1012 | + /** |
|
1013 | + * Adds a new spotter data |
|
1014 | + * |
|
1015 | + * @param String $fammarine_id the ID from flightaware |
|
1016 | + * @param String $ident the flight ident |
|
1017 | + * @param string $latitude |
|
1018 | + * @param string $longitude |
|
1019 | + * @param string $heading |
|
1020 | + * @param string $groundspeed |
|
1021 | + * @param string $date |
|
1022 | + * @param bool $putinarchive |
|
1023 | + * @param string $mmsi |
|
1024 | + * @param string $type |
|
1025 | + * @param string $typeid |
|
1026 | + * @param string $imo |
|
1027 | + * @param string $callsign |
|
1028 | + * @param string $arrival_code |
|
1029 | + * @param string $arrival_date |
|
1030 | + * @param string $status |
|
1031 | + * @param string $statusid |
|
1032 | + * @param bool $noarchive |
|
1033 | + * @param string $format_source |
|
1034 | + * @param string $source_name |
|
1035 | + * @param string $over_country |
|
1036 | + * @param string $captain_id |
|
1037 | + * @param string $captain_name |
|
1038 | + * @param string $race_id |
|
1039 | + * @param string $race_name |
|
1040 | + * @param string $distance |
|
1041 | + * @param string $race_rank |
|
1042 | + * @param string $race_time |
|
1043 | + * @return String success or false |
|
1044 | + */ |
|
1045 | 1045 | 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 = '') |
1046 | 1046 | { |
1047 | 1047 | global $globalArchive, $globalDebug; |
@@ -1123,10 +1123,10 @@ discard block |
||
1123 | 1123 | if ($statusid == '') $statusid = NULL; |
1124 | 1124 | if ($distance == '') $distance = NULL; |
1125 | 1125 | |
1126 | - //if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1127 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1128 | - if ($arrival_date == '') $arrival_date = NULL; |
|
1129 | - $query = ''; |
|
1126 | + //if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1127 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1128 | + if ($arrival_date == '') $arrival_date = NULL; |
|
1129 | + $query = ''; |
|
1130 | 1130 | if ($globalArchive) { |
1131 | 1131 | if ($globalDebug) echo '-- Delete previous data -- '; |
1132 | 1132 | $query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;'; |