@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | |
14 | 14 | |
15 | 15 | /** |
16 | - * Get SQL query part for filter used |
|
17 | - * @param Array $filter the filter |
|
18 | - * @return Array the SQL part |
|
19 | - */ |
|
16 | + * Get SQL query part for filter used |
|
17 | + * @param Array $filter the filter |
|
18 | + * @return Array the SQL part |
|
19 | + */ |
|
20 | 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
22 | 22 | $filters = array(); |
@@ -139,11 +139,11 @@ discard block |
||
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
142 | - * Gets all the spotter information based on the latest data entry |
|
143 | - * |
|
144 | - * @return Array the spotter information |
|
145 | - * |
|
146 | - */ |
|
142 | + * Gets all the spotter information based on the latest data entry |
|
143 | + * |
|
144 | + * @return Array the spotter information |
|
145 | + * |
|
146 | + */ |
|
147 | 147 | public function getLiveSpotterData($limit = '', $sort = '', $filter = array()) |
148 | 148 | { |
149 | 149 | global $globalDBdriver, $globalLiveInterval; |
@@ -186,11 +186,11 @@ discard block |
||
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
189 | - * Gets Minimal Live Spotter data |
|
190 | - * |
|
191 | - * @return Array the spotter information |
|
192 | - * |
|
193 | - */ |
|
189 | + * Gets Minimal Live Spotter data |
|
190 | + * |
|
191 | + * @return Array the spotter information |
|
192 | + * |
|
193 | + */ |
|
194 | 194 | public function getMinLiveSpotterData($filter = array()) |
195 | 195 | { |
196 | 196 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap2DAircraftsLimit; |
@@ -238,11 +238,11 @@ discard block |
||
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
241 | - * Gets Minimal Live Spotter data since xx seconds |
|
242 | - * |
|
243 | - * @return Array the spotter information |
|
244 | - * |
|
245 | - */ |
|
241 | + * Gets Minimal Live Spotter data since xx seconds |
|
242 | + * |
|
243 | + * @return Array the spotter information |
|
244 | + * |
|
245 | + */ |
|
246 | 246 | public function getMinLastLiveSpotterData($coord = array(),$filter = array(), $limit = false, $id = '') |
247 | 247 | { |
248 | 248 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit; |
@@ -339,11 +339,11 @@ discard block |
||
339 | 339 | } |
340 | 340 | |
341 | 341 | /** |
342 | - * Gets Minimal Live Spotter data since xx seconds |
|
343 | - * |
|
344 | - * @return Array the spotter information |
|
345 | - * |
|
346 | - */ |
|
342 | + * Gets Minimal Live Spotter data since xx seconds |
|
343 | + * |
|
344 | + * @return Array the spotter information |
|
345 | + * |
|
346 | + */ |
|
347 | 347 | public function getMinLastLiveSpotterDataByID($id = '',$filter = array(), $limit = false) |
348 | 348 | { |
349 | 349 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit; |
@@ -408,11 +408,11 @@ discard block |
||
408 | 408 | } |
409 | 409 | |
410 | 410 | /** |
411 | - * Gets number of latest data entry |
|
412 | - * |
|
413 | - * @return String number of entry |
|
414 | - * |
|
415 | - */ |
|
411 | + * Gets number of latest data entry |
|
412 | + * |
|
413 | + * @return String number of entry |
|
414 | + * |
|
415 | + */ |
|
416 | 416 | public function getLiveSpotterCount($filter = array()) |
417 | 417 | { |
418 | 418 | global $globalDBdriver, $globalLiveInterval; |
@@ -439,11 +439,11 @@ discard block |
||
439 | 439 | } |
440 | 440 | |
441 | 441 | /** |
442 | - * Gets all the spotter information based on the latest data entry and coord |
|
443 | - * |
|
444 | - * @return Array the spotter information |
|
445 | - * |
|
446 | - */ |
|
442 | + * Gets all the spotter information based on the latest data entry and coord |
|
443 | + * |
|
444 | + * @return Array the spotter information |
|
445 | + * |
|
446 | + */ |
|
447 | 447 | public function getLiveSpotterDatabyCoord($coord, $filter = array()) |
448 | 448 | { |
449 | 449 | global $globalDBdriver, $globalLiveInterval; |
@@ -468,11 +468,11 @@ discard block |
||
468 | 468 | } |
469 | 469 | |
470 | 470 | /** |
471 | - * Gets all the spotter information based on the latest data entry and coord |
|
472 | - * |
|
473 | - * @return Array the spotter information |
|
474 | - * |
|
475 | - */ |
|
471 | + * Gets all the spotter information based on the latest data entry and coord |
|
472 | + * |
|
473 | + * @return Array the spotter information |
|
474 | + * |
|
475 | + */ |
|
476 | 476 | public function getMinLiveSpotterDatabyCoord($coord, $filter = array()) |
477 | 477 | { |
478 | 478 | global $globalDBdriver, $globalLiveInterval, $globalArchive,$globalMap2DAircraftsLimit; |
@@ -560,11 +560,11 @@ discard block |
||
560 | 560 | } |
561 | 561 | |
562 | 562 | /** |
563 | - * Gets all the spotter information based on a user's latitude and longitude |
|
564 | - * |
|
565 | - * @return Array the spotter information |
|
566 | - * |
|
567 | - */ |
|
563 | + * Gets all the spotter information based on a user's latitude and longitude |
|
564 | + * |
|
565 | + * @return Array the spotter information |
|
566 | + * |
|
567 | + */ |
|
568 | 568 | public function getLatestSpotterForLayar($lat, $lng, $radius, $interval) |
569 | 569 | { |
570 | 570 | $Spotter = new Spotter($this->db); |
@@ -574,98 +574,98 @@ discard block |
||
574 | 574 | return false; |
575 | 575 | } |
576 | 576 | } |
577 | - if ($lng != '') |
|
578 | - { |
|
579 | - if (!is_numeric($lng)) |
|
580 | - { |
|
581 | - return false; |
|
582 | - } |
|
583 | - } |
|
584 | - |
|
585 | - if ($radius != '') |
|
586 | - { |
|
587 | - if (!is_numeric($radius)) |
|
588 | - { |
|
589 | - return false; |
|
590 | - } |
|
591 | - } |
|
577 | + if ($lng != '') |
|
578 | + { |
|
579 | + if (!is_numeric($lng)) |
|
580 | + { |
|
581 | + return false; |
|
582 | + } |
|
583 | + } |
|
584 | + |
|
585 | + if ($radius != '') |
|
586 | + { |
|
587 | + if (!is_numeric($radius)) |
|
588 | + { |
|
589 | + return false; |
|
590 | + } |
|
591 | + } |
|
592 | 592 | $additional_query = ''; |
593 | - if ($interval != '') |
|
594 | - { |
|
595 | - if (!is_string($interval)) |
|
596 | - { |
|
597 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
598 | - return false; |
|
599 | - } else { |
|
600 | - if ($interval == '1m') |
|
601 | - { |
|
602 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
603 | - } else if ($interval == '15m'){ |
|
604 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
605 | - } |
|
606 | - } |
|
607 | - } else { |
|
608 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
609 | - } |
|
610 | - |
|
611 | - $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
593 | + if ($interval != '') |
|
594 | + { |
|
595 | + if (!is_string($interval)) |
|
596 | + { |
|
597 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
598 | + return false; |
|
599 | + } else { |
|
600 | + if ($interval == '1m') |
|
601 | + { |
|
602 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
603 | + } else if ($interval == '15m'){ |
|
604 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
605 | + } |
|
606 | + } |
|
607 | + } else { |
|
608 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
609 | + } |
|
610 | + |
|
611 | + $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
612 | 612 | WHERE spotter_live.latitude <> '' |
613 | 613 | AND spotter_live.longitude <> '' |
614 | 614 | ".$additional_query." |
615 | 615 | HAVING distance < :radius |
616 | 616 | ORDER BY distance"; |
617 | 617 | |
618 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
618 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
619 | 619 | |
620 | - return $spotter_array; |
|
621 | - } |
|
620 | + return $spotter_array; |
|
621 | + } |
|
622 | 622 | |
623 | 623 | |
624 | - /** |
|
625 | - * Gets all the spotter information based on a particular callsign |
|
626 | - * |
|
627 | - * @return Array the spotter information |
|
628 | - * |
|
629 | - */ |
|
624 | + /** |
|
625 | + * Gets all the spotter information based on a particular callsign |
|
626 | + * |
|
627 | + * @return Array the spotter information |
|
628 | + * |
|
629 | + */ |
|
630 | 630 | public function getLastLiveSpotterDataByIdent($ident) |
631 | 631 | { |
632 | 632 | $Spotter = new Spotter($this->db); |
633 | 633 | date_default_timezone_set('UTC'); |
634 | 634 | |
635 | 635 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
636 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
636 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
637 | 637 | |
638 | 638 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
639 | 639 | |
640 | 640 | return $spotter_array; |
641 | 641 | } |
642 | 642 | |
643 | - /** |
|
644 | - * Gets all the spotter information based on a particular callsign |
|
645 | - * |
|
646 | - * @return Array the spotter information |
|
647 | - * |
|
648 | - */ |
|
643 | + /** |
|
644 | + * Gets all the spotter information based on a particular callsign |
|
645 | + * |
|
646 | + * @return Array the spotter information |
|
647 | + * |
|
648 | + */ |
|
649 | 649 | public function getDateLiveSpotterDataByIdent($ident,$date) |
650 | 650 | { |
651 | 651 | $Spotter = new Spotter($this->db); |
652 | 652 | date_default_timezone_set('UTC'); |
653 | 653 | |
654 | 654 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
655 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
655 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
656 | 656 | |
657 | - $date = date('c',$date); |
|
657 | + $date = date('c',$date); |
|
658 | 658 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
659 | 659 | |
660 | 660 | return $spotter_array; |
661 | 661 | } |
662 | 662 | |
663 | - /** |
|
664 | - * Gets last spotter information based on a particular callsign |
|
665 | - * |
|
666 | - * @return Array the spotter information |
|
667 | - * |
|
668 | - */ |
|
663 | + /** |
|
664 | + * Gets last spotter information based on a particular callsign |
|
665 | + * |
|
666 | + * @return Array the spotter information |
|
667 | + * |
|
668 | + */ |
|
669 | 669 | public function getLastLiveSpotterDataById($id) |
670 | 670 | { |
671 | 671 | $Spotter = new Spotter($this->db); |
@@ -676,12 +676,12 @@ discard block |
||
676 | 676 | return $spotter_array; |
677 | 677 | } |
678 | 678 | |
679 | - /** |
|
680 | - * Gets last spotter information based on a particular callsign |
|
681 | - * |
|
682 | - * @return Array the spotter information |
|
683 | - * |
|
684 | - */ |
|
679 | + /** |
|
680 | + * Gets last spotter information based on a particular callsign |
|
681 | + * |
|
682 | + * @return Array the spotter information |
|
683 | + * |
|
684 | + */ |
|
685 | 685 | public function getDateLiveSpotterDataById($id,$date) |
686 | 686 | { |
687 | 687 | $Spotter = new Spotter($this->db); |
@@ -694,21 +694,21 @@ discard block |
||
694 | 694 | return $spotter_array; |
695 | 695 | } |
696 | 696 | |
697 | - /** |
|
698 | - * Gets altitude information based on a particular callsign |
|
699 | - * |
|
700 | - * @return Array the spotter information |
|
701 | - * |
|
702 | - */ |
|
697 | + /** |
|
698 | + * Gets altitude information based on a particular callsign |
|
699 | + * |
|
700 | + * @return Array the spotter information |
|
701 | + * |
|
702 | + */ |
|
703 | 703 | public function getAltitudeLiveSpotterDataByIdent($ident) |
704 | 704 | { |
705 | 705 | |
706 | 706 | date_default_timezone_set('UTC'); |
707 | 707 | |
708 | 708 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
709 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
709 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
710 | 710 | |
711 | - try { |
|
711 | + try { |
|
712 | 712 | |
713 | 713 | $sth = $this->db->prepare($query); |
714 | 714 | $sth->execute(array(':ident' => $ident)); |
@@ -721,12 +721,12 @@ discard block |
||
721 | 721 | return $spotter_array; |
722 | 722 | } |
723 | 723 | |
724 | - /** |
|
725 | - * Gets all the spotter information based on a particular id |
|
726 | - * |
|
727 | - * @return Array the spotter information |
|
728 | - * |
|
729 | - */ |
|
724 | + /** |
|
725 | + * Gets all the spotter information based on a particular id |
|
726 | + * |
|
727 | + * @return Array the spotter information |
|
728 | + * |
|
729 | + */ |
|
730 | 730 | public function getAllLiveSpotterDataById($id,$liveinterval = false) |
731 | 731 | { |
732 | 732 | global $globalDBdriver, $globalLiveInterval; |
@@ -754,18 +754,18 @@ discard block |
||
754 | 754 | return $spotter_array; |
755 | 755 | } |
756 | 756 | |
757 | - /** |
|
758 | - * Gets all the spotter information based on a particular ident |
|
759 | - * |
|
760 | - * @return Array the spotter information |
|
761 | - * |
|
762 | - */ |
|
757 | + /** |
|
758 | + * Gets all the spotter information based on a particular ident |
|
759 | + * |
|
760 | + * @return Array the spotter information |
|
761 | + * |
|
762 | + */ |
|
763 | 763 | public function getAllLiveSpotterDataByIdent($ident) |
764 | 764 | { |
765 | 765 | date_default_timezone_set('UTC'); |
766 | 766 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
767 | 767 | $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
768 | - try { |
|
768 | + try { |
|
769 | 769 | |
770 | 770 | $sth = $this->db->prepare($query); |
771 | 771 | $sth->execute(array(':ident' => $ident)); |
@@ -779,23 +779,23 @@ discard block |
||
779 | 779 | |
780 | 780 | |
781 | 781 | /** |
782 | - * Deletes all info in the table |
|
783 | - * |
|
784 | - * @return String success or false |
|
785 | - * |
|
786 | - */ |
|
782 | + * Deletes all info in the table |
|
783 | + * |
|
784 | + * @return String success or false |
|
785 | + * |
|
786 | + */ |
|
787 | 787 | public function deleteLiveSpotterData() |
788 | 788 | { |
789 | 789 | global $globalDBdriver; |
790 | 790 | if ($globalDBdriver == 'mysql') { |
791 | 791 | //$query = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date"; |
792 | 792 | $query = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date'; |
793 | - //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
793 | + //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
794 | 794 | } else { |
795 | 795 | $query = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date"; |
796 | 796 | } |
797 | 797 | |
798 | - try { |
|
798 | + try { |
|
799 | 799 | |
800 | 800 | $sth = $this->db->prepare($query); |
801 | 801 | $sth->execute(); |
@@ -807,18 +807,18 @@ discard block |
||
807 | 807 | } |
808 | 808 | |
809 | 809 | /** |
810 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
811 | - * |
|
812 | - * @return String success or false |
|
813 | - * |
|
814 | - */ |
|
810 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
811 | + * |
|
812 | + * @return String success or false |
|
813 | + * |
|
814 | + */ |
|
815 | 815 | public function deleteLiveSpotterDataNotUpdated() |
816 | 816 | { |
817 | 817 | global $globalDBdriver, $globalDebug; |
818 | 818 | if ($globalDBdriver == 'mysql') { |
819 | 819 | //$query = 'SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < spotter_live.date) LIMIT 800 OFFSET 0'; |
820 | - $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0"; |
|
821 | - try { |
|
820 | + $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0"; |
|
821 | + try { |
|
822 | 822 | |
823 | 823 | $sth = $this->db->prepare($query); |
824 | 824 | $sth->execute(); |
@@ -826,8 +826,8 @@ discard block |
||
826 | 826 | return "error"; |
827 | 827 | } |
828 | 828 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
829 | - $i = 0; |
|
830 | - $j =0; |
|
829 | + $i = 0; |
|
830 | + $j =0; |
|
831 | 831 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
832 | 832 | foreach($all as $row) |
833 | 833 | { |
@@ -835,20 +835,20 @@ discard block |
||
835 | 835 | $j++; |
836 | 836 | if ($j == 30) { |
837 | 837 | if ($globalDebug) echo "."; |
838 | - try { |
|
838 | + try { |
|
839 | 839 | |
840 | 840 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
841 | 841 | $sth->execute(); |
842 | 842 | } catch(PDOException $e) { |
843 | 843 | return "error"; |
844 | 844 | } |
845 | - $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
846 | - $j = 0; |
|
845 | + $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
846 | + $j = 0; |
|
847 | 847 | } |
848 | 848 | $query_delete .= "'".$row['flightaware_id']."',"; |
849 | 849 | } |
850 | 850 | if ($i > 0) { |
851 | - try { |
|
851 | + try { |
|
852 | 852 | |
853 | 853 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
854 | 854 | $sth->execute(); |
@@ -859,9 +859,9 @@ discard block |
||
859 | 859 | return "success"; |
860 | 860 | } elseif ($globalDBdriver == 'pgsql') { |
861 | 861 | //$query = "SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < spotter_live.date) LIMIT 800 OFFSET 0"; |
862 | - //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
863 | - $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)"; |
|
864 | - try { |
|
862 | + //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
863 | + $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)"; |
|
864 | + try { |
|
865 | 865 | |
866 | 866 | $sth = $this->db->prepare($query); |
867 | 867 | $sth->execute(); |
@@ -905,17 +905,17 @@ discard block |
||
905 | 905 | } |
906 | 906 | |
907 | 907 | /** |
908 | - * Deletes all info in the table for an ident |
|
909 | - * |
|
910 | - * @return String success or false |
|
911 | - * |
|
912 | - */ |
|
908 | + * Deletes all info in the table for an ident |
|
909 | + * |
|
910 | + * @return String success or false |
|
911 | + * |
|
912 | + */ |
|
913 | 913 | public function deleteLiveSpotterDataByIdent($ident) |
914 | 914 | { |
915 | 915 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
916 | 916 | $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
917 | 917 | |
918 | - try { |
|
918 | + try { |
|
919 | 919 | |
920 | 920 | $sth = $this->db->prepare($query); |
921 | 921 | $sth->execute(array(':ident' => $ident)); |
@@ -927,17 +927,17 @@ discard block |
||
927 | 927 | } |
928 | 928 | |
929 | 929 | /** |
930 | - * Deletes all info in the table for an id |
|
931 | - * |
|
932 | - * @return String success or false |
|
933 | - * |
|
934 | - */ |
|
930 | + * Deletes all info in the table for an id |
|
931 | + * |
|
932 | + * @return String success or false |
|
933 | + * |
|
934 | + */ |
|
935 | 935 | public function deleteLiveSpotterDataById($id) |
936 | 936 | { |
937 | 937 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
938 | 938 | $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
939 | 939 | |
940 | - try { |
|
940 | + try { |
|
941 | 941 | |
942 | 942 | $sth = $this->db->prepare($query); |
943 | 943 | $sth->execute(array(':id' => $id)); |
@@ -950,11 +950,11 @@ discard block |
||
950 | 950 | |
951 | 951 | |
952 | 952 | /** |
953 | - * Gets the aircraft ident within the last hour |
|
954 | - * |
|
955 | - * @return String the ident |
|
956 | - * |
|
957 | - */ |
|
953 | + * Gets the aircraft ident within the last hour |
|
954 | + * |
|
955 | + * @return String the ident |
|
956 | + * |
|
957 | + */ |
|
958 | 958 | public function getIdentFromLastHour($ident) |
959 | 959 | { |
960 | 960 | global $globalDBdriver, $globalTimezone; |
@@ -980,14 +980,14 @@ discard block |
||
980 | 980 | $ident_result = $row['ident']; |
981 | 981 | } |
982 | 982 | return $ident_result; |
983 | - } |
|
983 | + } |
|
984 | 984 | |
985 | 985 | /** |
986 | - * Check recent aircraft |
|
987 | - * |
|
988 | - * @return String the ident |
|
989 | - * |
|
990 | - */ |
|
986 | + * Check recent aircraft |
|
987 | + * |
|
988 | + * @return String the ident |
|
989 | + * |
|
990 | + */ |
|
991 | 991 | public function checkIdentRecent($ident) |
992 | 992 | { |
993 | 993 | global $globalDBdriver, $globalTimezone; |
@@ -1013,14 +1013,14 @@ discard block |
||
1013 | 1013 | $ident_result = $row['flightaware_id']; |
1014 | 1014 | } |
1015 | 1015 | return $ident_result; |
1016 | - } |
|
1016 | + } |
|
1017 | 1017 | |
1018 | 1018 | /** |
1019 | - * Check recent aircraft by id |
|
1020 | - * |
|
1021 | - * @return String the ident |
|
1022 | - * |
|
1023 | - */ |
|
1019 | + * Check recent aircraft by id |
|
1020 | + * |
|
1021 | + * @return String the ident |
|
1022 | + * |
|
1023 | + */ |
|
1024 | 1024 | public function checkIdRecent($id) |
1025 | 1025 | { |
1026 | 1026 | global $globalDBdriver, $globalTimezone; |
@@ -1046,14 +1046,14 @@ discard block |
||
1046 | 1046 | $ident_result = $row['flightaware_id']; |
1047 | 1047 | } |
1048 | 1048 | return $ident_result; |
1049 | - } |
|
1049 | + } |
|
1050 | 1050 | |
1051 | 1051 | /** |
1052 | - * Check recent aircraft by ModeS |
|
1053 | - * |
|
1054 | - * @return String the ModeS |
|
1055 | - * |
|
1056 | - */ |
|
1052 | + * Check recent aircraft by ModeS |
|
1053 | + * |
|
1054 | + * @return String the ModeS |
|
1055 | + * |
|
1056 | + */ |
|
1057 | 1057 | public function checkModeSRecent($modes) |
1058 | 1058 | { |
1059 | 1059 | global $globalDBdriver, $globalTimezone; |
@@ -1083,11 +1083,11 @@ discard block |
||
1083 | 1083 | } |
1084 | 1084 | |
1085 | 1085 | /** |
1086 | - * Gets the aircraft data from the last 20 seconds |
|
1087 | - * |
|
1088 | - * @return Array the spotter data |
|
1089 | - * |
|
1090 | - */ |
|
1086 | + * Gets the aircraft data from the last 20 seconds |
|
1087 | + * |
|
1088 | + * @return Array the spotter data |
|
1089 | + * |
|
1090 | + */ |
|
1091 | 1091 | public function getRealTimeData($q = '') |
1092 | 1092 | { |
1093 | 1093 | global $globalDBdriver; |
@@ -1129,16 +1129,16 @@ discard block |
||
1129 | 1129 | } |
1130 | 1130 | |
1131 | 1131 | /** |
1132 | - * Adds a new spotter data |
|
1133 | - * |
|
1134 | - * @param String $flightaware_id the ID from flightaware |
|
1135 | - * @param String $ident the flight ident |
|
1136 | - * @param String $aircraft_icao the aircraft type |
|
1137 | - * @param String $departure_airport_icao the departure airport |
|
1138 | - * @param String $arrival_airport_icao the arrival airport |
|
1139 | - * @return String success or false |
|
1140 | - * |
|
1141 | - */ |
|
1132 | + * Adds a new spotter data |
|
1133 | + * |
|
1134 | + * @param String $flightaware_id the ID from flightaware |
|
1135 | + * @param String $ident the flight ident |
|
1136 | + * @param String $aircraft_icao the aircraft type |
|
1137 | + * @param String $departure_airport_icao the departure airport |
|
1138 | + * @param String $arrival_airport_icao the arrival airport |
|
1139 | + * @return String success or false |
|
1140 | + * |
|
1141 | + */ |
|
1142 | 1142 | public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
1143 | 1143 | { |
1144 | 1144 | global $globalURL, $globalArchive, $globalDebug; |
@@ -1281,10 +1281,10 @@ discard block |
||
1281 | 1281 | $arrival_airport_country = ''; |
1282 | 1282 | |
1283 | 1283 | |
1284 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1285 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1286 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1287 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1284 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1285 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1286 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1287 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1288 | 1288 | |
1289 | 1289 | $query = ''; |
1290 | 1290 | if ($globalArchive) { |
@@ -1305,10 +1305,10 @@ discard block |
||
1305 | 1305 | return "error : ".$e->getMessage(); |
1306 | 1306 | } |
1307 | 1307 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1308 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
1309 | - $SpotterArchive = new SpotterArchive($this->db); |
|
1310 | - $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
1311 | - if ($globalDebug) echo $result.')'; |
|
1308 | + if ($globalDebug) echo '(Add to SBS archive : '; |
|
1309 | + $SpotterArchive = new SpotterArchive($this->db); |
|
1310 | + $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
1311 | + if ($globalDebug) echo $result.')'; |
|
1312 | 1312 | } elseif ($globalDebug && $putinarchive !== true) { |
1313 | 1313 | echo '(Not adding to archive)'; |
1314 | 1314 | } elseif ($globalDebug && $noarchive === true) { |
@@ -17,62 +17,62 @@ discard block |
||
17 | 17 | * @param Array $filter the filter |
18 | 18 | * @return Array the SQL part |
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['airlines']) && !empty($flt['airlines'])) { |
38 | 38 | if ($flt['airlines'][0] != '' && $flt['airlines'][0] != 'all') { |
39 | 39 | if (isset($flt['source'])) { |
40 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
40 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
41 | 41 | } else { |
42 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
42 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | } |
46 | 46 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
47 | 47 | if (isset($flt['source'])) { |
48 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
48 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
49 | 49 | } else { |
50 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
50 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
54 | 54 | if (isset($flt['source'])) { |
55 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
55 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
56 | 56 | } else { |
57 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
57 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
61 | 61 | if (isset($flt['source'])) { |
62 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
62 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
63 | 63 | } else { |
64 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
64 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
65 | 65 | } |
66 | 66 | } |
67 | 67 | if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
68 | 68 | if (isset($flt['source'])) { |
69 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id"; |
|
69 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id"; |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | } |
73 | 73 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
74 | 74 | if ($filter['airlines'][0] != '' && $filter['airlines'][0] != 'all') { |
75 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id"; |
|
75 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id"; |
|
76 | 76 | } |
77 | 77 | } |
78 | 78 | if (isset($filter['alliance']) && !empty($filter['alliance'])) { |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id "; |
83 | 83 | } |
84 | 84 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
85 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id"; |
|
85 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id"; |
|
86 | 86 | } |
87 | 87 | if (isset($filter['blocked']) && $filter['blocked'] == true) { |
88 | 88 | $filter_query_join .= " INNER JOIN (SELECT callsign FROM aircraft_block) cblk ON cblk.callsign = spotter_live.ident"; |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | if (count($filter['source']) == 1) { |
92 | 92 | $filter_query_where .= " AND format_source = '".$filter['source'][0]."'"; |
93 | 93 | } else { |
94 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
94 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
95 | 95 | } |
96 | 96 | } |
97 | 97 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
@@ -124,15 +124,15 @@ discard block |
||
124 | 124 | $filter_query_date .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'"; |
125 | 125 | } |
126 | 126 | } |
127 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id"; |
|
127 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id"; |
|
128 | 128 | } |
129 | 129 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
130 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
130 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
131 | 131 | } |
132 | 132 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
133 | 133 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
134 | 134 | if ($filter_query_where != '') { |
135 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
135 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
136 | 136 | } |
137 | 137 | $filter_query = $filter_query_join.$filter_query_where; |
138 | 138 | return $filter_query; |
@@ -155,8 +155,8 @@ discard block |
||
155 | 155 | if ($limit != '') |
156 | 156 | { |
157 | 157 | $limit_array = explode(',', $limit); |
158 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
159 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
158 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
159 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
160 | 160 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
161 | 161 | { |
162 | 162 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | } else { |
181 | 181 | $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query.$orderby_query; |
182 | 182 | } |
183 | - $spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true); |
|
183 | + $spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true); |
|
184 | 184 | |
185 | 185 | return $spotter_array; |
186 | 186 | } |
@@ -195,30 +195,30 @@ discard block |
||
195 | 195 | { |
196 | 196 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap2DAircraftsLimit; |
197 | 197 | date_default_timezone_set('UTC'); |
198 | - $filter_query = $this->getFilter($filter,true,true); |
|
198 | + $filter_query = $this->getFilter($filter, true, true); |
|
199 | 199 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
200 | 200 | if ($globalDBdriver == 'mysql') { |
201 | 201 | if (isset($globalArchive) && $globalArchive === TRUE) { |
202 | 202 | // $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
203 | 203 | // FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date AND'." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0 ORDER BY date DESC"; |
204 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
204 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
205 | 205 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date AND'." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0"; |
206 | 206 | } else { |
207 | 207 | // $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
208 | 208 | // FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0 ORDER BY date DESC"; |
209 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
209 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
210 | 210 | FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0"; |
211 | 211 | } |
212 | 212 | } else { |
213 | 213 | if (isset($globalArchive) && $globalArchive === TRUE) { |
214 | 214 | // $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
215 | 215 | // FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' ORDER BY date DESC"; |
216 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
216 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
217 | 217 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'"; |
218 | 218 | } else { |
219 | 219 | // $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
220 | 220 | // FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' ORDER BY date DESC"; |
221 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
221 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
222 | 222 | FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'"; |
223 | 223 | } |
224 | 224 | } |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | try { |
230 | 230 | $sth = $this->db->prepare($query); |
231 | 231 | $sth->execute(); |
232 | - } catch(PDOException $e) { |
|
232 | + } catch (PDOException $e) { |
|
233 | 233 | echo $e->getMessage(); |
234 | 234 | die; |
235 | 235 | } |
@@ -243,20 +243,20 @@ discard block |
||
243 | 243 | * @return Array the spotter information |
244 | 244 | * |
245 | 245 | */ |
246 | - public function getMinLastLiveSpotterData($coord = array(),$filter = array(), $limit = false, $id = '') |
|
246 | + public function getMinLastLiveSpotterData($coord = array(), $filter = array(), $limit = false, $id = '') |
|
247 | 247 | { |
248 | 248 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit; |
249 | 249 | date_default_timezone_set('UTC'); |
250 | 250 | $usecoord = false; |
251 | 251 | if (is_array($coord) && !empty($coord)) { |
252 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
253 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
254 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
255 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
252 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
253 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
254 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
255 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
256 | 256 | $usecoord = true; |
257 | 257 | } |
258 | - $id = filter_var($id,FILTER_SANITIZE_STRING); |
|
259 | - $filter_query = $this->getFilter($filter,true,true); |
|
258 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
259 | + $filter_query = $this->getFilter($filter, true, true); |
|
260 | 260 | |
261 | 261 | if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200'; |
262 | 262 | if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300'; |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | WHERE spotter_archive.latitude <> '0' AND spotter_archive.longitude <> '0' |
269 | 269 | ORDER BY spotter_archive.flightaware_id, spotter_archive.date"; |
270 | 270 | */ |
271 | - $query = 'SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source, spotter_archive.registration |
|
271 | + $query = 'SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source, spotter_archive.registration |
|
272 | 272 | FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id "; |
273 | 273 | if ($usecoord) $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
274 | 274 | if ($id != '') $query .= "OR spotter_archive.flightaware_id = :id "; |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | ORDER BY flightaware_id, date"; |
283 | 283 | if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
284 | 284 | } else { |
285 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
285 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
286 | 286 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date "; |
287 | 287 | if ($usecoord) $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
288 | 288 | if ($id != '') $query .= "OR spotter_live.flightaware_id = :id "; |
@@ -298,13 +298,13 @@ discard block |
||
298 | 298 | WHERE spotter_archive.latitude <> '0' AND spotter_archive.longitude <> '0' |
299 | 299 | ORDER BY spotter_archive.flightaware_id, spotter_archive.date"; |
300 | 300 | */ |
301 | - $query = "SELECT * FROM ( |
|
301 | + $query = "SELECT * FROM ( |
|
302 | 302 | SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source, spotter_archive.registration |
303 | 303 | FROM spotter_archive |
304 | 304 | INNER JOIN ( |
305 | 305 | SELECT flightaware_id |
306 | 306 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date"; |
307 | - $query.= ") l ON l.flightaware_id = spotter_archive.flightaware_id "; |
|
307 | + $query .= ") l ON l.flightaware_id = spotter_archive.flightaware_id "; |
|
308 | 308 | if ($usecoord) $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
309 | 309 | if ($id != '') $query .= "OR spotter_archive.flightaware_id = :id "; |
310 | 310 | $query .= "UNION |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | try { |
331 | 331 | $sth = $this->db->prepare($query); |
332 | 332 | $sth->execute($query_values); |
333 | - } catch(PDOException $e) { |
|
333 | + } catch (PDOException $e) { |
|
334 | 334 | echo $e->getMessage(); |
335 | 335 | die; |
336 | 336 | } |
@@ -344,12 +344,12 @@ discard block |
||
344 | 344 | * @return Array the spotter information |
345 | 345 | * |
346 | 346 | */ |
347 | - public function getMinLastLiveSpotterDataByID($id = '',$filter = array(), $limit = false) |
|
347 | + public function getMinLastLiveSpotterDataByID($id = '', $filter = array(), $limit = false) |
|
348 | 348 | { |
349 | 349 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit; |
350 | 350 | date_default_timezone_set('UTC'); |
351 | - $id = filter_var($id,FILTER_SANITIZE_STRING); |
|
352 | - $filter_query = $this->getFilter($filter,true,true); |
|
351 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
352 | + $filter_query = $this->getFilter($filter, true, true); |
|
353 | 353 | |
354 | 354 | if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200'; |
355 | 355 | if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300'; |
@@ -373,13 +373,13 @@ discard block |
||
373 | 373 | } |
374 | 374 | } else { |
375 | 375 | if (isset($globalArchive) && $globalArchive === TRUE) { |
376 | - $query = "SELECT * FROM ( |
|
376 | + $query = "SELECT * FROM ( |
|
377 | 377 | SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source, spotter_archive.registration |
378 | 378 | FROM spotter_archive |
379 | 379 | INNER JOIN ( |
380 | 380 | SELECT flightaware_id |
381 | 381 | FROM spotter_live".$filter_query." spotter_live.flightaware_id = :id"; |
382 | - $query.= ") l ON l.flightaware_id = spotter_archive.flightaware_id "; |
|
382 | + $query .= ") l ON l.flightaware_id = spotter_archive.flightaware_id "; |
|
383 | 383 | $query .= "UNION |
384 | 384 | SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
385 | 385 | FROM spotter_live".$filter_query." spotter_live.flightaware_id = :id"; |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | try { |
400 | 400 | $sth = $this->db->prepare($query); |
401 | 401 | $sth->execute($query_values); |
402 | - } catch(PDOException $e) { |
|
402 | + } catch (PDOException $e) { |
|
403 | 403 | echo $e->getMessage(); |
404 | 404 | die; |
405 | 405 | } |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | public function getLiveSpotterCount($filter = array()) |
417 | 417 | { |
418 | 418 | global $globalDBdriver, $globalLiveInterval; |
419 | - $filter_query = $this->getFilter($filter,true,true); |
|
419 | + $filter_query = $this->getFilter($filter, true, true); |
|
420 | 420 | |
421 | 421 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
422 | 422 | if ($globalDBdriver == 'mysql') { |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | try { |
430 | 430 | $sth = $this->db->prepare($query); |
431 | 431 | $sth->execute(); |
432 | - } catch(PDOException $e) { |
|
432 | + } catch (PDOException $e) { |
|
433 | 433 | echo $e->getMessage(); |
434 | 434 | die; |
435 | 435 | } |
@@ -452,10 +452,10 @@ discard block |
||
452 | 452 | $filter_query = $this->getFilter($filter); |
453 | 453 | |
454 | 454 | if (is_array($coord)) { |
455 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
456 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
457 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
458 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
455 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
456 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
457 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
458 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
459 | 459 | } else return array(); |
460 | 460 | if ($globalDBdriver == 'mysql') { |
461 | 461 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
@@ -475,26 +475,26 @@ discard block |
||
475 | 475 | */ |
476 | 476 | public function getMinLiveSpotterDatabyCoord($coord, $filter = array()) |
477 | 477 | { |
478 | - global $globalDBdriver, $globalLiveInterval, $globalArchive,$globalMap2DAircraftsLimit; |
|
478 | + global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap2DAircraftsLimit; |
|
479 | 479 | $Spotter = new Spotter($this->db); |
480 | 480 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
481 | - $filter_query = $this->getFilter($filter,true,true); |
|
481 | + $filter_query = $this->getFilter($filter, true, true); |
|
482 | 482 | |
483 | 483 | if (is_array($coord)) { |
484 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
485 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
486 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
487 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
484 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
485 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
486 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
487 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
488 | 488 | } else return array(); |
489 | 489 | if ($globalDBdriver == 'mysql') { |
490 | 490 | if (isset($globalArchive) && $globalArchive === TRUE) { |
491 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
491 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
492 | 492 | FROM spotter_live |
493 | 493 | '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date |
494 | 494 | AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' |
495 | 495 | AND spotter_live.latitude <> 0 AND spotter_live.longitude <> 0 ORDER BY date DESC'; |
496 | 496 | } else { |
497 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
497 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
498 | 498 | FROM spotter_live |
499 | 499 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
500 | 500 | FROM spotter_live l |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." |
515 | 515 | AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' ORDER BY date DESC"; |
516 | 516 | */ |
517 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
517 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
518 | 518 | FROM spotter_live |
519 | 519 | ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date |
520 | 520 | AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | ) s on spotter_live.flightaware_id = s.flightaware_id |
534 | 534 | AND spotter_live.date = s.maxdate".$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' ORDER BY date DESC"; |
535 | 535 | */ |
536 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
536 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
|
537 | 537 | FROM spotter_live |
538 | 538 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
539 | 539 | FROM spotter_live l |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | try { |
552 | 552 | $sth = $this->db->prepare($query); |
553 | 553 | $sth->execute(); |
554 | - } catch(PDOException $e) { |
|
554 | + } catch (PDOException $e) { |
|
555 | 555 | echo $e->getMessage(); |
556 | 556 | die; |
557 | 557 | } |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | if ($interval == '1m') |
601 | 601 | { |
602 | 602 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
603 | - } else if ($interval == '15m'){ |
|
603 | + } else if ($interval == '15m') { |
|
604 | 604 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
605 | 605 | } |
606 | 606 | } |
@@ -608,14 +608,14 @@ discard block |
||
608 | 608 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
609 | 609 | } |
610 | 610 | |
611 | - $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
611 | + $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
612 | 612 | WHERE spotter_live.latitude <> '' |
613 | 613 | AND spotter_live.longitude <> '' |
614 | 614 | ".$additional_query." |
615 | 615 | HAVING distance < :radius |
616 | 616 | ORDER BY distance"; |
617 | 617 | |
618 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
618 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
619 | 619 | |
620 | 620 | return $spotter_array; |
621 | 621 | } |
@@ -633,9 +633,9 @@ discard block |
||
633 | 633 | date_default_timezone_set('UTC'); |
634 | 634 | |
635 | 635 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
636 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
636 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
637 | 637 | |
638 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
638 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
639 | 639 | |
640 | 640 | return $spotter_array; |
641 | 641 | } |
@@ -646,16 +646,16 @@ discard block |
||
646 | 646 | * @return Array the spotter information |
647 | 647 | * |
648 | 648 | */ |
649 | - public function getDateLiveSpotterDataByIdent($ident,$date) |
|
649 | + public function getDateLiveSpotterDataByIdent($ident, $date) |
|
650 | 650 | { |
651 | 651 | $Spotter = new Spotter($this->db); |
652 | 652 | date_default_timezone_set('UTC'); |
653 | 653 | |
654 | 654 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
655 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
655 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
656 | 656 | |
657 | - $date = date('c',$date); |
|
658 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
657 | + $date = date('c', $date); |
|
658 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
659 | 659 | |
660 | 660 | return $spotter_array; |
661 | 661 | } |
@@ -671,8 +671,8 @@ discard block |
||
671 | 671 | $Spotter = new Spotter($this->db); |
672 | 672 | date_default_timezone_set('UTC'); |
673 | 673 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
674 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
675 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
|
674 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
675 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true); |
|
676 | 676 | return $spotter_array; |
677 | 677 | } |
678 | 678 | |
@@ -682,15 +682,15 @@ discard block |
||
682 | 682 | * @return Array the spotter information |
683 | 683 | * |
684 | 684 | */ |
685 | - public function getDateLiveSpotterDataById($id,$date) |
|
685 | + public function getDateLiveSpotterDataById($id, $date) |
|
686 | 686 | { |
687 | 687 | $Spotter = new Spotter($this->db); |
688 | 688 | date_default_timezone_set('UTC'); |
689 | 689 | |
690 | 690 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
691 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
692 | - $date = date('c',$date); |
|
693 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
691 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
692 | + $date = date('c', $date); |
|
693 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
694 | 694 | return $spotter_array; |
695 | 695 | } |
696 | 696 | |
@@ -706,13 +706,13 @@ discard block |
||
706 | 706 | date_default_timezone_set('UTC'); |
707 | 707 | |
708 | 708 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
709 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
709 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
710 | 710 | |
711 | 711 | try { |
712 | 712 | |
713 | 713 | $sth = $this->db->prepare($query); |
714 | 714 | $sth->execute(array(':ident' => $ident)); |
715 | - } catch(PDOException $e) { |
|
715 | + } catch (PDOException $e) { |
|
716 | 716 | echo $e->getMessage(); |
717 | 717 | die; |
718 | 718 | } |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | * @return Array the spotter information |
728 | 728 | * |
729 | 729 | */ |
730 | - public function getAllLiveSpotterDataById($id,$liveinterval = false) |
|
730 | + public function getAllLiveSpotterDataById($id, $liveinterval = false) |
|
731 | 731 | { |
732 | 732 | global $globalDBdriver, $globalLiveInterval; |
733 | 733 | date_default_timezone_set('UTC'); |
@@ -746,7 +746,7 @@ discard block |
||
746 | 746 | try { |
747 | 747 | $sth = $this->db->prepare($query); |
748 | 748 | $sth->execute(array(':id' => $id)); |
749 | - } catch(PDOException $e) { |
|
749 | + } catch (PDOException $e) { |
|
750 | 750 | echo $e->getMessage(); |
751 | 751 | die; |
752 | 752 | } |
@@ -764,12 +764,12 @@ discard block |
||
764 | 764 | { |
765 | 765 | date_default_timezone_set('UTC'); |
766 | 766 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
767 | - $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
767 | + $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
768 | 768 | try { |
769 | 769 | |
770 | 770 | $sth = $this->db->prepare($query); |
771 | 771 | $sth->execute(array(':ident' => $ident)); |
772 | - } catch(PDOException $e) { |
|
772 | + } catch (PDOException $e) { |
|
773 | 773 | echo $e->getMessage(); |
774 | 774 | die; |
775 | 775 | } |
@@ -799,7 +799,7 @@ discard block |
||
799 | 799 | |
800 | 800 | $sth = $this->db->prepare($query); |
801 | 801 | $sth->execute(); |
802 | - } catch(PDOException $e) { |
|
802 | + } catch (PDOException $e) { |
|
803 | 803 | return "error"; |
804 | 804 | } |
805 | 805 | |
@@ -822,14 +822,14 @@ discard block |
||
822 | 822 | |
823 | 823 | $sth = $this->db->prepare($query); |
824 | 824 | $sth->execute(); |
825 | - } catch(PDOException $e) { |
|
825 | + } catch (PDOException $e) { |
|
826 | 826 | return "error"; |
827 | 827 | } |
828 | 828 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
829 | 829 | $i = 0; |
830 | - $j =0; |
|
830 | + $j = 0; |
|
831 | 831 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
832 | - foreach($all as $row) |
|
832 | + foreach ($all as $row) |
|
833 | 833 | { |
834 | 834 | $i++; |
835 | 835 | $j++; |
@@ -837,9 +837,9 @@ discard block |
||
837 | 837 | if ($globalDebug) echo "."; |
838 | 838 | try { |
839 | 839 | |
840 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
840 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
841 | 841 | $sth->execute(); |
842 | - } catch(PDOException $e) { |
|
842 | + } catch (PDOException $e) { |
|
843 | 843 | return "error"; |
844 | 844 | } |
845 | 845 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
@@ -850,9 +850,9 @@ discard block |
||
850 | 850 | if ($i > 0) { |
851 | 851 | try { |
852 | 852 | |
853 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
853 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
854 | 854 | $sth->execute(); |
855 | - } catch(PDOException $e) { |
|
855 | + } catch (PDOException $e) { |
|
856 | 856 | return "error"; |
857 | 857 | } |
858 | 858 | } |
@@ -865,7 +865,7 @@ discard block |
||
865 | 865 | |
866 | 866 | $sth = $this->db->prepare($query); |
867 | 867 | $sth->execute(); |
868 | - } catch(PDOException $e) { |
|
868 | + } catch (PDOException $e) { |
|
869 | 869 | return "error"; |
870 | 870 | } |
871 | 871 | /* $query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN ("; |
@@ -913,13 +913,13 @@ discard block |
||
913 | 913 | public function deleteLiveSpotterDataByIdent($ident) |
914 | 914 | { |
915 | 915 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
916 | - $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
916 | + $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
917 | 917 | |
918 | 918 | try { |
919 | 919 | |
920 | 920 | $sth = $this->db->prepare($query); |
921 | 921 | $sth->execute(array(':ident' => $ident)); |
922 | - } catch(PDOException $e) { |
|
922 | + } catch (PDOException $e) { |
|
923 | 923 | return "error"; |
924 | 924 | } |
925 | 925 | |
@@ -935,13 +935,13 @@ discard block |
||
935 | 935 | public function deleteLiveSpotterDataById($id) |
936 | 936 | { |
937 | 937 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
938 | - $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
938 | + $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
939 | 939 | |
940 | 940 | try { |
941 | 941 | |
942 | 942 | $sth = $this->db->prepare($query); |
943 | 943 | $sth->execute(array(':id' => $id)); |
944 | - } catch(PDOException $e) { |
|
944 | + } catch (PDOException $e) { |
|
945 | 945 | return "error"; |
946 | 946 | } |
947 | 947 | |
@@ -959,13 +959,13 @@ discard block |
||
959 | 959 | { |
960 | 960 | global $globalDBdriver, $globalTimezone; |
961 | 961 | if ($globalDBdriver == 'mysql') { |
962 | - $query = 'SELECT spotter_live.ident FROM spotter_live |
|
962 | + $query = 'SELECT spotter_live.ident FROM spotter_live |
|
963 | 963 | WHERE spotter_live.ident = :ident |
964 | 964 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
965 | 965 | AND spotter_live.date < UTC_TIMESTAMP()'; |
966 | 966 | $query_data = array(':ident' => $ident); |
967 | 967 | } else { |
968 | - $query = "SELECT spotter_live.ident FROM spotter_live |
|
968 | + $query = "SELECT spotter_live.ident FROM spotter_live |
|
969 | 969 | WHERE spotter_live.ident = :ident |
970 | 970 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
971 | 971 | AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -974,8 +974,8 @@ discard block |
||
974 | 974 | |
975 | 975 | $sth = $this->db->prepare($query); |
976 | 976 | $sth->execute($query_data); |
977 | - $ident_result=''; |
|
978 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
977 | + $ident_result = ''; |
|
978 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
979 | 979 | { |
980 | 980 | $ident_result = $row['ident']; |
981 | 981 | } |
@@ -992,13 +992,13 @@ discard block |
||
992 | 992 | { |
993 | 993 | global $globalDBdriver, $globalTimezone; |
994 | 994 | if ($globalDBdriver == 'mysql') { |
995 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
995 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
996 | 996 | WHERE spotter_live.ident = :ident |
997 | 997 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 MINUTE)'; |
998 | 998 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
999 | 999 | $query_data = array(':ident' => $ident); |
1000 | 1000 | } else { |
1001 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
1001 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
1002 | 1002 | WHERE spotter_live.ident = :ident |
1003 | 1003 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '20 MINUTES'"; |
1004 | 1004 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -1007,8 +1007,8 @@ discard block |
||
1007 | 1007 | |
1008 | 1008 | $sth = $this->db->prepare($query); |
1009 | 1009 | $sth->execute($query_data); |
1010 | - $ident_result=''; |
|
1011 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1010 | + $ident_result = ''; |
|
1011 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1012 | 1012 | { |
1013 | 1013 | $ident_result = $row['flightaware_id']; |
1014 | 1014 | } |
@@ -1025,13 +1025,13 @@ discard block |
||
1025 | 1025 | { |
1026 | 1026 | global $globalDBdriver, $globalTimezone; |
1027 | 1027 | if ($globalDBdriver == 'mysql') { |
1028 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
1028 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
1029 | 1029 | WHERE spotter_live.flightaware_id = :id |
1030 | 1030 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
1031 | 1031 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
1032 | 1032 | $query_data = array(':id' => $id); |
1033 | 1033 | } else { |
1034 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
1034 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
1035 | 1035 | WHERE spotter_live.flightaware_id = :id |
1036 | 1036 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
1037 | 1037 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -1040,8 +1040,8 @@ discard block |
||
1040 | 1040 | |
1041 | 1041 | $sth = $this->db->prepare($query); |
1042 | 1042 | $sth->execute($query_data); |
1043 | - $ident_result=''; |
|
1044 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1043 | + $ident_result = ''; |
|
1044 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1045 | 1045 | { |
1046 | 1046 | $ident_result = $row['flightaware_id']; |
1047 | 1047 | } |
@@ -1058,13 +1058,13 @@ discard block |
||
1058 | 1058 | { |
1059 | 1059 | global $globalDBdriver, $globalTimezone; |
1060 | 1060 | if ($globalDBdriver == 'mysql') { |
1061 | - $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
1061 | + $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
1062 | 1062 | WHERE spotter_live.ModeS = :modes |
1063 | 1063 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 MINUTE)'; |
1064 | 1064 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
1065 | 1065 | $query_data = array(':modes' => $modes); |
1066 | 1066 | } else { |
1067 | - $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
1067 | + $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
1068 | 1068 | WHERE spotter_live.ModeS = :modes |
1069 | 1069 | AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 MINUTE'"; |
1070 | 1070 | // // AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
@@ -1073,8 +1073,8 @@ discard block |
||
1073 | 1073 | |
1074 | 1074 | $sth = $this->db->prepare($query); |
1075 | 1075 | $sth->execute($query_data); |
1076 | - $ident_result=''; |
|
1077 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1076 | + $ident_result = ''; |
|
1077 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1078 | 1078 | { |
1079 | 1079 | //$ident_result = $row['spotter_live_id']; |
1080 | 1080 | $ident_result = $row['flightaware_id']; |
@@ -1099,8 +1099,8 @@ discard block |
||
1099 | 1099 | return array(); |
1100 | 1100 | } else { |
1101 | 1101 | $q_array = explode(" ", $q); |
1102 | - foreach ($q_array as $q_item){ |
|
1103 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
1102 | + foreach ($q_array as $q_item) { |
|
1103 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
1104 | 1104 | $additional_query .= " AND ("; |
1105 | 1105 | $additional_query .= "(spotter_live.aircraft_icao like '%".$q_item."%') OR "; |
1106 | 1106 | $additional_query .= "(spotter_live.aircraft_name like '%".$q_item."%') OR "; |
@@ -1115,11 +1115,11 @@ discard block |
||
1115 | 1115 | } |
1116 | 1116 | } |
1117 | 1117 | if ($globalDBdriver == 'mysql') { |
1118 | - $query = "SELECT spotter_live.* FROM spotter_live |
|
1118 | + $query = "SELECT spotter_live.* FROM spotter_live |
|
1119 | 1119 | WHERE spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
1120 | 1120 | AND spotter_live.date < UTC_TIMESTAMP()"; |
1121 | 1121 | } else { |
1122 | - $query = "SELECT spotter_live.* FROM spotter_live |
|
1122 | + $query = "SELECT spotter_live.* FROM spotter_live |
|
1123 | 1123 | WHERE spotter_live.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
1124 | 1124 | AND spotter_live.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
1125 | 1125 | } |
@@ -1139,7 +1139,7 @@ discard block |
||
1139 | 1139 | * @return String success or false |
1140 | 1140 | * |
1141 | 1141 | */ |
1142 | - public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
|
1142 | + public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false, $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false, $format_source = '', $source_name = '', $over_country = '') |
|
1143 | 1143 | { |
1144 | 1144 | global $globalURL, $globalArchive, $globalDebug; |
1145 | 1145 | $Common = new Common(); |
@@ -1239,27 +1239,27 @@ discard block |
||
1239 | 1239 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
1240 | 1240 | |
1241 | 1241 | |
1242 | - $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
|
1243 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
1244 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
1245 | - $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
1246 | - $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
1247 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1248 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1249 | - $waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING); |
|
1250 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1251 | - $altitude_real = filter_var($altitude_real,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1252 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
1253 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1254 | - $squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT); |
|
1255 | - $route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING); |
|
1256 | - $ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING); |
|
1257 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING); |
|
1258 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
1259 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
1260 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
1261 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
1262 | - $verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT); |
|
1242 | + $flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING); |
|
1243 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
1244 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
1245 | + $departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING); |
|
1246 | + $arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING); |
|
1247 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1248 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1249 | + $waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING); |
|
1250 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1251 | + $altitude_real = filter_var($altitude_real, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1252 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
1253 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1254 | + $squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT); |
|
1255 | + $route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING); |
|
1256 | + $ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING); |
|
1257 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING); |
|
1258 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
1259 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
1260 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
1261 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
1262 | + $verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT); |
|
1263 | 1263 | |
1264 | 1264 | $airline_name = ''; |
1265 | 1265 | $airline_icao = ''; |
@@ -1281,10 +1281,10 @@ discard block |
||
1281 | 1281 | $arrival_airport_country = ''; |
1282 | 1282 | |
1283 | 1283 | |
1284 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1285 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1286 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1287 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1284 | + if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL; |
|
1285 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL; |
|
1286 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
1287 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
1288 | 1288 | |
1289 | 1289 | $query = ''; |
1290 | 1290 | if ($globalArchive) { |
@@ -1295,19 +1295,19 @@ discard block |
||
1295 | 1295 | $query .= 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country, real_altitude) |
1296 | 1296 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country, :real_altitude)'; |
1297 | 1297 | |
1298 | - $query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,':aircraft_icao' => $aircraft_icao,':aircraft_shadow' => $aircraft_shadow,':aircraft_type' => $aircraft_type,':aircraft_manufacturer' => $aircraft_manufacturer,':departure_airport_icao' => $departure_airport_icao,':departure_airport_name' => $departure_airport_name,':departure_airport_city' => $departure_airport_city,':departure_airport_country' => $departure_airport_country,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk,':route_stop' => $route_stop,':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source,':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country,':real_altitude' => $altitude_real); |
|
1298 | + $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_type' => $aircraft_type, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country, ':real_altitude' => $altitude_real); |
|
1299 | 1299 | try { |
1300 | 1300 | |
1301 | 1301 | $sth = $this->db->prepare($query); |
1302 | 1302 | $sth->execute($query_values); |
1303 | 1303 | $sth->closeCursor(); |
1304 | - } catch(PDOException $e) { |
|
1304 | + } catch (PDOException $e) { |
|
1305 | 1305 | return "error : ".$e->getMessage(); |
1306 | 1306 | } |
1307 | 1307 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1308 | 1308 | if ($globalDebug) echo '(Add to SBS archive : '; |
1309 | 1309 | $SpotterArchive = new SpotterArchive($this->db); |
1310 | - $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
1310 | + $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time, $arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name, $verticalrate, $format_source, $source_name, $over_country); |
|
1311 | 1311 | if ($globalDebug) echo $result.')'; |
1312 | 1312 | } elseif ($globalDebug && $putinarchive !== true) { |
1313 | 1313 | echo '(Not adding to archive)'; |
@@ -1320,7 +1320,7 @@ discard block |
||
1320 | 1320 | |
1321 | 1321 | public function getOrderBy() |
1322 | 1322 | { |
1323 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC")); |
|
1323 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC")); |
|
1324 | 1324 | return $orderby; |
1325 | 1325 | } |
1326 | 1326 |
@@ -8,7 +8,9 @@ discard block |
||
8 | 8 | public function __construct($dbc = null) { |
9 | 9 | $Connection = new Connection($dbc); |
10 | 10 | $this->db = $Connection->db(); |
11 | - if ($this->db === null) die('Error: No DB connection. (SpotterLive)'); |
|
11 | + if ($this->db === null) { |
|
12 | + die('Error: No DB connection. (SpotterLive)'); |
|
13 | + } |
|
12 | 14 | } |
13 | 15 | |
14 | 16 | |
@@ -30,7 +32,9 @@ discard block |
||
30 | 32 | if (isset($filter[0]['source'])) { |
31 | 33 | $filters = array_merge($filters,$filter); |
32 | 34 | } |
33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
35 | + if (is_array($globalFilter)) { |
|
36 | + $filter = array_merge($filter,$globalFilter); |
|
37 | + } |
|
34 | 38 | $filter_query_join = ''; |
35 | 39 | $filter_query_where = ''; |
36 | 40 | foreach($filters as $flt) { |
@@ -129,8 +133,11 @@ discard block |
||
129 | 133 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
130 | 134 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
131 | 135 | } |
132 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
133 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
136 | + if ($filter_query_where == '' && $where) { |
|
137 | + $filter_query_where = ' WHERE'; |
|
138 | + } elseif ($filter_query_where != '' && $and) { |
|
139 | + $filter_query_where .= ' AND'; |
|
140 | + } |
|
134 | 141 | if ($filter_query_where != '') { |
135 | 142 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
136 | 143 | } |
@@ -171,9 +178,13 @@ discard block |
||
171 | 178 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
172 | 179 | } |
173 | 180 | } |
174 | - if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC'; |
|
181 | + if ($orderby_query == '') { |
|
182 | + $orderby_query = ' ORDER BY date DESC'; |
|
183 | + } |
|
175 | 184 | |
176 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
185 | + if (!isset($globalLiveInterval)) { |
|
186 | + $globalLiveInterval = '200'; |
|
187 | + } |
|
177 | 188 | if ($globalDBdriver == 'mysql') { |
178 | 189 | //$query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
179 | 190 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -196,7 +207,9 @@ discard block |
||
196 | 207 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap2DAircraftsLimit; |
197 | 208 | date_default_timezone_set('UTC'); |
198 | 209 | $filter_query = $this->getFilter($filter,true,true); |
199 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
210 | + if (!isset($globalLiveInterval)) { |
|
211 | + $globalLiveInterval = '200'; |
|
212 | + } |
|
200 | 213 | if ($globalDBdriver == 'mysql') { |
201 | 214 | if (isset($globalArchive) && $globalArchive === TRUE) { |
202 | 215 | // $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
@@ -258,8 +271,12 @@ discard block |
||
258 | 271 | $id = filter_var($id,FILTER_SANITIZE_STRING); |
259 | 272 | $filter_query = $this->getFilter($filter,true,true); |
260 | 273 | |
261 | - if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200'; |
|
262 | - if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300'; |
|
274 | + if (!isset($globalLiveInterval) || $globalLiveInterval == '') { |
|
275 | + $globalLiveInterval = '200'; |
|
276 | + } |
|
277 | + if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') { |
|
278 | + $globalMap3DAircraftsLimit = '300'; |
|
279 | + } |
|
263 | 280 | if ($globalDBdriver == 'mysql') { |
264 | 281 | if (isset($globalArchive) && $globalArchive === TRUE) { |
265 | 282 | /* |
@@ -270,25 +287,41 @@ discard block |
||
270 | 287 | */ |
271 | 288 | $query = 'SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source, spotter_archive.registration |
272 | 289 | FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id "; |
273 | - if ($usecoord) $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
274 | - if ($id != '') $query .= "OR spotter_archive.flightaware_id = :id "; |
|
290 | + if ($usecoord) { |
|
291 | + $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
292 | + } |
|
293 | + if ($id != '') { |
|
294 | + $query .= "OR spotter_archive.flightaware_id = :id "; |
|
295 | + } |
|
275 | 296 | $query .= "UNION |
276 | 297 | SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
277 | 298 | FROM spotter_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date"; |
278 | - if ($usecoord) $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
279 | - if ($id != '') $query .= " OR spotter_live.flightaware_id = :id"; |
|
299 | + if ($usecoord) { |
|
300 | + $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
301 | + } |
|
302 | + if ($id != '') { |
|
303 | + $query .= " OR spotter_live.flightaware_id = :id"; |
|
304 | + } |
|
280 | 305 | $query .= ") AS spotter |
281 | 306 | WHERE latitude <> '0' AND longitude <> '0' |
282 | 307 | ORDER BY flightaware_id, date"; |
283 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
308 | + if ($limit) { |
|
309 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
310 | + } |
|
284 | 311 | } else { |
285 | 312 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
286 | 313 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date "; |
287 | - if ($usecoord) $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
288 | - if ($id != '') $query .= "OR spotter_live.flightaware_id = :id "; |
|
314 | + if ($usecoord) { |
|
315 | + $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
316 | + } |
|
317 | + if ($id != '') { |
|
318 | + $query .= "OR spotter_live.flightaware_id = :id "; |
|
319 | + } |
|
289 | 320 | $query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
290 | 321 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
291 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
322 | + if ($limit) { |
|
323 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
324 | + } |
|
292 | 325 | } |
293 | 326 | } else { |
294 | 327 | if (isset($globalArchive) && $globalArchive === TRUE) { |
@@ -305,28 +338,46 @@ discard block |
||
305 | 338 | SELECT flightaware_id |
306 | 339 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date"; |
307 | 340 | $query.= ") l ON l.flightaware_id = spotter_archive.flightaware_id "; |
308 | - if ($usecoord) $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
309 | - if ($id != '') $query .= "OR spotter_archive.flightaware_id = :id "; |
|
341 | + if ($usecoord) { |
|
342 | + $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
343 | + } |
|
344 | + if ($id != '') { |
|
345 | + $query .= "OR spotter_archive.flightaware_id = :id "; |
|
346 | + } |
|
310 | 347 | $query .= "UNION |
311 | 348 | SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
312 | 349 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date"; |
313 | - if ($usecoord) $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
314 | - if ($id != '') $query .= " OR spotter_live.flightaware_id = :id"; |
|
350 | + if ($usecoord) { |
|
351 | + $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
352 | + } |
|
353 | + if ($id != '') { |
|
354 | + $query .= " OR spotter_live.flightaware_id = :id"; |
|
355 | + } |
|
315 | 356 | $query .= ") AS spotter WHERE latitude <> '0' AND longitude <> '0' "; |
316 | 357 | $query .= "ORDER BY flightaware_id, date"; |
317 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
358 | + if ($limit) { |
|
359 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
360 | + } |
|
318 | 361 | } else { |
319 | 362 | $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
320 | 363 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date "; |
321 | - if ($usecoord) $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
322 | - if ($id != '') $query .= "OR spotter_live.flightaware_id = :id "; |
|
364 | + if ($usecoord) { |
|
365 | + $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
366 | + } |
|
367 | + if ($id != '') { |
|
368 | + $query .= "OR spotter_live.flightaware_id = :id "; |
|
369 | + } |
|
323 | 370 | $query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
324 | 371 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
325 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
372 | + if ($limit) { |
|
373 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
374 | + } |
|
326 | 375 | } |
327 | 376 | } |
328 | 377 | $query_values = array(); |
329 | - if ($id != '') $query_values = array(':id' => $id); |
|
378 | + if ($id != '') { |
|
379 | + $query_values = array(':id' => $id); |
|
380 | + } |
|
330 | 381 | try { |
331 | 382 | $sth = $this->db->prepare($query); |
332 | 383 | $sth->execute($query_values); |
@@ -351,8 +402,12 @@ discard block |
||
351 | 402 | $id = filter_var($id,FILTER_SANITIZE_STRING); |
352 | 403 | $filter_query = $this->getFilter($filter,true,true); |
353 | 404 | |
354 | - if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200'; |
|
355 | - if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300'; |
|
405 | + if (!isset($globalLiveInterval) || $globalLiveInterval == '') { |
|
406 | + $globalLiveInterval = '200'; |
|
407 | + } |
|
408 | + if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') { |
|
409 | + $globalMap3DAircraftsLimit = '300'; |
|
410 | + } |
|
356 | 411 | if ($globalDBdriver == 'mysql') { |
357 | 412 | if (isset($globalArchive) && $globalArchive === TRUE) { |
358 | 413 | $query = 'SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source, spotter_archive.registration |
@@ -363,13 +418,17 @@ discard block |
||
363 | 418 | $query .= ") AS spotter |
364 | 419 | WHERE latitude <> '0' AND longitude <> '0' |
365 | 420 | ORDER BY flightaware_id, date"; |
366 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
421 | + if ($limit) { |
|
422 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
423 | + } |
|
367 | 424 | } else { |
368 | 425 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
369 | 426 | FROM spotter_live'.$filter_query.' spotter_live.flightaware_id = :id '; |
370 | 427 | $query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
371 | 428 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
372 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
429 | + if ($limit) { |
|
430 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
431 | + } |
|
373 | 432 | } |
374 | 433 | } else { |
375 | 434 | if (isset($globalArchive) && $globalArchive === TRUE) { |
@@ -385,13 +444,17 @@ discard block |
||
385 | 444 | FROM spotter_live".$filter_query." spotter_live.flightaware_id = :id"; |
386 | 445 | $query .= ") AS spotter WHERE latitude <> '0' AND longitude <> '0' "; |
387 | 446 | $query .= "ORDER BY flightaware_id, date"; |
388 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
447 | + if ($limit) { |
|
448 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
449 | + } |
|
389 | 450 | } else { |
390 | 451 | $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
391 | 452 | FROM spotter_live".$filter_query." spotter_live.flightaware_id = :id "; |
392 | 453 | $query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
393 | 454 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
394 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
455 | + if ($limit) { |
|
456 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
457 | + } |
|
395 | 458 | } |
396 | 459 | } |
397 | 460 | $query_values = array(); |
@@ -418,7 +481,9 @@ discard block |
||
418 | 481 | global $globalDBdriver, $globalLiveInterval; |
419 | 482 | $filter_query = $this->getFilter($filter,true,true); |
420 | 483 | |
421 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
484 | + if (!isset($globalLiveInterval)) { |
|
485 | + $globalLiveInterval = '200'; |
|
486 | + } |
|
422 | 487 | if ($globalDBdriver == 'mysql') { |
423 | 488 | //$query = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query; |
424 | 489 | $query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
@@ -448,7 +513,9 @@ discard block |
||
448 | 513 | { |
449 | 514 | global $globalDBdriver, $globalLiveInterval; |
450 | 515 | $Spotter = new Spotter($this->db); |
451 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
516 | + if (!isset($globalLiveInterval)) { |
|
517 | + $globalLiveInterval = '200'; |
|
518 | + } |
|
452 | 519 | $filter_query = $this->getFilter($filter); |
453 | 520 | |
454 | 521 | if (is_array($coord)) { |
@@ -456,7 +523,9 @@ discard block |
||
456 | 523 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
457 | 524 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
458 | 525 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
459 | - } else return array(); |
|
526 | + } else { |
|
527 | + return array(); |
|
528 | + } |
|
460 | 529 | if ($globalDBdriver == 'mysql') { |
461 | 530 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
462 | 531 | } else { |
@@ -477,7 +546,9 @@ discard block |
||
477 | 546 | { |
478 | 547 | global $globalDBdriver, $globalLiveInterval, $globalArchive,$globalMap2DAircraftsLimit; |
479 | 548 | $Spotter = new Spotter($this->db); |
480 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
549 | + if (!isset($globalLiveInterval)) { |
|
550 | + $globalLiveInterval = '200'; |
|
551 | + } |
|
481 | 552 | $filter_query = $this->getFilter($filter,true,true); |
482 | 553 | |
483 | 554 | if (is_array($coord)) { |
@@ -485,7 +556,9 @@ discard block |
||
485 | 556 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
486 | 557 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
487 | 558 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
488 | - } else return array(); |
|
559 | + } else { |
|
560 | + return array(); |
|
561 | + } |
|
489 | 562 | if ($globalDBdriver == 'mysql') { |
490 | 563 | if (isset($globalArchive) && $globalArchive === TRUE) { |
491 | 564 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
@@ -735,11 +808,15 @@ discard block |
||
735 | 808 | //$query = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date'; |
736 | 809 | if ($globalDBdriver == 'mysql') { |
737 | 810 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
738 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
811 | + if ($liveinterval) { |
|
812 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
813 | + } |
|
739 | 814 | $query .= ' ORDER BY date'; |
740 | 815 | } else { |
741 | 816 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
742 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
817 | + if ($liveinterval) { |
|
818 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
819 | + } |
|
743 | 820 | $query .= ' ORDER BY date'; |
744 | 821 | } |
745 | 822 | |
@@ -834,7 +911,9 @@ discard block |
||
834 | 911 | $i++; |
835 | 912 | $j++; |
836 | 913 | if ($j == 30) { |
837 | - if ($globalDebug) echo "."; |
|
914 | + if ($globalDebug) { |
|
915 | + echo "."; |
|
916 | + } |
|
838 | 917 | try { |
839 | 918 | |
840 | 919 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -1187,7 +1266,9 @@ discard block |
||
1187 | 1266 | { |
1188 | 1267 | return false; |
1189 | 1268 | } |
1190 | - } else return ''; |
|
1269 | + } else { |
|
1270 | + return ''; |
|
1271 | + } |
|
1191 | 1272 | |
1192 | 1273 | if ($longitude != '') |
1193 | 1274 | { |
@@ -1195,7 +1276,9 @@ discard block |
||
1195 | 1276 | { |
1196 | 1277 | return false; |
1197 | 1278 | } |
1198 | - } else return ''; |
|
1279 | + } else { |
|
1280 | + return ''; |
|
1281 | + } |
|
1199 | 1282 | |
1200 | 1283 | if ($waypoints != '') |
1201 | 1284 | { |
@@ -1211,14 +1294,18 @@ discard block |
||
1211 | 1294 | { |
1212 | 1295 | return false; |
1213 | 1296 | } |
1214 | - } else $altitude = 0; |
|
1297 | + } else { |
|
1298 | + $altitude = 0; |
|
1299 | + } |
|
1215 | 1300 | if ($altitude_real != '') |
1216 | 1301 | { |
1217 | 1302 | if (!is_numeric($altitude_real)) |
1218 | 1303 | { |
1219 | 1304 | return false; |
1220 | 1305 | } |
1221 | - } else $altitude_real = 0; |
|
1306 | + } else { |
|
1307 | + $altitude_real = 0; |
|
1308 | + } |
|
1222 | 1309 | |
1223 | 1310 | if ($heading != '') |
1224 | 1311 | { |
@@ -1226,7 +1313,9 @@ discard block |
||
1226 | 1313 | { |
1227 | 1314 | return false; |
1228 | 1315 | } |
1229 | - } else $heading = 0; |
|
1316 | + } else { |
|
1317 | + $heading = 0; |
|
1318 | + } |
|
1230 | 1319 | |
1231 | 1320 | if ($groundspeed != '') |
1232 | 1321 | { |
@@ -1234,9 +1323,13 @@ discard block |
||
1234 | 1323 | { |
1235 | 1324 | return false; |
1236 | 1325 | } |
1237 | - } else $groundspeed = 0; |
|
1326 | + } else { |
|
1327 | + $groundspeed = 0; |
|
1328 | + } |
|
1238 | 1329 | date_default_timezone_set('UTC'); |
1239 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
1330 | + if ($date == '') { |
|
1331 | + $date = date("Y-m-d H:i:s", time()); |
|
1332 | + } |
|
1240 | 1333 | |
1241 | 1334 | |
1242 | 1335 | $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
@@ -1281,14 +1374,24 @@ discard block |
||
1281 | 1374 | $arrival_airport_country = ''; |
1282 | 1375 | |
1283 | 1376 | |
1284 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1285 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1286 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1287 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1377 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) { |
|
1378 | + $squawk = NULL; |
|
1379 | + } |
|
1380 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) { |
|
1381 | + $verticalrate = NULL; |
|
1382 | + } |
|
1383 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
1384 | + $groundspeed = 0; |
|
1385 | + } |
|
1386 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
1387 | + $heading = 0; |
|
1388 | + } |
|
1288 | 1389 | |
1289 | 1390 | $query = ''; |
1290 | 1391 | if ($globalArchive) { |
1291 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
1392 | + if ($globalDebug) { |
|
1393 | + echo '-- Delete previous data -- '; |
|
1394 | + } |
|
1292 | 1395 | $query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;'; |
1293 | 1396 | } |
1294 | 1397 | |
@@ -1305,10 +1408,14 @@ discard block |
||
1305 | 1408 | return "error : ".$e->getMessage(); |
1306 | 1409 | } |
1307 | 1410 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1308 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
1411 | + if ($globalDebug) { |
|
1412 | + echo '(Add to SBS archive : '; |
|
1413 | + } |
|
1309 | 1414 | $SpotterArchive = new SpotterArchive($this->db); |
1310 | 1415 | $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
1311 | - if ($globalDebug) echo $result.')'; |
|
1416 | + if ($globalDebug) { |
|
1417 | + echo $result.')'; |
|
1418 | + } |
|
1312 | 1419 | } elseif ($globalDebug && $putinarchive !== true) { |
1313 | 1420 | echo '(Not adding to archive)'; |
1314 | 1421 | } elseif ($globalDebug && $noarchive === true) { |