@@ -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; |
@@ -537,11 +537,11 @@ discard block |
||
537 | 537 | } |
538 | 538 | |
539 | 539 | /** |
540 | - * Gets all the spotter information based on a user's latitude and longitude |
|
541 | - * |
|
542 | - * @return Array the spotter information |
|
543 | - * |
|
544 | - */ |
|
540 | + * Gets all the spotter information based on a user's latitude and longitude |
|
541 | + * |
|
542 | + * @return Array the spotter information |
|
543 | + * |
|
544 | + */ |
|
545 | 545 | public function getLatestSpotterForLayar($lat, $lng, $radius, $interval) |
546 | 546 | { |
547 | 547 | $Spotter = new Spotter($this->db); |
@@ -551,98 +551,98 @@ discard block |
||
551 | 551 | return false; |
552 | 552 | } |
553 | 553 | } |
554 | - if ($lng != '') |
|
555 | - { |
|
556 | - if (!is_numeric($lng)) |
|
557 | - { |
|
558 | - return false; |
|
559 | - } |
|
560 | - } |
|
561 | - |
|
562 | - if ($radius != '') |
|
563 | - { |
|
564 | - if (!is_numeric($radius)) |
|
565 | - { |
|
566 | - return false; |
|
567 | - } |
|
568 | - } |
|
554 | + if ($lng != '') |
|
555 | + { |
|
556 | + if (!is_numeric($lng)) |
|
557 | + { |
|
558 | + return false; |
|
559 | + } |
|
560 | + } |
|
561 | + |
|
562 | + if ($radius != '') |
|
563 | + { |
|
564 | + if (!is_numeric($radius)) |
|
565 | + { |
|
566 | + return false; |
|
567 | + } |
|
568 | + } |
|
569 | 569 | $additional_query = ''; |
570 | - if ($interval != '') |
|
571 | - { |
|
572 | - if (!is_string($interval)) |
|
573 | - { |
|
574 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
575 | - return false; |
|
576 | - } else { |
|
577 | - if ($interval == '1m') |
|
578 | - { |
|
579 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
580 | - } else if ($interval == '15m'){ |
|
581 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
582 | - } |
|
583 | - } |
|
584 | - } else { |
|
585 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
586 | - } |
|
587 | - |
|
588 | - $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 |
|
570 | + if ($interval != '') |
|
571 | + { |
|
572 | + if (!is_string($interval)) |
|
573 | + { |
|
574 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
575 | + return false; |
|
576 | + } else { |
|
577 | + if ($interval == '1m') |
|
578 | + { |
|
579 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
580 | + } else if ($interval == '15m'){ |
|
581 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
582 | + } |
|
583 | + } |
|
584 | + } else { |
|
585 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
586 | + } |
|
587 | + |
|
588 | + $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 |
|
589 | 589 | WHERE spotter_live.latitude <> '' |
590 | 590 | AND spotter_live.longitude <> '' |
591 | 591 | ".$additional_query." |
592 | 592 | HAVING distance < :radius |
593 | 593 | ORDER BY distance"; |
594 | 594 | |
595 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
595 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
596 | 596 | |
597 | - return $spotter_array; |
|
598 | - } |
|
597 | + return $spotter_array; |
|
598 | + } |
|
599 | 599 | |
600 | 600 | |
601 | - /** |
|
602 | - * Gets all the spotter information based on a particular callsign |
|
603 | - * |
|
604 | - * @return Array the spotter information |
|
605 | - * |
|
606 | - */ |
|
601 | + /** |
|
602 | + * Gets all the spotter information based on a particular callsign |
|
603 | + * |
|
604 | + * @return Array the spotter information |
|
605 | + * |
|
606 | + */ |
|
607 | 607 | public function getLastLiveSpotterDataByIdent($ident) |
608 | 608 | { |
609 | 609 | $Spotter = new Spotter($this->db); |
610 | 610 | date_default_timezone_set('UTC'); |
611 | 611 | |
612 | 612 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
613 | - $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'; |
|
613 | + $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'; |
|
614 | 614 | |
615 | 615 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
616 | 616 | |
617 | 617 | return $spotter_array; |
618 | 618 | } |
619 | 619 | |
620 | - /** |
|
621 | - * Gets all the spotter information based on a particular callsign |
|
622 | - * |
|
623 | - * @return Array the spotter information |
|
624 | - * |
|
625 | - */ |
|
620 | + /** |
|
621 | + * Gets all the spotter information based on a particular callsign |
|
622 | + * |
|
623 | + * @return Array the spotter information |
|
624 | + * |
|
625 | + */ |
|
626 | 626 | public function getDateLiveSpotterDataByIdent($ident,$date) |
627 | 627 | { |
628 | 628 | $Spotter = new Spotter($this->db); |
629 | 629 | date_default_timezone_set('UTC'); |
630 | 630 | |
631 | 631 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
632 | - $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'; |
|
632 | + $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'; |
|
633 | 633 | |
634 | - $date = date('c',$date); |
|
634 | + $date = date('c',$date); |
|
635 | 635 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
636 | 636 | |
637 | 637 | return $spotter_array; |
638 | 638 | } |
639 | 639 | |
640 | - /** |
|
641 | - * Gets last spotter information based on a particular callsign |
|
642 | - * |
|
643 | - * @return Array the spotter information |
|
644 | - * |
|
645 | - */ |
|
640 | + /** |
|
641 | + * Gets last spotter information based on a particular callsign |
|
642 | + * |
|
643 | + * @return Array the spotter information |
|
644 | + * |
|
645 | + */ |
|
646 | 646 | public function getLastLiveSpotterDataById($id) |
647 | 647 | { |
648 | 648 | $Spotter = new Spotter($this->db); |
@@ -653,12 +653,12 @@ discard block |
||
653 | 653 | return $spotter_array; |
654 | 654 | } |
655 | 655 | |
656 | - /** |
|
657 | - * Gets last spotter information based on a particular callsign |
|
658 | - * |
|
659 | - * @return Array the spotter information |
|
660 | - * |
|
661 | - */ |
|
656 | + /** |
|
657 | + * Gets last spotter information based on a particular callsign |
|
658 | + * |
|
659 | + * @return Array the spotter information |
|
660 | + * |
|
661 | + */ |
|
662 | 662 | public function getDateLiveSpotterDataById($id,$date) |
663 | 663 | { |
664 | 664 | $Spotter = new Spotter($this->db); |
@@ -671,21 +671,21 @@ discard block |
||
671 | 671 | return $spotter_array; |
672 | 672 | } |
673 | 673 | |
674 | - /** |
|
675 | - * Gets altitude information based on a particular callsign |
|
676 | - * |
|
677 | - * @return Array the spotter information |
|
678 | - * |
|
679 | - */ |
|
674 | + /** |
|
675 | + * Gets altitude information based on a particular callsign |
|
676 | + * |
|
677 | + * @return Array the spotter information |
|
678 | + * |
|
679 | + */ |
|
680 | 680 | public function getAltitudeLiveSpotterDataByIdent($ident) |
681 | 681 | { |
682 | 682 | |
683 | 683 | date_default_timezone_set('UTC'); |
684 | 684 | |
685 | 685 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
686 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
686 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
687 | 687 | |
688 | - try { |
|
688 | + try { |
|
689 | 689 | |
690 | 690 | $sth = $this->db->prepare($query); |
691 | 691 | $sth->execute(array(':ident' => $ident)); |
@@ -698,12 +698,12 @@ discard block |
||
698 | 698 | return $spotter_array; |
699 | 699 | } |
700 | 700 | |
701 | - /** |
|
702 | - * Gets all the spotter information based on a particular id |
|
703 | - * |
|
704 | - * @return Array the spotter information |
|
705 | - * |
|
706 | - */ |
|
701 | + /** |
|
702 | + * Gets all the spotter information based on a particular id |
|
703 | + * |
|
704 | + * @return Array the spotter information |
|
705 | + * |
|
706 | + */ |
|
707 | 707 | public function getAllLiveSpotterDataById($id,$liveinterval = false) |
708 | 708 | { |
709 | 709 | global $globalDBdriver, $globalLiveInterval; |
@@ -731,18 +731,18 @@ discard block |
||
731 | 731 | return $spotter_array; |
732 | 732 | } |
733 | 733 | |
734 | - /** |
|
735 | - * Gets all the spotter information based on a particular ident |
|
736 | - * |
|
737 | - * @return Array the spotter information |
|
738 | - * |
|
739 | - */ |
|
734 | + /** |
|
735 | + * Gets all the spotter information based on a particular ident |
|
736 | + * |
|
737 | + * @return Array the spotter information |
|
738 | + * |
|
739 | + */ |
|
740 | 740 | public function getAllLiveSpotterDataByIdent($ident) |
741 | 741 | { |
742 | 742 | date_default_timezone_set('UTC'); |
743 | 743 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
744 | 744 | $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
745 | - try { |
|
745 | + try { |
|
746 | 746 | |
747 | 747 | $sth = $this->db->prepare($query); |
748 | 748 | $sth->execute(array(':ident' => $ident)); |
@@ -756,23 +756,23 @@ discard block |
||
756 | 756 | |
757 | 757 | |
758 | 758 | /** |
759 | - * Deletes all info in the table |
|
760 | - * |
|
761 | - * @return String success or false |
|
762 | - * |
|
763 | - */ |
|
759 | + * Deletes all info in the table |
|
760 | + * |
|
761 | + * @return String success or false |
|
762 | + * |
|
763 | + */ |
|
764 | 764 | public function deleteLiveSpotterData() |
765 | 765 | { |
766 | 766 | global $globalDBdriver; |
767 | 767 | if ($globalDBdriver == 'mysql') { |
768 | 768 | //$query = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date"; |
769 | 769 | $query = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date'; |
770 | - //$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)"; |
|
770 | + //$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)"; |
|
771 | 771 | } else { |
772 | 772 | $query = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date"; |
773 | 773 | } |
774 | 774 | |
775 | - try { |
|
775 | + try { |
|
776 | 776 | |
777 | 777 | $sth = $this->db->prepare($query); |
778 | 778 | $sth->execute(); |
@@ -784,18 +784,18 @@ discard block |
||
784 | 784 | } |
785 | 785 | |
786 | 786 | /** |
787 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
788 | - * |
|
789 | - * @return String success or false |
|
790 | - * |
|
791 | - */ |
|
787 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
788 | + * |
|
789 | + * @return String success or false |
|
790 | + * |
|
791 | + */ |
|
792 | 792 | public function deleteLiveSpotterDataNotUpdated() |
793 | 793 | { |
794 | 794 | global $globalDBdriver, $globalDebug; |
795 | 795 | if ($globalDBdriver == 'mysql') { |
796 | 796 | //$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'; |
797 | - $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"; |
|
798 | - try { |
|
797 | + $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"; |
|
798 | + try { |
|
799 | 799 | |
800 | 800 | $sth = $this->db->prepare($query); |
801 | 801 | $sth->execute(); |
@@ -803,8 +803,8 @@ discard block |
||
803 | 803 | return "error"; |
804 | 804 | } |
805 | 805 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
806 | - $i = 0; |
|
807 | - $j =0; |
|
806 | + $i = 0; |
|
807 | + $j =0; |
|
808 | 808 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
809 | 809 | foreach($all as $row) |
810 | 810 | { |
@@ -812,20 +812,20 @@ discard block |
||
812 | 812 | $j++; |
813 | 813 | if ($j == 30) { |
814 | 814 | if ($globalDebug) echo "."; |
815 | - try { |
|
815 | + try { |
|
816 | 816 | |
817 | 817 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
818 | 818 | $sth->execute(); |
819 | 819 | } catch(PDOException $e) { |
820 | 820 | return "error"; |
821 | 821 | } |
822 | - $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
823 | - $j = 0; |
|
822 | + $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
823 | + $j = 0; |
|
824 | 824 | } |
825 | 825 | $query_delete .= "'".$row['flightaware_id']."',"; |
826 | 826 | } |
827 | 827 | if ($i > 0) { |
828 | - try { |
|
828 | + try { |
|
829 | 829 | |
830 | 830 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
831 | 831 | $sth->execute(); |
@@ -836,9 +836,9 @@ discard block |
||
836 | 836 | return "success"; |
837 | 837 | } elseif ($globalDBdriver == 'pgsql') { |
838 | 838 | //$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"; |
839 | - //$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"; |
|
840 | - $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)"; |
|
841 | - try { |
|
839 | + //$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"; |
|
840 | + $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)"; |
|
841 | + try { |
|
842 | 842 | |
843 | 843 | $sth = $this->db->prepare($query); |
844 | 844 | $sth->execute(); |
@@ -882,17 +882,17 @@ discard block |
||
882 | 882 | } |
883 | 883 | |
884 | 884 | /** |
885 | - * Deletes all info in the table for an ident |
|
886 | - * |
|
887 | - * @return String success or false |
|
888 | - * |
|
889 | - */ |
|
885 | + * Deletes all info in the table for an ident |
|
886 | + * |
|
887 | + * @return String success or false |
|
888 | + * |
|
889 | + */ |
|
890 | 890 | public function deleteLiveSpotterDataByIdent($ident) |
891 | 891 | { |
892 | 892 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
893 | 893 | $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
894 | 894 | |
895 | - try { |
|
895 | + try { |
|
896 | 896 | |
897 | 897 | $sth = $this->db->prepare($query); |
898 | 898 | $sth->execute(array(':ident' => $ident)); |
@@ -904,17 +904,17 @@ discard block |
||
904 | 904 | } |
905 | 905 | |
906 | 906 | /** |
907 | - * Deletes all info in the table for an id |
|
908 | - * |
|
909 | - * @return String success or false |
|
910 | - * |
|
911 | - */ |
|
907 | + * Deletes all info in the table for an id |
|
908 | + * |
|
909 | + * @return String success or false |
|
910 | + * |
|
911 | + */ |
|
912 | 912 | public function deleteLiveSpotterDataById($id) |
913 | 913 | { |
914 | 914 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
915 | 915 | $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
916 | 916 | |
917 | - try { |
|
917 | + try { |
|
918 | 918 | |
919 | 919 | $sth = $this->db->prepare($query); |
920 | 920 | $sth->execute(array(':id' => $id)); |
@@ -927,11 +927,11 @@ discard block |
||
927 | 927 | |
928 | 928 | |
929 | 929 | /** |
930 | - * Gets the aircraft ident within the last hour |
|
931 | - * |
|
932 | - * @return String the ident |
|
933 | - * |
|
934 | - */ |
|
930 | + * Gets the aircraft ident within the last hour |
|
931 | + * |
|
932 | + * @return String the ident |
|
933 | + * |
|
934 | + */ |
|
935 | 935 | public function getIdentFromLastHour($ident) |
936 | 936 | { |
937 | 937 | global $globalDBdriver, $globalTimezone; |
@@ -957,14 +957,14 @@ discard block |
||
957 | 957 | $ident_result = $row['ident']; |
958 | 958 | } |
959 | 959 | return $ident_result; |
960 | - } |
|
960 | + } |
|
961 | 961 | |
962 | 962 | /** |
963 | - * Check recent aircraft |
|
964 | - * |
|
965 | - * @return String the ident |
|
966 | - * |
|
967 | - */ |
|
963 | + * Check recent aircraft |
|
964 | + * |
|
965 | + * @return String the ident |
|
966 | + * |
|
967 | + */ |
|
968 | 968 | public function checkIdentRecent($ident) |
969 | 969 | { |
970 | 970 | global $globalDBdriver, $globalTimezone; |
@@ -990,14 +990,14 @@ discard block |
||
990 | 990 | $ident_result = $row['flightaware_id']; |
991 | 991 | } |
992 | 992 | return $ident_result; |
993 | - } |
|
993 | + } |
|
994 | 994 | |
995 | 995 | /** |
996 | - * Check recent aircraft by id |
|
997 | - * |
|
998 | - * @return String the ident |
|
999 | - * |
|
1000 | - */ |
|
996 | + * Check recent aircraft by id |
|
997 | + * |
|
998 | + * @return String the ident |
|
999 | + * |
|
1000 | + */ |
|
1001 | 1001 | public function checkIdRecent($id) |
1002 | 1002 | { |
1003 | 1003 | global $globalDBdriver, $globalTimezone; |
@@ -1023,14 +1023,14 @@ discard block |
||
1023 | 1023 | $ident_result = $row['flightaware_id']; |
1024 | 1024 | } |
1025 | 1025 | return $ident_result; |
1026 | - } |
|
1026 | + } |
|
1027 | 1027 | |
1028 | 1028 | /** |
1029 | - * Check recent aircraft by ModeS |
|
1030 | - * |
|
1031 | - * @return String the ModeS |
|
1032 | - * |
|
1033 | - */ |
|
1029 | + * Check recent aircraft by ModeS |
|
1030 | + * |
|
1031 | + * @return String the ModeS |
|
1032 | + * |
|
1033 | + */ |
|
1034 | 1034 | public function checkModeSRecent($modes) |
1035 | 1035 | { |
1036 | 1036 | global $globalDBdriver, $globalTimezone; |
@@ -1060,11 +1060,11 @@ discard block |
||
1060 | 1060 | } |
1061 | 1061 | |
1062 | 1062 | /** |
1063 | - * Gets the aircraft data from the last 20 seconds |
|
1064 | - * |
|
1065 | - * @return Array the spotter data |
|
1066 | - * |
|
1067 | - */ |
|
1063 | + * Gets the aircraft data from the last 20 seconds |
|
1064 | + * |
|
1065 | + * @return Array the spotter data |
|
1066 | + * |
|
1067 | + */ |
|
1068 | 1068 | public function getRealTimeData($q = '') |
1069 | 1069 | { |
1070 | 1070 | global $globalDBdriver; |
@@ -1106,16 +1106,16 @@ discard block |
||
1106 | 1106 | } |
1107 | 1107 | |
1108 | 1108 | /** |
1109 | - * Adds a new spotter data |
|
1110 | - * |
|
1111 | - * @param String $flightaware_id the ID from flightaware |
|
1112 | - * @param String $ident the flight ident |
|
1113 | - * @param String $aircraft_icao the aircraft type |
|
1114 | - * @param String $departure_airport_icao the departure airport |
|
1115 | - * @param String $arrival_airport_icao the arrival airport |
|
1116 | - * @return String success or false |
|
1117 | - * |
|
1118 | - */ |
|
1109 | + * Adds a new spotter data |
|
1110 | + * |
|
1111 | + * @param String $flightaware_id the ID from flightaware |
|
1112 | + * @param String $ident the flight ident |
|
1113 | + * @param String $aircraft_icao the aircraft type |
|
1114 | + * @param String $departure_airport_icao the departure airport |
|
1115 | + * @param String $arrival_airport_icao the arrival airport |
|
1116 | + * @return String success or false |
|
1117 | + * |
|
1118 | + */ |
|
1119 | 1119 | 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 = '') |
1120 | 1120 | { |
1121 | 1121 | global $globalURL, $globalArchive, $globalDebug; |
@@ -1258,10 +1258,10 @@ discard block |
||
1258 | 1258 | $arrival_airport_country = ''; |
1259 | 1259 | |
1260 | 1260 | |
1261 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1262 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1263 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1264 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1261 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1262 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1263 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1264 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1265 | 1265 | |
1266 | 1266 | $query = ''; |
1267 | 1267 | if ($globalArchive) { |
@@ -1282,10 +1282,10 @@ discard block |
||
1282 | 1282 | return "error : ".$e->getMessage(); |
1283 | 1283 | } |
1284 | 1284 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1285 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
1286 | - $SpotterArchive = new SpotterArchive($this->db); |
|
1287 | - $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); |
|
1288 | - if ($globalDebug) echo $result.')'; |
|
1285 | + if ($globalDebug) echo '(Add to SBS archive : '; |
|
1286 | + $SpotterArchive = new SpotterArchive($this->db); |
|
1287 | + $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); |
|
1288 | + if ($globalDebug) echo $result.')'; |
|
1289 | 1289 | } elseif ($globalDebug && $putinarchive !== true) { |
1290 | 1290 | echo '(Not adding to archive)'; |
1291 | 1291 | } 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; |
@@ -478,23 +478,23 @@ discard block |
||
478 | 478 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
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 |
@@ -506,14 +506,14 @@ discard block |
||
506 | 506 | } |
507 | 507 | } else { |
508 | 508 | if (isset($globalArchive) && $globalArchive === TRUE) { |
509 | - $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 |
|
509 | + $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 |
|
510 | 510 | FROM spotter_live |
511 | 511 | ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date |
512 | 512 | AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." |
513 | 513 | AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." |
514 | 514 | AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' ORDER BY date DESC"; |
515 | 515 | } else { |
516 | - $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 |
|
516 | + $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 | 517 | FROM spotter_live |
518 | 518 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
519 | 519 | FROM spotter_live l |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | try { |
529 | 529 | $sth = $this->db->prepare($query); |
530 | 530 | $sth->execute(); |
531 | - } catch(PDOException $e) { |
|
531 | + } catch (PDOException $e) { |
|
532 | 532 | echo $e->getMessage(); |
533 | 533 | die; |
534 | 534 | } |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | if ($interval == '1m') |
578 | 578 | { |
579 | 579 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
580 | - } else if ($interval == '15m'){ |
|
580 | + } else if ($interval == '15m') { |
|
581 | 581 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
582 | 582 | } |
583 | 583 | } |
@@ -585,14 +585,14 @@ discard block |
||
585 | 585 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
586 | 586 | } |
587 | 587 | |
588 | - $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 |
|
588 | + $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 |
|
589 | 589 | WHERE spotter_live.latitude <> '' |
590 | 590 | AND spotter_live.longitude <> '' |
591 | 591 | ".$additional_query." |
592 | 592 | HAVING distance < :radius |
593 | 593 | ORDER BY distance"; |
594 | 594 | |
595 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
595 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
596 | 596 | |
597 | 597 | return $spotter_array; |
598 | 598 | } |
@@ -610,9 +610,9 @@ discard block |
||
610 | 610 | date_default_timezone_set('UTC'); |
611 | 611 | |
612 | 612 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
613 | - $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'; |
|
613 | + $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'; |
|
614 | 614 | |
615 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
615 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
616 | 616 | |
617 | 617 | return $spotter_array; |
618 | 618 | } |
@@ -623,16 +623,16 @@ discard block |
||
623 | 623 | * @return Array the spotter information |
624 | 624 | * |
625 | 625 | */ |
626 | - public function getDateLiveSpotterDataByIdent($ident,$date) |
|
626 | + public function getDateLiveSpotterDataByIdent($ident, $date) |
|
627 | 627 | { |
628 | 628 | $Spotter = new Spotter($this->db); |
629 | 629 | date_default_timezone_set('UTC'); |
630 | 630 | |
631 | 631 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
632 | - $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'; |
|
632 | + $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'; |
|
633 | 633 | |
634 | - $date = date('c',$date); |
|
635 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
634 | + $date = date('c', $date); |
|
635 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
636 | 636 | |
637 | 637 | return $spotter_array; |
638 | 638 | } |
@@ -648,8 +648,8 @@ discard block |
||
648 | 648 | $Spotter = new Spotter($this->db); |
649 | 649 | date_default_timezone_set('UTC'); |
650 | 650 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
651 | - $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'; |
|
652 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
|
651 | + $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'; |
|
652 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true); |
|
653 | 653 | return $spotter_array; |
654 | 654 | } |
655 | 655 | |
@@ -659,15 +659,15 @@ discard block |
||
659 | 659 | * @return Array the spotter information |
660 | 660 | * |
661 | 661 | */ |
662 | - public function getDateLiveSpotterDataById($id,$date) |
|
662 | + public function getDateLiveSpotterDataById($id, $date) |
|
663 | 663 | { |
664 | 664 | $Spotter = new Spotter($this->db); |
665 | 665 | date_default_timezone_set('UTC'); |
666 | 666 | |
667 | 667 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
668 | - $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'; |
|
669 | - $date = date('c',$date); |
|
670 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
668 | + $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'; |
|
669 | + $date = date('c', $date); |
|
670 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
671 | 671 | return $spotter_array; |
672 | 672 | } |
673 | 673 | |
@@ -683,13 +683,13 @@ discard block |
||
683 | 683 | date_default_timezone_set('UTC'); |
684 | 684 | |
685 | 685 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
686 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
686 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
687 | 687 | |
688 | 688 | try { |
689 | 689 | |
690 | 690 | $sth = $this->db->prepare($query); |
691 | 691 | $sth->execute(array(':ident' => $ident)); |
692 | - } catch(PDOException $e) { |
|
692 | + } catch (PDOException $e) { |
|
693 | 693 | echo $e->getMessage(); |
694 | 694 | die; |
695 | 695 | } |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | * @return Array the spotter information |
705 | 705 | * |
706 | 706 | */ |
707 | - public function getAllLiveSpotterDataById($id,$liveinterval = false) |
|
707 | + public function getAllLiveSpotterDataById($id, $liveinterval = false) |
|
708 | 708 | { |
709 | 709 | global $globalDBdriver, $globalLiveInterval; |
710 | 710 | date_default_timezone_set('UTC'); |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | try { |
724 | 724 | $sth = $this->db->prepare($query); |
725 | 725 | $sth->execute(array(':id' => $id)); |
726 | - } catch(PDOException $e) { |
|
726 | + } catch (PDOException $e) { |
|
727 | 727 | echo $e->getMessage(); |
728 | 728 | die; |
729 | 729 | } |
@@ -741,12 +741,12 @@ discard block |
||
741 | 741 | { |
742 | 742 | date_default_timezone_set('UTC'); |
743 | 743 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
744 | - $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
744 | + $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
745 | 745 | try { |
746 | 746 | |
747 | 747 | $sth = $this->db->prepare($query); |
748 | 748 | $sth->execute(array(':ident' => $ident)); |
749 | - } catch(PDOException $e) { |
|
749 | + } catch (PDOException $e) { |
|
750 | 750 | echo $e->getMessage(); |
751 | 751 | die; |
752 | 752 | } |
@@ -776,7 +776,7 @@ discard block |
||
776 | 776 | |
777 | 777 | $sth = $this->db->prepare($query); |
778 | 778 | $sth->execute(); |
779 | - } catch(PDOException $e) { |
|
779 | + } catch (PDOException $e) { |
|
780 | 780 | return "error"; |
781 | 781 | } |
782 | 782 | |
@@ -799,14 +799,14 @@ 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 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
806 | 806 | $i = 0; |
807 | - $j =0; |
|
807 | + $j = 0; |
|
808 | 808 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
809 | - foreach($all as $row) |
|
809 | + foreach ($all as $row) |
|
810 | 810 | { |
811 | 811 | $i++; |
812 | 812 | $j++; |
@@ -814,9 +814,9 @@ discard block |
||
814 | 814 | if ($globalDebug) echo "."; |
815 | 815 | try { |
816 | 816 | |
817 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
817 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
818 | 818 | $sth->execute(); |
819 | - } catch(PDOException $e) { |
|
819 | + } catch (PDOException $e) { |
|
820 | 820 | return "error"; |
821 | 821 | } |
822 | 822 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
@@ -827,9 +827,9 @@ discard block |
||
827 | 827 | if ($i > 0) { |
828 | 828 | try { |
829 | 829 | |
830 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
830 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
831 | 831 | $sth->execute(); |
832 | - } catch(PDOException $e) { |
|
832 | + } catch (PDOException $e) { |
|
833 | 833 | return "error"; |
834 | 834 | } |
835 | 835 | } |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | |
843 | 843 | $sth = $this->db->prepare($query); |
844 | 844 | $sth->execute(); |
845 | - } catch(PDOException $e) { |
|
845 | + } catch (PDOException $e) { |
|
846 | 846 | return "error"; |
847 | 847 | } |
848 | 848 | /* $query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN ("; |
@@ -890,13 +890,13 @@ discard block |
||
890 | 890 | public function deleteLiveSpotterDataByIdent($ident) |
891 | 891 | { |
892 | 892 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
893 | - $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
893 | + $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
894 | 894 | |
895 | 895 | try { |
896 | 896 | |
897 | 897 | $sth = $this->db->prepare($query); |
898 | 898 | $sth->execute(array(':ident' => $ident)); |
899 | - } catch(PDOException $e) { |
|
899 | + } catch (PDOException $e) { |
|
900 | 900 | return "error"; |
901 | 901 | } |
902 | 902 | |
@@ -912,13 +912,13 @@ discard block |
||
912 | 912 | public function deleteLiveSpotterDataById($id) |
913 | 913 | { |
914 | 914 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
915 | - $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
915 | + $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
916 | 916 | |
917 | 917 | try { |
918 | 918 | |
919 | 919 | $sth = $this->db->prepare($query); |
920 | 920 | $sth->execute(array(':id' => $id)); |
921 | - } catch(PDOException $e) { |
|
921 | + } catch (PDOException $e) { |
|
922 | 922 | return "error"; |
923 | 923 | } |
924 | 924 | |
@@ -936,13 +936,13 @@ discard block |
||
936 | 936 | { |
937 | 937 | global $globalDBdriver, $globalTimezone; |
938 | 938 | if ($globalDBdriver == 'mysql') { |
939 | - $query = 'SELECT spotter_live.ident FROM spotter_live |
|
939 | + $query = 'SELECT spotter_live.ident FROM spotter_live |
|
940 | 940 | WHERE spotter_live.ident = :ident |
941 | 941 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
942 | 942 | AND spotter_live.date < UTC_TIMESTAMP()'; |
943 | 943 | $query_data = array(':ident' => $ident); |
944 | 944 | } else { |
945 | - $query = "SELECT spotter_live.ident FROM spotter_live |
|
945 | + $query = "SELECT spotter_live.ident FROM spotter_live |
|
946 | 946 | WHERE spotter_live.ident = :ident |
947 | 947 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
948 | 948 | AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -951,8 +951,8 @@ discard block |
||
951 | 951 | |
952 | 952 | $sth = $this->db->prepare($query); |
953 | 953 | $sth->execute($query_data); |
954 | - $ident_result=''; |
|
955 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
954 | + $ident_result = ''; |
|
955 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
956 | 956 | { |
957 | 957 | $ident_result = $row['ident']; |
958 | 958 | } |
@@ -969,13 +969,13 @@ discard block |
||
969 | 969 | { |
970 | 970 | global $globalDBdriver, $globalTimezone; |
971 | 971 | if ($globalDBdriver == 'mysql') { |
972 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
972 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
973 | 973 | WHERE spotter_live.ident = :ident |
974 | 974 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 MINUTE)'; |
975 | 975 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
976 | 976 | $query_data = array(':ident' => $ident); |
977 | 977 | } else { |
978 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
978 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
979 | 979 | WHERE spotter_live.ident = :ident |
980 | 980 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '20 MINUTES'"; |
981 | 981 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -984,8 +984,8 @@ discard block |
||
984 | 984 | |
985 | 985 | $sth = $this->db->prepare($query); |
986 | 986 | $sth->execute($query_data); |
987 | - $ident_result=''; |
|
988 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
987 | + $ident_result = ''; |
|
988 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
989 | 989 | { |
990 | 990 | $ident_result = $row['flightaware_id']; |
991 | 991 | } |
@@ -1002,13 +1002,13 @@ discard block |
||
1002 | 1002 | { |
1003 | 1003 | global $globalDBdriver, $globalTimezone; |
1004 | 1004 | if ($globalDBdriver == 'mysql') { |
1005 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
1005 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
1006 | 1006 | WHERE spotter_live.flightaware_id = :id |
1007 | 1007 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
1008 | 1008 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
1009 | 1009 | $query_data = array(':id' => $id); |
1010 | 1010 | } else { |
1011 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
1011 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
1012 | 1012 | WHERE spotter_live.flightaware_id = :id |
1013 | 1013 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
1014 | 1014 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -1017,8 +1017,8 @@ discard block |
||
1017 | 1017 | |
1018 | 1018 | $sth = $this->db->prepare($query); |
1019 | 1019 | $sth->execute($query_data); |
1020 | - $ident_result=''; |
|
1021 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1020 | + $ident_result = ''; |
|
1021 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1022 | 1022 | { |
1023 | 1023 | $ident_result = $row['flightaware_id']; |
1024 | 1024 | } |
@@ -1035,13 +1035,13 @@ discard block |
||
1035 | 1035 | { |
1036 | 1036 | global $globalDBdriver, $globalTimezone; |
1037 | 1037 | if ($globalDBdriver == 'mysql') { |
1038 | - $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
1038 | + $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
1039 | 1039 | WHERE spotter_live.ModeS = :modes |
1040 | 1040 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 MINUTE)'; |
1041 | 1041 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
1042 | 1042 | $query_data = array(':modes' => $modes); |
1043 | 1043 | } else { |
1044 | - $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
1044 | + $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
1045 | 1045 | WHERE spotter_live.ModeS = :modes |
1046 | 1046 | AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 MINUTE'"; |
1047 | 1047 | // // AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
@@ -1050,8 +1050,8 @@ discard block |
||
1050 | 1050 | |
1051 | 1051 | $sth = $this->db->prepare($query); |
1052 | 1052 | $sth->execute($query_data); |
1053 | - $ident_result=''; |
|
1054 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1053 | + $ident_result = ''; |
|
1054 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1055 | 1055 | { |
1056 | 1056 | //$ident_result = $row['spotter_live_id']; |
1057 | 1057 | $ident_result = $row['flightaware_id']; |
@@ -1076,8 +1076,8 @@ discard block |
||
1076 | 1076 | return array(); |
1077 | 1077 | } else { |
1078 | 1078 | $q_array = explode(" ", $q); |
1079 | - foreach ($q_array as $q_item){ |
|
1080 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
1079 | + foreach ($q_array as $q_item) { |
|
1080 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
1081 | 1081 | $additional_query .= " AND ("; |
1082 | 1082 | $additional_query .= "(spotter_live.aircraft_icao like '%".$q_item."%') OR "; |
1083 | 1083 | $additional_query .= "(spotter_live.aircraft_name like '%".$q_item."%') OR "; |
@@ -1092,11 +1092,11 @@ discard block |
||
1092 | 1092 | } |
1093 | 1093 | } |
1094 | 1094 | if ($globalDBdriver == 'mysql') { |
1095 | - $query = "SELECT spotter_live.* FROM spotter_live |
|
1095 | + $query = "SELECT spotter_live.* FROM spotter_live |
|
1096 | 1096 | WHERE spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
1097 | 1097 | AND spotter_live.date < UTC_TIMESTAMP()"; |
1098 | 1098 | } else { |
1099 | - $query = "SELECT spotter_live.* FROM spotter_live |
|
1099 | + $query = "SELECT spotter_live.* FROM spotter_live |
|
1100 | 1100 | WHERE spotter_live.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
1101 | 1101 | AND spotter_live.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
1102 | 1102 | } |
@@ -1116,7 +1116,7 @@ discard block |
||
1116 | 1116 | * @return String success or false |
1117 | 1117 | * |
1118 | 1118 | */ |
1119 | - 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 = '') |
|
1119 | + 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 = '') |
|
1120 | 1120 | { |
1121 | 1121 | global $globalURL, $globalArchive, $globalDebug; |
1122 | 1122 | $Common = new Common(); |
@@ -1216,27 +1216,27 @@ discard block |
||
1216 | 1216 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
1217 | 1217 | |
1218 | 1218 | |
1219 | - $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
|
1220 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
1221 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
1222 | - $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
1223 | - $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
1224 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1225 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1226 | - $waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING); |
|
1227 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1228 | - $altitude_real = filter_var($altitude_real,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1229 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
1230 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1231 | - $squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT); |
|
1232 | - $route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING); |
|
1233 | - $ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING); |
|
1234 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING); |
|
1235 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
1236 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
1237 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
1238 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
1239 | - $verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT); |
|
1219 | + $flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING); |
|
1220 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
1221 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
1222 | + $departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING); |
|
1223 | + $arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING); |
|
1224 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1225 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1226 | + $waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING); |
|
1227 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1228 | + $altitude_real = filter_var($altitude_real, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1229 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
1230 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1231 | + $squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT); |
|
1232 | + $route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING); |
|
1233 | + $ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING); |
|
1234 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING); |
|
1235 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
1236 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
1237 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
1238 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
1239 | + $verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT); |
|
1240 | 1240 | |
1241 | 1241 | $airline_name = ''; |
1242 | 1242 | $airline_icao = ''; |
@@ -1258,10 +1258,10 @@ discard block |
||
1258 | 1258 | $arrival_airport_country = ''; |
1259 | 1259 | |
1260 | 1260 | |
1261 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1262 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1263 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1264 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1261 | + if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL; |
|
1262 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL; |
|
1263 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
1264 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
1265 | 1265 | |
1266 | 1266 | $query = ''; |
1267 | 1267 | if ($globalArchive) { |
@@ -1272,19 +1272,19 @@ discard block |
||
1272 | 1272 | $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) |
1273 | 1273 | 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)'; |
1274 | 1274 | |
1275 | - $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); |
|
1275 | + $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); |
|
1276 | 1276 | try { |
1277 | 1277 | |
1278 | 1278 | $sth = $this->db->prepare($query); |
1279 | 1279 | $sth->execute($query_values); |
1280 | 1280 | $sth->closeCursor(); |
1281 | - } catch(PDOException $e) { |
|
1281 | + } catch (PDOException $e) { |
|
1282 | 1282 | return "error : ".$e->getMessage(); |
1283 | 1283 | } |
1284 | 1284 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1285 | 1285 | if ($globalDebug) echo '(Add to SBS archive : '; |
1286 | 1286 | $SpotterArchive = new SpotterArchive($this->db); |
1287 | - $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); |
|
1287 | + $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); |
|
1288 | 1288 | if ($globalDebug) echo $result.')'; |
1289 | 1289 | } elseif ($globalDebug && $putinarchive !== true) { |
1290 | 1290 | echo '(Not adding to archive)'; |
@@ -1297,7 +1297,7 @@ discard block |
||
1297 | 1297 | |
1298 | 1298 | public function getOrderBy() |
1299 | 1299 | { |
1300 | - $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")); |
|
1300 | + $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")); |
|
1301 | 1301 | return $orderby; |
1302 | 1302 | } |
1303 | 1303 |
@@ -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; |
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 |
@@ -712,11 +785,15 @@ discard block |
||
712 | 785 | //$query = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date'; |
713 | 786 | if ($globalDBdriver == 'mysql') { |
714 | 787 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
715 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
788 | + if ($liveinterval) { |
|
789 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
790 | + } |
|
716 | 791 | $query .= ' ORDER BY date'; |
717 | 792 | } else { |
718 | 793 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
719 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
794 | + if ($liveinterval) { |
|
795 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
796 | + } |
|
720 | 797 | $query .= ' ORDER BY date'; |
721 | 798 | } |
722 | 799 | |
@@ -811,7 +888,9 @@ discard block |
||
811 | 888 | $i++; |
812 | 889 | $j++; |
813 | 890 | if ($j == 30) { |
814 | - if ($globalDebug) echo "."; |
|
891 | + if ($globalDebug) { |
|
892 | + echo "."; |
|
893 | + } |
|
815 | 894 | try { |
816 | 895 | |
817 | 896 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -1164,7 +1243,9 @@ discard block |
||
1164 | 1243 | { |
1165 | 1244 | return false; |
1166 | 1245 | } |
1167 | - } else return ''; |
|
1246 | + } else { |
|
1247 | + return ''; |
|
1248 | + } |
|
1168 | 1249 | |
1169 | 1250 | if ($longitude != '') |
1170 | 1251 | { |
@@ -1172,7 +1253,9 @@ discard block |
||
1172 | 1253 | { |
1173 | 1254 | return false; |
1174 | 1255 | } |
1175 | - } else return ''; |
|
1256 | + } else { |
|
1257 | + return ''; |
|
1258 | + } |
|
1176 | 1259 | |
1177 | 1260 | if ($waypoints != '') |
1178 | 1261 | { |
@@ -1188,14 +1271,18 @@ discard block |
||
1188 | 1271 | { |
1189 | 1272 | return false; |
1190 | 1273 | } |
1191 | - } else $altitude = 0; |
|
1274 | + } else { |
|
1275 | + $altitude = 0; |
|
1276 | + } |
|
1192 | 1277 | if ($altitude_real != '') |
1193 | 1278 | { |
1194 | 1279 | if (!is_numeric($altitude_real)) |
1195 | 1280 | { |
1196 | 1281 | return false; |
1197 | 1282 | } |
1198 | - } else $altitude_real = 0; |
|
1283 | + } else { |
|
1284 | + $altitude_real = 0; |
|
1285 | + } |
|
1199 | 1286 | |
1200 | 1287 | if ($heading != '') |
1201 | 1288 | { |
@@ -1203,7 +1290,9 @@ discard block |
||
1203 | 1290 | { |
1204 | 1291 | return false; |
1205 | 1292 | } |
1206 | - } else $heading = 0; |
|
1293 | + } else { |
|
1294 | + $heading = 0; |
|
1295 | + } |
|
1207 | 1296 | |
1208 | 1297 | if ($groundspeed != '') |
1209 | 1298 | { |
@@ -1211,9 +1300,13 @@ discard block |
||
1211 | 1300 | { |
1212 | 1301 | return false; |
1213 | 1302 | } |
1214 | - } else $groundspeed = 0; |
|
1303 | + } else { |
|
1304 | + $groundspeed = 0; |
|
1305 | + } |
|
1215 | 1306 | date_default_timezone_set('UTC'); |
1216 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
1307 | + if ($date == '') { |
|
1308 | + $date = date("Y-m-d H:i:s", time()); |
|
1309 | + } |
|
1217 | 1310 | |
1218 | 1311 | |
1219 | 1312 | $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
@@ -1258,14 +1351,24 @@ discard block |
||
1258 | 1351 | $arrival_airport_country = ''; |
1259 | 1352 | |
1260 | 1353 | |
1261 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1262 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1263 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1264 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1354 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) { |
|
1355 | + $squawk = NULL; |
|
1356 | + } |
|
1357 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) { |
|
1358 | + $verticalrate = NULL; |
|
1359 | + } |
|
1360 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
1361 | + $groundspeed = 0; |
|
1362 | + } |
|
1363 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
1364 | + $heading = 0; |
|
1365 | + } |
|
1265 | 1366 | |
1266 | 1367 | $query = ''; |
1267 | 1368 | if ($globalArchive) { |
1268 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
1369 | + if ($globalDebug) { |
|
1370 | + echo '-- Delete previous data -- '; |
|
1371 | + } |
|
1269 | 1372 | $query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;'; |
1270 | 1373 | } |
1271 | 1374 | |
@@ -1282,10 +1385,14 @@ discard block |
||
1282 | 1385 | return "error : ".$e->getMessage(); |
1283 | 1386 | } |
1284 | 1387 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1285 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
1388 | + if ($globalDebug) { |
|
1389 | + echo '(Add to SBS archive : '; |
|
1390 | + } |
|
1286 | 1391 | $SpotterArchive = new SpotterArchive($this->db); |
1287 | 1392 | $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); |
1288 | - if ($globalDebug) echo $result.')'; |
|
1393 | + if ($globalDebug) { |
|
1394 | + echo $result.')'; |
|
1395 | + } |
|
1289 | 1396 | } elseif ($globalDebug && $putinarchive !== true) { |
1290 | 1397 | echo '(Not adding to archive)'; |
1291 | 1398 | } elseif ($globalDebug && $noarchive === true) { |