@@ -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 string the SQL part |
|
| 19 | - */ |
|
| 16 | + * Get SQL query part for filter used |
|
| 17 | + * @param array $filter the filter |
|
| 18 | + * @return string 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(); |
@@ -138,14 +138,14 @@ discard block |
||
| 138 | 138 | return $filter_query; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - /** |
|
| 142 | - * Gets all the spotter information based on the latest data entry |
|
| 143 | - * |
|
| 144 | - * @param string $limit |
|
| 145 | - * @param string $sort |
|
| 146 | - * @param array $filter |
|
| 147 | - * @return array the spotter information |
|
| 148 | - */ |
|
| 141 | + /** |
|
| 142 | + * Gets all the spotter information based on the latest data entry |
|
| 143 | + * |
|
| 144 | + * @param string $limit |
|
| 145 | + * @param string $sort |
|
| 146 | + * @param array $filter |
|
| 147 | + * @return array the spotter information |
|
| 148 | + */ |
|
| 149 | 149 | public function getLiveSpotterData($limit = '', $sort = '', $filter = array()) |
| 150 | 150 | { |
| 151 | 151 | global $globalDBdriver, $globalLiveInterval; |
@@ -187,13 +187,13 @@ discard block |
||
| 187 | 187 | return $spotter_array; |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - /** |
|
| 191 | - * Gets Minimal Live Spotter data |
|
| 192 | - * |
|
| 193 | - * @param int $limit |
|
| 194 | - * @param array $filter |
|
| 195 | - * @return array the spotter information |
|
| 196 | - */ |
|
| 190 | + /** |
|
| 191 | + * Gets Minimal Live Spotter data |
|
| 192 | + * |
|
| 193 | + * @param int $limit |
|
| 194 | + * @param array $filter |
|
| 195 | + * @return array the spotter information |
|
| 196 | + */ |
|
| 197 | 197 | public function getMinLiveSpotterData($limit = 0,$filter = array()) |
| 198 | 198 | { |
| 199 | 199 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap2DAircraftsLimit; |
@@ -244,15 +244,15 @@ discard block |
||
| 244 | 244 | return $spotter_array; |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - /** |
|
| 248 | - * Gets Minimal Live Spotter data since xx seconds |
|
| 249 | - * |
|
| 250 | - * @param array $coord |
|
| 251 | - * @param array $filter |
|
| 252 | - * @param int $limit |
|
| 253 | - * @param string $id |
|
| 254 | - * @return array the spotter information |
|
| 255 | - */ |
|
| 247 | + /** |
|
| 248 | + * Gets Minimal Live Spotter data since xx seconds |
|
| 249 | + * |
|
| 250 | + * @param array $coord |
|
| 251 | + * @param array $filter |
|
| 252 | + * @param int $limit |
|
| 253 | + * @param string $id |
|
| 254 | + * @return array the spotter information |
|
| 255 | + */ |
|
| 256 | 256 | public function getMinLastLiveSpotterData($coord = array(),$filter = array(), $limit = 0, $id = '') |
| 257 | 257 | { |
| 258 | 258 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit; |
@@ -354,14 +354,14 @@ discard block |
||
| 354 | 354 | return $spotter_array; |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | - /** |
|
| 358 | - * Gets Minimal Live Spotter data since xx seconds |
|
| 359 | - * |
|
| 360 | - * @param string $id |
|
| 361 | - * @param array $filter |
|
| 362 | - * @param int $limit |
|
| 363 | - * @return array the spotter information |
|
| 364 | - */ |
|
| 357 | + /** |
|
| 358 | + * Gets Minimal Live Spotter data since xx seconds |
|
| 359 | + * |
|
| 360 | + * @param string $id |
|
| 361 | + * @param array $filter |
|
| 362 | + * @param int $limit |
|
| 363 | + * @return array the spotter information |
|
| 364 | + */ |
|
| 365 | 365 | public function getMinLastLiveSpotterDataByID($id = '',$filter = array(), $limit = 0) |
| 366 | 366 | { |
| 367 | 367 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit; |
@@ -426,12 +426,12 @@ discard block |
||
| 426 | 426 | return $spotter_array; |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | - /** |
|
| 430 | - * Gets number of latest data entry |
|
| 431 | - * |
|
| 432 | - * @param array $filter |
|
| 433 | - * @return String number of entry |
|
| 434 | - */ |
|
| 429 | + /** |
|
| 430 | + * Gets number of latest data entry |
|
| 431 | + * |
|
| 432 | + * @param array $filter |
|
| 433 | + * @return String number of entry |
|
| 434 | + */ |
|
| 435 | 435 | public function getLiveSpotterCount($filter = array()) |
| 436 | 436 | { |
| 437 | 437 | global $globalDBdriver, $globalLiveInterval; |
@@ -457,13 +457,13 @@ discard block |
||
| 457 | 457 | return $result['nb']; |
| 458 | 458 | } |
| 459 | 459 | |
| 460 | - /** |
|
| 461 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 462 | - * |
|
| 463 | - * @param $coord |
|
| 464 | - * @param array $filter |
|
| 465 | - * @return array the spotter information |
|
| 466 | - */ |
|
| 460 | + /** |
|
| 461 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 462 | + * |
|
| 463 | + * @param $coord |
|
| 464 | + * @param array $filter |
|
| 465 | + * @return array the spotter information |
|
| 466 | + */ |
|
| 467 | 467 | public function getLiveSpotterDatabyCoord($coord, $filter = array()) |
| 468 | 468 | { |
| 469 | 469 | global $globalDBdriver, $globalLiveInterval,$globalMap2DAircraftsLimit; |
@@ -490,14 +490,14 @@ discard block |
||
| 490 | 490 | return $spotter_array; |
| 491 | 491 | } |
| 492 | 492 | |
| 493 | - /** |
|
| 494 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 495 | - * |
|
| 496 | - * @param $coord |
|
| 497 | - * @param int $limit |
|
| 498 | - * @param array $filter |
|
| 499 | - * @return array the spotter information |
|
| 500 | - */ |
|
| 493 | + /** |
|
| 494 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 495 | + * |
|
| 496 | + * @param $coord |
|
| 497 | + * @param int $limit |
|
| 498 | + * @param array $filter |
|
| 499 | + * @return array the spotter information |
|
| 500 | + */ |
|
| 501 | 501 | public function getMinLiveSpotterDatabyCoord($coord,$limit = 0, $filter = array()) |
| 502 | 502 | { |
| 503 | 503 | global $globalDBdriver, $globalLiveInterval, $globalArchive,$globalMap2DAircraftsLimit; |
@@ -587,15 +587,15 @@ discard block |
||
| 587 | 587 | return $spotter_array; |
| 588 | 588 | } |
| 589 | 589 | |
| 590 | - /** |
|
| 591 | - * Gets all the spotter information based on a user's latitude and longitude |
|
| 592 | - * |
|
| 593 | - * @param $lat |
|
| 594 | - * @param $lng |
|
| 595 | - * @param $radius |
|
| 596 | - * @param $interval |
|
| 597 | - * @return array the spotter information |
|
| 598 | - */ |
|
| 590 | + /** |
|
| 591 | + * Gets all the spotter information based on a user's latitude and longitude |
|
| 592 | + * |
|
| 593 | + * @param $lat |
|
| 594 | + * @param $lng |
|
| 595 | + * @param $radius |
|
| 596 | + * @param $interval |
|
| 597 | + * @return array the spotter information |
|
| 598 | + */ |
|
| 599 | 599 | public function getLatestSpotterForLayar($lat, $lng, $radius, $interval) |
| 600 | 600 | { |
| 601 | 601 | $Spotter = new Spotter($this->db); |
@@ -605,95 +605,95 @@ discard block |
||
| 605 | 605 | return array(); |
| 606 | 606 | } |
| 607 | 607 | } |
| 608 | - if ($lng != '') |
|
| 609 | - { |
|
| 610 | - if (!is_numeric($lng)) |
|
| 611 | - { |
|
| 612 | - return array(); |
|
| 613 | - } |
|
| 614 | - } |
|
| 615 | - if ($radius != '') |
|
| 616 | - { |
|
| 617 | - if (!is_numeric($radius)) |
|
| 618 | - { |
|
| 619 | - return array(); |
|
| 620 | - } |
|
| 621 | - } |
|
| 608 | + if ($lng != '') |
|
| 609 | + { |
|
| 610 | + if (!is_numeric($lng)) |
|
| 611 | + { |
|
| 612 | + return array(); |
|
| 613 | + } |
|
| 614 | + } |
|
| 615 | + if ($radius != '') |
|
| 616 | + { |
|
| 617 | + if (!is_numeric($radius)) |
|
| 618 | + { |
|
| 619 | + return array(); |
|
| 620 | + } |
|
| 621 | + } |
|
| 622 | 622 | $additional_query = ''; |
| 623 | - if ($interval != '') |
|
| 624 | - { |
|
| 625 | - if (!is_string($interval)) |
|
| 626 | - { |
|
| 627 | - return array(); |
|
| 628 | - } else { |
|
| 629 | - if ($interval == '1m') |
|
| 630 | - { |
|
| 631 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 632 | - } else if ($interval == '15m'){ |
|
| 633 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
| 634 | - } |
|
| 635 | - } |
|
| 636 | - } else { |
|
| 637 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 638 | - } |
|
| 639 | - $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 |
|
| 623 | + if ($interval != '') |
|
| 624 | + { |
|
| 625 | + if (!is_string($interval)) |
|
| 626 | + { |
|
| 627 | + return array(); |
|
| 628 | + } else { |
|
| 629 | + if ($interval == '1m') |
|
| 630 | + { |
|
| 631 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 632 | + } else if ($interval == '15m'){ |
|
| 633 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
| 634 | + } |
|
| 635 | + } |
|
| 636 | + } else { |
|
| 637 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 638 | + } |
|
| 639 | + $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 |
|
| 640 | 640 | WHERE spotter_live.latitude <> '' |
| 641 | 641 | AND spotter_live.longitude <> '' |
| 642 | 642 | ".$additional_query." |
| 643 | 643 | HAVING distance < :radius |
| 644 | 644 | ORDER BY distance"; |
| 645 | 645 | |
| 646 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 647 | - return $spotter_array; |
|
| 648 | - } |
|
| 646 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 647 | + return $spotter_array; |
|
| 648 | + } |
|
| 649 | 649 | |
| 650 | 650 | |
| 651 | - /** |
|
| 652 | - * Gets all the spotter information based on a particular callsign |
|
| 653 | - * |
|
| 654 | - * @param $ident |
|
| 655 | - * @return array the spotter information |
|
| 656 | - */ |
|
| 651 | + /** |
|
| 652 | + * Gets all the spotter information based on a particular callsign |
|
| 653 | + * |
|
| 654 | + * @param $ident |
|
| 655 | + * @return array the spotter information |
|
| 656 | + */ |
|
| 657 | 657 | public function getLastLiveSpotterDataByIdent($ident) |
| 658 | 658 | { |
| 659 | 659 | $Spotter = new Spotter($this->db); |
| 660 | 660 | date_default_timezone_set('UTC'); |
| 661 | 661 | |
| 662 | 662 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 663 | - $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'; |
|
| 663 | + $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'; |
|
| 664 | 664 | |
| 665 | 665 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
| 666 | 666 | |
| 667 | 667 | return $spotter_array; |
| 668 | 668 | } |
| 669 | 669 | |
| 670 | - /** |
|
| 671 | - * Gets all the spotter information based on a particular callsign |
|
| 672 | - * |
|
| 673 | - * @param $ident |
|
| 674 | - * @param $date |
|
| 675 | - * @return array the spotter information |
|
| 676 | - */ |
|
| 670 | + /** |
|
| 671 | + * Gets all the spotter information based on a particular callsign |
|
| 672 | + * |
|
| 673 | + * @param $ident |
|
| 674 | + * @param $date |
|
| 675 | + * @return array the spotter information |
|
| 676 | + */ |
|
| 677 | 677 | public function getDateLiveSpotterDataByIdent($ident,$date) |
| 678 | 678 | { |
| 679 | 679 | $Spotter = new Spotter($this->db); |
| 680 | 680 | date_default_timezone_set('UTC'); |
| 681 | 681 | |
| 682 | 682 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 683 | - $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'; |
|
| 683 | + $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'; |
|
| 684 | 684 | |
| 685 | - $date = date('c',$date); |
|
| 685 | + $date = date('c',$date); |
|
| 686 | 686 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
| 687 | 687 | |
| 688 | 688 | return $spotter_array; |
| 689 | 689 | } |
| 690 | 690 | |
| 691 | - /** |
|
| 692 | - * Gets last spotter information based on a particular callsign |
|
| 693 | - * |
|
| 694 | - * @param $id |
|
| 695 | - * @return array the spotter information |
|
| 696 | - */ |
|
| 691 | + /** |
|
| 692 | + * Gets last spotter information based on a particular callsign |
|
| 693 | + * |
|
| 694 | + * @param $id |
|
| 695 | + * @return array the spotter information |
|
| 696 | + */ |
|
| 697 | 697 | public function getLastLiveSpotterDataById($id) |
| 698 | 698 | { |
| 699 | 699 | $Spotter = new Spotter($this->db); |
@@ -704,13 +704,13 @@ discard block |
||
| 704 | 704 | return $spotter_array; |
| 705 | 705 | } |
| 706 | 706 | |
| 707 | - /** |
|
| 708 | - * Gets last spotter information based on a particular callsign |
|
| 709 | - * |
|
| 710 | - * @param $id |
|
| 711 | - * @param $date |
|
| 712 | - * @return array the spotter information |
|
| 713 | - */ |
|
| 707 | + /** |
|
| 708 | + * Gets last spotter information based on a particular callsign |
|
| 709 | + * |
|
| 710 | + * @param $id |
|
| 711 | + * @param $date |
|
| 712 | + * @return array the spotter information |
|
| 713 | + */ |
|
| 714 | 714 | public function getDateLiveSpotterDataById($id,$date) |
| 715 | 715 | { |
| 716 | 716 | $Spotter = new Spotter($this->db); |
@@ -723,21 +723,21 @@ discard block |
||
| 723 | 723 | return $spotter_array; |
| 724 | 724 | } |
| 725 | 725 | |
| 726 | - /** |
|
| 727 | - * Gets altitude information based on a particular callsign |
|
| 728 | - * |
|
| 729 | - * @param $ident |
|
| 730 | - * @return array the spotter information |
|
| 731 | - */ |
|
| 726 | + /** |
|
| 727 | + * Gets altitude information based on a particular callsign |
|
| 728 | + * |
|
| 729 | + * @param $ident |
|
| 730 | + * @return array the spotter information |
|
| 731 | + */ |
|
| 732 | 732 | public function getAltitudeLiveSpotterDataByIdent($ident) |
| 733 | 733 | { |
| 734 | 734 | |
| 735 | 735 | date_default_timezone_set('UTC'); |
| 736 | 736 | |
| 737 | 737 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 738 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 738 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 739 | 739 | |
| 740 | - try { |
|
| 740 | + try { |
|
| 741 | 741 | |
| 742 | 742 | $sth = $this->db->prepare($query); |
| 743 | 743 | $sth->execute(array(':ident' => $ident)); |
@@ -750,13 +750,13 @@ discard block |
||
| 750 | 750 | return $spotter_array; |
| 751 | 751 | } |
| 752 | 752 | |
| 753 | - /** |
|
| 754 | - * Gets all the spotter information based on a particular id |
|
| 755 | - * |
|
| 756 | - * @param $id |
|
| 757 | - * @param bool $liveinterval |
|
| 758 | - * @return array the spotter information |
|
| 759 | - */ |
|
| 753 | + /** |
|
| 754 | + * Gets all the spotter information based on a particular id |
|
| 755 | + * |
|
| 756 | + * @param $id |
|
| 757 | + * @param bool $liveinterval |
|
| 758 | + * @return array the spotter information |
|
| 759 | + */ |
|
| 760 | 760 | public function getAllLiveSpotterDataById($id,$liveinterval = false) |
| 761 | 761 | { |
| 762 | 762 | global $globalDBdriver, $globalLiveInterval; |
@@ -784,18 +784,18 @@ discard block |
||
| 784 | 784 | return $spotter_array; |
| 785 | 785 | } |
| 786 | 786 | |
| 787 | - /** |
|
| 788 | - * Gets all the spotter information based on a particular ident |
|
| 789 | - * |
|
| 790 | - * @param $ident |
|
| 791 | - * @return array the spotter information |
|
| 792 | - */ |
|
| 787 | + /** |
|
| 788 | + * Gets all the spotter information based on a particular ident |
|
| 789 | + * |
|
| 790 | + * @param $ident |
|
| 791 | + * @return array the spotter information |
|
| 792 | + */ |
|
| 793 | 793 | public function getAllLiveSpotterDataByIdent($ident) |
| 794 | 794 | { |
| 795 | 795 | date_default_timezone_set('UTC'); |
| 796 | 796 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 797 | 797 | $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
| 798 | - try { |
|
| 798 | + try { |
|
| 799 | 799 | |
| 800 | 800 | $sth = $this->db->prepare($query); |
| 801 | 801 | $sth->execute(array(':ident' => $ident)); |
@@ -809,23 +809,23 @@ discard block |
||
| 809 | 809 | |
| 810 | 810 | |
| 811 | 811 | /** |
| 812 | - * Deletes all info in the table |
|
| 813 | - * |
|
| 814 | - * @return String success or false |
|
| 815 | - * |
|
| 816 | - */ |
|
| 812 | + * Deletes all info in the table |
|
| 813 | + * |
|
| 814 | + * @return String success or false |
|
| 815 | + * |
|
| 816 | + */ |
|
| 817 | 817 | public function deleteLiveSpotterData() |
| 818 | 818 | { |
| 819 | 819 | global $globalDBdriver; |
| 820 | 820 | if ($globalDBdriver == 'mysql') { |
| 821 | 821 | //$query = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date"; |
| 822 | 822 | $query = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date'; |
| 823 | - //$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)"; |
|
| 823 | + //$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)"; |
|
| 824 | 824 | } else { |
| 825 | 825 | $query = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date"; |
| 826 | 826 | } |
| 827 | 827 | |
| 828 | - try { |
|
| 828 | + try { |
|
| 829 | 829 | |
| 830 | 830 | $sth = $this->db->prepare($query); |
| 831 | 831 | $sth->execute(); |
@@ -837,18 +837,18 @@ discard block |
||
| 837 | 837 | } |
| 838 | 838 | |
| 839 | 839 | /** |
| 840 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 841 | - * |
|
| 842 | - * @return String success or false |
|
| 843 | - * |
|
| 844 | - */ |
|
| 840 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 841 | + * |
|
| 842 | + * @return String success or false |
|
| 843 | + * |
|
| 844 | + */ |
|
| 845 | 845 | public function deleteLiveSpotterDataNotUpdated() |
| 846 | 846 | { |
| 847 | 847 | global $globalDBdriver, $globalDebug; |
| 848 | 848 | if ($globalDBdriver == 'mysql') { |
| 849 | 849 | //$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'; |
| 850 | - $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"; |
|
| 851 | - try { |
|
| 850 | + $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"; |
|
| 851 | + try { |
|
| 852 | 852 | |
| 853 | 853 | $sth = $this->db->prepare($query); |
| 854 | 854 | $sth->execute(); |
@@ -856,8 +856,8 @@ discard block |
||
| 856 | 856 | return "error"; |
| 857 | 857 | } |
| 858 | 858 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
| 859 | - $i = 0; |
|
| 860 | - $j =0; |
|
| 859 | + $i = 0; |
|
| 860 | + $j =0; |
|
| 861 | 861 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 862 | 862 | foreach($all as $row) |
| 863 | 863 | { |
@@ -865,20 +865,20 @@ discard block |
||
| 865 | 865 | $j++; |
| 866 | 866 | if ($j == 30) { |
| 867 | 867 | if ($globalDebug) echo "."; |
| 868 | - try { |
|
| 868 | + try { |
|
| 869 | 869 | |
| 870 | 870 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 871 | 871 | $sth->execute(); |
| 872 | 872 | } catch(PDOException $e) { |
| 873 | 873 | return "error"; |
| 874 | 874 | } |
| 875 | - $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
| 876 | - $j = 0; |
|
| 875 | + $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
| 876 | + $j = 0; |
|
| 877 | 877 | } |
| 878 | 878 | $query_delete .= "'".$row['flightaware_id']."',"; |
| 879 | 879 | } |
| 880 | 880 | if ($i > 0) { |
| 881 | - try { |
|
| 881 | + try { |
|
| 882 | 882 | |
| 883 | 883 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 884 | 884 | $sth->execute(); |
@@ -889,9 +889,9 @@ discard block |
||
| 889 | 889 | return "success"; |
| 890 | 890 | } elseif ($globalDBdriver == 'pgsql') { |
| 891 | 891 | //$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"; |
| 892 | - //$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"; |
|
| 893 | - $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)"; |
|
| 894 | - try { |
|
| 892 | + //$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"; |
|
| 893 | + $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)"; |
|
| 894 | + try { |
|
| 895 | 895 | |
| 896 | 896 | $sth = $this->db->prepare($query); |
| 897 | 897 | $sth->execute(); |
@@ -934,18 +934,18 @@ discard block |
||
| 934 | 934 | } |
| 935 | 935 | } |
| 936 | 936 | |
| 937 | - /** |
|
| 938 | - * Deletes all info in the table for an ident |
|
| 939 | - * |
|
| 940 | - * @param $ident |
|
| 941 | - * @return String success or false |
|
| 942 | - */ |
|
| 937 | + /** |
|
| 938 | + * Deletes all info in the table for an ident |
|
| 939 | + * |
|
| 940 | + * @param $ident |
|
| 941 | + * @return String success or false |
|
| 942 | + */ |
|
| 943 | 943 | public function deleteLiveSpotterDataByIdent($ident) |
| 944 | 944 | { |
| 945 | 945 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 946 | 946 | $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
| 947 | 947 | |
| 948 | - try { |
|
| 948 | + try { |
|
| 949 | 949 | |
| 950 | 950 | $sth = $this->db->prepare($query); |
| 951 | 951 | $sth->execute(array(':ident' => $ident)); |
@@ -956,18 +956,18 @@ discard block |
||
| 956 | 956 | return "success"; |
| 957 | 957 | } |
| 958 | 958 | |
| 959 | - /** |
|
| 960 | - * Deletes all info in the table for an id |
|
| 961 | - * |
|
| 962 | - * @param $id |
|
| 963 | - * @return String success or false |
|
| 964 | - */ |
|
| 959 | + /** |
|
| 960 | + * Deletes all info in the table for an id |
|
| 961 | + * |
|
| 962 | + * @param $id |
|
| 963 | + * @return String success or false |
|
| 964 | + */ |
|
| 965 | 965 | public function deleteLiveSpotterDataById($id) |
| 966 | 966 | { |
| 967 | 967 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 968 | 968 | $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
| 969 | 969 | |
| 970 | - try { |
|
| 970 | + try { |
|
| 971 | 971 | |
| 972 | 972 | $sth = $this->db->prepare($query); |
| 973 | 973 | $sth->execute(array(':id' => $id)); |
@@ -979,12 +979,12 @@ discard block |
||
| 979 | 979 | } |
| 980 | 980 | |
| 981 | 981 | |
| 982 | - /** |
|
| 983 | - * Gets the aircraft ident within the last hour |
|
| 984 | - * |
|
| 985 | - * @param $ident |
|
| 986 | - * @return String the ident |
|
| 987 | - */ |
|
| 982 | + /** |
|
| 983 | + * Gets the aircraft ident within the last hour |
|
| 984 | + * |
|
| 985 | + * @param $ident |
|
| 986 | + * @return String the ident |
|
| 987 | + */ |
|
| 988 | 988 | public function getIdentFromLastHour($ident) |
| 989 | 989 | { |
| 990 | 990 | global $globalDBdriver, $globalTimezone; |
@@ -1010,14 +1010,14 @@ discard block |
||
| 1010 | 1010 | $ident_result = $row['ident']; |
| 1011 | 1011 | } |
| 1012 | 1012 | return $ident_result; |
| 1013 | - } |
|
| 1014 | - |
|
| 1015 | - /** |
|
| 1016 | - * Check recent aircraft |
|
| 1017 | - * |
|
| 1018 | - * @param $ident |
|
| 1019 | - * @return String the ident |
|
| 1020 | - */ |
|
| 1013 | + } |
|
| 1014 | + |
|
| 1015 | + /** |
|
| 1016 | + * Check recent aircraft |
|
| 1017 | + * |
|
| 1018 | + * @param $ident |
|
| 1019 | + * @return String the ident |
|
| 1020 | + */ |
|
| 1021 | 1021 | public function checkIdentRecent($ident) |
| 1022 | 1022 | { |
| 1023 | 1023 | global $globalDBdriver, $globalTimezone; |
@@ -1043,14 +1043,14 @@ discard block |
||
| 1043 | 1043 | $ident_result = $row['flightaware_id']; |
| 1044 | 1044 | } |
| 1045 | 1045 | return $ident_result; |
| 1046 | - } |
|
| 1047 | - |
|
| 1048 | - /** |
|
| 1049 | - * Check recent aircraft by id |
|
| 1050 | - * |
|
| 1051 | - * @param $id |
|
| 1052 | - * @return String the ident |
|
| 1053 | - */ |
|
| 1046 | + } |
|
| 1047 | + |
|
| 1048 | + /** |
|
| 1049 | + * Check recent aircraft by id |
|
| 1050 | + * |
|
| 1051 | + * @param $id |
|
| 1052 | + * @return String the ident |
|
| 1053 | + */ |
|
| 1054 | 1054 | public function checkIdRecent($id) |
| 1055 | 1055 | { |
| 1056 | 1056 | global $globalDBdriver, $globalTimezone; |
@@ -1076,14 +1076,14 @@ discard block |
||
| 1076 | 1076 | $ident_result = $row['flightaware_id']; |
| 1077 | 1077 | } |
| 1078 | 1078 | return $ident_result; |
| 1079 | - } |
|
| 1080 | - |
|
| 1081 | - /** |
|
| 1082 | - * Check recent aircraft by ModeS |
|
| 1083 | - * |
|
| 1084 | - * @param $modes |
|
| 1085 | - * @return String the ModeS |
|
| 1086 | - */ |
|
| 1079 | + } |
|
| 1080 | + |
|
| 1081 | + /** |
|
| 1082 | + * Check recent aircraft by ModeS |
|
| 1083 | + * |
|
| 1084 | + * @param $modes |
|
| 1085 | + * @return String the ModeS |
|
| 1086 | + */ |
|
| 1087 | 1087 | public function checkModeSRecent($modes) |
| 1088 | 1088 | { |
| 1089 | 1089 | global $globalDBdriver, $globalTimezone; |
@@ -1112,12 +1112,12 @@ discard block |
||
| 1112 | 1112 | return $ident_result; |
| 1113 | 1113 | } |
| 1114 | 1114 | |
| 1115 | - /** |
|
| 1116 | - * Gets the aircraft data from the last 20 seconds |
|
| 1117 | - * |
|
| 1118 | - * @param string $q |
|
| 1119 | - * @return array the spotter data |
|
| 1120 | - */ |
|
| 1115 | + /** |
|
| 1116 | + * Gets the aircraft data from the last 20 seconds |
|
| 1117 | + * |
|
| 1118 | + * @param string $q |
|
| 1119 | + * @return array the spotter data |
|
| 1120 | + */ |
|
| 1121 | 1121 | public function getRealTimeData($q = '') |
| 1122 | 1122 | { |
| 1123 | 1123 | global $globalDBdriver; |
@@ -1158,39 +1158,39 @@ discard block |
||
| 1158 | 1158 | return $spotter_array; |
| 1159 | 1159 | } |
| 1160 | 1160 | |
| 1161 | - /** |
|
| 1162 | - * Adds a new spotter data |
|
| 1163 | - * |
|
| 1164 | - * @param String $flightaware_id the ID from flightaware |
|
| 1165 | - * @param String $ident the flight ident |
|
| 1166 | - * @param String $aircraft_icao the aircraft type |
|
| 1167 | - * @param String $departure_airport_icao the departure airport |
|
| 1168 | - * @param String $arrival_airport_icao the arrival airport |
|
| 1169 | - * @param string $latitude |
|
| 1170 | - * @param string $longitude |
|
| 1171 | - * @param string $waypoints |
|
| 1172 | - * @param string $altitude |
|
| 1173 | - * @param string $altitude_real |
|
| 1174 | - * @param string $heading |
|
| 1175 | - * @param string $groundspeed |
|
| 1176 | - * @param string $date |
|
| 1177 | - * @param string $departure_airport_time |
|
| 1178 | - * @param string $arrival_airport_time |
|
| 1179 | - * @param string $squawk |
|
| 1180 | - * @param string $route_stop |
|
| 1181 | - * @param string $ModeS |
|
| 1182 | - * @param bool $putinarchive |
|
| 1183 | - * @param string $registration |
|
| 1184 | - * @param string $pilot_id |
|
| 1185 | - * @param string $pilot_name |
|
| 1186 | - * @param string $verticalrate |
|
| 1187 | - * @param bool $noarchive |
|
| 1188 | - * @param bool $ground |
|
| 1189 | - * @param string $format_source |
|
| 1190 | - * @param string $source_name |
|
| 1191 | - * @param string $over_country |
|
| 1192 | - * @return String success or false |
|
| 1193 | - */ |
|
| 1161 | + /** |
|
| 1162 | + * Adds a new spotter data |
|
| 1163 | + * |
|
| 1164 | + * @param String $flightaware_id the ID from flightaware |
|
| 1165 | + * @param String $ident the flight ident |
|
| 1166 | + * @param String $aircraft_icao the aircraft type |
|
| 1167 | + * @param String $departure_airport_icao the departure airport |
|
| 1168 | + * @param String $arrival_airport_icao the arrival airport |
|
| 1169 | + * @param string $latitude |
|
| 1170 | + * @param string $longitude |
|
| 1171 | + * @param string $waypoints |
|
| 1172 | + * @param string $altitude |
|
| 1173 | + * @param string $altitude_real |
|
| 1174 | + * @param string $heading |
|
| 1175 | + * @param string $groundspeed |
|
| 1176 | + * @param string $date |
|
| 1177 | + * @param string $departure_airport_time |
|
| 1178 | + * @param string $arrival_airport_time |
|
| 1179 | + * @param string $squawk |
|
| 1180 | + * @param string $route_stop |
|
| 1181 | + * @param string $ModeS |
|
| 1182 | + * @param bool $putinarchive |
|
| 1183 | + * @param string $registration |
|
| 1184 | + * @param string $pilot_id |
|
| 1185 | + * @param string $pilot_name |
|
| 1186 | + * @param string $verticalrate |
|
| 1187 | + * @param bool $noarchive |
|
| 1188 | + * @param bool $ground |
|
| 1189 | + * @param string $format_source |
|
| 1190 | + * @param string $source_name |
|
| 1191 | + * @param string $over_country |
|
| 1192 | + * @return String success or false |
|
| 1193 | + */ |
|
| 1194 | 1194 | 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 = '') |
| 1195 | 1195 | { |
| 1196 | 1196 | global $globalURL, $globalArchive, $globalDebug; |
@@ -1333,10 +1333,10 @@ discard block |
||
| 1333 | 1333 | $arrival_airport_country = ''; |
| 1334 | 1334 | |
| 1335 | 1335 | |
| 1336 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1337 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1338 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1339 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1336 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1337 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1338 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1339 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1340 | 1340 | |
| 1341 | 1341 | $query = ''; |
| 1342 | 1342 | if ($globalArchive) { |
@@ -1357,10 +1357,10 @@ discard block |
||
| 1357 | 1357 | return "error : ".$e->getMessage(); |
| 1358 | 1358 | } |
| 1359 | 1359 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1360 | - if ($globalDebug) echo '(Add to Spotter archive : '; |
|
| 1361 | - $SpotterArchive = new SpotterArchive($this->db); |
|
| 1362 | - $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); |
|
| 1363 | - if ($globalDebug) echo $result.')'; |
|
| 1360 | + if ($globalDebug) echo '(Add to Spotter archive : '; |
|
| 1361 | + $SpotterArchive = new SpotterArchive($this->db); |
|
| 1362 | + $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); |
|
| 1363 | + if ($globalDebug) echo $result.')'; |
|
| 1364 | 1364 | } elseif ($globalDebug && $putinarchive !== true) { |
| 1365 | 1365 | echo '(Not adding to archive)'; |
| 1366 | 1366 | } elseif ($globalDebug && $noarchive === true) { |
@@ -17,62 +17,62 @@ discard block |
||
| 17 | 17 | * @param array $filter the filter |
| 18 | 18 | * @return string 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; |
@@ -157,8 +157,8 @@ discard block |
||
| 157 | 157 | if ($limit != '') |
| 158 | 158 | { |
| 159 | 159 | $limit_array = explode(',', $limit); |
| 160 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 161 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 160 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 161 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 162 | 162 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 163 | 163 | { |
| 164 | 164 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | } else { |
| 183 | 183 | $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; |
| 184 | 184 | } |
| 185 | - $spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true); |
|
| 185 | + $spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true); |
|
| 186 | 186 | |
| 187 | 187 | return $spotter_array; |
| 188 | 188 | } |
@@ -194,34 +194,34 @@ discard block |
||
| 194 | 194 | * @param array $filter |
| 195 | 195 | * @return array the spotter information |
| 196 | 196 | */ |
| 197 | - public function getMinLiveSpotterData($limit = 0,$filter = array()) |
|
| 197 | + public function getMinLiveSpotterData($limit = 0, $filter = array()) |
|
| 198 | 198 | { |
| 199 | 199 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap2DAircraftsLimit; |
| 200 | 200 | date_default_timezone_set('UTC'); |
| 201 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 201 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 202 | 202 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 203 | 203 | if ($globalDBdriver == 'mysql') { |
| 204 | 204 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 205 | 205 | // $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 |
| 206 | 206 | // 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"; |
| 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 |
|
| 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'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date AND'." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0"; |
| 209 | 209 | } else { |
| 210 | 210 | // $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 |
| 211 | 211 | // 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"; |
| 212 | - $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 |
|
| 212 | + $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 |
|
| 213 | 213 | 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"; |
| 214 | 214 | } |
| 215 | 215 | } else { |
| 216 | 216 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 217 | 217 | // $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 |
| 218 | 218 | // 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"; |
| 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 |
|
| 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".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'"; |
| 221 | 221 | } else { |
| 222 | 222 | // $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 |
| 223 | 223 | // 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"; |
| 224 | - $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 |
|
| 224 | + $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 |
|
| 225 | 225 | 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'"; |
| 226 | 226 | } |
| 227 | 227 | } |
@@ -229,14 +229,14 @@ discard block |
||
| 229 | 229 | if ($limit == 0 && isset($globalMap2DAircraftsLimit) && $globalMap2DAircraftsLimit != '') { |
| 230 | 230 | $limit = $globalMap2DAircraftsLimit; |
| 231 | 231 | } |
| 232 | - if ($limit != 0 && filter_var($limit,FILTER_VALIDATE_INT)) { |
|
| 232 | + if ($limit != 0 && filter_var($limit, FILTER_VALIDATE_INT)) { |
|
| 233 | 233 | $query .= ' LIMIT '.$limit; |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | try { |
| 237 | 237 | $sth = $this->db->prepare($query); |
| 238 | 238 | $sth->execute(); |
| 239 | - } catch(PDOException $e) { |
|
| 239 | + } catch (PDOException $e) { |
|
| 240 | 240 | echo $e->getMessage(); |
| 241 | 241 | die; |
| 242 | 242 | } |
@@ -253,20 +253,20 @@ discard block |
||
| 253 | 253 | * @param string $id |
| 254 | 254 | * @return array the spotter information |
| 255 | 255 | */ |
| 256 | - public function getMinLastLiveSpotterData($coord = array(),$filter = array(), $limit = 0, $id = '') |
|
| 256 | + public function getMinLastLiveSpotterData($coord = array(), $filter = array(), $limit = 0, $id = '') |
|
| 257 | 257 | { |
| 258 | 258 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit; |
| 259 | 259 | date_default_timezone_set('UTC'); |
| 260 | 260 | $usecoord = false; |
| 261 | 261 | if (is_array($coord) && !empty($coord)) { |
| 262 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 263 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 264 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 265 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 262 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 263 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 264 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 265 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 266 | 266 | if ($minlong != '' && $minlat != '' && $maxlong != '' && $maxlat != '') $usecoord = true; |
| 267 | 267 | } |
| 268 | - $id = filter_var($id,FILTER_SANITIZE_STRING); |
|
| 269 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 268 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 269 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 270 | 270 | |
| 271 | 271 | if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200'; |
| 272 | 272 | if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300'; |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | ORDER BY flightaware_id, date"; |
| 297 | 297 | if ($limit > 0) $query .= " LIMIT ".$limit; |
| 298 | 298 | } else { |
| 299 | - $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 |
|
| 299 | + $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 |
|
| 300 | 300 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date "; |
| 301 | 301 | if ($usecoord) $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
| 302 | 302 | if ($id != '') $query .= "OR spotter_live.flightaware_id = :id "; |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | try { |
| 347 | 347 | $sth = $this->db->prepare($query); |
| 348 | 348 | $sth->execute($query_values); |
| 349 | - } catch(PDOException $e) { |
|
| 349 | + } catch (PDOException $e) { |
|
| 350 | 350 | echo $e->getMessage(); |
| 351 | 351 | die; |
| 352 | 352 | } |
@@ -362,12 +362,12 @@ discard block |
||
| 362 | 362 | * @param int $limit |
| 363 | 363 | * @return array the spotter information |
| 364 | 364 | */ |
| 365 | - public function getMinLastLiveSpotterDataByID($id = '',$filter = array(), $limit = 0) |
|
| 365 | + public function getMinLastLiveSpotterDataByID($id = '', $filter = array(), $limit = 0) |
|
| 366 | 366 | { |
| 367 | 367 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit; |
| 368 | 368 | date_default_timezone_set('UTC'); |
| 369 | - $id = filter_var($id,FILTER_SANITIZE_STRING); |
|
| 370 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 369 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 370 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 371 | 371 | |
| 372 | 372 | if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200'; |
| 373 | 373 | if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300'; |
@@ -392,13 +392,13 @@ discard block |
||
| 392 | 392 | } |
| 393 | 393 | } else { |
| 394 | 394 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 395 | - $query = "SELECT * FROM ( |
|
| 395 | + $query = "SELECT * FROM ( |
|
| 396 | 396 | 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 |
| 397 | 397 | FROM spotter_archive |
| 398 | 398 | INNER JOIN ( |
| 399 | 399 | SELECT flightaware_id |
| 400 | 400 | FROM spotter_live".$filter_query." spotter_live.flightaware_id = :id"; |
| 401 | - $query.= ") l ON l.flightaware_id = spotter_archive.flightaware_id "; |
|
| 401 | + $query .= ") l ON l.flightaware_id = spotter_archive.flightaware_id "; |
|
| 402 | 402 | $query .= "UNION |
| 403 | 403 | 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 |
| 404 | 404 | FROM spotter_live".$filter_query." spotter_live.flightaware_id = :id"; |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | try { |
| 418 | 418 | $sth = $this->db->prepare($query); |
| 419 | 419 | $sth->execute($query_values); |
| 420 | - } catch(PDOException $e) { |
|
| 420 | + } catch (PDOException $e) { |
|
| 421 | 421 | echo $e->getMessage(); |
| 422 | 422 | die; |
| 423 | 423 | } |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | public function getLiveSpotterCount($filter = array()) |
| 435 | 435 | { |
| 436 | 436 | global $globalDBdriver, $globalLiveInterval; |
| 437 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 437 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 438 | 438 | |
| 439 | 439 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 440 | 440 | if ($globalDBdriver == 'mysql') { |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | try { |
| 448 | 448 | $sth = $this->db->prepare($query); |
| 449 | 449 | $sth->execute(); |
| 450 | - } catch(PDOException $e) { |
|
| 450 | + } catch (PDOException $e) { |
|
| 451 | 451 | echo $e->getMessage(); |
| 452 | 452 | die; |
| 453 | 453 | } |
@@ -465,16 +465,16 @@ discard block |
||
| 465 | 465 | */ |
| 466 | 466 | public function getLiveSpotterDatabyCoord($coord, $filter = array()) |
| 467 | 467 | { |
| 468 | - global $globalDBdriver, $globalLiveInterval,$globalMap2DAircraftsLimit; |
|
| 468 | + global $globalDBdriver, $globalLiveInterval, $globalMap2DAircraftsLimit; |
|
| 469 | 469 | $Spotter = new Spotter($this->db); |
| 470 | 470 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 471 | 471 | $filter_query = $this->getFilter($filter); |
| 472 | 472 | |
| 473 | 473 | if (is_array($coord)) { |
| 474 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 475 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 476 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 477 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 474 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 475 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 476 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 477 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 478 | 478 | } else return array(); |
| 479 | 479 | if ($globalDBdriver == 'mysql') { |
| 480 | 480 | $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; |
@@ -497,27 +497,27 @@ discard block |
||
| 497 | 497 | * @param array $filter |
| 498 | 498 | * @return array the spotter information |
| 499 | 499 | */ |
| 500 | - public function getMinLiveSpotterDatabyCoord($coord,$limit = 0, $filter = array()) |
|
| 500 | + public function getMinLiveSpotterDatabyCoord($coord, $limit = 0, $filter = array()) |
|
| 501 | 501 | { |
| 502 | - global $globalDBdriver, $globalLiveInterval, $globalArchive,$globalMap2DAircraftsLimit; |
|
| 502 | + global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap2DAircraftsLimit; |
|
| 503 | 503 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 504 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 504 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 505 | 505 | |
| 506 | 506 | if (is_array($coord)) { |
| 507 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 508 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 509 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 510 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 507 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 508 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 509 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 510 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 511 | 511 | } else return array(); |
| 512 | 512 | if ($globalDBdriver == 'mysql') { |
| 513 | 513 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 514 | - $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 |
|
| 514 | + $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 |
|
| 515 | 515 | FROM spotter_live |
| 516 | 516 | '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date |
| 517 | 517 | AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' |
| 518 | 518 | AND spotter_live.latitude <> 0 AND spotter_live.longitude <> 0 ORDER BY date DESC'; |
| 519 | 519 | } else { |
| 520 | - $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 |
|
| 520 | + $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 |
|
| 521 | 521 | FROM spotter_live |
| 522 | 522 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
| 523 | 523 | FROM spotter_live l |
@@ -537,7 +537,7 @@ discard block |
||
| 537 | 537 | AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." |
| 538 | 538 | AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' ORDER BY date DESC"; |
| 539 | 539 | */ |
| 540 | - $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 |
|
| 540 | + $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 |
|
| 541 | 541 | FROM spotter_live |
| 542 | 542 | ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date |
| 543 | 543 | AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." |
@@ -556,7 +556,7 @@ discard block |
||
| 556 | 556 | ) s on spotter_live.flightaware_id = s.flightaware_id |
| 557 | 557 | AND spotter_live.date = s.maxdate".$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' ORDER BY date DESC"; |
| 558 | 558 | */ |
| 559 | - $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 |
|
| 559 | + $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 |
|
| 560 | 560 | FROM spotter_live |
| 561 | 561 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
| 562 | 562 | FROM spotter_live l |
@@ -571,13 +571,13 @@ discard block |
||
| 571 | 571 | if ($limit == 0 && isset($globalMap2DAircraftsLimit) && $globalMap2DAircraftsLimit != '') { |
| 572 | 572 | $limit = $globalMap2DAircraftsLimit; |
| 573 | 573 | } |
| 574 | - if ($limit != 0 && filter_var($limit,FILTER_VALIDATE_INT)) { |
|
| 574 | + if ($limit != 0 && filter_var($limit, FILTER_VALIDATE_INT)) { |
|
| 575 | 575 | $query .= ' LIMIT '.$limit; |
| 576 | 576 | } |
| 577 | 577 | try { |
| 578 | 578 | $sth = $this->db->prepare($query); |
| 579 | 579 | $sth->execute(); |
| 580 | - } catch(PDOException $e) { |
|
| 580 | + } catch (PDOException $e) { |
|
| 581 | 581 | echo $e->getMessage(); |
| 582 | 582 | die; |
| 583 | 583 | } |
@@ -627,21 +627,21 @@ discard block |
||
| 627 | 627 | if ($interval == '1m') |
| 628 | 628 | { |
| 629 | 629 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
| 630 | - } else if ($interval == '15m'){ |
|
| 630 | + } else if ($interval == '15m') { |
|
| 631 | 631 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
| 632 | 632 | } |
| 633 | 633 | } |
| 634 | 634 | } else { |
| 635 | 635 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
| 636 | 636 | } |
| 637 | - $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 |
|
| 637 | + $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 |
|
| 638 | 638 | WHERE spotter_live.latitude <> '' |
| 639 | 639 | AND spotter_live.longitude <> '' |
| 640 | 640 | ".$additional_query." |
| 641 | 641 | HAVING distance < :radius |
| 642 | 642 | ORDER BY distance"; |
| 643 | 643 | |
| 644 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 644 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
| 645 | 645 | return $spotter_array; |
| 646 | 646 | } |
| 647 | 647 | |
@@ -658,9 +658,9 @@ discard block |
||
| 658 | 658 | date_default_timezone_set('UTC'); |
| 659 | 659 | |
| 660 | 660 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 661 | - $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'; |
|
| 661 | + $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'; |
|
| 662 | 662 | |
| 663 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
| 663 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
| 664 | 664 | |
| 665 | 665 | return $spotter_array; |
| 666 | 666 | } |
@@ -672,16 +672,16 @@ discard block |
||
| 672 | 672 | * @param $date |
| 673 | 673 | * @return array the spotter information |
| 674 | 674 | */ |
| 675 | - public function getDateLiveSpotterDataByIdent($ident,$date) |
|
| 675 | + public function getDateLiveSpotterDataByIdent($ident, $date) |
|
| 676 | 676 | { |
| 677 | 677 | $Spotter = new Spotter($this->db); |
| 678 | 678 | date_default_timezone_set('UTC'); |
| 679 | 679 | |
| 680 | 680 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 681 | - $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'; |
|
| 681 | + $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'; |
|
| 682 | 682 | |
| 683 | - $date = date('c',$date); |
|
| 684 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 683 | + $date = date('c', $date); |
|
| 684 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 685 | 685 | |
| 686 | 686 | return $spotter_array; |
| 687 | 687 | } |
@@ -697,8 +697,8 @@ discard block |
||
| 697 | 697 | $Spotter = new Spotter($this->db); |
| 698 | 698 | date_default_timezone_set('UTC'); |
| 699 | 699 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 700 | - $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'; |
|
| 701 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
|
| 700 | + $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'; |
|
| 701 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true); |
|
| 702 | 702 | return $spotter_array; |
| 703 | 703 | } |
| 704 | 704 | |
@@ -709,15 +709,15 @@ discard block |
||
| 709 | 709 | * @param $date |
| 710 | 710 | * @return array the spotter information |
| 711 | 711 | */ |
| 712 | - public function getDateLiveSpotterDataById($id,$date) |
|
| 712 | + public function getDateLiveSpotterDataById($id, $date) |
|
| 713 | 713 | { |
| 714 | 714 | $Spotter = new Spotter($this->db); |
| 715 | 715 | date_default_timezone_set('UTC'); |
| 716 | 716 | |
| 717 | 717 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 718 | - $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'; |
|
| 719 | - $date = date('c',$date); |
|
| 720 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
| 718 | + $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'; |
|
| 719 | + $date = date('c', $date); |
|
| 720 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
| 721 | 721 | return $spotter_array; |
| 722 | 722 | } |
| 723 | 723 | |
@@ -733,13 +733,13 @@ discard block |
||
| 733 | 733 | date_default_timezone_set('UTC'); |
| 734 | 734 | |
| 735 | 735 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 736 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 736 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 737 | 737 | |
| 738 | 738 | try { |
| 739 | 739 | |
| 740 | 740 | $sth = $this->db->prepare($query); |
| 741 | 741 | $sth->execute(array(':ident' => $ident)); |
| 742 | - } catch(PDOException $e) { |
|
| 742 | + } catch (PDOException $e) { |
|
| 743 | 743 | echo $e->getMessage(); |
| 744 | 744 | die; |
| 745 | 745 | } |
@@ -755,7 +755,7 @@ discard block |
||
| 755 | 755 | * @param bool $liveinterval |
| 756 | 756 | * @return array the spotter information |
| 757 | 757 | */ |
| 758 | - public function getAllLiveSpotterDataById($id,$liveinterval = false) |
|
| 758 | + public function getAllLiveSpotterDataById($id, $liveinterval = false) |
|
| 759 | 759 | { |
| 760 | 760 | global $globalDBdriver, $globalLiveInterval; |
| 761 | 761 | date_default_timezone_set('UTC'); |
@@ -774,7 +774,7 @@ discard block |
||
| 774 | 774 | try { |
| 775 | 775 | $sth = $this->db->prepare($query); |
| 776 | 776 | $sth->execute(array(':id' => $id)); |
| 777 | - } catch(PDOException $e) { |
|
| 777 | + } catch (PDOException $e) { |
|
| 778 | 778 | echo $e->getMessage(); |
| 779 | 779 | die; |
| 780 | 780 | } |
@@ -792,12 +792,12 @@ discard block |
||
| 792 | 792 | { |
| 793 | 793 | date_default_timezone_set('UTC'); |
| 794 | 794 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 795 | - $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
| 795 | + $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
| 796 | 796 | try { |
| 797 | 797 | |
| 798 | 798 | $sth = $this->db->prepare($query); |
| 799 | 799 | $sth->execute(array(':ident' => $ident)); |
| 800 | - } catch(PDOException $e) { |
|
| 800 | + } catch (PDOException $e) { |
|
| 801 | 801 | echo $e->getMessage(); |
| 802 | 802 | die; |
| 803 | 803 | } |
@@ -827,7 +827,7 @@ discard block |
||
| 827 | 827 | |
| 828 | 828 | $sth = $this->db->prepare($query); |
| 829 | 829 | $sth->execute(); |
| 830 | - } catch(PDOException $e) { |
|
| 830 | + } catch (PDOException $e) { |
|
| 831 | 831 | return "error"; |
| 832 | 832 | } |
| 833 | 833 | |
@@ -850,14 +850,14 @@ discard block |
||
| 850 | 850 | |
| 851 | 851 | $sth = $this->db->prepare($query); |
| 852 | 852 | $sth->execute(); |
| 853 | - } catch(PDOException $e) { |
|
| 853 | + } catch (PDOException $e) { |
|
| 854 | 854 | return "error"; |
| 855 | 855 | } |
| 856 | 856 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
| 857 | 857 | $i = 0; |
| 858 | - $j =0; |
|
| 858 | + $j = 0; |
|
| 859 | 859 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 860 | - foreach($all as $row) |
|
| 860 | + foreach ($all as $row) |
|
| 861 | 861 | { |
| 862 | 862 | $i++; |
| 863 | 863 | $j++; |
@@ -865,9 +865,9 @@ discard block |
||
| 865 | 865 | if ($globalDebug) echo "."; |
| 866 | 866 | try { |
| 867 | 867 | |
| 868 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 868 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 869 | 869 | $sth->execute(); |
| 870 | - } catch(PDOException $e) { |
|
| 870 | + } catch (PDOException $e) { |
|
| 871 | 871 | return "error"; |
| 872 | 872 | } |
| 873 | 873 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
@@ -878,9 +878,9 @@ discard block |
||
| 878 | 878 | if ($i > 0) { |
| 879 | 879 | try { |
| 880 | 880 | |
| 881 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 881 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 882 | 882 | $sth->execute(); |
| 883 | - } catch(PDOException $e) { |
|
| 883 | + } catch (PDOException $e) { |
|
| 884 | 884 | return "error"; |
| 885 | 885 | } |
| 886 | 886 | } |
@@ -893,7 +893,7 @@ discard block |
||
| 893 | 893 | |
| 894 | 894 | $sth = $this->db->prepare($query); |
| 895 | 895 | $sth->execute(); |
| 896 | - } catch(PDOException $e) { |
|
| 896 | + } catch (PDOException $e) { |
|
| 897 | 897 | return "error"; |
| 898 | 898 | } |
| 899 | 899 | /* $query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN ("; |
@@ -941,13 +941,13 @@ discard block |
||
| 941 | 941 | public function deleteLiveSpotterDataByIdent($ident) |
| 942 | 942 | { |
| 943 | 943 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 944 | - $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
| 944 | + $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
| 945 | 945 | |
| 946 | 946 | try { |
| 947 | 947 | |
| 948 | 948 | $sth = $this->db->prepare($query); |
| 949 | 949 | $sth->execute(array(':ident' => $ident)); |
| 950 | - } catch(PDOException $e) { |
|
| 950 | + } catch (PDOException $e) { |
|
| 951 | 951 | return "error"; |
| 952 | 952 | } |
| 953 | 953 | |
@@ -963,13 +963,13 @@ discard block |
||
| 963 | 963 | public function deleteLiveSpotterDataById($id) |
| 964 | 964 | { |
| 965 | 965 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 966 | - $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
| 966 | + $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
| 967 | 967 | |
| 968 | 968 | try { |
| 969 | 969 | |
| 970 | 970 | $sth = $this->db->prepare($query); |
| 971 | 971 | $sth->execute(array(':id' => $id)); |
| 972 | - } catch(PDOException $e) { |
|
| 972 | + } catch (PDOException $e) { |
|
| 973 | 973 | return "error"; |
| 974 | 974 | } |
| 975 | 975 | |
@@ -987,13 +987,13 @@ discard block |
||
| 987 | 987 | { |
| 988 | 988 | global $globalDBdriver, $globalTimezone; |
| 989 | 989 | if ($globalDBdriver == 'mysql') { |
| 990 | - $query = 'SELECT spotter_live.ident FROM spotter_live |
|
| 990 | + $query = 'SELECT spotter_live.ident FROM spotter_live |
|
| 991 | 991 | WHERE spotter_live.ident = :ident |
| 992 | 992 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 993 | 993 | AND spotter_live.date < UTC_TIMESTAMP()'; |
| 994 | 994 | $query_data = array(':ident' => $ident); |
| 995 | 995 | } else { |
| 996 | - $query = "SELECT spotter_live.ident FROM spotter_live |
|
| 996 | + $query = "SELECT spotter_live.ident FROM spotter_live |
|
| 997 | 997 | WHERE spotter_live.ident = :ident |
| 998 | 998 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 999 | 999 | AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -1002,8 +1002,8 @@ discard block |
||
| 1002 | 1002 | |
| 1003 | 1003 | $sth = $this->db->prepare($query); |
| 1004 | 1004 | $sth->execute($query_data); |
| 1005 | - $ident_result=''; |
|
| 1006 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1005 | + $ident_result = ''; |
|
| 1006 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1007 | 1007 | { |
| 1008 | 1008 | $ident_result = $row['ident']; |
| 1009 | 1009 | } |
@@ -1020,13 +1020,13 @@ discard block |
||
| 1020 | 1020 | { |
| 1021 | 1021 | global $globalDBdriver, $globalTimezone; |
| 1022 | 1022 | if ($globalDBdriver == 'mysql') { |
| 1023 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 1023 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 1024 | 1024 | WHERE spotter_live.ident = :ident |
| 1025 | 1025 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 MINUTE)'; |
| 1026 | 1026 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
| 1027 | 1027 | $query_data = array(':ident' => $ident); |
| 1028 | 1028 | } else { |
| 1029 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 1029 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 1030 | 1030 | WHERE spotter_live.ident = :ident |
| 1031 | 1031 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '20 MINUTES'"; |
| 1032 | 1032 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -1035,8 +1035,8 @@ discard block |
||
| 1035 | 1035 | |
| 1036 | 1036 | $sth = $this->db->prepare($query); |
| 1037 | 1037 | $sth->execute($query_data); |
| 1038 | - $ident_result=''; |
|
| 1039 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1038 | + $ident_result = ''; |
|
| 1039 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1040 | 1040 | { |
| 1041 | 1041 | $ident_result = $row['flightaware_id']; |
| 1042 | 1042 | } |
@@ -1053,13 +1053,13 @@ discard block |
||
| 1053 | 1053 | { |
| 1054 | 1054 | global $globalDBdriver, $globalTimezone; |
| 1055 | 1055 | if ($globalDBdriver == 'mysql') { |
| 1056 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 1056 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 1057 | 1057 | WHERE spotter_live.flightaware_id = :id |
| 1058 | 1058 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
| 1059 | 1059 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
| 1060 | 1060 | $query_data = array(':id' => $id); |
| 1061 | 1061 | } else { |
| 1062 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 1062 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 1063 | 1063 | WHERE spotter_live.flightaware_id = :id |
| 1064 | 1064 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
| 1065 | 1065 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -1068,8 +1068,8 @@ discard block |
||
| 1068 | 1068 | |
| 1069 | 1069 | $sth = $this->db->prepare($query); |
| 1070 | 1070 | $sth->execute($query_data); |
| 1071 | - $ident_result=''; |
|
| 1072 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1071 | + $ident_result = ''; |
|
| 1072 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1073 | 1073 | { |
| 1074 | 1074 | $ident_result = $row['flightaware_id']; |
| 1075 | 1075 | } |
@@ -1086,13 +1086,13 @@ discard block |
||
| 1086 | 1086 | { |
| 1087 | 1087 | global $globalDBdriver, $globalTimezone; |
| 1088 | 1088 | if ($globalDBdriver == 'mysql') { |
| 1089 | - $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 1089 | + $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 1090 | 1090 | WHERE spotter_live.ModeS = :modes |
| 1091 | 1091 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 MINUTE)'; |
| 1092 | 1092 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
| 1093 | 1093 | $query_data = array(':modes' => $modes); |
| 1094 | 1094 | } else { |
| 1095 | - $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 1095 | + $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 1096 | 1096 | WHERE spotter_live.ModeS = :modes |
| 1097 | 1097 | AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 MINUTE'"; |
| 1098 | 1098 | // // AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
@@ -1101,8 +1101,8 @@ discard block |
||
| 1101 | 1101 | |
| 1102 | 1102 | $sth = $this->db->prepare($query); |
| 1103 | 1103 | $sth->execute($query_data); |
| 1104 | - $ident_result=''; |
|
| 1105 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1104 | + $ident_result = ''; |
|
| 1105 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1106 | 1106 | { |
| 1107 | 1107 | //$ident_result = $row['spotter_live_id']; |
| 1108 | 1108 | $ident_result = $row['flightaware_id']; |
@@ -1127,8 +1127,8 @@ discard block |
||
| 1127 | 1127 | return array(); |
| 1128 | 1128 | } else { |
| 1129 | 1129 | $q_array = explode(" ", $q); |
| 1130 | - foreach ($q_array as $q_item){ |
|
| 1131 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
| 1130 | + foreach ($q_array as $q_item) { |
|
| 1131 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
| 1132 | 1132 | $additional_query .= " AND ("; |
| 1133 | 1133 | $additional_query .= "(spotter_live.aircraft_icao like '%".$q_item."%') OR "; |
| 1134 | 1134 | $additional_query .= "(spotter_live.aircraft_name like '%".$q_item."%') OR "; |
@@ -1143,11 +1143,11 @@ discard block |
||
| 1143 | 1143 | } |
| 1144 | 1144 | } |
| 1145 | 1145 | if ($globalDBdriver == 'mysql') { |
| 1146 | - $query = "SELECT spotter_live.* FROM spotter_live |
|
| 1146 | + $query = "SELECT spotter_live.* FROM spotter_live |
|
| 1147 | 1147 | WHERE spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
| 1148 | 1148 | AND spotter_live.date < UTC_TIMESTAMP()"; |
| 1149 | 1149 | } else { |
| 1150 | - $query = "SELECT spotter_live.* FROM spotter_live |
|
| 1150 | + $query = "SELECT spotter_live.* FROM spotter_live |
|
| 1151 | 1151 | WHERE spotter_live.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
| 1152 | 1152 | AND spotter_live.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
| 1153 | 1153 | } |
@@ -1189,7 +1189,7 @@ discard block |
||
| 1189 | 1189 | * @param string $over_country |
| 1190 | 1190 | * @return String success or false |
| 1191 | 1191 | */ |
| 1192 | - 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 = '') |
|
| 1192 | + 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 = '') |
|
| 1193 | 1193 | { |
| 1194 | 1194 | global $globalURL, $globalArchive, $globalDebug; |
| 1195 | 1195 | $Common = new Common(); |
@@ -1289,27 +1289,27 @@ discard block |
||
| 1289 | 1289 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
| 1290 | 1290 | |
| 1291 | 1291 | |
| 1292 | - $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
|
| 1293 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 1294 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 1295 | - $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
| 1296 | - $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
| 1297 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1298 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1299 | - $waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING); |
|
| 1300 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1301 | - $altitude_real = filter_var($altitude_real,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1302 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 1303 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1304 | - $squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT); |
|
| 1305 | - $route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING); |
|
| 1306 | - $ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING); |
|
| 1307 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING); |
|
| 1308 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 1309 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 1310 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
| 1311 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
| 1312 | - $verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT); |
|
| 1292 | + $flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING); |
|
| 1293 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 1294 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 1295 | + $departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING); |
|
| 1296 | + $arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING); |
|
| 1297 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1298 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1299 | + $waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING); |
|
| 1300 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1301 | + $altitude_real = filter_var($altitude_real, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1302 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 1303 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1304 | + $squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT); |
|
| 1305 | + $route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING); |
|
| 1306 | + $ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING); |
|
| 1307 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING); |
|
| 1308 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
| 1309 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 1310 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
| 1311 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
| 1312 | + $verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT); |
|
| 1313 | 1313 | |
| 1314 | 1314 | $airline_name = ''; |
| 1315 | 1315 | $airline_icao = ''; |
@@ -1331,10 +1331,10 @@ discard block |
||
| 1331 | 1331 | $arrival_airport_country = ''; |
| 1332 | 1332 | |
| 1333 | 1333 | |
| 1334 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1335 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1336 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1337 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1334 | + if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL; |
|
| 1335 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL; |
|
| 1336 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 1337 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 1338 | 1338 | |
| 1339 | 1339 | $query = ''; |
| 1340 | 1340 | if ($globalArchive) { |
@@ -1345,19 +1345,19 @@ discard block |
||
| 1345 | 1345 | $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) |
| 1346 | 1346 | 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)'; |
| 1347 | 1347 | |
| 1348 | - $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); |
|
| 1348 | + $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); |
|
| 1349 | 1349 | try { |
| 1350 | 1350 | |
| 1351 | 1351 | $sth = $this->db->prepare($query); |
| 1352 | 1352 | $sth->execute($query_values); |
| 1353 | 1353 | $sth->closeCursor(); |
| 1354 | - } catch(PDOException $e) { |
|
| 1354 | + } catch (PDOException $e) { |
|
| 1355 | 1355 | return "error : ".$e->getMessage(); |
| 1356 | 1356 | } |
| 1357 | 1357 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1358 | 1358 | if ($globalDebug) echo '(Add to Spotter archive : '; |
| 1359 | 1359 | $SpotterArchive = new SpotterArchive($this->db); |
| 1360 | - $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); |
|
| 1360 | + $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); |
|
| 1361 | 1361 | if ($globalDebug) echo $result.')'; |
| 1362 | 1362 | } elseif ($globalDebug && $putinarchive !== true) { |
| 1363 | 1363 | echo '(Not adding to archive)'; |
@@ -1370,7 +1370,7 @@ discard block |
||
| 1370 | 1370 | |
| 1371 | 1371 | public function getOrderBy() |
| 1372 | 1372 | { |
| 1373 | - $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")); |
|
| 1373 | + $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")); |
|
| 1374 | 1374 | return $orderby; |
| 1375 | 1375 | } |
| 1376 | 1376 | |
@@ -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 | } |
@@ -173,9 +180,13 @@ discard block |
||
| 173 | 180 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
| 174 | 181 | } |
| 175 | 182 | } |
| 176 | - if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC'; |
|
| 183 | + if ($orderby_query == '') { |
|
| 184 | + $orderby_query = ' ORDER BY date DESC'; |
|
| 185 | + } |
|
| 177 | 186 | |
| 178 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 187 | + if (!isset($globalLiveInterval)) { |
|
| 188 | + $globalLiveInterval = '200'; |
|
| 189 | + } |
|
| 179 | 190 | if ($globalDBdriver == 'mysql') { |
| 180 | 191 | //$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"; |
| 181 | 192 | $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; |
@@ -199,7 +210,9 @@ discard block |
||
| 199 | 210 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap2DAircraftsLimit; |
| 200 | 211 | date_default_timezone_set('UTC'); |
| 201 | 212 | $filter_query = $this->getFilter($filter,true,true); |
| 202 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 213 | + if (!isset($globalLiveInterval)) { |
|
| 214 | + $globalLiveInterval = '200'; |
|
| 215 | + } |
|
| 203 | 216 | if ($globalDBdriver == 'mysql') { |
| 204 | 217 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 205 | 218 | // $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 |
@@ -263,14 +276,22 @@ discard block |
||
| 263 | 276 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 264 | 277 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 265 | 278 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 266 | - if ($minlong != '' && $minlat != '' && $maxlong != '' && $maxlat != '') $usecoord = true; |
|
| 279 | + if ($minlong != '' && $minlat != '' && $maxlong != '' && $maxlat != '') { |
|
| 280 | + $usecoord = true; |
|
| 281 | + } |
|
| 267 | 282 | } |
| 268 | 283 | $id = filter_var($id,FILTER_SANITIZE_STRING); |
| 269 | 284 | $filter_query = $this->getFilter($filter,true,true); |
| 270 | 285 | |
| 271 | - if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200'; |
|
| 272 | - if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300'; |
|
| 273 | - if ($limit == 0 || $limit == '') $limit = $globalMap3DAircraftsLimit; |
|
| 286 | + if (!isset($globalLiveInterval) || $globalLiveInterval == '') { |
|
| 287 | + $globalLiveInterval = '200'; |
|
| 288 | + } |
|
| 289 | + if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') { |
|
| 290 | + $globalMap3DAircraftsLimit = '300'; |
|
| 291 | + } |
|
| 292 | + if ($limit == 0 || $limit == '') { |
|
| 293 | + $limit = $globalMap3DAircraftsLimit; |
|
| 294 | + } |
|
| 274 | 295 | if ($globalDBdriver == 'mysql') { |
| 275 | 296 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 276 | 297 | /* |
@@ -283,26 +304,42 @@ discard block |
||
| 283 | 304 | FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date"; |
| 284 | 305 | //if ($limit > 0) $query .= " LIMIT ".$limit; |
| 285 | 306 | $query .= ") l ON l.flightaware_id = spotter_archive.flightaware_id "; |
| 286 | - if ($usecoord) $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 287 | - if ($id != '') $query .= "OR spotter_archive.flightaware_id = :id "; |
|
| 307 | + if ($usecoord) { |
|
| 308 | + $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 309 | + } |
|
| 310 | + if ($id != '') { |
|
| 311 | + $query .= "OR spotter_archive.flightaware_id = :id "; |
|
| 312 | + } |
|
| 288 | 313 | $query .= "UNION |
| 289 | 314 | 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 |
| 290 | 315 | FROM spotter_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date"; |
| 291 | - if ($usecoord) $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
| 292 | - if ($id != '') $query .= " OR spotter_live.flightaware_id = :id"; |
|
| 316 | + if ($usecoord) { |
|
| 317 | + $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
| 318 | + } |
|
| 319 | + if ($id != '') { |
|
| 320 | + $query .= " OR spotter_live.flightaware_id = :id"; |
|
| 321 | + } |
|
| 293 | 322 | //if ($limit > 0) $query .= " LIMIT ".$limit; |
| 294 | 323 | $query .= ") AS spotter |
| 295 | 324 | WHERE latitude <> '0' AND longitude <> '0' |
| 296 | 325 | ORDER BY flightaware_id, date"; |
| 297 | - if ($limit > 0) $query .= " LIMIT ".$limit; |
|
| 326 | + if ($limit > 0) { |
|
| 327 | + $query .= " LIMIT ".$limit; |
|
| 328 | + } |
|
| 298 | 329 | } else { |
| 299 | 330 | $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 |
| 300 | 331 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date "; |
| 301 | - if ($usecoord) $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 302 | - if ($id != '') $query .= "OR spotter_live.flightaware_id = :id "; |
|
| 332 | + if ($usecoord) { |
|
| 333 | + $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 334 | + } |
|
| 335 | + if ($id != '') { |
|
| 336 | + $query .= "OR spotter_live.flightaware_id = :id "; |
|
| 337 | + } |
|
| 303 | 338 | $query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 304 | 339 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 305 | - if ($limit > 0) $query .= " LIMIT ".$limit; |
|
| 340 | + if ($limit > 0) { |
|
| 341 | + $query .= " LIMIT ".$limit; |
|
| 342 | + } |
|
| 306 | 343 | } |
| 307 | 344 | } else { |
| 308 | 345 | if (isset($globalArchive) && $globalArchive === TRUE) { |
@@ -320,29 +357,47 @@ discard block |
||
| 320 | 357 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date"; |
| 321 | 358 | //if ($limit > 0) $query .= " ORDER BY spotter_live.date ASC LIMIT ".$limit; |
| 322 | 359 | $query .= ") l ON l.flightaware_id = spotter_archive.flightaware_id "; |
| 323 | - if ($usecoord) $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 324 | - if ($id != '') $query .= "OR spotter_archive.flightaware_id = :id "; |
|
| 360 | + if ($usecoord) { |
|
| 361 | + $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 362 | + } |
|
| 363 | + if ($id != '') { |
|
| 364 | + $query .= "OR spotter_archive.flightaware_id = :id "; |
|
| 365 | + } |
|
| 325 | 366 | $query .= "UNION |
| 326 | 367 | 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 |
| 327 | 368 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date"; |
| 328 | - if ($usecoord) $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
| 329 | - if ($id != '') $query .= " OR spotter_live.flightaware_id = :id"; |
|
| 369 | + if ($usecoord) { |
|
| 370 | + $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
| 371 | + } |
|
| 372 | + if ($id != '') { |
|
| 373 | + $query .= " OR spotter_live.flightaware_id = :id"; |
|
| 374 | + } |
|
| 330 | 375 | //if ($limit > 0) $query .= " ORDER BY date ASC LIMIT ".$limit; |
| 331 | 376 | $query .= ") AS spotter WHERE latitude <> '0' AND longitude <> '0' "; |
| 332 | 377 | $query .= "ORDER BY flightaware_id, date"; |
| 333 | - if ($limit > 0) $query .= " LIMIT ".$limit; |
|
| 378 | + if ($limit > 0) { |
|
| 379 | + $query .= " LIMIT ".$limit; |
|
| 380 | + } |
|
| 334 | 381 | } else { |
| 335 | 382 | $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 |
| 336 | 383 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date "; |
| 337 | - if ($usecoord) $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 338 | - if ($id != '') $query .= "OR spotter_live.flightaware_id = :id "; |
|
| 384 | + if ($usecoord) { |
|
| 385 | + $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 386 | + } |
|
| 387 | + if ($id != '') { |
|
| 388 | + $query .= "OR spotter_live.flightaware_id = :id "; |
|
| 389 | + } |
|
| 339 | 390 | $query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 340 | 391 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 341 | - if ($limit > 0) $query .= " LIMIT ".$limit; |
|
| 392 | + if ($limit > 0) { |
|
| 393 | + $query .= " LIMIT ".$limit; |
|
| 394 | + } |
|
| 342 | 395 | } |
| 343 | 396 | } |
| 344 | 397 | $query_values = array(); |
| 345 | - if ($id != '') $query_values = array(':id' => $id); |
|
| 398 | + if ($id != '') { |
|
| 399 | + $query_values = array(':id' => $id); |
|
| 400 | + } |
|
| 346 | 401 | try { |
| 347 | 402 | $sth = $this->db->prepare($query); |
| 348 | 403 | $sth->execute($query_values); |
@@ -369,9 +424,15 @@ discard block |
||
| 369 | 424 | $id = filter_var($id,FILTER_SANITIZE_STRING); |
| 370 | 425 | $filter_query = $this->getFilter($filter,true,true); |
| 371 | 426 | |
| 372 | - if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200'; |
|
| 373 | - if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300'; |
|
| 374 | - if ($limit == 0 || $limit == '') $limit = $globalMap3DAircraftsLimit; |
|
| 427 | + if (!isset($globalLiveInterval) || $globalLiveInterval == '') { |
|
| 428 | + $globalLiveInterval = '200'; |
|
| 429 | + } |
|
| 430 | + if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') { |
|
| 431 | + $globalMap3DAircraftsLimit = '300'; |
|
| 432 | + } |
|
| 433 | + if ($limit == 0 || $limit == '') { |
|
| 434 | + $limit = $globalMap3DAircraftsLimit; |
|
| 435 | + } |
|
| 375 | 436 | if ($globalDBdriver == 'mysql') { |
| 376 | 437 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 377 | 438 | $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 |
@@ -382,13 +443,17 @@ discard block |
||
| 382 | 443 | $query .= ") AS spotter |
| 383 | 444 | WHERE latitude <> '0' AND longitude <> '0' |
| 384 | 445 | ORDER BY flightaware_id, date"; |
| 385 | - if ($limit > 0) $query .= " LIMIT ".$limit; |
|
| 446 | + if ($limit > 0) { |
|
| 447 | + $query .= " LIMIT ".$limit; |
|
| 448 | + } |
|
| 386 | 449 | } else { |
| 387 | 450 | $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 |
| 388 | 451 | FROM spotter_live'.$filter_query.' spotter_live.flightaware_id = :id '; |
| 389 | 452 | $query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 390 | 453 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 391 | - if ($limit > 0) $query .= " LIMIT ".$limit; |
|
| 454 | + if ($limit > 0) { |
|
| 455 | + $query .= " LIMIT ".$limit; |
|
| 456 | + } |
|
| 392 | 457 | } |
| 393 | 458 | } else { |
| 394 | 459 | if (isset($globalArchive) && $globalArchive === TRUE) { |
@@ -404,13 +469,17 @@ discard block |
||
| 404 | 469 | FROM spotter_live".$filter_query." spotter_live.flightaware_id = :id"; |
| 405 | 470 | $query .= ") AS spotter WHERE latitude <> '0' AND longitude <> '0' "; |
| 406 | 471 | $query .= "ORDER BY flightaware_id, date"; |
| 407 | - if ($limit > 0) $query .= " LIMIT ".$limit; |
|
| 472 | + if ($limit > 0) { |
|
| 473 | + $query .= " LIMIT ".$limit; |
|
| 474 | + } |
|
| 408 | 475 | } else { |
| 409 | 476 | $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 |
| 410 | 477 | FROM spotter_live".$filter_query." spotter_live.flightaware_id = :id "; |
| 411 | 478 | $query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 412 | 479 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 413 | - if ($limit > 0) $query .= " LIMIT ".$limit; |
|
| 480 | + if ($limit > 0) { |
|
| 481 | + $query .= " LIMIT ".$limit; |
|
| 482 | + } |
|
| 414 | 483 | } |
| 415 | 484 | } |
| 416 | 485 | $query_values = array(':id' => $id); |
@@ -436,7 +505,9 @@ discard block |
||
| 436 | 505 | global $globalDBdriver, $globalLiveInterval; |
| 437 | 506 | $filter_query = $this->getFilter($filter,true,true); |
| 438 | 507 | |
| 439 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 508 | + if (!isset($globalLiveInterval)) { |
|
| 509 | + $globalLiveInterval = '200'; |
|
| 510 | + } |
|
| 440 | 511 | if ($globalDBdriver == 'mysql') { |
| 441 | 512 | //$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; |
| 442 | 513 | $query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
@@ -467,7 +538,9 @@ discard block |
||
| 467 | 538 | { |
| 468 | 539 | global $globalDBdriver, $globalLiveInterval,$globalMap2DAircraftsLimit; |
| 469 | 540 | $Spotter = new Spotter($this->db); |
| 470 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 541 | + if (!isset($globalLiveInterval)) { |
|
| 542 | + $globalLiveInterval = '200'; |
|
| 543 | + } |
|
| 471 | 544 | $filter_query = $this->getFilter($filter); |
| 472 | 545 | |
| 473 | 546 | if (is_array($coord)) { |
@@ -475,7 +548,9 @@ discard block |
||
| 475 | 548 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 476 | 549 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 477 | 550 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 478 | - } else return array(); |
|
| 551 | + } else { |
|
| 552 | + return array(); |
|
| 553 | + } |
|
| 479 | 554 | if ($globalDBdriver == 'mysql') { |
| 480 | 555 | $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; |
| 481 | 556 | } else { |
@@ -500,7 +575,9 @@ discard block |
||
| 500 | 575 | public function getMinLiveSpotterDatabyCoord($coord,$limit = 0, $filter = array()) |
| 501 | 576 | { |
| 502 | 577 | global $globalDBdriver, $globalLiveInterval, $globalArchive,$globalMap2DAircraftsLimit; |
| 503 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 578 | + if (!isset($globalLiveInterval)) { |
|
| 579 | + $globalLiveInterval = '200'; |
|
| 580 | + } |
|
| 504 | 581 | $filter_query = $this->getFilter($filter,true,true); |
| 505 | 582 | |
| 506 | 583 | if (is_array($coord)) { |
@@ -508,7 +585,9 @@ discard block |
||
| 508 | 585 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 509 | 586 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 510 | 587 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 511 | - } else return array(); |
|
| 588 | + } else { |
|
| 589 | + return array(); |
|
| 590 | + } |
|
| 512 | 591 | if ($globalDBdriver == 'mysql') { |
| 513 | 592 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 514 | 593 | $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 |
@@ -763,11 +842,15 @@ discard block |
||
| 763 | 842 | //$query = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date'; |
| 764 | 843 | if ($globalDBdriver == 'mysql') { |
| 765 | 844 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
| 766 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 845 | + if ($liveinterval) { |
|
| 846 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 847 | + } |
|
| 767 | 848 | $query .= ' ORDER BY date'; |
| 768 | 849 | } else { |
| 769 | 850 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
| 770 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 851 | + if ($liveinterval) { |
|
| 852 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 853 | + } |
|
| 771 | 854 | $query .= ' ORDER BY date'; |
| 772 | 855 | } |
| 773 | 856 | |
@@ -862,7 +945,9 @@ discard block |
||
| 862 | 945 | $i++; |
| 863 | 946 | $j++; |
| 864 | 947 | if ($j == 30) { |
| 865 | - if ($globalDebug) echo "."; |
|
| 948 | + if ($globalDebug) { |
|
| 949 | + echo "."; |
|
| 950 | + } |
|
| 866 | 951 | try { |
| 867 | 952 | |
| 868 | 953 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -1237,7 +1322,9 @@ discard block |
||
| 1237 | 1322 | { |
| 1238 | 1323 | return false; |
| 1239 | 1324 | } |
| 1240 | - } else return ''; |
|
| 1325 | + } else { |
|
| 1326 | + return ''; |
|
| 1327 | + } |
|
| 1241 | 1328 | |
| 1242 | 1329 | if ($longitude != '') |
| 1243 | 1330 | { |
@@ -1245,7 +1332,9 @@ discard block |
||
| 1245 | 1332 | { |
| 1246 | 1333 | return false; |
| 1247 | 1334 | } |
| 1248 | - } else return ''; |
|
| 1335 | + } else { |
|
| 1336 | + return ''; |
|
| 1337 | + } |
|
| 1249 | 1338 | |
| 1250 | 1339 | if ($waypoints != '') |
| 1251 | 1340 | { |
@@ -1261,14 +1350,18 @@ discard block |
||
| 1261 | 1350 | { |
| 1262 | 1351 | return false; |
| 1263 | 1352 | } |
| 1264 | - } else $altitude = 0; |
|
| 1353 | + } else { |
|
| 1354 | + $altitude = 0; |
|
| 1355 | + } |
|
| 1265 | 1356 | if ($altitude_real != '') |
| 1266 | 1357 | { |
| 1267 | 1358 | if (!is_numeric($altitude_real)) |
| 1268 | 1359 | { |
| 1269 | 1360 | return false; |
| 1270 | 1361 | } |
| 1271 | - } else $altitude_real = 0; |
|
| 1362 | + } else { |
|
| 1363 | + $altitude_real = 0; |
|
| 1364 | + } |
|
| 1272 | 1365 | |
| 1273 | 1366 | if ($heading != '') |
| 1274 | 1367 | { |
@@ -1276,7 +1369,9 @@ discard block |
||
| 1276 | 1369 | { |
| 1277 | 1370 | return false; |
| 1278 | 1371 | } |
| 1279 | - } else $heading = 0; |
|
| 1372 | + } else { |
|
| 1373 | + $heading = 0; |
|
| 1374 | + } |
|
| 1280 | 1375 | |
| 1281 | 1376 | if ($groundspeed != '') |
| 1282 | 1377 | { |
@@ -1284,9 +1379,13 @@ discard block |
||
| 1284 | 1379 | { |
| 1285 | 1380 | return false; |
| 1286 | 1381 | } |
| 1287 | - } else $groundspeed = 0; |
|
| 1382 | + } else { |
|
| 1383 | + $groundspeed = 0; |
|
| 1384 | + } |
|
| 1288 | 1385 | date_default_timezone_set('UTC'); |
| 1289 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
| 1386 | + if ($date == '') { |
|
| 1387 | + $date = date("Y-m-d H:i:s", time()); |
|
| 1388 | + } |
|
| 1290 | 1389 | |
| 1291 | 1390 | |
| 1292 | 1391 | $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
@@ -1331,14 +1430,24 @@ discard block |
||
| 1331 | 1430 | $arrival_airport_country = ''; |
| 1332 | 1431 | |
| 1333 | 1432 | |
| 1334 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1335 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1336 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1337 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1433 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) { |
|
| 1434 | + $squawk = NULL; |
|
| 1435 | + } |
|
| 1436 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) { |
|
| 1437 | + $verticalrate = NULL; |
|
| 1438 | + } |
|
| 1439 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
| 1440 | + $groundspeed = 0; |
|
| 1441 | + } |
|
| 1442 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
| 1443 | + $heading = 0; |
|
| 1444 | + } |
|
| 1338 | 1445 | |
| 1339 | 1446 | $query = ''; |
| 1340 | 1447 | if ($globalArchive) { |
| 1341 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
| 1448 | + if ($globalDebug) { |
|
| 1449 | + echo '-- Delete previous data -- '; |
|
| 1450 | + } |
|
| 1342 | 1451 | $query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;'; |
| 1343 | 1452 | } |
| 1344 | 1453 | |
@@ -1355,10 +1464,14 @@ discard block |
||
| 1355 | 1464 | return "error : ".$e->getMessage(); |
| 1356 | 1465 | } |
| 1357 | 1466 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1358 | - if ($globalDebug) echo '(Add to Spotter archive : '; |
|
| 1467 | + if ($globalDebug) { |
|
| 1468 | + echo '(Add to Spotter archive : '; |
|
| 1469 | + } |
|
| 1359 | 1470 | $SpotterArchive = new SpotterArchive($this->db); |
| 1360 | 1471 | $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); |
| 1361 | - if ($globalDebug) echo $result.')'; |
|
| 1472 | + if ($globalDebug) { |
|
| 1473 | + echo $result.')'; |
|
| 1474 | + } |
|
| 1362 | 1475 | } elseif ($globalDebug && $putinarchive !== true) { |
| 1363 | 1476 | echo '(Not adding to archive)'; |
| 1364 | 1477 | } elseif ($globalDebug && $noarchive === true) { |
@@ -9,13 +9,13 @@ discard block |
||
| 9 | 9 | if ($this->db === null) die('Error: No DB connection. (SpotterArchive)'); |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | - /** |
|
| 13 | - * Get SQL query part for filter used |
|
| 14 | - * @param array $filter the filter |
|
| 15 | - * @param bool $where |
|
| 16 | - * @param bool $and |
|
| 17 | - * @return string the SQL part |
|
| 18 | - */ |
|
| 12 | + /** |
|
| 13 | + * Get SQL query part for filter used |
|
| 14 | + * @param array $filter the filter |
|
| 15 | + * @param bool $where |
|
| 16 | + * @param bool $and |
|
| 17 | + * @return string the SQL part |
|
| 18 | + */ |
|
| 19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 21 | 21 | $filters = array(); |
@@ -160,12 +160,12 @@ discard block |
||
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | |
| 163 | - /** |
|
| 164 | - * Gets all the spotter information based on a particular callsign |
|
| 165 | - * |
|
| 166 | - * @param $ident |
|
| 167 | - * @return array the spotter information |
|
| 168 | - */ |
|
| 163 | + /** |
|
| 164 | + * Gets all the spotter information based on a particular callsign |
|
| 165 | + * |
|
| 166 | + * @param $ident |
|
| 167 | + * @return array the spotter information |
|
| 168 | + */ |
|
| 169 | 169 | public function getLastArchiveSpotterDataByIdent($ident) { |
| 170 | 170 | $Spotter = new Spotter($this->db); |
| 171 | 171 | date_default_timezone_set('UTC'); |
@@ -180,12 +180,12 @@ discard block |
||
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | |
| 183 | - /** |
|
| 184 | - * Gets last the spotter information based on a particular id |
|
| 185 | - * |
|
| 186 | - * @param $id |
|
| 187 | - * @return array the spotter information |
|
| 188 | - */ |
|
| 183 | + /** |
|
| 184 | + * Gets last the spotter information based on a particular id |
|
| 185 | + * |
|
| 186 | + * @param $id |
|
| 187 | + * @return array the spotter information |
|
| 188 | + */ |
|
| 189 | 189 | public function getLastArchiveSpotterDataById($id) { |
| 190 | 190 | $Spotter = new Spotter($this->db); |
| 191 | 191 | date_default_timezone_set('UTC'); |
@@ -210,12 +210,12 @@ discard block |
||
| 210 | 210 | return $spotter_array; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - /** |
|
| 214 | - * Gets all the spotter information based on a particular id |
|
| 215 | - * |
|
| 216 | - * @param $id |
|
| 217 | - * @return array the spotter information |
|
| 218 | - */ |
|
| 213 | + /** |
|
| 214 | + * Gets all the spotter information based on a particular id |
|
| 215 | + * |
|
| 216 | + * @param $id |
|
| 217 | + * @return array the spotter information |
|
| 218 | + */ |
|
| 219 | 219 | public function getAllArchiveSpotterDataById($id) { |
| 220 | 220 | date_default_timezone_set('UTC'); |
| 221 | 221 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -235,12 +235,12 @@ discard block |
||
| 235 | 235 | return $spotter_array; |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - /** |
|
| 239 | - * Gets coordinate & time spotter information based on a particular id |
|
| 240 | - * |
|
| 241 | - * @param $id |
|
| 242 | - * @return array the spotter information |
|
| 243 | - */ |
|
| 238 | + /** |
|
| 239 | + * Gets coordinate & time spotter information based on a particular id |
|
| 240 | + * |
|
| 241 | + * @param $id |
|
| 242 | + * @return array the spotter information |
|
| 243 | + */ |
|
| 244 | 244 | public function getCoordArchiveSpotterDataById($id) { |
| 245 | 245 | date_default_timezone_set('UTC'); |
| 246 | 246 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -256,14 +256,14 @@ discard block |
||
| 256 | 256 | return $spotter_array; |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - /** |
|
| 260 | - * Gets coordinate & time spotter information based on a particular id |
|
| 261 | - * |
|
| 262 | - * @param $id |
|
| 263 | - * @param $begindate |
|
| 264 | - * @param $enddate |
|
| 265 | - * @return array the spotter information |
|
| 266 | - */ |
|
| 259 | + /** |
|
| 260 | + * Gets coordinate & time spotter information based on a particular id |
|
| 261 | + * |
|
| 262 | + * @param $id |
|
| 263 | + * @param $begindate |
|
| 264 | + * @param $enddate |
|
| 265 | + * @return array the spotter information |
|
| 266 | + */ |
|
| 267 | 267 | public function getCoordArchiveSpotterDataByIdDate($id,$begindate,$enddate) { |
| 268 | 268 | date_default_timezone_set('UTC'); |
| 269 | 269 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -280,12 +280,12 @@ discard block |
||
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | |
| 283 | - /** |
|
| 284 | - * Gets altitude information based on a particular callsign |
|
| 285 | - * |
|
| 286 | - * @param $ident |
|
| 287 | - * @return array the spotter information |
|
| 288 | - */ |
|
| 283 | + /** |
|
| 284 | + * Gets altitude information based on a particular callsign |
|
| 285 | + * |
|
| 286 | + * @param $ident |
|
| 287 | + * @return array the spotter information |
|
| 288 | + */ |
|
| 289 | 289 | public function getAltitudeArchiveSpotterDataByIdent($ident) { |
| 290 | 290 | |
| 291 | 291 | date_default_timezone_set('UTC'); |
@@ -305,12 +305,12 @@ discard block |
||
| 305 | 305 | return $spotter_array; |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | - /** |
|
| 309 | - * Gets altitude information based on a particular id |
|
| 310 | - * |
|
| 311 | - * @param $id |
|
| 312 | - * @return array the spotter information |
|
| 313 | - */ |
|
| 308 | + /** |
|
| 309 | + * Gets altitude information based on a particular id |
|
| 310 | + * |
|
| 311 | + * @param $id |
|
| 312 | + * @return array the spotter information |
|
| 313 | + */ |
|
| 314 | 314 | public function getAltitudeArchiveSpotterDataById($id) { |
| 315 | 315 | |
| 316 | 316 | date_default_timezone_set('UTC'); |
@@ -330,12 +330,12 @@ discard block |
||
| 330 | 330 | return $spotter_array; |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | - /** |
|
| 334 | - * Gets altitude & speed information based on a particular id |
|
| 335 | - * |
|
| 336 | - * @param $id |
|
| 337 | - * @return array the spotter information |
|
| 338 | - */ |
|
| 333 | + /** |
|
| 334 | + * Gets altitude & speed information based on a particular id |
|
| 335 | + * |
|
| 336 | + * @param $id |
|
| 337 | + * @return array the spotter information |
|
| 338 | + */ |
|
| 339 | 339 | public function getAltitudeSpeedArchiveSpotterDataById($id) { |
| 340 | 340 | date_default_timezone_set('UTC'); |
| 341 | 341 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -351,12 +351,12 @@ discard block |
||
| 351 | 351 | return $spotter_array; |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | - /** |
|
| 355 | - * Gets altitude information based on a particular callsign |
|
| 356 | - * |
|
| 357 | - * @param $ident |
|
| 358 | - * @return array the spotter information |
|
| 359 | - */ |
|
| 354 | + /** |
|
| 355 | + * Gets altitude information based on a particular callsign |
|
| 356 | + * |
|
| 357 | + * @param $ident |
|
| 358 | + * @return array the spotter information |
|
| 359 | + */ |
|
| 360 | 360 | public function getLastAltitudeArchiveSpotterDataByIdent($ident) { |
| 361 | 361 | date_default_timezone_set('UTC'); |
| 362 | 362 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -374,14 +374,14 @@ discard block |
||
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | |
| 377 | - /** |
|
| 378 | - * Gets all the archive spotter information |
|
| 379 | - * |
|
| 380 | - * @param $ident |
|
| 381 | - * @param $flightaware_id |
|
| 382 | - * @param $date |
|
| 383 | - * @return array the spotter information |
|
| 384 | - */ |
|
| 377 | + /** |
|
| 378 | + * Gets all the archive spotter information |
|
| 379 | + * |
|
| 380 | + * @param $ident |
|
| 381 | + * @param $flightaware_id |
|
| 382 | + * @param $date |
|
| 383 | + * @return array the spotter information |
|
| 384 | + */ |
|
| 385 | 385 | public function getSpotterArchiveData($ident,$flightaware_id,$date) { |
| 386 | 386 | $Spotter = new Spotter($this->db); |
| 387 | 387 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -406,11 +406,11 @@ discard block |
||
| 406 | 406 | } |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | - /** |
|
| 410 | - * Delete row in spotter_archive table based on flightaware_id |
|
| 411 | - * @param $id flightaware_id |
|
| 412 | - */ |
|
| 413 | - public function deleteSpotterArchiveTrackDataByID($id) { |
|
| 409 | + /** |
|
| 410 | + * Delete row in spotter_archive table based on flightaware_id |
|
| 411 | + * @param $id flightaware_id |
|
| 412 | + */ |
|
| 413 | + public function deleteSpotterArchiveTrackDataByID($id) { |
|
| 414 | 414 | global $globalArchiveKeepTrackMonths, $globalDBdriver; |
| 415 | 415 | $query = 'DELETE FROM spotter_archive WHERE spotter_archive.flightaware_id = :id'; |
| 416 | 416 | try { |
@@ -422,15 +422,15 @@ discard block |
||
| 422 | 422 | } |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | - /** |
|
| 426 | - * Gets Minimal Live Spotter data |
|
| 427 | - * |
|
| 428 | - * @param $begindate |
|
| 429 | - * @param $enddate |
|
| 430 | - * @param array $filter |
|
| 431 | - * @param int $part |
|
| 432 | - * @return array the spotter information |
|
| 433 | - */ |
|
| 425 | + /** |
|
| 426 | + * Gets Minimal Live Spotter data |
|
| 427 | + * |
|
| 428 | + * @param $begindate |
|
| 429 | + * @param $enddate |
|
| 430 | + * @param array $filter |
|
| 431 | + * @param int $part |
|
| 432 | + * @return array the spotter information |
|
| 433 | + */ |
|
| 434 | 434 | public function getMinLiveSpotterData($begindate,$enddate,$filter = array(),$part = 0) { |
| 435 | 435 | global $globalDBdriver; |
| 436 | 436 | date_default_timezone_set('UTC'); |
@@ -481,14 +481,14 @@ discard block |
||
| 481 | 481 | return $spotter_array; |
| 482 | 482 | } |
| 483 | 483 | |
| 484 | - /** |
|
| 485 | - * Gets Minimal Live Spotter data |
|
| 486 | - * |
|
| 487 | - * @param $begindate |
|
| 488 | - * @param $enddate |
|
| 489 | - * @param array $filter |
|
| 490 | - * @return array the spotter information |
|
| 491 | - */ |
|
| 484 | + /** |
|
| 485 | + * Gets Minimal Live Spotter data |
|
| 486 | + * |
|
| 487 | + * @param $begindate |
|
| 488 | + * @param $enddate |
|
| 489 | + * @param array $filter |
|
| 490 | + * @return array the spotter information |
|
| 491 | + */ |
|
| 492 | 492 | public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) { |
| 493 | 493 | global $globalDBdriver; |
| 494 | 494 | date_default_timezone_set('UTC'); |
@@ -554,14 +554,14 @@ discard block |
||
| 554 | 554 | return $spotter_array; |
| 555 | 555 | } |
| 556 | 556 | |
| 557 | - /** |
|
| 558 | - * Gets count Live Spotter data |
|
| 559 | - * |
|
| 560 | - * @param $begindate |
|
| 561 | - * @param $enddate |
|
| 562 | - * @param array $filter |
|
| 563 | - * @return array the spotter information |
|
| 564 | - */ |
|
| 557 | + /** |
|
| 558 | + * Gets count Live Spotter data |
|
| 559 | + * |
|
| 560 | + * @param $begindate |
|
| 561 | + * @param $enddate |
|
| 562 | + * @param array $filter |
|
| 563 | + * @return array the spotter information |
|
| 564 | + */ |
|
| 565 | 565 | public function getLiveSpotterCount($begindate,$enddate,$filter = array()) { |
| 566 | 566 | global $globalDBdriver, $globalLiveInterval; |
| 567 | 567 | date_default_timezone_set('UTC'); |
@@ -606,36 +606,36 @@ discard block |
||
| 606 | 606 | |
| 607 | 607 | // Spotter_Archive_output |
| 608 | 608 | |
| 609 | - /** |
|
| 610 | - * Gets all the spotter information |
|
| 611 | - * |
|
| 612 | - * @param string $q |
|
| 613 | - * @param string $registration |
|
| 614 | - * @param string $aircraft_icao |
|
| 615 | - * @param string $aircraft_manufacturer |
|
| 616 | - * @param string $highlights |
|
| 617 | - * @param string $airline_icao |
|
| 618 | - * @param string $airline_country |
|
| 619 | - * @param string $airline_type |
|
| 620 | - * @param string $airport |
|
| 621 | - * @param string $airport_country |
|
| 622 | - * @param string $callsign |
|
| 623 | - * @param string $departure_airport_route |
|
| 624 | - * @param string $arrival_airport_route |
|
| 625 | - * @param string $owner |
|
| 626 | - * @param string $pilot_id |
|
| 627 | - * @param string $pilot_name |
|
| 628 | - * @param string $altitude |
|
| 629 | - * @param string $date_posted |
|
| 630 | - * @param string $limit |
|
| 631 | - * @param string $sort |
|
| 632 | - * @param string $includegeodata |
|
| 633 | - * @param string $origLat |
|
| 634 | - * @param string $origLon |
|
| 635 | - * @param string $dist |
|
| 636 | - * @param array $filters |
|
| 637 | - * @return array the spotter information |
|
| 638 | - */ |
|
| 609 | + /** |
|
| 610 | + * Gets all the spotter information |
|
| 611 | + * |
|
| 612 | + * @param string $q |
|
| 613 | + * @param string $registration |
|
| 614 | + * @param string $aircraft_icao |
|
| 615 | + * @param string $aircraft_manufacturer |
|
| 616 | + * @param string $highlights |
|
| 617 | + * @param string $airline_icao |
|
| 618 | + * @param string $airline_country |
|
| 619 | + * @param string $airline_type |
|
| 620 | + * @param string $airport |
|
| 621 | + * @param string $airport_country |
|
| 622 | + * @param string $callsign |
|
| 623 | + * @param string $departure_airport_route |
|
| 624 | + * @param string $arrival_airport_route |
|
| 625 | + * @param string $owner |
|
| 626 | + * @param string $pilot_id |
|
| 627 | + * @param string $pilot_name |
|
| 628 | + * @param string $altitude |
|
| 629 | + * @param string $date_posted |
|
| 630 | + * @param string $limit |
|
| 631 | + * @param string $sort |
|
| 632 | + * @param string $includegeodata |
|
| 633 | + * @param string $origLat |
|
| 634 | + * @param string $origLon |
|
| 635 | + * @param string $dist |
|
| 636 | + * @param array $filters |
|
| 637 | + * @return array the spotter information |
|
| 638 | + */ |
|
| 639 | 639 | public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) { |
| 640 | 640 | global $globalTimezone, $globalDBdriver; |
| 641 | 641 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -927,14 +927,14 @@ discard block |
||
| 927 | 927 | } |
| 928 | 928 | } |
| 929 | 929 | |
| 930 | - /** |
|
| 931 | - * Gets all the spotter information based on the callsign |
|
| 932 | - * |
|
| 933 | - * @param string $ident |
|
| 934 | - * @param string $limit |
|
| 935 | - * @param string $sort |
|
| 936 | - * @return array the spotter information |
|
| 937 | - */ |
|
| 930 | + /** |
|
| 931 | + * Gets all the spotter information based on the callsign |
|
| 932 | + * |
|
| 933 | + * @param string $ident |
|
| 934 | + * @param string $limit |
|
| 935 | + * @param string $sort |
|
| 936 | + * @return array the spotter information |
|
| 937 | + */ |
|
| 938 | 938 | public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') { |
| 939 | 939 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
| 940 | 940 | |
@@ -981,15 +981,15 @@ discard block |
||
| 981 | 981 | } |
| 982 | 982 | |
| 983 | 983 | |
| 984 | - /** |
|
| 985 | - * Gets all the spotter information based on the owner |
|
| 986 | - * |
|
| 987 | - * @param string $owner |
|
| 988 | - * @param string $limit |
|
| 989 | - * @param string $sort |
|
| 990 | - * @param array $filter |
|
| 991 | - * @return array the spotter information |
|
| 992 | - */ |
|
| 984 | + /** |
|
| 985 | + * Gets all the spotter information based on the owner |
|
| 986 | + * |
|
| 987 | + * @param string $owner |
|
| 988 | + * @param string $limit |
|
| 989 | + * @param string $sort |
|
| 990 | + * @param array $filter |
|
| 991 | + * @return array the spotter information |
|
| 992 | + */ |
|
| 993 | 993 | public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) { |
| 994 | 994 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
| 995 | 995 | |
@@ -1036,15 +1036,15 @@ discard block |
||
| 1036 | 1036 | return $spotter_array; |
| 1037 | 1037 | } |
| 1038 | 1038 | |
| 1039 | - /** |
|
| 1040 | - * Gets all the spotter information based on the pilot |
|
| 1041 | - * |
|
| 1042 | - * @param string $pilot |
|
| 1043 | - * @param string $limit |
|
| 1044 | - * @param string $sort |
|
| 1045 | - * @param array $filter |
|
| 1046 | - * @return array the spotter information |
|
| 1047 | - */ |
|
| 1039 | + /** |
|
| 1040 | + * Gets all the spotter information based on the pilot |
|
| 1041 | + * |
|
| 1042 | + * @param string $pilot |
|
| 1043 | + * @param string $limit |
|
| 1044 | + * @param string $sort |
|
| 1045 | + * @param array $filter |
|
| 1046 | + * @return array the spotter information |
|
| 1047 | + */ |
|
| 1048 | 1048 | public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) { |
| 1049 | 1049 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
| 1050 | 1050 | |
@@ -1087,14 +1087,14 @@ discard block |
||
| 1087 | 1087 | return $spotter_array; |
| 1088 | 1088 | } |
| 1089 | 1089 | |
| 1090 | - /** |
|
| 1091 | - * Gets all number of flight over countries |
|
| 1092 | - * |
|
| 1093 | - * @param bool $limit |
|
| 1094 | - * @param int $olderthanmonths |
|
| 1095 | - * @param string $sincedate |
|
| 1096 | - * @return array the airline country list |
|
| 1097 | - */ |
|
| 1090 | + /** |
|
| 1091 | + * Gets all number of flight over countries |
|
| 1092 | + * |
|
| 1093 | + * @param bool $limit |
|
| 1094 | + * @param int $olderthanmonths |
|
| 1095 | + * @param string $sincedate |
|
| 1096 | + * @return array the airline country list |
|
| 1097 | + */ |
|
| 1098 | 1098 | public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') { |
| 1099 | 1099 | global $globalDBdriver; |
| 1100 | 1100 | /* |
@@ -1133,14 +1133,14 @@ discard block |
||
| 1133 | 1133 | return $flight_array; |
| 1134 | 1134 | } |
| 1135 | 1135 | |
| 1136 | - /** |
|
| 1137 | - * Gets all number of flight over countries |
|
| 1138 | - * |
|
| 1139 | - * @param bool $limit |
|
| 1140 | - * @param int $olderthanmonths |
|
| 1141 | - * @param string $sincedate |
|
| 1142 | - * @return array the airline country list |
|
| 1143 | - */ |
|
| 1136 | + /** |
|
| 1137 | + * Gets all number of flight over countries |
|
| 1138 | + * |
|
| 1139 | + * @param bool $limit |
|
| 1140 | + * @param int $olderthanmonths |
|
| 1141 | + * @param string $sincedate |
|
| 1142 | + * @return array the airline country list |
|
| 1143 | + */ |
|
| 1144 | 1144 | public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') { |
| 1145 | 1145 | global $globalDBdriver; |
| 1146 | 1146 | /* |
@@ -1180,13 +1180,13 @@ discard block |
||
| 1180 | 1180 | return $flight_array; |
| 1181 | 1181 | } |
| 1182 | 1182 | |
| 1183 | - /** |
|
| 1184 | - * Gets all aircraft types that have flown over by owner |
|
| 1185 | - * |
|
| 1186 | - * @param $owner |
|
| 1187 | - * @param array $filters |
|
| 1188 | - * @return array the aircraft list |
|
| 1189 | - */ |
|
| 1183 | + /** |
|
| 1184 | + * Gets all aircraft types that have flown over by owner |
|
| 1185 | + * |
|
| 1186 | + * @param $owner |
|
| 1187 | + * @param array $filters |
|
| 1188 | + * @return array the aircraft list |
|
| 1189 | + */ |
|
| 1190 | 1190 | public function countAllAircraftTypesByOwner($owner,$filters = array()) |
| 1191 | 1191 | { |
| 1192 | 1192 | $filter_query = $this->getFilter($filters,true,true); |
@@ -1202,13 +1202,13 @@ discard block |
||
| 1202 | 1202 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1203 | 1203 | } |
| 1204 | 1204 | |
| 1205 | - /** |
|
| 1206 | - * Gets all airlines by owner |
|
| 1207 | - * |
|
| 1208 | - * @param $owner |
|
| 1209 | - * @param array $filters |
|
| 1210 | - * @return array the airline list |
|
| 1211 | - */ |
|
| 1205 | + /** |
|
| 1206 | + * Gets all airlines by owner |
|
| 1207 | + * |
|
| 1208 | + * @param $owner |
|
| 1209 | + * @param array $filters |
|
| 1210 | + * @return array the airline list |
|
| 1211 | + */ |
|
| 1212 | 1212 | public function countAllAirlinesByOwner($owner,$filters = array()) |
| 1213 | 1213 | { |
| 1214 | 1214 | $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
@@ -1223,13 +1223,13 @@ discard block |
||
| 1223 | 1223 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1224 | 1224 | } |
| 1225 | 1225 | |
| 1226 | - /** |
|
| 1227 | - * Gets all arrival airports by country of the airplanes that have flown over based on a owner |
|
| 1228 | - * |
|
| 1229 | - * @param $owner |
|
| 1230 | - * @param array $filters |
|
| 1231 | - * @return array the airport list |
|
| 1232 | - */ |
|
| 1226 | + /** |
|
| 1227 | + * Gets all arrival airports by country of the airplanes that have flown over based on a owner |
|
| 1228 | + * |
|
| 1229 | + * @param $owner |
|
| 1230 | + * @param array $filters |
|
| 1231 | + * @return array the airport list |
|
| 1232 | + */ |
|
| 1233 | 1233 | public function countAllArrivalAirportCountriesByOwner($owner, $filters = array()) |
| 1234 | 1234 | { |
| 1235 | 1235 | $filter_query = $this->getFilter($filters,true,true); |
@@ -1243,13 +1243,13 @@ discard block |
||
| 1243 | 1243 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1244 | 1244 | } |
| 1245 | 1245 | |
| 1246 | - /** |
|
| 1247 | - * Gets all arrival airports of the airplanes that have flown over based on a owner |
|
| 1248 | - * |
|
| 1249 | - * @param $owner |
|
| 1250 | - * @param array $filters |
|
| 1251 | - * @return array the airport list |
|
| 1252 | - */ |
|
| 1246 | + /** |
|
| 1247 | + * Gets all arrival airports of the airplanes that have flown over based on a owner |
|
| 1248 | + * |
|
| 1249 | + * @param $owner |
|
| 1250 | + * @param array $filters |
|
| 1251 | + * @return array the airport list |
|
| 1252 | + */ |
|
| 1253 | 1253 | public function countAllArrivalAirportsByOwner($owner,$filters = array()) |
| 1254 | 1254 | { |
| 1255 | 1255 | $filter_query = $this->getFilter($filters,true,true); |
@@ -1274,13 +1274,13 @@ discard block |
||
| 1274 | 1274 | return $airport_array; |
| 1275 | 1275 | } |
| 1276 | 1276 | |
| 1277 | - /** |
|
| 1278 | - * Gets all departure airports by country of the airplanes that have flown over based on owner |
|
| 1279 | - * |
|
| 1280 | - * @param $owner |
|
| 1281 | - * @param array $filters |
|
| 1282 | - * @return array the airport list |
|
| 1283 | - */ |
|
| 1277 | + /** |
|
| 1278 | + * Gets all departure airports by country of the airplanes that have flown over based on owner |
|
| 1279 | + * |
|
| 1280 | + * @param $owner |
|
| 1281 | + * @param array $filters |
|
| 1282 | + * @return array the airport list |
|
| 1283 | + */ |
|
| 1284 | 1284 | public function countAllDepartureAirportCountriesByOwner($owner,$filters = array()) |
| 1285 | 1285 | { |
| 1286 | 1286 | $filter_query = $this->getFilter($filters,true,true); |
@@ -1294,13 +1294,13 @@ discard block |
||
| 1294 | 1294 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1295 | 1295 | } |
| 1296 | 1296 | |
| 1297 | - /** |
|
| 1298 | - * Gets all departure airports of the airplanes that have flown over based on a owner |
|
| 1299 | - * |
|
| 1300 | - * @param $owner |
|
| 1301 | - * @param array $filters |
|
| 1302 | - * @return array the airport list |
|
| 1303 | - */ |
|
| 1297 | + /** |
|
| 1298 | + * Gets all departure airports of the airplanes that have flown over based on a owner |
|
| 1299 | + * |
|
| 1300 | + * @param $owner |
|
| 1301 | + * @param array $filters |
|
| 1302 | + * @return array the airport list |
|
| 1303 | + */ |
|
| 1304 | 1304 | public function countAllDepartureAirportsByOwner($owner,$filters = array()) |
| 1305 | 1305 | { |
| 1306 | 1306 | $filter_query = $this->getFilter($filters,true,true); |
@@ -1327,13 +1327,13 @@ discard block |
||
| 1327 | 1327 | return $airport_array; |
| 1328 | 1328 | } |
| 1329 | 1329 | |
| 1330 | - /** |
|
| 1331 | - * Gets all aircraft manufacturer that have flown over by owner |
|
| 1332 | - * |
|
| 1333 | - * @param $owner |
|
| 1334 | - * @param array $filters |
|
| 1335 | - * @return array the aircraft manufacturer list |
|
| 1336 | - */ |
|
| 1330 | + /** |
|
| 1331 | + * Gets all aircraft manufacturer that have flown over by owner |
|
| 1332 | + * |
|
| 1333 | + * @param $owner |
|
| 1334 | + * @param array $filters |
|
| 1335 | + * @return array the aircraft manufacturer list |
|
| 1336 | + */ |
|
| 1337 | 1337 | public function countAllAircraftManufacturerByOwner($owner,$filters = array()) |
| 1338 | 1338 | { |
| 1339 | 1339 | $filter_query = $this->getFilter($filters,true,true); |
@@ -1349,13 +1349,13 @@ discard block |
||
| 1349 | 1349 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1350 | 1350 | } |
| 1351 | 1351 | |
| 1352 | - /** |
|
| 1353 | - * Gets all aircraft registration that have flown over by owner |
|
| 1354 | - * |
|
| 1355 | - * @param $owner |
|
| 1356 | - * @param array $filters |
|
| 1357 | - * @return array the aircraft list |
|
| 1358 | - */ |
|
| 1352 | + /** |
|
| 1353 | + * Gets all aircraft registration that have flown over by owner |
|
| 1354 | + * |
|
| 1355 | + * @param $owner |
|
| 1356 | + * @param array $filters |
|
| 1357 | + * @return array the aircraft list |
|
| 1358 | + */ |
|
| 1359 | 1359 | public function countAllAircraftRegistrationByOwner($owner,$filters = array()) |
| 1360 | 1360 | { |
| 1361 | 1361 | $filter_query = $this->getFilter($filters,true,true); |
@@ -1391,13 +1391,13 @@ discard block |
||
| 1391 | 1391 | return $aircraft_array; |
| 1392 | 1392 | } |
| 1393 | 1393 | |
| 1394 | - /** |
|
| 1395 | - * Gets all route combinations based on an owner |
|
| 1396 | - * |
|
| 1397 | - * @param $owner |
|
| 1398 | - * @param array $filters |
|
| 1399 | - * @return array the route list |
|
| 1400 | - */ |
|
| 1394 | + /** |
|
| 1395 | + * Gets all route combinations based on an owner |
|
| 1396 | + * |
|
| 1397 | + * @param $owner |
|
| 1398 | + * @param array $filters |
|
| 1399 | + * @return array the route list |
|
| 1400 | + */ |
|
| 1401 | 1401 | public function countAllRoutesByOwner($owner,$filters = array()) |
| 1402 | 1402 | { |
| 1403 | 1403 | $filter_query = $this->getFilter($filters,true,true); |
@@ -1426,13 +1426,13 @@ discard block |
||
| 1426 | 1426 | return $routes_array; |
| 1427 | 1427 | } |
| 1428 | 1428 | |
| 1429 | - /** |
|
| 1430 | - * Counts all hours by a owner |
|
| 1431 | - * |
|
| 1432 | - * @param $owner |
|
| 1433 | - * @param array $filters |
|
| 1434 | - * @return array the hour list |
|
| 1435 | - */ |
|
| 1429 | + /** |
|
| 1430 | + * Counts all hours by a owner |
|
| 1431 | + * |
|
| 1432 | + * @param $owner |
|
| 1433 | + * @param array $filters |
|
| 1434 | + * @return array the hour list |
|
| 1435 | + */ |
|
| 1436 | 1436 | public function countAllHoursByOwner($owner, $filters = array()) |
| 1437 | 1437 | { |
| 1438 | 1438 | global $globalTimezone, $globalDBdriver; |
@@ -1467,13 +1467,13 @@ discard block |
||
| 1467 | 1467 | return $hour_array; |
| 1468 | 1468 | } |
| 1469 | 1469 | |
| 1470 | - /** |
|
| 1471 | - * Gets last spotter information based on a particular callsign |
|
| 1472 | - * |
|
| 1473 | - * @param $id |
|
| 1474 | - * @param $date |
|
| 1475 | - * @return array the spotter information |
|
| 1476 | - */ |
|
| 1470 | + /** |
|
| 1471 | + * Gets last spotter information based on a particular callsign |
|
| 1472 | + * |
|
| 1473 | + * @param $id |
|
| 1474 | + * @param $date |
|
| 1475 | + * @return array the spotter information |
|
| 1476 | + */ |
|
| 1477 | 1477 | public function getDateArchiveSpotterDataById($id,$date) { |
| 1478 | 1478 | $Spotter = new Spotter($this->db); |
| 1479 | 1479 | date_default_timezone_set('UTC'); |
@@ -1484,13 +1484,13 @@ discard block |
||
| 1484 | 1484 | return $spotter_array; |
| 1485 | 1485 | } |
| 1486 | 1486 | |
| 1487 | - /** |
|
| 1488 | - * Gets all the spotter information based on a particular callsign |
|
| 1489 | - * |
|
| 1490 | - * @param $ident |
|
| 1491 | - * @param $date |
|
| 1492 | - * @return array the spotter information |
|
| 1493 | - */ |
|
| 1487 | + /** |
|
| 1488 | + * Gets all the spotter information based on a particular callsign |
|
| 1489 | + * |
|
| 1490 | + * @param $ident |
|
| 1491 | + * @param $date |
|
| 1492 | + * @return array the spotter information |
|
| 1493 | + */ |
|
| 1494 | 1494 | public function getDateArchiveSpotterDataByIdent($ident,$date) { |
| 1495 | 1495 | $Spotter = new Spotter($this->db); |
| 1496 | 1496 | date_default_timezone_set('UTC'); |
@@ -1501,15 +1501,15 @@ discard block |
||
| 1501 | 1501 | return $spotter_array; |
| 1502 | 1502 | } |
| 1503 | 1503 | |
| 1504 | - /** |
|
| 1505 | - * Gets all the spotter information based on the airport |
|
| 1506 | - * |
|
| 1507 | - * @param string $airport |
|
| 1508 | - * @param string $limit |
|
| 1509 | - * @param string $sort |
|
| 1510 | - * @param array $filters |
|
| 1511 | - * @return array the spotter information |
|
| 1512 | - */ |
|
| 1504 | + /** |
|
| 1505 | + * Gets all the spotter information based on the airport |
|
| 1506 | + * |
|
| 1507 | + * @param string $airport |
|
| 1508 | + * @param string $limit |
|
| 1509 | + * @param string $sort |
|
| 1510 | + * @param array $filters |
|
| 1511 | + * @return array the spotter information |
|
| 1512 | + */ |
|
| 1513 | 1513 | public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) { |
| 1514 | 1514 | global $global_query; |
| 1515 | 1515 | $Spotter = new Spotter($this->db); |
@@ -16,75 +16,75 @@ discard block |
||
| 16 | 16 | * @param bool $and |
| 17 | 17 | * @return string the SQL part |
| 18 | 18 | */ |
| 19 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 19 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 21 | 21 | $filters = array(); |
| 22 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 23 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 24 | 24 | $filters = $globalStatsFilters[$globalFilterName]; |
| 25 | 25 | } else { |
| 26 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 26 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | if (isset($filter[0]['source'])) { |
| 30 | - $filters = array_merge($filters,$filter); |
|
| 30 | + $filters = array_merge($filters, $filter); |
|
| 31 | 31 | } |
| 32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 32 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 33 | 33 | $filter_query_join = ''; |
| 34 | 34 | $filter_query_where = ''; |
| 35 | - foreach($filters as $flt) { |
|
| 35 | + foreach ($filters as $flt) { |
|
| 36 | 36 | if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
| 37 | 37 | if ($flt['airlines'][0] != '' && $flt['airlines'][0] != 'all') { |
| 38 | 38 | if (isset($flt['source'])) { |
| 39 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 39 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 40 | 40 | } else { |
| 41 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 41 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
| 46 | 46 | if (isset($flt['source'])) { |
| 47 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 47 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 48 | 48 | } else { |
| 49 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 49 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 53 | 53 | if (isset($flt['source'])) { |
| 54 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 54 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 55 | 55 | } else { |
| 56 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 56 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
| 60 | 60 | if (isset($flt['source'])) { |
| 61 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 61 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 62 | 62 | } else { |
| 63 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 63 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
| 67 | 67 | if (isset($flt['source'])) { |
| 68 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 68 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 73 | 73 | if ($filter['airlines'][0] != '' && $filter['airlines'][0] != 'all') { |
| 74 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 74 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 78 | 78 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
| 79 | 79 | } |
| 80 | 80 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
| 81 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 81 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 82 | 82 | } |
| 83 | 83 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 84 | 84 | if (count($filter['source']) == 1) { |
| 85 | 85 | $filter_query_where .= " AND format_source = '".$filter['source'][0]."'"; |
| 86 | 86 | } else { |
| 87 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 87 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | $filter_query_where .= " AND flightaware_id = '".$filter['id']."'"; |
| 95 | 95 | } |
| 96 | 96 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 97 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 97 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 98 | 98 | } |
| 99 | 99 | if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) { |
| 100 | 100 | $filter_query_date = ''; |
@@ -119,41 +119,41 @@ discard block |
||
| 119 | 119 | $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'"; |
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 122 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
| 123 | 123 | } |
| 124 | 124 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 125 | 125 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 126 | 126 | if ($filter_query_where != '') { |
| 127 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 127 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 128 | 128 | } |
| 129 | 129 | $filter_query = $filter_query_join.$filter_query_where; |
| 130 | 130 | return $filter_query; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | // Spotter_archive |
| 134 | - public function 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 = '', $real_altitude = '',$heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') { |
|
| 134 | + public function 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 = '', $real_altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $format_source = '', $source_name = '', $over_country = '') { |
|
| 135 | 135 | require_once(dirname(__FILE__).'/class.Spotter.php'); |
| 136 | 136 | if ($over_country == '') { |
| 137 | 137 | $Spotter = new Spotter($this->db); |
| 138 | - $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
| 138 | + $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
| 139 | 139 | if (!empty($data_country)) $country = $data_country['iso2']; |
| 140 | 140 | else $country = ''; |
| 141 | 141 | } else $country = $over_country; |
| 142 | - if ($airline_type === NULL) $airline_type =''; |
|
| 142 | + if ($airline_type === NULL) $airline_type = ''; |
|
| 143 | 143 | |
| 144 | 144 | //if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n"; |
| 145 | 145 | //else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n"; |
| 146 | 146 | |
| 147 | 147 | // Route is not added in spotter_archive |
| 148 | - $query = "INSERT INTO spotter_archive (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, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name,real_altitude) |
|
| 148 | + $query = "INSERT INTO spotter_archive (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, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name,real_altitude) |
|
| 149 | 149 | VALUES (: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, :heading, :ground_speed, :squawk, :ModeS, :pilot_id, :pilot_name, :verticalrate, :format_source, :over_country, :source_name,:real_altitude)"; |
| 150 | 150 | |
| 151 | - $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_name' => $aircraft_name, ':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, ':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date,':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name,':real_altitude' => $real_altitude); |
|
| 151 | + $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_name' => $aircraft_name, ':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, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name, ':real_altitude' => $real_altitude); |
|
| 152 | 152 | try { |
| 153 | 153 | $sth = $this->db->prepare($query); |
| 154 | 154 | $sth->execute($query_values); |
| 155 | 155 | $sth->closeCursor(); |
| 156 | - } catch(PDOException $e) { |
|
| 156 | + } catch (PDOException $e) { |
|
| 157 | 157 | return "error : ".$e->getMessage(); |
| 158 | 158 | } |
| 159 | 159 | return "success"; |
@@ -172,9 +172,9 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 174 | 174 | //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
| 175 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 175 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 176 | 176 | |
| 177 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
| 177 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident)); |
|
| 178 | 178 | |
| 179 | 179 | return $spotter_array; |
| 180 | 180 | } |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 193 | 193 | //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
| 194 | 194 | //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
| 195 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 195 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 196 | 196 | |
| 197 | 197 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 198 | 198 | /* |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | } |
| 206 | 206 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 207 | 207 | */ |
| 208 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
| 208 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id)); |
|
| 209 | 209 | |
| 210 | 210 | return $spotter_array; |
| 211 | 211 | } |
@@ -219,14 +219,14 @@ discard block |
||
| 219 | 219 | public function getAllArchiveSpotterDataById($id) { |
| 220 | 220 | date_default_timezone_set('UTC'); |
| 221 | 221 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 222 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 222 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 223 | 223 | |
| 224 | 224 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
| 225 | 225 | |
| 226 | 226 | try { |
| 227 | 227 | $sth = $this->db->prepare($query); |
| 228 | 228 | $sth->execute(array(':id' => $id)); |
| 229 | - } catch(PDOException $e) { |
|
| 229 | + } catch (PDOException $e) { |
|
| 230 | 230 | echo $e->getMessage(); |
| 231 | 231 | die; |
| 232 | 232 | } |
@@ -244,11 +244,11 @@ discard block |
||
| 244 | 244 | public function getCoordArchiveSpotterDataById($id) { |
| 245 | 245 | date_default_timezone_set('UTC'); |
| 246 | 246 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 247 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER by spotter_archive.date ASC"; |
|
| 247 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER by spotter_archive.date ASC"; |
|
| 248 | 248 | try { |
| 249 | 249 | $sth = $this->db->prepare($query); |
| 250 | 250 | $sth->execute(array(':id' => $id)); |
| 251 | - } catch(PDOException $e) { |
|
| 251 | + } catch (PDOException $e) { |
|
| 252 | 252 | echo $e->getMessage(); |
| 253 | 253 | die; |
| 254 | 254 | } |
@@ -264,14 +264,14 @@ discard block |
||
| 264 | 264 | * @param $enddate |
| 265 | 265 | * @return array the spotter information |
| 266 | 266 | */ |
| 267 | - public function getCoordArchiveSpotterDataByIdDate($id,$begindate,$enddate) { |
|
| 267 | + public function getCoordArchiveSpotterDataByIdDate($id, $begindate, $enddate) { |
|
| 268 | 268 | date_default_timezone_set('UTC'); |
| 269 | 269 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 270 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.date BETWEEN :begindate AND :enddate ORDER by spotter_archive.date ASC"; |
|
| 270 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.date BETWEEN :begindate AND :enddate ORDER by spotter_archive.date ASC"; |
|
| 271 | 271 | try { |
| 272 | 272 | $sth = $this->db->prepare($query); |
| 273 | - $sth->execute(array(':id' => $id,':begindate' => $begindate,':enddate' => $enddate)); |
|
| 274 | - } catch(PDOException $e) { |
|
| 273 | + $sth->execute(array(':id' => $id, ':begindate' => $begindate, ':enddate' => $enddate)); |
|
| 274 | + } catch (PDOException $e) { |
|
| 275 | 275 | echo $e->getMessage(); |
| 276 | 276 | die; |
| 277 | 277 | } |
@@ -291,12 +291,12 @@ discard block |
||
| 291 | 291 | date_default_timezone_set('UTC'); |
| 292 | 292 | |
| 293 | 293 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 294 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 294 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 295 | 295 | |
| 296 | 296 | try { |
| 297 | 297 | $sth = $this->db->prepare($query); |
| 298 | 298 | $sth->execute(array(':ident' => $ident)); |
| 299 | - } catch(PDOException $e) { |
|
| 299 | + } catch (PDOException $e) { |
|
| 300 | 300 | echo $e->getMessage(); |
| 301 | 301 | die; |
| 302 | 302 | } |
@@ -316,12 +316,12 @@ discard block |
||
| 316 | 316 | date_default_timezone_set('UTC'); |
| 317 | 317 | |
| 318 | 318 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 319 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 319 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
| 320 | 320 | |
| 321 | 321 | try { |
| 322 | 322 | $sth = $this->db->prepare($query); |
| 323 | 323 | $sth->execute(array(':id' => $id)); |
| 324 | - } catch(PDOException $e) { |
|
| 324 | + } catch (PDOException $e) { |
|
| 325 | 325 | echo $e->getMessage(); |
| 326 | 326 | die; |
| 327 | 327 | } |
@@ -339,11 +339,11 @@ discard block |
||
| 339 | 339 | public function getAltitudeSpeedArchiveSpotterDataById($id) { |
| 340 | 340 | date_default_timezone_set('UTC'); |
| 341 | 341 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 342 | - $query = "SELECT spotter_archive.altitude, spotter_archive.real_altitude,spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 342 | + $query = "SELECT spotter_archive.altitude, spotter_archive.real_altitude,spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
| 343 | 343 | try { |
| 344 | 344 | $sth = $this->db->prepare($query); |
| 345 | 345 | $sth->execute(array(':id' => $id)); |
| 346 | - } catch(PDOException $e) { |
|
| 346 | + } catch (PDOException $e) { |
|
| 347 | 347 | echo $e->getMessage(); |
| 348 | 348 | die; |
| 349 | 349 | } |
@@ -360,12 +360,12 @@ discard block |
||
| 360 | 360 | public function getLastAltitudeArchiveSpotterDataByIdent($ident) { |
| 361 | 361 | date_default_timezone_set('UTC'); |
| 362 | 362 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 363 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 363 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
| 364 | 364 | // $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
| 365 | 365 | try { |
| 366 | 366 | $sth = $this->db->prepare($query); |
| 367 | 367 | $sth->execute(array(':ident' => $ident)); |
| 368 | - } catch(PDOException $e) { |
|
| 368 | + } catch (PDOException $e) { |
|
| 369 | 369 | echo $e->getMessage(); |
| 370 | 370 | die; |
| 371 | 371 | } |
@@ -382,11 +382,11 @@ discard block |
||
| 382 | 382 | * @param $date |
| 383 | 383 | * @return array the spotter information |
| 384 | 384 | */ |
| 385 | - public function getSpotterArchiveData($ident,$flightaware_id,$date) { |
|
| 385 | + public function getSpotterArchiveData($ident, $flightaware_id, $date) { |
|
| 386 | 386 | $Spotter = new Spotter($this->db); |
| 387 | 387 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 388 | - $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.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
| 389 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
| 388 | + $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.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
| 389 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%')); |
|
| 390 | 390 | return $spotter_array; |
| 391 | 391 | } |
| 392 | 392 | |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | try { |
| 401 | 401 | $sth = $this->db->prepare($query); |
| 402 | 402 | $sth->execute(); |
| 403 | - } catch(PDOException $e) { |
|
| 403 | + } catch (PDOException $e) { |
|
| 404 | 404 | echo $e->getMessage(); |
| 405 | 405 | die; |
| 406 | 406 | } |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | try { |
| 417 | 417 | $sth = $this->db->prepare($query); |
| 418 | 418 | $sth->execute(array(':id' => $id)); |
| 419 | - } catch(PDOException $e) { |
|
| 419 | + } catch (PDOException $e) { |
|
| 420 | 420 | echo $e->getMessage(); |
| 421 | 421 | die; |
| 422 | 422 | } |
@@ -431,39 +431,39 @@ discard block |
||
| 431 | 431 | * @param int $part |
| 432 | 432 | * @return array the spotter information |
| 433 | 433 | */ |
| 434 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array(),$part = 0) { |
|
| 434 | + public function getMinLiveSpotterData($begindate, $enddate, $filter = array(), $part = 0) { |
|
| 435 | 435 | global $globalDBdriver; |
| 436 | 436 | date_default_timezone_set('UTC'); |
| 437 | 437 | //$filter_query = $this->getFilter($filter,true,true); |
| 438 | 438 | |
| 439 | 439 | $filter_query = ''; |
| 440 | 440 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 441 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 441 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 442 | 442 | } |
| 443 | 443 | // Use spotter_output also ? |
| 444 | 444 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 445 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 445 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 446 | 446 | } |
| 447 | 447 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 448 | 448 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
| 449 | 449 | } |
| 450 | 450 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 451 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 451 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | $limit = ''; |
| 455 | 455 | if ($part != 0) { |
| 456 | - $limit = ' LIMIT 100 OFFSET '.($part-1)*100; |
|
| 456 | + $limit = ' LIMIT 100 OFFSET '.($part - 1)*100; |
|
| 457 | 457 | } |
| 458 | 458 | if ($globalDBdriver == 'mysql') { |
| 459 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, 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, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 459 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, 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, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 460 | 460 | FROM spotter_archive |
| 461 | 461 | INNER JOIN aircraft a on spotter_archive.aircraft_icao = a.icao |
| 462 | 462 | WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".' |
| 463 | 463 | '.$filter_query.' ORDER BY flightaware_id'.$limit; |
| 464 | 464 | } else { |
| 465 | 465 | |
| 466 | - $query = 'SELECT spotter_archive.flightaware_id, spotter_archive.date, spotter_archive.ident, 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, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 466 | + $query = 'SELECT spotter_archive.flightaware_id, spotter_archive.date, spotter_archive.ident, 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, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 467 | 467 | FROM spotter_archive |
| 468 | 468 | INNER JOIN aircraft a on spotter_archive.aircraft_icao = a.icao |
| 469 | 469 | WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".' |
@@ -473,7 +473,7 @@ discard block |
||
| 473 | 473 | try { |
| 474 | 474 | $sth = $this->db->prepare($query); |
| 475 | 475 | $sth->execute(); |
| 476 | - } catch(PDOException $e) { |
|
| 476 | + } catch (PDOException $e) { |
|
| 477 | 477 | echo $e->getMessage(); |
| 478 | 478 | die; |
| 479 | 479 | } |
@@ -489,7 +489,7 @@ discard block |
||
| 489 | 489 | * @param array $filter |
| 490 | 490 | * @return array the spotter information |
| 491 | 491 | */ |
| 492 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) { |
|
| 492 | + public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array()) { |
|
| 493 | 493 | global $globalDBdriver; |
| 494 | 494 | date_default_timezone_set('UTC'); |
| 495 | 495 | |
@@ -497,17 +497,17 @@ discard block |
||
| 497 | 497 | |
| 498 | 498 | $filter_query = ''; |
| 499 | 499 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 500 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 500 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 501 | 501 | } |
| 502 | 502 | // Use spotter_output also ? |
| 503 | 503 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 504 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 504 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 505 | 505 | } |
| 506 | 506 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 507 | 507 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
| 508 | 508 | } |
| 509 | 509 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 510 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 510 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 511 | 511 | } |
| 512 | 512 | |
| 513 | 513 | |
@@ -518,7 +518,7 @@ discard block |
||
| 518 | 518 | FROM spotter_archive |
| 519 | 519 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
| 520 | 520 | */ |
| 521 | - $query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk |
|
| 521 | + $query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk |
|
| 522 | 522 | FROM spotter_archive_output |
| 523 | 523 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao |
| 524 | 524 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -533,7 +533,7 @@ discard block |
||
| 533 | 533 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
| 534 | 534 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
| 535 | 535 | */ |
| 536 | - $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
| 536 | + $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
| 537 | 537 | FROM spotter_archive_output |
| 538 | 538 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
| 539 | 539 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
@@ -545,7 +545,7 @@ discard block |
||
| 545 | 545 | try { |
| 546 | 546 | $sth = $this->db->prepare($query); |
| 547 | 547 | $sth->execute(); |
| 548 | - } catch(PDOException $e) { |
|
| 548 | + } catch (PDOException $e) { |
|
| 549 | 549 | echo $e->getMessage(); |
| 550 | 550 | die; |
| 551 | 551 | } |
@@ -562,22 +562,22 @@ discard block |
||
| 562 | 562 | * @param array $filter |
| 563 | 563 | * @return array the spotter information |
| 564 | 564 | */ |
| 565 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) { |
|
| 565 | + public function getLiveSpotterCount($begindate, $enddate, $filter = array()) { |
|
| 566 | 566 | global $globalDBdriver, $globalLiveInterval; |
| 567 | 567 | date_default_timezone_set('UTC'); |
| 568 | 568 | |
| 569 | 569 | $filter_query = ''; |
| 570 | 570 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 571 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 571 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 572 | 572 | } |
| 573 | 573 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 574 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 574 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
| 575 | 575 | } |
| 576 | 576 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 577 | 577 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
| 578 | 578 | } |
| 579 | 579 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 580 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 580 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 581 | 581 | } |
| 582 | 582 | |
| 583 | 583 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -592,7 +592,7 @@ discard block |
||
| 592 | 592 | try { |
| 593 | 593 | $sth = $this->db->prepare($query); |
| 594 | 594 | $sth->execute(); |
| 595 | - } catch(PDOException $e) { |
|
| 595 | + } catch (PDOException $e) { |
|
| 596 | 596 | echo $e->getMessage(); |
| 597 | 597 | die; |
| 598 | 598 | } |
@@ -636,7 +636,7 @@ discard block |
||
| 636 | 636 | * @param array $filters |
| 637 | 637 | * @return array the spotter information |
| 638 | 638 | */ |
| 639 | - public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) { |
|
| 639 | + public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) { |
|
| 640 | 640 | global $globalTimezone, $globalDBdriver; |
| 641 | 641 | require_once(dirname(__FILE__).'/class.Translation.php'); |
| 642 | 642 | $Translation = new Translation($this->db); |
@@ -686,7 +686,7 @@ discard block |
||
| 686 | 686 | } |
| 687 | 687 | |
| 688 | 688 | if ($registration != "") { |
| 689 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 689 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 690 | 690 | if (!is_string($registration)) { |
| 691 | 691 | return array(); |
| 692 | 692 | } else { |
@@ -695,7 +695,7 @@ discard block |
||
| 695 | 695 | } |
| 696 | 696 | |
| 697 | 697 | if ($aircraft_icao != "") { |
| 698 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 698 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 699 | 699 | if (!is_string($aircraft_icao)) { |
| 700 | 700 | return array(); |
| 701 | 701 | } else { |
@@ -704,7 +704,7 @@ discard block |
||
| 704 | 704 | } |
| 705 | 705 | |
| 706 | 706 | if ($aircraft_manufacturer != "") { |
| 707 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 707 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
| 708 | 708 | if (!is_string($aircraft_manufacturer)) { |
| 709 | 709 | return array(); |
| 710 | 710 | } else { |
@@ -721,7 +721,7 @@ discard block |
||
| 721 | 721 | } |
| 722 | 722 | |
| 723 | 723 | if ($airline_icao != "") { |
| 724 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 724 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 725 | 725 | if (!is_string($airline_icao)) { |
| 726 | 726 | return array(); |
| 727 | 727 | } else { |
@@ -730,7 +730,7 @@ discard block |
||
| 730 | 730 | } |
| 731 | 731 | |
| 732 | 732 | if ($airline_country != "") { |
| 733 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 733 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
| 734 | 734 | if (!is_string($airline_country)) { |
| 735 | 735 | return array(); |
| 736 | 736 | } else { |
@@ -739,7 +739,7 @@ discard block |
||
| 739 | 739 | } |
| 740 | 740 | |
| 741 | 741 | if ($airline_type != "") { |
| 742 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 742 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
| 743 | 743 | if (!is_string($airline_type)) { |
| 744 | 744 | return array(); |
| 745 | 745 | } else { |
@@ -756,7 +756,7 @@ discard block |
||
| 756 | 756 | } |
| 757 | 757 | |
| 758 | 758 | if ($airport != "") { |
| 759 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 759 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
| 760 | 760 | if (!is_string($airport)) { |
| 761 | 761 | return array(); |
| 762 | 762 | } else { |
@@ -765,7 +765,7 @@ discard block |
||
| 765 | 765 | } |
| 766 | 766 | |
| 767 | 767 | if ($airport_country != "") { |
| 768 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 768 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
| 769 | 769 | if (!is_string($airport_country)) { |
| 770 | 770 | return array(); |
| 771 | 771 | } else { |
@@ -774,14 +774,14 @@ discard block |
||
| 774 | 774 | } |
| 775 | 775 | |
| 776 | 776 | if ($callsign != "") { |
| 777 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 777 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 778 | 778 | if (!is_string($callsign)) { |
| 779 | 779 | return array(); |
| 780 | 780 | } else { |
| 781 | 781 | $translate = $Translation->ident2icao($callsign); |
| 782 | 782 | if ($translate != $callsign) { |
| 783 | 783 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
| 784 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
| 784 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
| 785 | 785 | } else { |
| 786 | 786 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
| 787 | 787 | } |
@@ -789,7 +789,7 @@ discard block |
||
| 789 | 789 | } |
| 790 | 790 | |
| 791 | 791 | if ($owner != "") { |
| 792 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 792 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 793 | 793 | if (!is_string($owner)) { |
| 794 | 794 | return array(); |
| 795 | 795 | } else { |
@@ -798,7 +798,7 @@ discard block |
||
| 798 | 798 | } |
| 799 | 799 | |
| 800 | 800 | if ($pilot_name != "") { |
| 801 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 801 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
| 802 | 802 | if (!is_string($pilot_name)) { |
| 803 | 803 | return array(); |
| 804 | 804 | } else { |
@@ -807,7 +807,7 @@ discard block |
||
| 807 | 807 | } |
| 808 | 808 | |
| 809 | 809 | if ($pilot_id != "") { |
| 810 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 810 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
| 811 | 811 | if (!is_string($pilot_id)) { |
| 812 | 812 | return array(); |
| 813 | 813 | } else { |
@@ -816,7 +816,7 @@ discard block |
||
| 816 | 816 | } |
| 817 | 817 | |
| 818 | 818 | if ($departure_airport_route != "") { |
| 819 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 819 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
| 820 | 820 | if (!is_string($departure_airport_route)) { |
| 821 | 821 | return array(); |
| 822 | 822 | } else { |
@@ -825,7 +825,7 @@ discard block |
||
| 825 | 825 | } |
| 826 | 826 | |
| 827 | 827 | if ($arrival_airport_route != "") { |
| 828 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 828 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
| 829 | 829 | if (!is_string($arrival_airport_route)) { |
| 830 | 830 | return array(); |
| 831 | 831 | } else { |
@@ -836,8 +836,8 @@ discard block |
||
| 836 | 836 | if ($altitude != "") { |
| 837 | 837 | $altitude_array = explode(",", $altitude); |
| 838 | 838 | |
| 839 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 840 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 839 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 840 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 841 | 841 | |
| 842 | 842 | |
| 843 | 843 | if ($altitude_array[1] != "") { |
@@ -852,8 +852,8 @@ discard block |
||
| 852 | 852 | |
| 853 | 853 | if ($date_posted != "") { |
| 854 | 854 | $date_array = explode(",", $date_posted); |
| 855 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 856 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 855 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
| 856 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
| 857 | 857 | if ($globalTimezone != '') { |
| 858 | 858 | date_default_timezone_set($globalTimezone); |
| 859 | 859 | $datetime = new DateTime(); |
@@ -878,16 +878,16 @@ discard block |
||
| 878 | 878 | } |
| 879 | 879 | if ($limit != "") { |
| 880 | 880 | $limit_array = explode(",", $limit); |
| 881 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 882 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 881 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 882 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 883 | 883 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) { |
| 884 | 884 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 885 | 885 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 886 | 886 | } |
| 887 | 887 | } |
| 888 | 888 | if ($origLat != "" && $origLon != "" && $dist != "") { |
| 889 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
| 890 | - $query="SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 889 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
| 890 | + $query = "SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 891 | 891 | FROM spotter_archive_output, spotter_archive WHERE spotter_output_archive.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 892 | 892 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
| 893 | 893 | } else { |
@@ -901,12 +901,12 @@ discard block |
||
| 901 | 901 | $additional_query .= " AND (spotter_archive_output.waypoints <> '')"; |
| 902 | 902 | } |
| 903 | 903 | |
| 904 | - $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
| 904 | + $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
| 905 | 905 | WHERE spotter_archive_output.ident <> '' |
| 906 | 906 | ".$additional_query." |
| 907 | 907 | ".$filter_query.$orderby_query; |
| 908 | 908 | } |
| 909 | - $spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query); |
|
| 909 | + $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
|
| 910 | 910 | return $spotter_array; |
| 911 | 911 | } |
| 912 | 912 | |
@@ -922,7 +922,7 @@ discard block |
||
| 922 | 922 | $sth = $this->db->prepare($query); |
| 923 | 923 | $sth->execute(); |
| 924 | 924 | return ''; |
| 925 | - } catch(PDOException $e) { |
|
| 925 | + } catch (PDOException $e) { |
|
| 926 | 926 | return "error"; |
| 927 | 927 | } |
| 928 | 928 | } |
@@ -957,8 +957,8 @@ discard block |
||
| 957 | 957 | if ($limit != "") { |
| 958 | 958 | $limit_array = explode(",", $limit); |
| 959 | 959 | |
| 960 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 961 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 960 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 961 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 962 | 962 | |
| 963 | 963 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) { |
| 964 | 964 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -999,7 +999,7 @@ discard block |
||
| 999 | 999 | $query_values = array(); |
| 1000 | 1000 | $limit_query = ''; |
| 1001 | 1001 | $additional_query = ''; |
| 1002 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1002 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1003 | 1003 | |
| 1004 | 1004 | if ($owner != "") { |
| 1005 | 1005 | if (!is_string($owner)) { |
@@ -1013,8 +1013,8 @@ discard block |
||
| 1013 | 1013 | if ($limit != "") { |
| 1014 | 1014 | $limit_array = explode(",", $limit); |
| 1015 | 1015 | |
| 1016 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1017 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1016 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1017 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1018 | 1018 | |
| 1019 | 1019 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0 && $limit_array[0] != '' && $limit_array[1] != '') { |
| 1020 | 1020 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -1054,7 +1054,7 @@ discard block |
||
| 1054 | 1054 | $query_values = array(); |
| 1055 | 1055 | $limit_query = ''; |
| 1056 | 1056 | $additional_query = ''; |
| 1057 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1057 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1058 | 1058 | |
| 1059 | 1059 | if ($pilot != "") { |
| 1060 | 1060 | $additional_query = " AND (spotter_archive_output.pilot_id = :pilot OR spotter_archive_output.pilot_name = :pilot)"; |
@@ -1064,8 +1064,8 @@ discard block |
||
| 1064 | 1064 | if ($limit != "") { |
| 1065 | 1065 | $limit_array = explode(",", $limit); |
| 1066 | 1066 | |
| 1067 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1068 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1067 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1068 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1069 | 1069 | |
| 1070 | 1070 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) { |
| 1071 | 1071 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -1095,7 +1095,7 @@ discard block |
||
| 1095 | 1095 | * @param string $sincedate |
| 1096 | 1096 | * @return array the airline country list |
| 1097 | 1097 | */ |
| 1098 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') { |
|
| 1098 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') { |
|
| 1099 | 1099 | global $globalDBdriver; |
| 1100 | 1100 | /* |
| 1101 | 1101 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1123,7 +1123,7 @@ discard block |
||
| 1123 | 1123 | $flight_array = array(); |
| 1124 | 1124 | $temp_array = array(); |
| 1125 | 1125 | |
| 1126 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 1126 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 1127 | 1127 | $temp_array['flight_count'] = $row['nb']; |
| 1128 | 1128 | $temp_array['flight_country'] = $row['name']; |
| 1129 | 1129 | $temp_array['flight_country_iso3'] = $row['iso3']; |
@@ -1141,7 +1141,7 @@ discard block |
||
| 1141 | 1141 | * @param string $sincedate |
| 1142 | 1142 | * @return array the airline country list |
| 1143 | 1143 | */ |
| 1144 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') { |
|
| 1144 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') { |
|
| 1145 | 1145 | global $globalDBdriver; |
| 1146 | 1146 | /* |
| 1147 | 1147 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1169,7 +1169,7 @@ discard block |
||
| 1169 | 1169 | $flight_array = array(); |
| 1170 | 1170 | $temp_array = array(); |
| 1171 | 1171 | |
| 1172 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 1172 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 1173 | 1173 | $temp_array['airline_icao'] = $row['airline_icao']; |
| 1174 | 1174 | $temp_array['flight_count'] = $row['nb']; |
| 1175 | 1175 | $temp_array['flight_country'] = $row['name']; |
@@ -1187,16 +1187,16 @@ discard block |
||
| 1187 | 1187 | * @param array $filters |
| 1188 | 1188 | * @return array the aircraft list |
| 1189 | 1189 | */ |
| 1190 | - public function countAllAircraftTypesByOwner($owner,$filters = array()) |
|
| 1190 | + public function countAllAircraftTypesByOwner($owner, $filters = array()) |
|
| 1191 | 1191 | { |
| 1192 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1193 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 1192 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1193 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 1194 | 1194 | $query = "SELECT DISTINCT spotter_archive_output.aircraft_icao, COUNT(spotter_archive_output.aircraft_icao) AS aircraft_icao_count, spotter_archive_output.aircraft_name, spotter_archive_output.aircraft_manufacturer |
| 1195 | 1195 | FROM spotter_archive_output".$filter_query." spotter_archive_output.owner_name = :owner"; |
| 1196 | 1196 | $query_values = array(); |
| 1197 | 1197 | $query .= " GROUP BY spotter_archive_output.aircraft_name, spotter_archive_output.aircraft_manufacturer, spotter_archive_output.aircraft_icao |
| 1198 | 1198 | ORDER BY aircraft_icao_count DESC"; |
| 1199 | - $query_values = array_merge($query_values,array(':owner' => $owner)); |
|
| 1199 | + $query_values = array_merge($query_values, array(':owner' => $owner)); |
|
| 1200 | 1200 | $sth = $this->db->prepare($query); |
| 1201 | 1201 | $sth->execute($query_values); |
| 1202 | 1202 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1209,11 +1209,11 @@ discard block |
||
| 1209 | 1209 | * @param array $filters |
| 1210 | 1210 | * @return array the airline list |
| 1211 | 1211 | */ |
| 1212 | - public function countAllAirlinesByOwner($owner,$filters = array()) |
|
| 1212 | + public function countAllAirlinesByOwner($owner, $filters = array()) |
|
| 1213 | 1213 | { |
| 1214 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 1215 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1216 | - $query = "SELECT DISTINCT spotter_archive_output.airline_name, spotter_archive_output.airline_icao, spotter_archive_output.airline_country, COUNT(spotter_archive_output.airline_name) AS airline_count |
|
| 1214 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 1215 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1216 | + $query = "SELECT DISTINCT spotter_archive_output.airline_name, spotter_archive_output.airline_icao, spotter_archive_output.airline_country, COUNT(spotter_archive_output.airline_name) AS airline_count |
|
| 1217 | 1217 | FROM spotter_archive_output".$filter_query." spotter_archive_output.owner_name = :owner |
| 1218 | 1218 | GROUP BY spotter_archive_output.airline_icao, spotter_archive_output.airline_name, spotter_archive_output.airline_country |
| 1219 | 1219 | ORDER BY airline_count DESC"; |
@@ -1232,9 +1232,9 @@ discard block |
||
| 1232 | 1232 | */ |
| 1233 | 1233 | public function countAllArrivalAirportCountriesByOwner($owner, $filters = array()) |
| 1234 | 1234 | { |
| 1235 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1236 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 1237 | - $query = "SELECT DISTINCT spotter_archive_output.arrival_airport_country, COUNT(spotter_archive_output.arrival_airport_country) AS airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 |
|
| 1235 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1236 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 1237 | + $query = "SELECT DISTINCT spotter_archive_output.arrival_airport_country, COUNT(spotter_archive_output.arrival_airport_country) AS airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 |
|
| 1238 | 1238 | FROM countries, spotter_archive_output".$filter_query." spotter_archive_output.arrival_airport_country <> '' AND spotter_archive_output.owner_name = :owner AND countries.name = spotter_archive_output.arrival_airport_country |
| 1239 | 1239 | GROUP BY spotter_archive_output.arrival_airport_country, countries.iso3 |
| 1240 | 1240 | ORDER BY airport_arrival_country_count DESC"; |
@@ -1250,11 +1250,11 @@ discard block |
||
| 1250 | 1250 | * @param array $filters |
| 1251 | 1251 | * @return array the airport list |
| 1252 | 1252 | */ |
| 1253 | - public function countAllArrivalAirportsByOwner($owner,$filters = array()) |
|
| 1253 | + public function countAllArrivalAirportsByOwner($owner, $filters = array()) |
|
| 1254 | 1254 | { |
| 1255 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1256 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 1257 | - $query = "SELECT DISTINCT spotter_archive_output.arrival_airport_icao, COUNT(spotter_archive_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_archive_output.arrival_airport_name, spotter_archive_output.arrival_airport_city, spotter_archive_output.arrival_airport_country |
|
| 1255 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1256 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 1257 | + $query = "SELECT DISTINCT spotter_archive_output.arrival_airport_icao, COUNT(spotter_archive_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_archive_output.arrival_airport_name, spotter_archive_output.arrival_airport_city, spotter_archive_output.arrival_airport_country |
|
| 1258 | 1258 | FROM spotter_archive_output".$filter_query." spotter_archive_output.arrival_airport_name <> '' AND spotter_archive_output.arrival_airport_icao <> 'NA' AND spotter_archive_output.arrival_airport_icao <> '' AND spotter_archive_output.owner_name = :owner |
| 1259 | 1259 | GROUP BY spotter_archive_output.arrival_airport_icao, spotter_archive_output.arrival_airport_name, spotter_archive_output.arrival_airport_city, spotter_archive_output.arrival_airport_country |
| 1260 | 1260 | ORDER BY airport_arrival_icao_count DESC"; |
@@ -1262,7 +1262,7 @@ discard block |
||
| 1262 | 1262 | $sth->execute(array(':owner' => $owner)); |
| 1263 | 1263 | $airport_array = array(); |
| 1264 | 1264 | $temp_array = array(); |
| 1265 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1265 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1266 | 1266 | { |
| 1267 | 1267 | $temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
| 1268 | 1268 | $temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; |
@@ -1281,11 +1281,11 @@ discard block |
||
| 1281 | 1281 | * @param array $filters |
| 1282 | 1282 | * @return array the airport list |
| 1283 | 1283 | */ |
| 1284 | - public function countAllDepartureAirportCountriesByOwner($owner,$filters = array()) |
|
| 1284 | + public function countAllDepartureAirportCountriesByOwner($owner, $filters = array()) |
|
| 1285 | 1285 | { |
| 1286 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1287 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 1288 | - $query = "SELECT DISTINCT spotter_archive_output.departure_airport_country, COUNT(spotter_archive_output.departure_airport_country) AS airport_departure_country_count, countries.iso3 AS airport_departure_country_iso3 |
|
| 1286 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1287 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 1288 | + $query = "SELECT DISTINCT spotter_archive_output.departure_airport_country, COUNT(spotter_archive_output.departure_airport_country) AS airport_departure_country_count, countries.iso3 AS airport_departure_country_iso3 |
|
| 1289 | 1289 | FROM spotter_archive_output,countries".$filter_query." spotter_archive_output.departure_airport_country <> '' AND spotter_archive_output.owner_name = :owner AND countries.name = spotter_archive_output.departure_airport_country |
| 1290 | 1290 | GROUP BY spotter_archive_output.departure_airport_country, countries.iso3 |
| 1291 | 1291 | ORDER BY airport_departure_country_count DESC"; |
@@ -1301,11 +1301,11 @@ discard block |
||
| 1301 | 1301 | * @param array $filters |
| 1302 | 1302 | * @return array the airport list |
| 1303 | 1303 | */ |
| 1304 | - public function countAllDepartureAirportsByOwner($owner,$filters = array()) |
|
| 1304 | + public function countAllDepartureAirportsByOwner($owner, $filters = array()) |
|
| 1305 | 1305 | { |
| 1306 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1307 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 1308 | - $query = "SELECT DISTINCT spotter_archive_output.departure_airport_icao, COUNT(spotter_archive_output.departure_airport_icao) AS airport_departure_icao_count, spotter_archive_output.departure_airport_name, spotter_archive_output.departure_airport_city, spotter_archive_output.departure_airport_country, airport.latitude, airport.longitude |
|
| 1306 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1307 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 1308 | + $query = "SELECT DISTINCT spotter_archive_output.departure_airport_icao, COUNT(spotter_archive_output.departure_airport_icao) AS airport_departure_icao_count, spotter_archive_output.departure_airport_name, spotter_archive_output.departure_airport_city, spotter_archive_output.departure_airport_country, airport.latitude, airport.longitude |
|
| 1309 | 1309 | FROM spotter_archive_output,airport".$filter_query." spotter_archive_output.departure_airport_name <> '' AND spotter_archive_output.departure_airport_icao <> 'NA' AND spotter_archive_output.departure_airport_icao <> '' AND spotter_archive_output.owner_name = :owner AND airport.icao = spotter_archive_output.departure_airport_icao |
| 1310 | 1310 | GROUP BY spotter_archive_output.departure_airport_icao, spotter_archive_output.departure_airport_name, spotter_archive_output.departure_airport_city, spotter_archive_output.departure_airport_country, airport.latitude, airport.longitude |
| 1311 | 1311 | ORDER BY airport_departure_icao_count DESC"; |
@@ -1313,7 +1313,7 @@ discard block |
||
| 1313 | 1313 | $sth->execute(array(':owner' => $owner)); |
| 1314 | 1314 | $airport_array = array(); |
| 1315 | 1315 | $temp_array = array(); |
| 1316 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1316 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1317 | 1317 | { |
| 1318 | 1318 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
| 1319 | 1319 | $temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
@@ -1334,14 +1334,14 @@ discard block |
||
| 1334 | 1334 | * @param array $filters |
| 1335 | 1335 | * @return array the aircraft manufacturer list |
| 1336 | 1336 | */ |
| 1337 | - public function countAllAircraftManufacturerByOwner($owner,$filters = array()) |
|
| 1337 | + public function countAllAircraftManufacturerByOwner($owner, $filters = array()) |
|
| 1338 | 1338 | { |
| 1339 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1340 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 1341 | - $query = "SELECT DISTINCT spotter_archive_output.aircraft_manufacturer, COUNT(spotter_archive_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
|
| 1339 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1340 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 1341 | + $query = "SELECT DISTINCT spotter_archive_output.aircraft_manufacturer, COUNT(spotter_archive_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
|
| 1342 | 1342 | FROM spotter_archive_output".$filter_query." spotter_archive_output.aircraft_manufacturer <> '' AND spotter_archive_output.owner_name = :owner"; |
| 1343 | 1343 | $query_values = array(); |
| 1344 | - $query_values = array_merge($query_values,array(':owner' => $owner)); |
|
| 1344 | + $query_values = array_merge($query_values, array(':owner' => $owner)); |
|
| 1345 | 1345 | $query .= " GROUP BY spotter_archive_output.aircraft_manufacturer |
| 1346 | 1346 | ORDER BY aircraft_manufacturer_count DESC"; |
| 1347 | 1347 | $sth = $this->db->prepare($query); |
@@ -1356,22 +1356,22 @@ discard block |
||
| 1356 | 1356 | * @param array $filters |
| 1357 | 1357 | * @return array the aircraft list |
| 1358 | 1358 | */ |
| 1359 | - public function countAllAircraftRegistrationByOwner($owner,$filters = array()) |
|
| 1359 | + public function countAllAircraftRegistrationByOwner($owner, $filters = array()) |
|
| 1360 | 1360 | { |
| 1361 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1361 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1362 | 1362 | $Image = new Image($this->db); |
| 1363 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 1364 | - $query = "SELECT DISTINCT spotter_archive_output.aircraft_icao, COUNT(spotter_archive_output.registration) AS registration_count, spotter_archive_output.aircraft_name, spotter_archive_output.aircraft_manufacturer, spotter_archive_output.registration, spotter_archive_output.airline_name |
|
| 1363 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 1364 | + $query = "SELECT DISTINCT spotter_archive_output.aircraft_icao, COUNT(spotter_archive_output.registration) AS registration_count, spotter_archive_output.aircraft_name, spotter_archive_output.aircraft_manufacturer, spotter_archive_output.registration, spotter_archive_output.airline_name |
|
| 1365 | 1365 | FROM spotter_archive_output".$filter_query." spotter_archive_output.registration <> '' AND spotter_archive_output.owner_name = :owner"; |
| 1366 | 1366 | $query_values = array(); |
| 1367 | - $query_values = array_merge($query_values,array(':owner' => $owner)); |
|
| 1367 | + $query_values = array_merge($query_values, array(':owner' => $owner)); |
|
| 1368 | 1368 | $query .= " GROUP BY spotter_archive_output.registration,spotter_archive_output.aircraft_icao, spotter_archive_output.aircraft_name, spotter_archive_output.aircraft_manufacturer, spotter_archive_output.airline_name |
| 1369 | 1369 | ORDER BY registration_count DESC"; |
| 1370 | 1370 | $sth = $this->db->prepare($query); |
| 1371 | 1371 | $sth->execute($query_values); |
| 1372 | 1372 | $aircraft_array = array(); |
| 1373 | 1373 | $temp_array = array(); |
| 1374 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1374 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1375 | 1375 | { |
| 1376 | 1376 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
| 1377 | 1377 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
@@ -1379,7 +1379,7 @@ discard block |
||
| 1379 | 1379 | $temp_array['registration'] = $row['registration']; |
| 1380 | 1380 | $temp_array['airline_name'] = $row['airline_name']; |
| 1381 | 1381 | $temp_array['image_thumbnail'] = ""; |
| 1382 | - if($row['registration'] != "") |
|
| 1382 | + if ($row['registration'] != "") |
|
| 1383 | 1383 | { |
| 1384 | 1384 | $image_array = $Image->getSpotterImage($row['registration']); |
| 1385 | 1385 | if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
@@ -1398,11 +1398,11 @@ discard block |
||
| 1398 | 1398 | * @param array $filters |
| 1399 | 1399 | * @return array the route list |
| 1400 | 1400 | */ |
| 1401 | - public function countAllRoutesByOwner($owner,$filters = array()) |
|
| 1401 | + public function countAllRoutesByOwner($owner, $filters = array()) |
|
| 1402 | 1402 | { |
| 1403 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1404 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 1405 | - $query = "SELECT DISTINCT concat(spotter_archive_output.departure_airport_icao, ' - ', spotter_archive_output.arrival_airport_icao) AS route, count(concat(spotter_archive_output.departure_airport_icao, ' - ', spotter_archive_output.arrival_airport_icao)) AS route_count, spotter_archive_output.departure_airport_icao, spotter_archive_output.departure_airport_name AS airport_departure_name, spotter_archive_output.departure_airport_city AS airport_departure_city, spotter_archive_output.departure_airport_country AS airport_departure_country, spotter_archive_output.arrival_airport_icao, spotter_archive_output.arrival_airport_name AS airport_arrival_name, spotter_archive_output.arrival_airport_city AS airport_arrival_city, spotter_archive_output.arrival_airport_country AS airport_arrival_country |
|
| 1403 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1404 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 1405 | + $query = "SELECT DISTINCT concat(spotter_archive_output.departure_airport_icao, ' - ', spotter_archive_output.arrival_airport_icao) AS route, count(concat(spotter_archive_output.departure_airport_icao, ' - ', spotter_archive_output.arrival_airport_icao)) AS route_count, spotter_archive_output.departure_airport_icao, spotter_archive_output.departure_airport_name AS airport_departure_name, spotter_archive_output.departure_airport_city AS airport_departure_city, spotter_archive_output.departure_airport_country AS airport_departure_country, spotter_archive_output.arrival_airport_icao, spotter_archive_output.arrival_airport_name AS airport_arrival_name, spotter_archive_output.arrival_airport_city AS airport_arrival_city, spotter_archive_output.arrival_airport_country AS airport_arrival_country |
|
| 1406 | 1406 | FROM spotter_archive_output".$filter_query." spotter_archive_output.ident <> '' AND spotter_archive_output.owner_name = :owner |
| 1407 | 1407 | GROUP BY route, spotter_archive_output.departure_airport_icao, spotter_archive_output.departure_airport_name, spotter_archive_output.departure_airport_city, spotter_archive_output.departure_airport_country, spotter_archive_output.arrival_airport_icao, spotter_archive_output.arrival_airport_name, spotter_archive_output.arrival_airport_city, spotter_archive_output.arrival_airport_country |
| 1408 | 1408 | ORDER BY route_count DESC"; |
@@ -1410,7 +1410,7 @@ discard block |
||
| 1410 | 1410 | $sth->execute(array(':owner' => $owner)); |
| 1411 | 1411 | $routes_array = array(); |
| 1412 | 1412 | $temp_array = array(); |
| 1413 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1413 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1414 | 1414 | { |
| 1415 | 1415 | $temp_array['route_count'] = $row['route_count']; |
| 1416 | 1416 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
@@ -1436,8 +1436,8 @@ discard block |
||
| 1436 | 1436 | public function countAllHoursByOwner($owner, $filters = array()) |
| 1437 | 1437 | { |
| 1438 | 1438 | global $globalTimezone, $globalDBdriver; |
| 1439 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1440 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 1439 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1440 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 1441 | 1441 | if ($globalTimezone != '') { |
| 1442 | 1442 | date_default_timezone_set($globalTimezone); |
| 1443 | 1443 | $datetime = new DateTime(); |
@@ -1449,16 +1449,16 @@ discard block |
||
| 1449 | 1449 | GROUP BY hour_name |
| 1450 | 1450 | ORDER BY hour_name ASC"; |
| 1451 | 1451 | } else { |
| 1452 | - $query = "SELECT EXTRACT(HOUR FROM spotter_archive_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1452 | + $query = "SELECT EXTRACT(HOUR FROM spotter_archive_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1453 | 1453 | FROM spotter_archive_output".$filter_query." spotter_archive_output.owner_name = :owner |
| 1454 | 1454 | GROUP BY hour_name |
| 1455 | 1455 | ORDER BY hour_name ASC"; |
| 1456 | 1456 | } |
| 1457 | 1457 | $sth = $this->db->prepare($query); |
| 1458 | - $sth->execute(array(':owner' => $owner,':offset' => $offset)); |
|
| 1458 | + $sth->execute(array(':owner' => $owner, ':offset' => $offset)); |
|
| 1459 | 1459 | $hour_array = array(); |
| 1460 | 1460 | $temp_array = array(); |
| 1461 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1461 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1462 | 1462 | { |
| 1463 | 1463 | $temp_array['hour_name'] = $row['hour_name']; |
| 1464 | 1464 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1474,13 +1474,13 @@ discard block |
||
| 1474 | 1474 | * @param $date |
| 1475 | 1475 | * @return array the spotter information |
| 1476 | 1476 | */ |
| 1477 | - public function getDateArchiveSpotterDataById($id,$date) { |
|
| 1477 | + public function getDateArchiveSpotterDataById($id, $date) { |
|
| 1478 | 1478 | $Spotter = new Spotter($this->db); |
| 1479 | 1479 | date_default_timezone_set('UTC'); |
| 1480 | 1480 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 1481 | - $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
| 1482 | - $date = date('c',$date); |
|
| 1483 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
| 1481 | + $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
| 1482 | + $date = date('c', $date); |
|
| 1483 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
| 1484 | 1484 | return $spotter_array; |
| 1485 | 1485 | } |
| 1486 | 1486 | |
@@ -1491,13 +1491,13 @@ discard block |
||
| 1491 | 1491 | * @param $date |
| 1492 | 1492 | * @return array the spotter information |
| 1493 | 1493 | */ |
| 1494 | - public function getDateArchiveSpotterDataByIdent($ident,$date) { |
|
| 1494 | + public function getDateArchiveSpotterDataByIdent($ident, $date) { |
|
| 1495 | 1495 | $Spotter = new Spotter($this->db); |
| 1496 | 1496 | date_default_timezone_set('UTC'); |
| 1497 | 1497 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 1498 | - $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
| 1499 | - $date = date('c',$date); |
|
| 1500 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 1498 | + $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
| 1499 | + $date = date('c', $date); |
|
| 1500 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 1501 | 1501 | return $spotter_array; |
| 1502 | 1502 | } |
| 1503 | 1503 | |
@@ -1510,14 +1510,14 @@ discard block |
||
| 1510 | 1510 | * @param array $filters |
| 1511 | 1511 | * @return array the spotter information |
| 1512 | 1512 | */ |
| 1513 | - public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) { |
|
| 1513 | + public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) { |
|
| 1514 | 1514 | global $global_query; |
| 1515 | 1515 | $Spotter = new Spotter($this->db); |
| 1516 | 1516 | date_default_timezone_set('UTC'); |
| 1517 | 1517 | $query_values = array(); |
| 1518 | 1518 | $limit_query = ''; |
| 1519 | 1519 | $additional_query = ''; |
| 1520 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1520 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1521 | 1521 | |
| 1522 | 1522 | if ($airport != "") { |
| 1523 | 1523 | if (!is_string($airport)) { |
@@ -1531,8 +1531,8 @@ discard block |
||
| 1531 | 1531 | if ($limit != "") { |
| 1532 | 1532 | $limit_array = explode(",", $limit); |
| 1533 | 1533 | |
| 1534 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1535 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1534 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1535 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1536 | 1536 | |
| 1537 | 1537 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) { |
| 1538 | 1538 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -6,7 +6,9 @@ discard block |
||
| 6 | 6 | public function __construct($dbc = null) { |
| 7 | 7 | $Connection = new Connection($dbc); |
| 8 | 8 | $this->db = $Connection->db; |
| 9 | - if ($this->db === null) die('Error: No DB connection. (SpotterArchive)'); |
|
| 9 | + if ($this->db === null) { |
|
| 10 | + die('Error: No DB connection. (SpotterArchive)'); |
|
| 11 | + } |
|
| 10 | 12 | } |
| 11 | 13 | |
| 12 | 14 | /** |
@@ -29,7 +31,9 @@ discard block |
||
| 29 | 31 | if (isset($filter[0]['source'])) { |
| 30 | 32 | $filters = array_merge($filters,$filter); |
| 31 | 33 | } |
| 32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 34 | + if (is_array($globalFilter)) { |
|
| 35 | + $filter = array_merge($filter,$globalFilter); |
|
| 36 | + } |
|
| 33 | 37 | $filter_query_join = ''; |
| 34 | 38 | $filter_query_where = ''; |
| 35 | 39 | foreach($filters as $flt) { |
@@ -121,8 +125,11 @@ discard block |
||
| 121 | 125 | } |
| 122 | 126 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
| 123 | 127 | } |
| 124 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 125 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 128 | + if ($filter_query_where == '' && $where) { |
|
| 129 | + $filter_query_where = ' WHERE'; |
|
| 130 | + } elseif ($filter_query_where != '' && $and) { |
|
| 131 | + $filter_query_where .= ' AND'; |
|
| 132 | + } |
|
| 126 | 133 | if ($filter_query_where != '') { |
| 127 | 134 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 128 | 135 | } |
@@ -136,10 +143,17 @@ discard block |
||
| 136 | 143 | if ($over_country == '') { |
| 137 | 144 | $Spotter = new Spotter($this->db); |
| 138 | 145 | $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
| 139 | - if (!empty($data_country)) $country = $data_country['iso2']; |
|
| 140 | - else $country = ''; |
|
| 141 | - } else $country = $over_country; |
|
| 142 | - if ($airline_type === NULL) $airline_type =''; |
|
| 146 | + if (!empty($data_country)) { |
|
| 147 | + $country = $data_country['iso2']; |
|
| 148 | + } else { |
|
| 149 | + $country = ''; |
|
| 150 | + } |
|
| 151 | + } else { |
|
| 152 | + $country = $over_country; |
|
| 153 | + } |
|
| 154 | + if ($airline_type === NULL) { |
|
| 155 | + $airline_type =''; |
|
| 156 | + } |
|
| 143 | 157 | |
| 144 | 158 | //if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n"; |
| 145 | 159 | //else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n"; |
@@ -678,7 +692,9 @@ discard block |
||
| 678 | 692 | $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
| 679 | 693 | $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
| 680 | 694 | $translate = $Translation->ident2icao($q_item); |
| 681 | - if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 695 | + if ($translate != $q_item) { |
|
| 696 | + $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 697 | + } |
|
| 682 | 698 | $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
| 683 | 699 | $additional_query .= ")"; |
| 684 | 700 | } |
@@ -858,7 +874,9 @@ discard block |
||
| 858 | 874 | date_default_timezone_set($globalTimezone); |
| 859 | 875 | $datetime = new DateTime(); |
| 860 | 876 | $offset = $datetime->format('P'); |
| 861 | - } else $offset = '+00:00'; |
|
| 877 | + } else { |
|
| 878 | + $offset = '+00:00'; |
|
| 879 | + } |
|
| 862 | 880 | if ($date_array[1] != "") { |
| 863 | 881 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
| 864 | 882 | $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
@@ -1112,9 +1130,13 @@ discard block |
||
| 1112 | 1130 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1113 | 1131 | } |
| 1114 | 1132 | } |
| 1115 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1133 | + if ($sincedate != '') { |
|
| 1134 | + $query .= "AND date > '".$sincedate."' "; |
|
| 1135 | + } |
|
| 1116 | 1136 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1117 | - if ($limit) $query .= " LIMIT 0,10"; |
|
| 1137 | + if ($limit) { |
|
| 1138 | + $query .= " LIMIT 0,10"; |
|
| 1139 | + } |
|
| 1118 | 1140 | |
| 1119 | 1141 | |
| 1120 | 1142 | $sth = $this->db->prepare($query); |
@@ -1158,9 +1180,13 @@ discard block |
||
| 1158 | 1180 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1159 | 1181 | } |
| 1160 | 1182 | } |
| 1161 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1183 | + if ($sincedate != '') { |
|
| 1184 | + $query .= "AND s.date > '".$sincedate."' "; |
|
| 1185 | + } |
|
| 1162 | 1186 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1163 | - if ($limit) $query .= " LIMIT 0,10"; |
|
| 1187 | + if ($limit) { |
|
| 1188 | + $query .= " LIMIT 0,10"; |
|
| 1189 | + } |
|
| 1164 | 1190 | |
| 1165 | 1191 | |
| 1166 | 1192 | $sth = $this->db->prepare($query); |
@@ -1382,8 +1408,11 @@ discard block |
||
| 1382 | 1408 | if($row['registration'] != "") |
| 1383 | 1409 | { |
| 1384 | 1410 | $image_array = $Image->getSpotterImage($row['registration']); |
| 1385 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
| 1386 | - else $temp_array['image_thumbnail'] = ''; |
|
| 1411 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
| 1412 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
| 1413 | + } else { |
|
| 1414 | + $temp_array['image_thumbnail'] = ''; |
|
| 1415 | + } |
|
| 1387 | 1416 | } |
| 1388 | 1417 | $temp_array['registration_count'] = $row['registration_count']; |
| 1389 | 1418 | $aircraft_array[] = $temp_array; |
@@ -1442,7 +1471,9 @@ discard block |
||
| 1442 | 1471 | date_default_timezone_set($globalTimezone); |
| 1443 | 1472 | $datetime = new DateTime(); |
| 1444 | 1473 | $offset = $datetime->format('P'); |
| 1445 | - } else $offset = '+00:00'; |
|
| 1474 | + } else { |
|
| 1475 | + $offset = '+00:00'; |
|
| 1476 | + } |
|
| 1446 | 1477 | if ($globalDBdriver == 'mysql') { |
| 1447 | 1478 | $query = "SELECT HOUR(CONVERT_TZ(spotter_archive_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
| 1448 | 1479 | FROM spotter_archive_output".$filter_query." spotter_archive_output.owner_name = :owner |
@@ -21,13 +21,13 @@ discard block |
||
| 21 | 21 | if ($this->db === null) die('Error: No DB connection. (ATC)'); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Get SQL query part for filter used |
|
| 26 | - * @param array $filter the filter |
|
| 27 | - * @param bool $where |
|
| 28 | - * @param bool $and |
|
| 29 | - * @return String the SQL part |
|
| 30 | - */ |
|
| 24 | + /** |
|
| 25 | + * Get SQL query part for filter used |
|
| 26 | + * @param array $filter the filter |
|
| 27 | + * @param bool $where |
|
| 28 | + * @param bool $and |
|
| 29 | + * @return String the SQL part |
|
| 30 | + */ |
|
| 31 | 31 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 32 | 32 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
| 33 | 33 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * Get all ATC from atc table |
| 56 | 56 | * @return array Return all ATC |
| 57 | 57 | */ |
| 58 | - public function getAll() { |
|
| 58 | + public function getAll() { |
|
| 59 | 59 | $filter_query = $this->getFilter(array()); |
| 60 | 60 | $query = "SELECT * FROM atc".$filter_query; |
| 61 | 61 | $query_values = array(); |
@@ -18,7 +18,9 @@ discard block |
||
| 18 | 18 | public function __construct($dbc = null) { |
| 19 | 19 | $Connection = new Connection($dbc); |
| 20 | 20 | $this->db = $Connection->db; |
| 21 | - if ($this->db === null) die('Error: No DB connection. (ATC)'); |
|
| 21 | + if ($this->db === null) { |
|
| 22 | + die('Error: No DB connection. (ATC)'); |
|
| 23 | + } |
|
| 22 | 24 | } |
| 23 | 25 | |
| 24 | 26 | /** |
@@ -33,20 +35,27 @@ discard block |
||
| 33 | 35 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 34 | 36 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 35 | 37 | foreach($globalStatsFilters[$globalFilterName] as $source) { |
| 36 | - if (isset($source['source'])) $filter['source'][] = $source['source']; |
|
| 38 | + if (isset($source['source'])) { |
|
| 39 | + $filter['source'][] = $source['source']; |
|
| 40 | + } |
|
| 37 | 41 | } |
| 38 | 42 | } else { |
| 39 | 43 | $filter = $globalStatsFilters[$globalFilterName]; |
| 40 | 44 | } |
| 41 | 45 | } |
| 42 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 46 | + if (is_array($globalFilter)) { |
|
| 47 | + $filter = array_merge($filter,$globalFilter); |
|
| 48 | + } |
|
| 43 | 49 | $filter_query_join = ''; |
| 44 | 50 | $filter_query_where = ''; |
| 45 | 51 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 46 | 52 | $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
| 47 | 53 | } |
| 48 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 49 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 54 | + if ($filter_query_where == '' && $where) { |
|
| 55 | + $filter_query_where = ' WHERE'; |
|
| 56 | + } elseif ($filter_query_where != '' && $and) { |
|
| 57 | + $filter_query_where .= ' AND'; |
|
| 58 | + } |
|
| 50 | 59 | $filter_query = $filter_query_join.$filter_query_where; |
| 51 | 60 | return $filter_query; |
| 52 | 61 | } |
@@ -133,7 +142,9 @@ discard block |
||
| 133 | 142 | $info = str_replace('^','<br />',$info); |
| 134 | 143 | $info = str_replace('&sect;','',$info); |
| 135 | 144 | $info = str_replace('"','',$info); |
| 136 | - if ($type == '') $type = NULL; |
|
| 145 | + if ($type == '') { |
|
| 146 | + $type = NULL; |
|
| 147 | + } |
|
| 137 | 148 | $query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)"; |
| 138 | 149 | $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name); |
| 139 | 150 | try { |
@@ -164,7 +175,9 @@ discard block |
||
| 164 | 175 | $info = str_replace('^','<br />',$info); |
| 165 | 176 | $info = str_replace('&sect;','',$info); |
| 166 | 177 | $info = str_replace('"','',$info); |
| 167 | - if ($type == '') $type = NULL; |
|
| 178 | + if ($type == '') { |
|
| 179 | + $type = NULL; |
|
| 180 | + } |
|
| 168 | 181 | $query = "UPDATE atc SET frequency = :frequency,latitude = :latitude,longitude = :longitude,atc_range = :range,info = :info,atc_lastseen = :date,type = :type,ivao_id = :ivao_id,ivao_name = :ivao_name WHERE ident = :ident AND format_source = :format_source AND source_name = :source_name"; |
| 169 | 182 | $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name); |
| 170 | 183 | try { |
@@ -28,22 +28,22 @@ discard block |
||
| 28 | 28 | * @param bool $and |
| 29 | 29 | * @return String the SQL part |
| 30 | 30 | */ |
| 31 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 31 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 32 | 32 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
| 33 | 33 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 34 | 34 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 35 | - foreach($globalStatsFilters[$globalFilterName] as $source) { |
|
| 35 | + foreach ($globalStatsFilters[$globalFilterName] as $source) { |
|
| 36 | 36 | if (isset($source['source'])) $filter['source'][] = $source['source']; |
| 37 | 37 | } |
| 38 | 38 | } else { |
| 39 | 39 | $filter = $globalStatsFilters[$globalFilterName]; |
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 42 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 43 | 43 | $filter_query_join = ''; |
| 44 | 44 | $filter_query_where = ''; |
| 45 | 45 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 46 | - $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 46 | + $filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 47 | 47 | } |
| 48 | 48 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 49 | 49 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | try { |
| 63 | 63 | $sth = $this->db->prepare($query); |
| 64 | 64 | $sth->execute($query_values); |
| 65 | - } catch(PDOException $e) { |
|
| 65 | + } catch (PDOException $e) { |
|
| 66 | 66 | return "error : ".$e->getMessage(); |
| 67 | 67 | } |
| 68 | 68 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -75,13 +75,13 @@ discard block |
||
| 75 | 75 | * @return Array Return ATC |
| 76 | 76 | */ |
| 77 | 77 | public function getById($id) { |
| 78 | - $filter_query = $this->getFilter(array(),true,true); |
|
| 78 | + $filter_query = $this->getFilter(array(), true, true); |
|
| 79 | 79 | $query = "SELECT * FROM atc".$filter_query." atc_id = :id"; |
| 80 | 80 | $query_values = array(':id' => $id); |
| 81 | 81 | try { |
| 82 | 82 | $sth = $this->db->prepare($query); |
| 83 | 83 | $sth->execute($query_values); |
| 84 | - } catch(PDOException $e) { |
|
| 84 | + } catch (PDOException $e) { |
|
| 85 | 85 | return "error : ".$e->getMessage(); |
| 86 | 86 | } |
| 87 | 87 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -94,19 +94,19 @@ discard block |
||
| 94 | 94 | * @param String $format_source Format source |
| 95 | 95 | * @return Array Return ATC |
| 96 | 96 | */ |
| 97 | - public function getByIdent($ident,$format_source = '') { |
|
| 98 | - $filter_query = $this->getFilter(array(),true,true); |
|
| 97 | + public function getByIdent($ident, $format_source = '') { |
|
| 98 | + $filter_query = $this->getFilter(array(), true, true); |
|
| 99 | 99 | if ($format_source == '') { |
| 100 | 100 | $query = "SELECT * FROM atc".$filter_query." ident = :ident"; |
| 101 | 101 | $query_values = array(':ident' => $ident); |
| 102 | 102 | } else { |
| 103 | 103 | $query = "SELECT * FROM atc".$filter_query." ident = :ident AND format_source = :format_source"; |
| 104 | - $query_values = array(':ident' => $ident,':format_source' => $format_source); |
|
| 104 | + $query_values = array(':ident' => $ident, ':format_source' => $format_source); |
|
| 105 | 105 | } |
| 106 | 106 | try { |
| 107 | 107 | $sth = $this->db->prepare($query); |
| 108 | 108 | $sth->execute($query_values); |
| 109 | - } catch(PDOException $e) { |
|
| 109 | + } catch (PDOException $e) { |
|
| 110 | 110 | return "error : ".$e->getMessage(); |
| 111 | 111 | } |
| 112 | 112 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -128,18 +128,18 @@ discard block |
||
| 128 | 128 | * @param String $format_source Format source |
| 129 | 129 | * @param String $source_name Source name |
| 130 | 130 | */ |
| 131 | - public function add($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') { |
|
| 132 | - $info = preg_replace('/[^(\x20-\x7F)]*/','',$info); |
|
| 133 | - $info = str_replace('^','<br />',$info); |
|
| 134 | - $info = str_replace('&sect;','',$info); |
|
| 135 | - $info = str_replace('"','',$info); |
|
| 131 | + public function add($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '', $format_source = '', $source_name = '') { |
|
| 132 | + $info = preg_replace('/[^(\x20-\x7F)]*/', '', $info); |
|
| 133 | + $info = str_replace('^', '<br />', $info); |
|
| 134 | + $info = str_replace('&sect;', '', $info); |
|
| 135 | + $info = str_replace('"', '', $info); |
|
| 136 | 136 | if ($type == '') $type = NULL; |
| 137 | 137 | $query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)"; |
| 138 | - $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name); |
|
| 138 | + $query_values = array(':ident' => $ident, ':frequency' => $frequency, ':latitude' => $latitude, ':longitude' => $longitude, ':range' => $range, ':info' => $info, ':date' => $date, ':ivao_id' => $ivao_id, ':ivao_name' => $ivao_name, ':type' => $type, ':format_source' => $format_source, ':source_name' => $source_name); |
|
| 139 | 139 | try { |
| 140 | 140 | $sth = $this->db->prepare($query); |
| 141 | 141 | $sth->execute($query_values); |
| 142 | - } catch(PDOException $e) { |
|
| 142 | + } catch (PDOException $e) { |
|
| 143 | 143 | return "error : ".$e->getMessage(); |
| 144 | 144 | } |
| 145 | 145 | return ''; |
@@ -160,18 +160,18 @@ discard block |
||
| 160 | 160 | * @param String $format_source Format source |
| 161 | 161 | * @param String $source_name Source name |
| 162 | 162 | */ |
| 163 | - public function update($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') { |
|
| 164 | - $info = preg_replace('/[^(\x20-\x7F)]*/','',$info); |
|
| 165 | - $info = str_replace('^','<br />',$info); |
|
| 166 | - $info = str_replace('&sect;','',$info); |
|
| 167 | - $info = str_replace('"','',$info); |
|
| 163 | + public function update($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '', $format_source = '', $source_name = '') { |
|
| 164 | + $info = preg_replace('/[^(\x20-\x7F)]*/', '', $info); |
|
| 165 | + $info = str_replace('^', '<br />', $info); |
|
| 166 | + $info = str_replace('&sect;', '', $info); |
|
| 167 | + $info = str_replace('"', '', $info); |
|
| 168 | 168 | if ($type == '') $type = NULL; |
| 169 | 169 | $query = "UPDATE atc SET frequency = :frequency,latitude = :latitude,longitude = :longitude,atc_range = :range,info = :info,atc_lastseen = :date,type = :type,ivao_id = :ivao_id,ivao_name = :ivao_name WHERE ident = :ident AND format_source = :format_source AND source_name = :source_name"; |
| 170 | - $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name); |
|
| 170 | + $query_values = array(':ident' => $ident, ':frequency' => $frequency, ':latitude' => $latitude, ':longitude' => $longitude, ':range' => $range, ':info' => $info, ':date' => $date, ':ivao_id' => $ivao_id, ':ivao_name' => $ivao_name, ':type' => $type, ':format_source' => $format_source, ':source_name' => $source_name); |
|
| 171 | 171 | try { |
| 172 | 172 | $sth = $this->db->prepare($query); |
| 173 | 173 | $sth->execute($query_values); |
| 174 | - } catch(PDOException $e) { |
|
| 174 | + } catch (PDOException $e) { |
|
| 175 | 175 | return "error : ".$e->getMessage(); |
| 176 | 176 | } |
| 177 | 177 | return ''; |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | try { |
| 188 | 188 | $sth = $this->db->prepare($query); |
| 189 | 189 | $sth->execute($query_values); |
| 190 | - } catch(PDOException $e) { |
|
| 190 | + } catch (PDOException $e) { |
|
| 191 | 191 | return "error : ".$e->getMessage(); |
| 192 | 192 | } |
| 193 | 193 | return ''; |
@@ -198,13 +198,13 @@ discard block |
||
| 198 | 198 | * @param String $ident Flight ident |
| 199 | 199 | * @param String $format_source Format source |
| 200 | 200 | */ |
| 201 | - public function deleteByIdent($ident,$format_source) { |
|
| 201 | + public function deleteByIdent($ident, $format_source) { |
|
| 202 | 202 | $query = "DELETE FROM atc WHERE ident = :ident AND format_source = :format_source"; |
| 203 | - $query_values = array(':ident' => $ident,':format_source' => $format_source); |
|
| 203 | + $query_values = array(':ident' => $ident, ':format_source' => $format_source); |
|
| 204 | 204 | try { |
| 205 | 205 | $sth = $this->db->prepare($query); |
| 206 | 206 | $sth->execute($query_values); |
| 207 | - } catch(PDOException $e) { |
|
| 207 | + } catch (PDOException $e) { |
|
| 208 | 208 | return "error : ".$e->getMessage(); |
| 209 | 209 | } |
| 210 | 210 | return ''; |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | try { |
| 220 | 220 | $sth = $this->db->prepare($query); |
| 221 | 221 | $sth->execute($query_values); |
| 222 | - } catch(PDOException $e) { |
|
| 222 | + } catch (PDOException $e) { |
|
| 223 | 223 | return "error : ".$e->getMessage(); |
| 224 | 224 | } |
| 225 | 225 | return ''; |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | try { |
| 239 | 239 | $sth = $this->db->prepare($query); |
| 240 | 240 | $sth->execute(); |
| 241 | - } catch(PDOException $e) { |
|
| 241 | + } catch (PDOException $e) { |
|
| 242 | 242 | return "error"; |
| 243 | 243 | } |
| 244 | 244 | return "success"; |
@@ -13,7 +13,9 @@ discard block |
||
| 13 | 13 | public function __construct($dbc = null) { |
| 14 | 14 | $Connection = new Connection($dbc); |
| 15 | 15 | $this->db = $Connection->db; |
| 16 | - if ($this->db === null) die('Error: No DB connection. (MarineArchive)'); |
|
| 16 | + if ($this->db === null) { |
|
| 17 | + die('Error: No DB connection. (MarineArchive)'); |
|
| 18 | + } |
|
| 17 | 19 | } |
| 18 | 20 | |
| 19 | 21 | /** |
@@ -36,7 +38,9 @@ discard block |
||
| 36 | 38 | if (isset($filter[0]['source'])) { |
| 37 | 39 | $filters = array_merge($filters,$filter); |
| 38 | 40 | } |
| 39 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 41 | + if (is_array($globalFilter)) { |
|
| 42 | + $filter = array_merge($filter,$globalFilter); |
|
| 43 | + } |
|
| 40 | 44 | $filter_query_join = ''; |
| 41 | 45 | $filter_query_where = ''; |
| 42 | 46 | foreach($filters as $flt) { |
@@ -82,8 +86,11 @@ discard block |
||
| 82 | 86 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 83 | 87 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 84 | 88 | } |
| 85 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 86 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 89 | + if ($filter_query_where == '' && $where) { |
|
| 90 | + $filter_query_where = ' WHERE'; |
|
| 91 | + } elseif ($filter_query_where != '' && $and) { |
|
| 92 | + $filter_query_where .= ' AND'; |
|
| 93 | + } |
|
| 87 | 94 | if ($filter_query_where != '') { |
| 88 | 95 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 89 | 96 | } |
@@ -129,9 +136,14 @@ discard block |
||
| 129 | 136 | if ($over_country == '') { |
| 130 | 137 | $Marine = new Marine($this->db); |
| 131 | 138 | $data_country = $Marine->getCountryFromLatitudeLongitude($latitude,$longitude); |
| 132 | - if (!empty($data_country)) $country = $data_country['iso2']; |
|
| 133 | - else $country = ''; |
|
| 134 | - } else $country = $over_country; |
|
| 139 | + if (!empty($data_country)) { |
|
| 140 | + $country = $data_country['iso2']; |
|
| 141 | + } else { |
|
| 142 | + $country = ''; |
|
| 143 | + } |
|
| 144 | + } else { |
|
| 145 | + $country = $over_country; |
|
| 146 | + } |
|
| 135 | 147 | |
| 136 | 148 | //$country = $over_country; |
| 137 | 149 | // Route is not added in marine_archive |
@@ -661,7 +673,9 @@ discard block |
||
| 661 | 673 | $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR "; |
| 662 | 674 | $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR "; |
| 663 | 675 | $translate = $Translation->ident2icao($q_item); |
| 664 | - if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
| 676 | + if ($translate != $q_item) { |
|
| 677 | + $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
| 678 | + } |
|
| 665 | 679 | $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')"; |
| 666 | 680 | $additional_query .= ")"; |
| 667 | 681 | } |
@@ -879,7 +893,9 @@ discard block |
||
| 879 | 893 | date_default_timezone_set($globalTimezone); |
| 880 | 894 | $datetime = new DateTime(); |
| 881 | 895 | $offset = $datetime->format('P'); |
| 882 | - } else $offset = '+00:00'; |
|
| 896 | + } else { |
|
| 897 | + $offset = '+00:00'; |
|
| 898 | + } |
|
| 883 | 899 | |
| 884 | 900 | |
| 885 | 901 | if ($date_array[1] != "") |
@@ -1165,9 +1181,13 @@ discard block |
||
| 1165 | 1181 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1166 | 1182 | } |
| 1167 | 1183 | } |
| 1168 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1184 | + if ($sincedate != '') { |
|
| 1185 | + $query .= "AND date > '".$sincedate."' "; |
|
| 1186 | + } |
|
| 1169 | 1187 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1170 | - if ($limit) $query .= " LIMIT 0,10"; |
|
| 1188 | + if ($limit) { |
|
| 1189 | + $query .= " LIMIT 0,10"; |
|
| 1190 | + } |
|
| 1171 | 1191 | |
| 1172 | 1192 | |
| 1173 | 1193 | $sth = $this->db->prepare($query); |
@@ -1213,9 +1233,13 @@ discard block |
||
| 1213 | 1233 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1214 | 1234 | } |
| 1215 | 1235 | } |
| 1216 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1236 | + if ($sincedate != '') { |
|
| 1237 | + $query .= "AND s.date > '".$sincedate."' "; |
|
| 1238 | + } |
|
| 1217 | 1239 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1218 | - if ($limit) $query .= " LIMIT 0,10"; |
|
| 1240 | + if ($limit) { |
|
| 1241 | + $query .= " LIMIT 0,10"; |
|
| 1242 | + } |
|
| 1219 | 1243 | |
| 1220 | 1244 | |
| 1221 | 1245 | $sth = $this->db->prepare($query); |
@@ -16,13 +16,13 @@ discard block |
||
| 16 | 16 | if ($this->db === null) die('Error: No DB connection. (MarineArchive)'); |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Get SQL query part for filter used |
|
| 21 | - * @param array $filter the filter |
|
| 22 | - * @param bool $where |
|
| 23 | - * @param bool $and |
|
| 24 | - * @return string the SQL part |
|
| 25 | - */ |
|
| 19 | + /** |
|
| 20 | + * Get SQL query part for filter used |
|
| 21 | + * @param array $filter the filter |
|
| 22 | + * @param bool $where |
|
| 23 | + * @param bool $and |
|
| 24 | + * @return string the SQL part |
|
| 25 | + */ |
|
| 26 | 26 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 27 | 27 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 28 | 28 | $filters = array(); |
@@ -91,40 +91,40 @@ discard block |
||
| 91 | 91 | return $filter_query; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * Add to Mariche archive |
|
| 96 | - * |
|
| 97 | - * @param string $fammarine_id |
|
| 98 | - * @param string $ident |
|
| 99 | - * @param string $latitude |
|
| 100 | - * @param string $longitude |
|
| 101 | - * @param string $heading |
|
| 102 | - * @param string $groundspeed |
|
| 103 | - * @param string $date |
|
| 104 | - * @param bool $putinarchive |
|
| 105 | - * @param string $mmsi |
|
| 106 | - * @param string $type |
|
| 107 | - * @param string $typeid |
|
| 108 | - * @param string $imo |
|
| 109 | - * @param string $callsign |
|
| 110 | - * @param string $arrival_code |
|
| 111 | - * @param string $arrival_date |
|
| 112 | - * @param string $status |
|
| 113 | - * @param string $statusid |
|
| 114 | - * @param bool $noarchive |
|
| 115 | - * @param string $format_source |
|
| 116 | - * @param string $source_name |
|
| 117 | - * @param string $over_country |
|
| 118 | - * @param string $captain_id |
|
| 119 | - * @param string $captain_name |
|
| 120 | - * @param string $race_id |
|
| 121 | - * @param string $race_name |
|
| 122 | - * @param string $distance |
|
| 123 | - * @param string $race_rank |
|
| 124 | - * @param string $race_time |
|
| 125 | - * @return string |
|
| 126 | - */ |
|
| 127 | - public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '', $captain_id = '', $captain_name = '', $race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '') { |
|
| 94 | + /** |
|
| 95 | + * Add to Mariche archive |
|
| 96 | + * |
|
| 97 | + * @param string $fammarine_id |
|
| 98 | + * @param string $ident |
|
| 99 | + * @param string $latitude |
|
| 100 | + * @param string $longitude |
|
| 101 | + * @param string $heading |
|
| 102 | + * @param string $groundspeed |
|
| 103 | + * @param string $date |
|
| 104 | + * @param bool $putinarchive |
|
| 105 | + * @param string $mmsi |
|
| 106 | + * @param string $type |
|
| 107 | + * @param string $typeid |
|
| 108 | + * @param string $imo |
|
| 109 | + * @param string $callsign |
|
| 110 | + * @param string $arrival_code |
|
| 111 | + * @param string $arrival_date |
|
| 112 | + * @param string $status |
|
| 113 | + * @param string $statusid |
|
| 114 | + * @param bool $noarchive |
|
| 115 | + * @param string $format_source |
|
| 116 | + * @param string $source_name |
|
| 117 | + * @param string $over_country |
|
| 118 | + * @param string $captain_id |
|
| 119 | + * @param string $captain_name |
|
| 120 | + * @param string $race_id |
|
| 121 | + * @param string $race_name |
|
| 122 | + * @param string $distance |
|
| 123 | + * @param string $race_rank |
|
| 124 | + * @param string $race_time |
|
| 125 | + * @return string |
|
| 126 | + */ |
|
| 127 | + public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '', $captain_id = '', $captain_name = '', $race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '') { |
|
| 128 | 128 | require_once(dirname(__FILE__).'/class.Marine.php'); |
| 129 | 129 | if ($over_country == '') { |
| 130 | 130 | $Marine = new Marine($this->db); |
@@ -149,42 +149,42 @@ discard block |
||
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | |
| 152 | - /** |
|
| 153 | - * Gets all the spotter information based on a particular callsign |
|
| 154 | - * |
|
| 155 | - * @param $ident |
|
| 156 | - * @return array the spotter information |
|
| 157 | - */ |
|
| 158 | - public function getLastArchiveMarineDataByIdent($ident) |
|
| 159 | - { |
|
| 160 | - $Marine = new Marine($this->db); |
|
| 161 | - date_default_timezone_set('UTC'); |
|
| 162 | - |
|
| 163 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 164 | - //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
| 165 | - $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 166 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident)); |
|
| 167 | - return $spotter_array; |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - |
|
| 171 | - /** |
|
| 172 | - * Gets last the spotter information based on a particular id |
|
| 173 | - * |
|
| 174 | - * @param $id |
|
| 175 | - * @return array the spotter information |
|
| 176 | - */ |
|
| 177 | - public function getLastArchiveMarineDataById($id) |
|
| 178 | - { |
|
| 179 | - $Marine = new Marine($this->db); |
|
| 180 | - date_default_timezone_set('UTC'); |
|
| 181 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 182 | - //$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id"; |
|
| 183 | - //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
| 184 | - $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 152 | + /** |
|
| 153 | + * Gets all the spotter information based on a particular callsign |
|
| 154 | + * |
|
| 155 | + * @param $ident |
|
| 156 | + * @return array the spotter information |
|
| 157 | + */ |
|
| 158 | + public function getLastArchiveMarineDataByIdent($ident) |
|
| 159 | + { |
|
| 160 | + $Marine = new Marine($this->db); |
|
| 161 | + date_default_timezone_set('UTC'); |
|
| 162 | + |
|
| 163 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 164 | + //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
| 165 | + $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 166 | + $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident)); |
|
| 167 | + return $spotter_array; |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + |
|
| 171 | + /** |
|
| 172 | + * Gets last the spotter information based on a particular id |
|
| 173 | + * |
|
| 174 | + * @param $id |
|
| 175 | + * @return array the spotter information |
|
| 176 | + */ |
|
| 177 | + public function getLastArchiveMarineDataById($id) |
|
| 178 | + { |
|
| 179 | + $Marine = new Marine($this->db); |
|
| 180 | + date_default_timezone_set('UTC'); |
|
| 181 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 182 | + //$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id"; |
|
| 183 | + //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
| 184 | + $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 185 | 185 | |
| 186 | 186 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
| 187 | - /* |
|
| 187 | + /* |
|
| 188 | 188 | try { |
| 189 | 189 | $Connection = new Connection(); |
| 190 | 190 | $sth = Connection->$db->prepare($query); |
@@ -194,196 +194,196 @@ discard block |
||
| 194 | 194 | } |
| 195 | 195 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 196 | 196 | */ |
| 197 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); |
|
| 198 | - return $spotter_array; |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - /** |
|
| 202 | - * Gets all the spotter information based on a particular id |
|
| 203 | - * |
|
| 204 | - * @param $id |
|
| 205 | - * @return array the spotter information |
|
| 206 | - */ |
|
| 207 | - public function getAllArchiveMarineDataById($id) |
|
| 197 | + $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); |
|
| 198 | + return $spotter_array; |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + /** |
|
| 202 | + * Gets all the spotter information based on a particular id |
|
| 203 | + * |
|
| 204 | + * @param $id |
|
| 205 | + * @return array the spotter information |
|
| 206 | + */ |
|
| 207 | + public function getAllArchiveMarineDataById($id) |
|
| 208 | 208 | { |
| 209 | - date_default_timezone_set('UTC'); |
|
| 210 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 211 | - $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 209 | + date_default_timezone_set('UTC'); |
|
| 210 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 211 | + $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 212 | 212 | |
| 213 | 213 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
| 214 | 214 | |
| 215 | - try { |
|
| 216 | - $sth = $this->db->prepare($query); |
|
| 217 | - $sth->execute(array(':id' => $id)); |
|
| 218 | - } catch(PDOException $e) { |
|
| 219 | - echo $e->getMessage(); |
|
| 220 | - die; |
|
| 221 | - } |
|
| 222 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 223 | - return $spotter_array; |
|
| 215 | + try { |
|
| 216 | + $sth = $this->db->prepare($query); |
|
| 217 | + $sth->execute(array(':id' => $id)); |
|
| 218 | + } catch(PDOException $e) { |
|
| 219 | + echo $e->getMessage(); |
|
| 220 | + die; |
|
| 221 | + } |
|
| 222 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 223 | + return $spotter_array; |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - /** |
|
| 227 | - * Gets coordinate & time spotter information based on a particular id |
|
| 228 | - * |
|
| 229 | - * @param $id |
|
| 230 | - * @return array the spotter information |
|
| 231 | - */ |
|
| 232 | - public function getCoordArchiveMarineDataById($id) |
|
| 233 | - { |
|
| 234 | - date_default_timezone_set('UTC'); |
|
| 235 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 236 | - $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
| 226 | + /** |
|
| 227 | + * Gets coordinate & time spotter information based on a particular id |
|
| 228 | + * |
|
| 229 | + * @param $id |
|
| 230 | + * @return array the spotter information |
|
| 231 | + */ |
|
| 232 | + public function getCoordArchiveMarineDataById($id) |
|
| 233 | + { |
|
| 234 | + date_default_timezone_set('UTC'); |
|
| 235 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 236 | + $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
| 237 | 237 | |
| 238 | 238 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
| 239 | 239 | |
| 240 | - try { |
|
| 241 | - $sth = $this->db->prepare($query); |
|
| 242 | - $sth->execute(array(':id' => $id)); |
|
| 243 | - } catch(PDOException $e) { |
|
| 244 | - echo $e->getMessage(); |
|
| 245 | - die; |
|
| 246 | - } |
|
| 247 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 248 | - |
|
| 249 | - return $spotter_array; |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - |
|
| 253 | - /** |
|
| 254 | - * Gets altitude information based on a particular callsign |
|
| 255 | - * |
|
| 256 | - * @param $ident |
|
| 257 | - * @return array the spotter information |
|
| 258 | - */ |
|
| 259 | - public function getAltitudeArchiveMarineDataByIdent($ident) |
|
| 260 | - { |
|
| 261 | - |
|
| 262 | - date_default_timezone_set('UTC'); |
|
| 263 | - |
|
| 264 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 265 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 266 | - |
|
| 267 | - try { |
|
| 268 | - $sth = $this->db->prepare($query); |
|
| 269 | - $sth->execute(array(':ident' => $ident)); |
|
| 270 | - } catch(PDOException $e) { |
|
| 271 | - echo $e->getMessage(); |
|
| 272 | - die; |
|
| 273 | - } |
|
| 274 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 275 | - |
|
| 276 | - return $spotter_array; |
|
| 277 | - } |
|
| 278 | - |
|
| 279 | - /** |
|
| 280 | - * Gets altitude information based on a particular id |
|
| 281 | - * |
|
| 282 | - * @param $id |
|
| 283 | - * @return array the spotter information |
|
| 284 | - */ |
|
| 285 | - public function getAltitudeArchiveMarineDataById($id) |
|
| 286 | - { |
|
| 287 | - |
|
| 288 | - date_default_timezone_set('UTC'); |
|
| 289 | - |
|
| 290 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 291 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 292 | - |
|
| 293 | - try { |
|
| 294 | - $sth = $this->db->prepare($query); |
|
| 295 | - $sth->execute(array(':id' => $id)); |
|
| 296 | - } catch(PDOException $e) { |
|
| 297 | - echo $e->getMessage(); |
|
| 298 | - die; |
|
| 299 | - } |
|
| 300 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 301 | - |
|
| 302 | - return $spotter_array; |
|
| 303 | - } |
|
| 304 | - |
|
| 305 | - /** |
|
| 306 | - * Gets altitude & speed information based on a particular id |
|
| 307 | - * |
|
| 308 | - * @param $id |
|
| 309 | - * @return array the spotter information |
|
| 310 | - */ |
|
| 311 | - public function getAltitudeSpeedArchiveMarineDataById($id) |
|
| 312 | - { |
|
| 313 | - date_default_timezone_set('UTC'); |
|
| 314 | - |
|
| 315 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 316 | - $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 317 | - |
|
| 318 | - try { |
|
| 319 | - $sth = $this->db->prepare($query); |
|
| 320 | - $sth->execute(array(':id' => $id)); |
|
| 321 | - } catch(PDOException $e) { |
|
| 322 | - echo $e->getMessage(); |
|
| 323 | - die; |
|
| 324 | - } |
|
| 325 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 326 | - |
|
| 327 | - return $spotter_array; |
|
| 328 | - } |
|
| 329 | - |
|
| 330 | - |
|
| 331 | - /** |
|
| 332 | - * Gets altitude information based on a particular callsign |
|
| 333 | - * |
|
| 334 | - * @param $ident |
|
| 335 | - * @return array the spotter information |
|
| 336 | - */ |
|
| 337 | - public function getLastAltitudeArchiveMarineDataByIdent($ident) |
|
| 338 | - { |
|
| 339 | - |
|
| 340 | - date_default_timezone_set('UTC'); |
|
| 341 | - |
|
| 342 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 343 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
| 240 | + try { |
|
| 241 | + $sth = $this->db->prepare($query); |
|
| 242 | + $sth->execute(array(':id' => $id)); |
|
| 243 | + } catch(PDOException $e) { |
|
| 244 | + echo $e->getMessage(); |
|
| 245 | + die; |
|
| 246 | + } |
|
| 247 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 248 | + |
|
| 249 | + return $spotter_array; |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + |
|
| 253 | + /** |
|
| 254 | + * Gets altitude information based on a particular callsign |
|
| 255 | + * |
|
| 256 | + * @param $ident |
|
| 257 | + * @return array the spotter information |
|
| 258 | + */ |
|
| 259 | + public function getAltitudeArchiveMarineDataByIdent($ident) |
|
| 260 | + { |
|
| 261 | + |
|
| 262 | + date_default_timezone_set('UTC'); |
|
| 263 | + |
|
| 264 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 265 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 266 | + |
|
| 267 | + try { |
|
| 268 | + $sth = $this->db->prepare($query); |
|
| 269 | + $sth->execute(array(':ident' => $ident)); |
|
| 270 | + } catch(PDOException $e) { |
|
| 271 | + echo $e->getMessage(); |
|
| 272 | + die; |
|
| 273 | + } |
|
| 274 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 275 | + |
|
| 276 | + return $spotter_array; |
|
| 277 | + } |
|
| 278 | + |
|
| 279 | + /** |
|
| 280 | + * Gets altitude information based on a particular id |
|
| 281 | + * |
|
| 282 | + * @param $id |
|
| 283 | + * @return array the spotter information |
|
| 284 | + */ |
|
| 285 | + public function getAltitudeArchiveMarineDataById($id) |
|
| 286 | + { |
|
| 287 | + |
|
| 288 | + date_default_timezone_set('UTC'); |
|
| 289 | + |
|
| 290 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 291 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 292 | + |
|
| 293 | + try { |
|
| 294 | + $sth = $this->db->prepare($query); |
|
| 295 | + $sth->execute(array(':id' => $id)); |
|
| 296 | + } catch(PDOException $e) { |
|
| 297 | + echo $e->getMessage(); |
|
| 298 | + die; |
|
| 299 | + } |
|
| 300 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 301 | + |
|
| 302 | + return $spotter_array; |
|
| 303 | + } |
|
| 304 | + |
|
| 305 | + /** |
|
| 306 | + * Gets altitude & speed information based on a particular id |
|
| 307 | + * |
|
| 308 | + * @param $id |
|
| 309 | + * @return array the spotter information |
|
| 310 | + */ |
|
| 311 | + public function getAltitudeSpeedArchiveMarineDataById($id) |
|
| 312 | + { |
|
| 313 | + date_default_timezone_set('UTC'); |
|
| 314 | + |
|
| 315 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 316 | + $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 317 | + |
|
| 318 | + try { |
|
| 319 | + $sth = $this->db->prepare($query); |
|
| 320 | + $sth->execute(array(':id' => $id)); |
|
| 321 | + } catch(PDOException $e) { |
|
| 322 | + echo $e->getMessage(); |
|
| 323 | + die; |
|
| 324 | + } |
|
| 325 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 326 | + |
|
| 327 | + return $spotter_array; |
|
| 328 | + } |
|
| 329 | + |
|
| 330 | + |
|
| 331 | + /** |
|
| 332 | + * Gets altitude information based on a particular callsign |
|
| 333 | + * |
|
| 334 | + * @param $ident |
|
| 335 | + * @return array the spotter information |
|
| 336 | + */ |
|
| 337 | + public function getLastAltitudeArchiveMarineDataByIdent($ident) |
|
| 338 | + { |
|
| 339 | + |
|
| 340 | + date_default_timezone_set('UTC'); |
|
| 341 | + |
|
| 342 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 343 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
| 344 | 344 | // $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident"; |
| 345 | 345 | |
| 346 | - try { |
|
| 347 | - $sth = $this->db->prepare($query); |
|
| 348 | - $sth->execute(array(':ident' => $ident)); |
|
| 349 | - } catch(PDOException $e) { |
|
| 350 | - echo $e->getMessage(); |
|
| 351 | - die; |
|
| 352 | - } |
|
| 353 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 354 | - |
|
| 355 | - return $spotter_array; |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - |
|
| 359 | - /** |
|
| 360 | - * Gets all the archive spotter information |
|
| 361 | - * |
|
| 362 | - * @param $ident |
|
| 363 | - * @param $fammarine_id |
|
| 364 | - * @param $date |
|
| 365 | - * @return array the spotter information |
|
| 366 | - */ |
|
| 367 | - public function getMarineArchiveData($ident,$fammarine_id,$date) |
|
| 368 | - { |
|
| 369 | - $Marine = new Marine($this->db); |
|
| 370 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 371 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate"; |
|
| 372 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%')); |
|
| 373 | - return $spotter_array; |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - /** |
|
| 377 | - * Delete all tracking data |
|
| 378 | - * |
|
| 379 | - */ |
|
| 380 | - public function deleteMarineArchiveTrackData() |
|
| 381 | - { |
|
| 382 | - global $globalArchiveKeepTrackMonths, $globalDBdriver; |
|
| 383 | - if ($globalDBdriver == 'mysql') { |
|
| 384 | - $query = 'DELETE FROM marine_archive WHERE marine_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)'; |
|
| 385 | - } else { |
|
| 386 | - $query = "DELETE FROM marine_archive WHERE marine_archive_id IN (SELECT marine_archive_id FROM marine_archive WHERE marine_archive.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepTrackMonths." MONTH' LIMIT 10000)"; |
|
| 346 | + try { |
|
| 347 | + $sth = $this->db->prepare($query); |
|
| 348 | + $sth->execute(array(':ident' => $ident)); |
|
| 349 | + } catch(PDOException $e) { |
|
| 350 | + echo $e->getMessage(); |
|
| 351 | + die; |
|
| 352 | + } |
|
| 353 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 354 | + |
|
| 355 | + return $spotter_array; |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + |
|
| 359 | + /** |
|
| 360 | + * Gets all the archive spotter information |
|
| 361 | + * |
|
| 362 | + * @param $ident |
|
| 363 | + * @param $fammarine_id |
|
| 364 | + * @param $date |
|
| 365 | + * @return array the spotter information |
|
| 366 | + */ |
|
| 367 | + public function getMarineArchiveData($ident,$fammarine_id,$date) |
|
| 368 | + { |
|
| 369 | + $Marine = new Marine($this->db); |
|
| 370 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 371 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate"; |
|
| 372 | + $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%')); |
|
| 373 | + return $spotter_array; |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + /** |
|
| 377 | + * Delete all tracking data |
|
| 378 | + * |
|
| 379 | + */ |
|
| 380 | + public function deleteMarineArchiveTrackData() |
|
| 381 | + { |
|
| 382 | + global $globalArchiveKeepTrackMonths, $globalDBdriver; |
|
| 383 | + if ($globalDBdriver == 'mysql') { |
|
| 384 | + $query = 'DELETE FROM marine_archive WHERE marine_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)'; |
|
| 385 | + } else { |
|
| 386 | + $query = "DELETE FROM marine_archive WHERE marine_archive_id IN (SELECT marine_archive_id FROM marine_archive WHERE marine_archive.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepTrackMonths." MONTH' LIMIT 10000)"; |
|
| 387 | 387 | } |
| 388 | 388 | try { |
| 389 | 389 | $sth = $this->db->prepare($query); |
@@ -394,42 +394,42 @@ discard block |
||
| 394 | 394 | } |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - /** |
|
| 398 | - * Gets Minimal Live Marine data |
|
| 399 | - * |
|
| 400 | - * @param $begindate |
|
| 401 | - * @param $enddate |
|
| 402 | - * @param array $filter |
|
| 403 | - * @return array the spotter information |
|
| 404 | - */ |
|
| 405 | - public function getMinLiveMarineData($begindate,$enddate,$filter = array()) |
|
| 406 | - { |
|
| 407 | - global $globalDBdriver; |
|
| 408 | - date_default_timezone_set('UTC'); |
|
| 409 | - |
|
| 410 | - $filter_query = ''; |
|
| 411 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 412 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 413 | - } |
|
| 414 | - // Use spotter_output also ? |
|
| 415 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 416 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 417 | - } |
|
| 418 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 419 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
| 420 | - } |
|
| 421 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 422 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 423 | - } |
|
| 424 | - |
|
| 425 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 426 | - if ($globalDBdriver == 'mysql') { |
|
| 427 | - /* |
|
| 397 | + /** |
|
| 398 | + * Gets Minimal Live Marine data |
|
| 399 | + * |
|
| 400 | + * @param $begindate |
|
| 401 | + * @param $enddate |
|
| 402 | + * @param array $filter |
|
| 403 | + * @return array the spotter information |
|
| 404 | + */ |
|
| 405 | + public function getMinLiveMarineData($begindate,$enddate,$filter = array()) |
|
| 406 | + { |
|
| 407 | + global $globalDBdriver; |
|
| 408 | + date_default_timezone_set('UTC'); |
|
| 409 | + |
|
| 410 | + $filter_query = ''; |
|
| 411 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 412 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 413 | + } |
|
| 414 | + // Use spotter_output also ? |
|
| 415 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 416 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 417 | + } |
|
| 418 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 419 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
| 420 | + } |
|
| 421 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 422 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 423 | + } |
|
| 424 | + |
|
| 425 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 426 | + if ($globalDBdriver == 'mysql') { |
|
| 427 | + /* |
|
| 428 | 428 | $query = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk |
| 429 | 429 | FROM marine_archive |
| 430 | 430 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
| 431 | 431 | */ |
| 432 | - /* |
|
| 432 | + /* |
|
| 433 | 433 | $query = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk |
| 434 | 434 | FROM marine_archive |
| 435 | 435 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate |
@@ -438,541 +438,541 @@ discard block |
||
| 438 | 438 | GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id |
| 439 | 439 | AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
| 440 | 440 | */ |
| 441 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 441 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 442 | 442 | FROM marine_archive |
| 443 | 443 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
| 444 | 444 | WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
| 445 | 445 | '.$filter_query.' ORDER BY fammarine_id'; |
| 446 | - } else { |
|
| 447 | - //$query = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao'; |
|
| 448 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 446 | + } else { |
|
| 447 | + //$query = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao'; |
|
| 448 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 449 | 449 | FROM marine_archive |
| 450 | 450 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
| 451 | 451 | WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".' |
| 452 | 452 | '.$filter_query.' ORDER BY fammarine_id'; |
| 453 | - } |
|
| 454 | - //echo $query; |
|
| 455 | - try { |
|
| 456 | - $sth = $this->db->prepare($query); |
|
| 457 | - $sth->execute(); |
|
| 458 | - } catch(PDOException $e) { |
|
| 459 | - echo $e->getMessage(); |
|
| 460 | - die; |
|
| 461 | - } |
|
| 462 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 463 | - |
|
| 464 | - return $spotter_array; |
|
| 465 | - } |
|
| 466 | - |
|
| 467 | - /** |
|
| 468 | - * Gets Minimal Live Marine data |
|
| 469 | - * |
|
| 470 | - * @param $begindate |
|
| 471 | - * @param $enddate |
|
| 472 | - * @param array $filter |
|
| 473 | - * @return array the spotter information |
|
| 474 | - */ |
|
| 475 | - public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array()) |
|
| 476 | - { |
|
| 477 | - global $globalDBdriver; |
|
| 478 | - date_default_timezone_set('UTC'); |
|
| 479 | - |
|
| 480 | - $filter_query = ''; |
|
| 481 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 482 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 483 | - } |
|
| 484 | - // Should use spotter_output also ? |
|
| 485 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 486 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 487 | - } |
|
| 488 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 489 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
| 490 | - } |
|
| 491 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 492 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 493 | - } |
|
| 494 | - |
|
| 495 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 496 | - if ($globalDBdriver == 'mysql') { |
|
| 497 | - /* |
|
| 453 | + } |
|
| 454 | + //echo $query; |
|
| 455 | + try { |
|
| 456 | + $sth = $this->db->prepare($query); |
|
| 457 | + $sth->execute(); |
|
| 458 | + } catch(PDOException $e) { |
|
| 459 | + echo $e->getMessage(); |
|
| 460 | + die; |
|
| 461 | + } |
|
| 462 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 463 | + |
|
| 464 | + return $spotter_array; |
|
| 465 | + } |
|
| 466 | + |
|
| 467 | + /** |
|
| 468 | + * Gets Minimal Live Marine data |
|
| 469 | + * |
|
| 470 | + * @param $begindate |
|
| 471 | + * @param $enddate |
|
| 472 | + * @param array $filter |
|
| 473 | + * @return array the spotter information |
|
| 474 | + */ |
|
| 475 | + public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array()) |
|
| 476 | + { |
|
| 477 | + global $globalDBdriver; |
|
| 478 | + date_default_timezone_set('UTC'); |
|
| 479 | + |
|
| 480 | + $filter_query = ''; |
|
| 481 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 482 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 483 | + } |
|
| 484 | + // Should use spotter_output also ? |
|
| 485 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 486 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 487 | + } |
|
| 488 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 489 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
| 490 | + } |
|
| 491 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 492 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 493 | + } |
|
| 494 | + |
|
| 495 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 496 | + if ($globalDBdriver == 'mysql') { |
|
| 497 | + /* |
|
| 498 | 498 | $query = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk |
| 499 | 499 | FROM marine_archive |
| 500 | 500 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
| 501 | 501 | */ |
| 502 | - $query = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk |
|
| 502 | + $query = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk |
|
| 503 | 503 | FROM marine_archive_output |
| 504 | 504 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive_output.aircraft_icao = a.icao |
| 505 | 505 | WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
| 506 | 506 | '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow'; |
| 507 | 507 | |
| 508 | - } else { |
|
| 509 | - //$query = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow FROM marine_archive_output INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive_output.fammarine_id = s.fammarine_id AND marine_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao'; |
|
| 510 | - /* |
|
| 508 | + } else { |
|
| 509 | + //$query = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow FROM marine_archive_output INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive_output.fammarine_id = s.fammarine_id AND marine_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao'; |
|
| 510 | + /* |
|
| 511 | 511 | $query = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
| 512 | 512 | FROM marine_archive_output |
| 513 | 513 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao |
| 514 | 514 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
| 515 | 515 | '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow'; |
| 516 | 516 | */ |
| 517 | - $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
| 517 | + $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
| 518 | 518 | FROM marine_archive_output |
| 519 | 519 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao |
| 520 | 520 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
| 521 | 521 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
| 522 | 522 | // .' GROUP BY spotter_output.fammarine_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow'; |
| 523 | 523 | |
| 524 | - } |
|
| 525 | - //echo $query; |
|
| 526 | - try { |
|
| 527 | - $sth = $this->db->prepare($query); |
|
| 528 | - $sth->execute(); |
|
| 529 | - } catch(PDOException $e) { |
|
| 530 | - echo $e->getMessage(); |
|
| 531 | - die; |
|
| 532 | - } |
|
| 533 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 534 | - |
|
| 535 | - return $spotter_array; |
|
| 536 | - } |
|
| 537 | - |
|
| 538 | - /** |
|
| 539 | - * Gets count Live Marine data |
|
| 540 | - * |
|
| 541 | - * @param $begindate |
|
| 542 | - * @param $enddate |
|
| 543 | - * @param array $filter |
|
| 544 | - * @return array the spotter information |
|
| 545 | - */ |
|
| 546 | - public function getLiveMarineCount($begindate,$enddate,$filter = array()) |
|
| 547 | - { |
|
| 548 | - global $globalDBdriver, $globalLiveInterval; |
|
| 549 | - date_default_timezone_set('UTC'); |
|
| 550 | - |
|
| 551 | - $filter_query = ''; |
|
| 552 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 553 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 554 | - } |
|
| 555 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 556 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 557 | - } |
|
| 558 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 559 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
| 560 | - } |
|
| 561 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 562 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 563 | - } |
|
| 564 | - |
|
| 565 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 566 | - if ($globalDBdriver == 'mysql') { |
|
| 567 | - $query = 'SELECT COUNT(DISTINCT fammarine_id) as nb |
|
| 524 | + } |
|
| 525 | + //echo $query; |
|
| 526 | + try { |
|
| 527 | + $sth = $this->db->prepare($query); |
|
| 528 | + $sth->execute(); |
|
| 529 | + } catch(PDOException $e) { |
|
| 530 | + echo $e->getMessage(); |
|
| 531 | + die; |
|
| 532 | + } |
|
| 533 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 534 | + |
|
| 535 | + return $spotter_array; |
|
| 536 | + } |
|
| 537 | + |
|
| 538 | + /** |
|
| 539 | + * Gets count Live Marine data |
|
| 540 | + * |
|
| 541 | + * @param $begindate |
|
| 542 | + * @param $enddate |
|
| 543 | + * @param array $filter |
|
| 544 | + * @return array the spotter information |
|
| 545 | + */ |
|
| 546 | + public function getLiveMarineCount($begindate,$enddate,$filter = array()) |
|
| 547 | + { |
|
| 548 | + global $globalDBdriver, $globalLiveInterval; |
|
| 549 | + date_default_timezone_set('UTC'); |
|
| 550 | + |
|
| 551 | + $filter_query = ''; |
|
| 552 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 553 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 554 | + } |
|
| 555 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 556 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 557 | + } |
|
| 558 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 559 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
| 560 | + } |
|
| 561 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 562 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 563 | + } |
|
| 564 | + |
|
| 565 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 566 | + if ($globalDBdriver == 'mysql') { |
|
| 567 | + $query = 'SELECT COUNT(DISTINCT fammarine_id) as nb |
|
| 568 | 568 | FROM marine_archive l |
| 569 | 569 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
| 570 | - } else { |
|
| 571 | - $query = 'SELECT COUNT(DISTINCT fammarine_id) as nb FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
|
| 572 | - } |
|
| 573 | - //echo $query; |
|
| 574 | - try { |
|
| 575 | - $sth = $this->db->prepare($query); |
|
| 576 | - $sth->execute(); |
|
| 577 | - } catch(PDOException $e) { |
|
| 578 | - echo $e->getMessage(); |
|
| 579 | - die; |
|
| 580 | - } |
|
| 581 | - $result = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 582 | - $sth->closeCursor(); |
|
| 583 | - return $result['nb']; |
|
| 584 | - } |
|
| 570 | + } else { |
|
| 571 | + $query = 'SELECT COUNT(DISTINCT fammarine_id) as nb FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
|
| 572 | + } |
|
| 573 | + //echo $query; |
|
| 574 | + try { |
|
| 575 | + $sth = $this->db->prepare($query); |
|
| 576 | + $sth->execute(); |
|
| 577 | + } catch(PDOException $e) { |
|
| 578 | + echo $e->getMessage(); |
|
| 579 | + die; |
|
| 580 | + } |
|
| 581 | + $result = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 582 | + $sth->closeCursor(); |
|
| 583 | + return $result['nb']; |
|
| 584 | + } |
|
| 585 | 585 | |
| 586 | 586 | |
| 587 | 587 | |
| 588 | 588 | // marine_archive_output |
| 589 | 589 | |
| 590 | - /** |
|
| 591 | - * Gets all the spotter information |
|
| 592 | - * |
|
| 593 | - * @param string $q |
|
| 594 | - * @param string $registration |
|
| 595 | - * @param string $aircraft_icao |
|
| 596 | - * @param string $aircraft_manufacturer |
|
| 597 | - * @param string $highlights |
|
| 598 | - * @param string $airline_icao |
|
| 599 | - * @param string $airline_country |
|
| 600 | - * @param string $airline_type |
|
| 601 | - * @param string $airport |
|
| 602 | - * @param string $airport_country |
|
| 603 | - * @param string $callsign |
|
| 604 | - * @param string $departure_airport_route |
|
| 605 | - * @param string $arrival_airport_route |
|
| 606 | - * @param string $owner |
|
| 607 | - * @param string $pilot_id |
|
| 608 | - * @param string $pilot_name |
|
| 609 | - * @param string $altitude |
|
| 610 | - * @param string $date_posted |
|
| 611 | - * @param string $limit |
|
| 612 | - * @param string $sort |
|
| 613 | - * @param string $includegeodata |
|
| 614 | - * @param string $origLat |
|
| 615 | - * @param string $origLon |
|
| 616 | - * @param string $dist |
|
| 617 | - * @param array $filters |
|
| 618 | - * @return array the spotter information |
|
| 619 | - */ |
|
| 620 | - public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 621 | - { |
|
| 622 | - global $globalTimezone, $globalDBdriver; |
|
| 623 | - require_once(dirname(__FILE__).'/class.Translation.php'); |
|
| 624 | - $Translation = new Translation($this->db); |
|
| 625 | - $Marine = new Marine($this->db); |
|
| 626 | - |
|
| 627 | - date_default_timezone_set('UTC'); |
|
| 590 | + /** |
|
| 591 | + * Gets all the spotter information |
|
| 592 | + * |
|
| 593 | + * @param string $q |
|
| 594 | + * @param string $registration |
|
| 595 | + * @param string $aircraft_icao |
|
| 596 | + * @param string $aircraft_manufacturer |
|
| 597 | + * @param string $highlights |
|
| 598 | + * @param string $airline_icao |
|
| 599 | + * @param string $airline_country |
|
| 600 | + * @param string $airline_type |
|
| 601 | + * @param string $airport |
|
| 602 | + * @param string $airport_country |
|
| 603 | + * @param string $callsign |
|
| 604 | + * @param string $departure_airport_route |
|
| 605 | + * @param string $arrival_airport_route |
|
| 606 | + * @param string $owner |
|
| 607 | + * @param string $pilot_id |
|
| 608 | + * @param string $pilot_name |
|
| 609 | + * @param string $altitude |
|
| 610 | + * @param string $date_posted |
|
| 611 | + * @param string $limit |
|
| 612 | + * @param string $sort |
|
| 613 | + * @param string $includegeodata |
|
| 614 | + * @param string $origLat |
|
| 615 | + * @param string $origLon |
|
| 616 | + * @param string $dist |
|
| 617 | + * @param array $filters |
|
| 618 | + * @return array the spotter information |
|
| 619 | + */ |
|
| 620 | + public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 621 | + { |
|
| 622 | + global $globalTimezone, $globalDBdriver; |
|
| 623 | + require_once(dirname(__FILE__).'/class.Translation.php'); |
|
| 624 | + $Translation = new Translation($this->db); |
|
| 625 | + $Marine = new Marine($this->db); |
|
| 626 | + |
|
| 627 | + date_default_timezone_set('UTC'); |
|
| 628 | 628 | |
| 629 | - $query_values = array(); |
|
| 630 | - $additional_query = ''; |
|
| 631 | - $limit_query = ''; |
|
| 632 | - $filter_query = $this->getFilter($filters); |
|
| 633 | - if ($q != "") |
|
| 634 | - { |
|
| 635 | - if (!is_string($q)) |
|
| 636 | - { |
|
| 637 | - return array(); |
|
| 638 | - } else { |
|
| 639 | - $q_array = explode(" ", $q); |
|
| 629 | + $query_values = array(); |
|
| 630 | + $additional_query = ''; |
|
| 631 | + $limit_query = ''; |
|
| 632 | + $filter_query = $this->getFilter($filters); |
|
| 633 | + if ($q != "") |
|
| 634 | + { |
|
| 635 | + if (!is_string($q)) |
|
| 636 | + { |
|
| 637 | + return array(); |
|
| 638 | + } else { |
|
| 639 | + $q_array = explode(" ", $q); |
|
| 640 | 640 | |
| 641 | - foreach ($q_array as $q_item){ |
|
| 642 | - $additional_query .= " AND ("; |
|
| 643 | - $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
| 644 | - $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
| 645 | - $additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
| 646 | - $additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
| 647 | - $additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
| 648 | - $additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR "; |
|
| 649 | - $additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR "; |
|
| 650 | - $additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
| 651 | - $additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
| 652 | - $additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
| 653 | - $additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
| 654 | - $additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
| 655 | - $additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
| 656 | - $additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
| 657 | - $additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
| 658 | - $additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR "; |
|
| 659 | - $additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR "; |
|
| 660 | - $additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
| 661 | - $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
| 662 | - $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR "; |
|
| 663 | - $translate = $Translation->ident2icao($q_item); |
|
| 664 | - if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
| 665 | - $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')"; |
|
| 666 | - $additional_query .= ")"; |
|
| 667 | - } |
|
| 668 | - } |
|
| 669 | - } |
|
| 641 | + foreach ($q_array as $q_item){ |
|
| 642 | + $additional_query .= " AND ("; |
|
| 643 | + $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
| 644 | + $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
| 645 | + $additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
| 646 | + $additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
| 647 | + $additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
| 648 | + $additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR "; |
|
| 649 | + $additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR "; |
|
| 650 | + $additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
| 651 | + $additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
| 652 | + $additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
| 653 | + $additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
| 654 | + $additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
| 655 | + $additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
| 656 | + $additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
| 657 | + $additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
| 658 | + $additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR "; |
|
| 659 | + $additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR "; |
|
| 660 | + $additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
| 661 | + $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
| 662 | + $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR "; |
|
| 663 | + $translate = $Translation->ident2icao($q_item); |
|
| 664 | + if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
| 665 | + $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')"; |
|
| 666 | + $additional_query .= ")"; |
|
| 667 | + } |
|
| 668 | + } |
|
| 669 | + } |
|
| 670 | 670 | |
| 671 | - if ($registration != "") |
|
| 672 | - { |
|
| 673 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 674 | - if (!is_string($registration)) |
|
| 675 | - { |
|
| 676 | - return array(); |
|
| 677 | - } else { |
|
| 678 | - $additional_query .= " AND (marine_archive_output.registration = '".$registration."')"; |
|
| 679 | - } |
|
| 680 | - } |
|
| 671 | + if ($registration != "") |
|
| 672 | + { |
|
| 673 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 674 | + if (!is_string($registration)) |
|
| 675 | + { |
|
| 676 | + return array(); |
|
| 677 | + } else { |
|
| 678 | + $additional_query .= " AND (marine_archive_output.registration = '".$registration."')"; |
|
| 679 | + } |
|
| 680 | + } |
|
| 681 | 681 | |
| 682 | - if ($aircraft_icao != "") |
|
| 683 | - { |
|
| 684 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 685 | - if (!is_string($aircraft_icao)) |
|
| 686 | - { |
|
| 687 | - return array(); |
|
| 688 | - } else { |
|
| 689 | - $additional_query .= " AND (marine_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
|
| 690 | - } |
|
| 691 | - } |
|
| 682 | + if ($aircraft_icao != "") |
|
| 683 | + { |
|
| 684 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 685 | + if (!is_string($aircraft_icao)) |
|
| 686 | + { |
|
| 687 | + return array(); |
|
| 688 | + } else { |
|
| 689 | + $additional_query .= " AND (marine_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
|
| 690 | + } |
|
| 691 | + } |
|
| 692 | 692 | |
| 693 | - if ($aircraft_manufacturer != "") |
|
| 694 | - { |
|
| 695 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 696 | - if (!is_string($aircraft_manufacturer)) |
|
| 697 | - { |
|
| 698 | - return array(); |
|
| 699 | - } else { |
|
| 700 | - $additional_query .= " AND (marine_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
|
| 701 | - } |
|
| 702 | - } |
|
| 693 | + if ($aircraft_manufacturer != "") |
|
| 694 | + { |
|
| 695 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 696 | + if (!is_string($aircraft_manufacturer)) |
|
| 697 | + { |
|
| 698 | + return array(); |
|
| 699 | + } else { |
|
| 700 | + $additional_query .= " AND (marine_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
|
| 701 | + } |
|
| 702 | + } |
|
| 703 | 703 | |
| 704 | - if ($highlights == "true") |
|
| 705 | - { |
|
| 706 | - if (!is_string($highlights)) |
|
| 707 | - { |
|
| 708 | - return array(); |
|
| 709 | - } else { |
|
| 710 | - $additional_query .= " AND (marine_archive_output.highlight <> '')"; |
|
| 711 | - } |
|
| 712 | - } |
|
| 704 | + if ($highlights == "true") |
|
| 705 | + { |
|
| 706 | + if (!is_string($highlights)) |
|
| 707 | + { |
|
| 708 | + return array(); |
|
| 709 | + } else { |
|
| 710 | + $additional_query .= " AND (marine_archive_output.highlight <> '')"; |
|
| 711 | + } |
|
| 712 | + } |
|
| 713 | 713 | |
| 714 | - if ($airline_icao != "") |
|
| 715 | - { |
|
| 716 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 717 | - if (!is_string($airline_icao)) |
|
| 718 | - { |
|
| 719 | - return array(); |
|
| 720 | - } else { |
|
| 721 | - $additional_query .= " AND (marine_archive_output.airline_icao = '".$airline_icao."')"; |
|
| 722 | - } |
|
| 723 | - } |
|
| 714 | + if ($airline_icao != "") |
|
| 715 | + { |
|
| 716 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 717 | + if (!is_string($airline_icao)) |
|
| 718 | + { |
|
| 719 | + return array(); |
|
| 720 | + } else { |
|
| 721 | + $additional_query .= " AND (marine_archive_output.airline_icao = '".$airline_icao."')"; |
|
| 722 | + } |
|
| 723 | + } |
|
| 724 | 724 | |
| 725 | - if ($airline_country != "") |
|
| 726 | - { |
|
| 727 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 728 | - if (!is_string($airline_country)) |
|
| 729 | - { |
|
| 730 | - return array(); |
|
| 731 | - } else { |
|
| 732 | - $additional_query .= " AND (marine_archive_output.airline_country = '".$airline_country."')"; |
|
| 733 | - } |
|
| 734 | - } |
|
| 725 | + if ($airline_country != "") |
|
| 726 | + { |
|
| 727 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 728 | + if (!is_string($airline_country)) |
|
| 729 | + { |
|
| 730 | + return array(); |
|
| 731 | + } else { |
|
| 732 | + $additional_query .= " AND (marine_archive_output.airline_country = '".$airline_country."')"; |
|
| 733 | + } |
|
| 734 | + } |
|
| 735 | 735 | |
| 736 | - if ($airline_type != "") |
|
| 737 | - { |
|
| 738 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 739 | - if (!is_string($airline_type)) |
|
| 740 | - { |
|
| 741 | - return array(); |
|
| 742 | - } else { |
|
| 743 | - if ($airline_type == "passenger") |
|
| 744 | - { |
|
| 745 | - $additional_query .= " AND (marine_archive_output.airline_type = 'passenger')"; |
|
| 746 | - } |
|
| 747 | - if ($airline_type == "cargo") |
|
| 748 | - { |
|
| 749 | - $additional_query .= " AND (marine_archive_output.airline_type = 'cargo')"; |
|
| 750 | - } |
|
| 751 | - if ($airline_type == "military") |
|
| 752 | - { |
|
| 753 | - $additional_query .= " AND (marine_archive_output.airline_type = 'military')"; |
|
| 754 | - } |
|
| 755 | - } |
|
| 756 | - } |
|
| 736 | + if ($airline_type != "") |
|
| 737 | + { |
|
| 738 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 739 | + if (!is_string($airline_type)) |
|
| 740 | + { |
|
| 741 | + return array(); |
|
| 742 | + } else { |
|
| 743 | + if ($airline_type == "passenger") |
|
| 744 | + { |
|
| 745 | + $additional_query .= " AND (marine_archive_output.airline_type = 'passenger')"; |
|
| 746 | + } |
|
| 747 | + if ($airline_type == "cargo") |
|
| 748 | + { |
|
| 749 | + $additional_query .= " AND (marine_archive_output.airline_type = 'cargo')"; |
|
| 750 | + } |
|
| 751 | + if ($airline_type == "military") |
|
| 752 | + { |
|
| 753 | + $additional_query .= " AND (marine_archive_output.airline_type = 'military')"; |
|
| 754 | + } |
|
| 755 | + } |
|
| 756 | + } |
|
| 757 | 757 | |
| 758 | - if ($airport != "") |
|
| 759 | - { |
|
| 760 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 761 | - if (!is_string($airport)) |
|
| 762 | - { |
|
| 763 | - return array(); |
|
| 764 | - } else { |
|
| 765 | - $additional_query .= " AND ((marine_archive_output.departure_airport_icao = '".$airport."') OR (marine_archive_output.arrival_airport_icao = '".$airport."'))"; |
|
| 766 | - } |
|
| 767 | - } |
|
| 758 | + if ($airport != "") |
|
| 759 | + { |
|
| 760 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 761 | + if (!is_string($airport)) |
|
| 762 | + { |
|
| 763 | + return array(); |
|
| 764 | + } else { |
|
| 765 | + $additional_query .= " AND ((marine_archive_output.departure_airport_icao = '".$airport."') OR (marine_archive_output.arrival_airport_icao = '".$airport."'))"; |
|
| 766 | + } |
|
| 767 | + } |
|
| 768 | 768 | |
| 769 | - if ($airport_country != "") |
|
| 770 | - { |
|
| 771 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 772 | - if (!is_string($airport_country)) |
|
| 773 | - { |
|
| 774 | - return array(); |
|
| 775 | - } else { |
|
| 776 | - $additional_query .= " AND ((marine_archive_output.departure_airport_country = '".$airport_country."') OR (marine_archive_output.arrival_airport_country = '".$airport_country."'))"; |
|
| 777 | - } |
|
| 778 | - } |
|
| 769 | + if ($airport_country != "") |
|
| 770 | + { |
|
| 771 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 772 | + if (!is_string($airport_country)) |
|
| 773 | + { |
|
| 774 | + return array(); |
|
| 775 | + } else { |
|
| 776 | + $additional_query .= " AND ((marine_archive_output.departure_airport_country = '".$airport_country."') OR (marine_archive_output.arrival_airport_country = '".$airport_country."'))"; |
|
| 777 | + } |
|
| 778 | + } |
|
| 779 | 779 | |
| 780 | - if ($callsign != "") |
|
| 781 | - { |
|
| 782 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 783 | - if (!is_string($callsign)) |
|
| 784 | - { |
|
| 785 | - return array(); |
|
| 786 | - } else { |
|
| 787 | - $translate = $Translation->ident2icao($callsign); |
|
| 788 | - if ($translate != $callsign) { |
|
| 789 | - $additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)"; |
|
| 790 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
| 791 | - } else { |
|
| 792 | - $additional_query .= " AND (marine_archive_output.ident = '".$callsign."')"; |
|
| 793 | - } |
|
| 794 | - } |
|
| 795 | - } |
|
| 796 | - |
|
| 797 | - if ($owner != "") |
|
| 798 | - { |
|
| 799 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 800 | - if (!is_string($owner)) |
|
| 801 | - { |
|
| 802 | - return array(); |
|
| 803 | - } else { |
|
| 804 | - $additional_query .= " AND (marine_archive_output.owner_name = '".$owner."')"; |
|
| 805 | - } |
|
| 806 | - } |
|
| 807 | - |
|
| 808 | - if ($pilot_name != "") |
|
| 809 | - { |
|
| 810 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 811 | - if (!is_string($pilot_name)) |
|
| 812 | - { |
|
| 813 | - return array(); |
|
| 814 | - } else { |
|
| 815 | - $additional_query .= " AND (marine_archive_output.pilot_name = '".$pilot_name."')"; |
|
| 816 | - } |
|
| 817 | - } |
|
| 780 | + if ($callsign != "") |
|
| 781 | + { |
|
| 782 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 783 | + if (!is_string($callsign)) |
|
| 784 | + { |
|
| 785 | + return array(); |
|
| 786 | + } else { |
|
| 787 | + $translate = $Translation->ident2icao($callsign); |
|
| 788 | + if ($translate != $callsign) { |
|
| 789 | + $additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)"; |
|
| 790 | + $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
| 791 | + } else { |
|
| 792 | + $additional_query .= " AND (marine_archive_output.ident = '".$callsign."')"; |
|
| 793 | + } |
|
| 794 | + } |
|
| 795 | + } |
|
| 796 | + |
|
| 797 | + if ($owner != "") |
|
| 798 | + { |
|
| 799 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 800 | + if (!is_string($owner)) |
|
| 801 | + { |
|
| 802 | + return array(); |
|
| 803 | + } else { |
|
| 804 | + $additional_query .= " AND (marine_archive_output.owner_name = '".$owner."')"; |
|
| 805 | + } |
|
| 806 | + } |
|
| 807 | + |
|
| 808 | + if ($pilot_name != "") |
|
| 809 | + { |
|
| 810 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 811 | + if (!is_string($pilot_name)) |
|
| 812 | + { |
|
| 813 | + return array(); |
|
| 814 | + } else { |
|
| 815 | + $additional_query .= " AND (marine_archive_output.pilot_name = '".$pilot_name."')"; |
|
| 816 | + } |
|
| 817 | + } |
|
| 818 | 818 | |
| 819 | - if ($pilot_id != "") |
|
| 820 | - { |
|
| 821 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 822 | - if (!is_string($pilot_id)) |
|
| 823 | - { |
|
| 824 | - return array(); |
|
| 825 | - } else { |
|
| 826 | - $additional_query .= " AND (marine_archive_output.pilot_id = '".$pilot_id."')"; |
|
| 827 | - } |
|
| 828 | - } |
|
| 819 | + if ($pilot_id != "") |
|
| 820 | + { |
|
| 821 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 822 | + if (!is_string($pilot_id)) |
|
| 823 | + { |
|
| 824 | + return array(); |
|
| 825 | + } else { |
|
| 826 | + $additional_query .= " AND (marine_archive_output.pilot_id = '".$pilot_id."')"; |
|
| 827 | + } |
|
| 828 | + } |
|
| 829 | 829 | |
| 830 | - if ($departure_airport_route != "") |
|
| 831 | - { |
|
| 832 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 833 | - if (!is_string($departure_airport_route)) |
|
| 834 | - { |
|
| 835 | - return array(); |
|
| 836 | - } else { |
|
| 837 | - $additional_query .= " AND (marine_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
|
| 838 | - } |
|
| 839 | - } |
|
| 830 | + if ($departure_airport_route != "") |
|
| 831 | + { |
|
| 832 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 833 | + if (!is_string($departure_airport_route)) |
|
| 834 | + { |
|
| 835 | + return array(); |
|
| 836 | + } else { |
|
| 837 | + $additional_query .= " AND (marine_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
|
| 838 | + } |
|
| 839 | + } |
|
| 840 | 840 | |
| 841 | - if ($arrival_airport_route != "") |
|
| 842 | - { |
|
| 843 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 844 | - if (!is_string($arrival_airport_route)) |
|
| 845 | - { |
|
| 846 | - return array(); |
|
| 847 | - } else { |
|
| 848 | - $additional_query .= " AND (marine_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
|
| 849 | - } |
|
| 850 | - } |
|
| 841 | + if ($arrival_airport_route != "") |
|
| 842 | + { |
|
| 843 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 844 | + if (!is_string($arrival_airport_route)) |
|
| 845 | + { |
|
| 846 | + return array(); |
|
| 847 | + } else { |
|
| 848 | + $additional_query .= " AND (marine_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
|
| 849 | + } |
|
| 850 | + } |
|
| 851 | 851 | |
| 852 | - if ($altitude != "") |
|
| 853 | - { |
|
| 854 | - $altitude_array = explode(",", $altitude); |
|
| 852 | + if ($altitude != "") |
|
| 853 | + { |
|
| 854 | + $altitude_array = explode(",", $altitude); |
|
| 855 | 855 | |
| 856 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 857 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 856 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 857 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 858 | 858 | |
| 859 | 859 | |
| 860 | - if ($altitude_array[1] != "") |
|
| 861 | - { |
|
| 862 | - $altitude_array[0] = substr($altitude_array[0], 0, -2); |
|
| 863 | - $altitude_array[1] = substr($altitude_array[1], 0, -2); |
|
| 864 | - $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
|
| 865 | - } else { |
|
| 866 | - $altitude_array[0] = substr($altitude_array[0], 0, -2); |
|
| 867 | - $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
|
| 868 | - } |
|
| 869 | - } |
|
| 860 | + if ($altitude_array[1] != "") |
|
| 861 | + { |
|
| 862 | + $altitude_array[0] = substr($altitude_array[0], 0, -2); |
|
| 863 | + $altitude_array[1] = substr($altitude_array[1], 0, -2); |
|
| 864 | + $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
|
| 865 | + } else { |
|
| 866 | + $altitude_array[0] = substr($altitude_array[0], 0, -2); |
|
| 867 | + $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
|
| 868 | + } |
|
| 869 | + } |
|
| 870 | 870 | |
| 871 | - if ($date_posted != "") |
|
| 872 | - { |
|
| 873 | - $date_array = explode(",", $date_posted); |
|
| 871 | + if ($date_posted != "") |
|
| 872 | + { |
|
| 873 | + $date_array = explode(",", $date_posted); |
|
| 874 | 874 | |
| 875 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 876 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 875 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 876 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 877 | 877 | |
| 878 | - if ($globalTimezone != '') { |
|
| 879 | - date_default_timezone_set($globalTimezone); |
|
| 880 | - $datetime = new DateTime(); |
|
| 881 | - $offset = $datetime->format('P'); |
|
| 882 | - } else $offset = '+00:00'; |
|
| 883 | - |
|
| 884 | - |
|
| 885 | - if ($date_array[1] != "") |
|
| 886 | - { |
|
| 887 | - $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
|
| 888 | - $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
|
| 889 | - if ($globalDBdriver == 'mysql') { |
|
| 890 | - $additional_query .= " AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) <= '".$date_array[1]."' "; |
|
| 891 | - } else { |
|
| 892 | - $additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) "; |
|
| 893 | - } |
|
| 894 | - } else { |
|
| 895 | - $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
|
| 896 | - if ($globalDBdriver == 'mysql') { |
|
| 897 | - $additional_query .= " AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
|
| 898 | - } else { |
|
| 899 | - $additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
|
| 900 | - } |
|
| 901 | - } |
|
| 902 | - } |
|
| 878 | + if ($globalTimezone != '') { |
|
| 879 | + date_default_timezone_set($globalTimezone); |
|
| 880 | + $datetime = new DateTime(); |
|
| 881 | + $offset = $datetime->format('P'); |
|
| 882 | + } else $offset = '+00:00'; |
|
| 883 | + |
|
| 884 | + |
|
| 885 | + if ($date_array[1] != "") |
|
| 886 | + { |
|
| 887 | + $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
|
| 888 | + $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
|
| 889 | + if ($globalDBdriver == 'mysql') { |
|
| 890 | + $additional_query .= " AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) <= '".$date_array[1]."' "; |
|
| 891 | + } else { |
|
| 892 | + $additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) "; |
|
| 893 | + } |
|
| 894 | + } else { |
|
| 895 | + $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
|
| 896 | + if ($globalDBdriver == 'mysql') { |
|
| 897 | + $additional_query .= " AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
|
| 898 | + } else { |
|
| 899 | + $additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
|
| 900 | + } |
|
| 901 | + } |
|
| 902 | + } |
|
| 903 | 903 | |
| 904 | - if ($limit != "") |
|
| 905 | - { |
|
| 906 | - $limit_array = explode(",", $limit); |
|
| 904 | + if ($limit != "") |
|
| 905 | + { |
|
| 906 | + $limit_array = explode(",", $limit); |
|
| 907 | 907 | |
| 908 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 909 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 908 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 909 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 910 | 910 | |
| 911 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 912 | - { |
|
| 913 | - //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
| 914 | - $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
| 915 | - } |
|
| 916 | - } |
|
| 911 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 912 | + { |
|
| 913 | + //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
| 914 | + $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
| 915 | + } |
|
| 916 | + } |
|
| 917 | 917 | |
| 918 | 918 | |
| 919 | - if ($origLat != "" && $origLon != "" && $dist != "") { |
|
| 920 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
| 921 | - $query="SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 919 | + if ($origLat != "" && $origLon != "" && $dist != "") { |
|
| 920 | + $dist = number_format($dist*0.621371,2,'.',''); |
|
| 921 | + $query="SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 922 | 922 | FROM marine_archive_output, marine_archive WHERE spotter_output_archive.fammarine_id = marine_archive.fammarine_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 923 | 923 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
| 924 | - } else { |
|
| 925 | - if ($sort != "") |
|
| 926 | - { |
|
| 927 | - $search_orderby_array = $Marine->getOrderBy(); |
|
| 928 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 929 | - } else { |
|
| 930 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 931 | - } |
|
| 924 | + } else { |
|
| 925 | + if ($sort != "") |
|
| 926 | + { |
|
| 927 | + $search_orderby_array = $Marine->getOrderBy(); |
|
| 928 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 929 | + } else { |
|
| 930 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 931 | + } |
|
| 932 | 932 | |
| 933 | - if ($includegeodata == "true") |
|
| 934 | - { |
|
| 935 | - $additional_query .= " AND (marine_archive_output.waypoints <> '')"; |
|
| 936 | - } |
|
| 933 | + if ($includegeodata == "true") |
|
| 934 | + { |
|
| 935 | + $additional_query .= " AND (marine_archive_output.waypoints <> '')"; |
|
| 936 | + } |
|
| 937 | 937 | |
| 938 | - $query = "SELECT marine_archive_output.* FROM marine_archive_output |
|
| 938 | + $query = "SELECT marine_archive_output.* FROM marine_archive_output |
|
| 939 | 939 | WHERE marine_archive_output.ident <> '' |
| 940 | 940 | ".$additional_query." |
| 941 | 941 | ".$filter_query.$orderby_query; |
| 942 | - } |
|
| 943 | - $spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query); |
|
| 944 | - |
|
| 945 | - return $spotter_array; |
|
| 946 | - } |
|
| 947 | - |
|
| 948 | - public function deleteMarineArchiveData() |
|
| 949 | - { |
|
| 950 | - global $globalArchiveKeepMonths, $globalDBdriver; |
|
| 951 | - date_default_timezone_set('UTC'); |
|
| 952 | - if ($globalDBdriver == 'mysql') { |
|
| 953 | - $query = 'DELETE FROM marine_archive_output WHERE marine_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
|
| 954 | - } else { |
|
| 955 | - $query = "DELETE FROM marine_archive_output WHERE marine_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
|
| 956 | - } |
|
| 957 | - try { |
|
| 958 | - $sth = $this->db->prepare($query); |
|
| 959 | - $sth->execute(); |
|
| 960 | - } catch(PDOException $e) { |
|
| 961 | - return "error"; |
|
| 962 | - } |
|
| 963 | - return ''; |
|
| 964 | - } |
|
| 965 | - |
|
| 966 | - /** |
|
| 967 | - * Gets all the spotter information based on the callsign |
|
| 968 | - * |
|
| 969 | - * @param string $ident |
|
| 970 | - * @param string $limit |
|
| 971 | - * @param string $sort |
|
| 972 | - * @return array the spotter information |
|
| 973 | - */ |
|
| 974 | - public function getMarineDataByIdent($ident = '', $limit = '', $sort = '') |
|
| 975 | - { |
|
| 942 | + } |
|
| 943 | + $spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query); |
|
| 944 | + |
|
| 945 | + return $spotter_array; |
|
| 946 | + } |
|
| 947 | + |
|
| 948 | + public function deleteMarineArchiveData() |
|
| 949 | + { |
|
| 950 | + global $globalArchiveKeepMonths, $globalDBdriver; |
|
| 951 | + date_default_timezone_set('UTC'); |
|
| 952 | + if ($globalDBdriver == 'mysql') { |
|
| 953 | + $query = 'DELETE FROM marine_archive_output WHERE marine_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
|
| 954 | + } else { |
|
| 955 | + $query = "DELETE FROM marine_archive_output WHERE marine_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
|
| 956 | + } |
|
| 957 | + try { |
|
| 958 | + $sth = $this->db->prepare($query); |
|
| 959 | + $sth->execute(); |
|
| 960 | + } catch(PDOException $e) { |
|
| 961 | + return "error"; |
|
| 962 | + } |
|
| 963 | + return ''; |
|
| 964 | + } |
|
| 965 | + |
|
| 966 | + /** |
|
| 967 | + * Gets all the spotter information based on the callsign |
|
| 968 | + * |
|
| 969 | + * @param string $ident |
|
| 970 | + * @param string $limit |
|
| 971 | + * @param string $sort |
|
| 972 | + * @return array the spotter information |
|
| 973 | + */ |
|
| 974 | + public function getMarineDataByIdent($ident = '', $limit = '', $sort = '') |
|
| 975 | + { |
|
| 976 | 976 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output"; |
| 977 | 977 | |
| 978 | 978 | date_default_timezone_set('UTC'); |
@@ -984,35 +984,35 @@ discard block |
||
| 984 | 984 | |
| 985 | 985 | if ($ident != "") |
| 986 | 986 | { |
| 987 | - if (!is_string($ident)) |
|
| 988 | - { |
|
| 989 | - return array(); |
|
| 990 | - } else { |
|
| 991 | - $additional_query = " AND (marine_archive_output.ident = :ident)"; |
|
| 992 | - $query_values = array(':ident' => $ident); |
|
| 993 | - } |
|
| 987 | + if (!is_string($ident)) |
|
| 988 | + { |
|
| 989 | + return array(); |
|
| 990 | + } else { |
|
| 991 | + $additional_query = " AND (marine_archive_output.ident = :ident)"; |
|
| 992 | + $query_values = array(':ident' => $ident); |
|
| 993 | + } |
|
| 994 | 994 | } |
| 995 | 995 | |
| 996 | 996 | if ($limit != "") |
| 997 | 997 | { |
| 998 | - $limit_array = explode(",", $limit); |
|
| 998 | + $limit_array = explode(",", $limit); |
|
| 999 | 999 | |
| 1000 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1001 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1000 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1001 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1002 | 1002 | |
| 1003 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1004 | - { |
|
| 1003 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1004 | + { |
|
| 1005 | 1005 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1006 | 1006 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1007 | - } |
|
| 1007 | + } |
|
| 1008 | 1008 | } |
| 1009 | 1009 | |
| 1010 | 1010 | if ($sort != "") |
| 1011 | 1011 | { |
| 1012 | - $search_orderby_array = $Marine->getOrderBy(); |
|
| 1013 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1012 | + $search_orderby_array = $Marine->getOrderBy(); |
|
| 1013 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1014 | 1014 | } else { |
| 1015 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 1015 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 1016 | 1016 | } |
| 1017 | 1017 | |
| 1018 | 1018 | $query = $global_query." WHERE marine_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -1020,20 +1020,20 @@ discard block |
||
| 1020 | 1020 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
| 1021 | 1021 | |
| 1022 | 1022 | return $spotter_array; |
| 1023 | - } |
|
| 1024 | - |
|
| 1025 | - |
|
| 1026 | - /** |
|
| 1027 | - * Gets all the spotter information based on the owner |
|
| 1028 | - * |
|
| 1029 | - * @param string $owner |
|
| 1030 | - * @param string $limit |
|
| 1031 | - * @param string $sort |
|
| 1032 | - * @param array $filter |
|
| 1033 | - * @return array the spotter information |
|
| 1034 | - */ |
|
| 1035 | - public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
| 1036 | - { |
|
| 1023 | + } |
|
| 1024 | + |
|
| 1025 | + |
|
| 1026 | + /** |
|
| 1027 | + * Gets all the spotter information based on the owner |
|
| 1028 | + * |
|
| 1029 | + * @param string $owner |
|
| 1030 | + * @param string $limit |
|
| 1031 | + * @param string $sort |
|
| 1032 | + * @param array $filter |
|
| 1033 | + * @return array the spotter information |
|
| 1034 | + */ |
|
| 1035 | + public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
| 1036 | + { |
|
| 1037 | 1037 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output"; |
| 1038 | 1038 | |
| 1039 | 1039 | date_default_timezone_set('UTC'); |
@@ -1046,35 +1046,35 @@ discard block |
||
| 1046 | 1046 | |
| 1047 | 1047 | if ($owner != "") |
| 1048 | 1048 | { |
| 1049 | - if (!is_string($owner)) |
|
| 1050 | - { |
|
| 1049 | + if (!is_string($owner)) |
|
| 1050 | + { |
|
| 1051 | 1051 | return array(); |
| 1052 | - } else { |
|
| 1052 | + } else { |
|
| 1053 | 1053 | $additional_query = " AND (marine_archive_output.owner_name = :owner)"; |
| 1054 | 1054 | $query_values = array(':owner' => $owner); |
| 1055 | - } |
|
| 1055 | + } |
|
| 1056 | 1056 | } |
| 1057 | 1057 | |
| 1058 | 1058 | if ($limit != "") |
| 1059 | 1059 | { |
| 1060 | - $limit_array = explode(",", $limit); |
|
| 1060 | + $limit_array = explode(",", $limit); |
|
| 1061 | 1061 | |
| 1062 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1063 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1062 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1063 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1064 | 1064 | |
| 1065 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1066 | - { |
|
| 1065 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1066 | + { |
|
| 1067 | 1067 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1068 | 1068 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1069 | - } |
|
| 1069 | + } |
|
| 1070 | 1070 | } |
| 1071 | 1071 | |
| 1072 | 1072 | if ($sort != "") |
| 1073 | 1073 | { |
| 1074 | - $search_orderby_array = $Marine->getOrderBy(); |
|
| 1075 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1074 | + $search_orderby_array = $Marine->getOrderBy(); |
|
| 1075 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1076 | 1076 | } else { |
| 1077 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 1077 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 1078 | 1078 | } |
| 1079 | 1079 | |
| 1080 | 1080 | $query = $global_query.$filter_query." marine_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1082,19 +1082,19 @@ discard block |
||
| 1082 | 1082 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
| 1083 | 1083 | |
| 1084 | 1084 | return $spotter_array; |
| 1085 | - } |
|
| 1086 | - |
|
| 1087 | - /** |
|
| 1088 | - * Gets all the spotter information based on the pilot |
|
| 1089 | - * |
|
| 1090 | - * @param string $pilot |
|
| 1091 | - * @param string $limit |
|
| 1092 | - * @param string $sort |
|
| 1093 | - * @param array $filter |
|
| 1094 | - * @return array the spotter information |
|
| 1095 | - */ |
|
| 1096 | - public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
| 1097 | - { |
|
| 1085 | + } |
|
| 1086 | + |
|
| 1087 | + /** |
|
| 1088 | + * Gets all the spotter information based on the pilot |
|
| 1089 | + * |
|
| 1090 | + * @param string $pilot |
|
| 1091 | + * @param string $limit |
|
| 1092 | + * @param string $sort |
|
| 1093 | + * @param array $filter |
|
| 1094 | + * @return array the spotter information |
|
| 1095 | + */ |
|
| 1096 | + public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
| 1097 | + { |
|
| 1098 | 1098 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output"; |
| 1099 | 1099 | |
| 1100 | 1100 | date_default_timezone_set('UTC'); |
@@ -1113,24 +1113,24 @@ discard block |
||
| 1113 | 1113 | |
| 1114 | 1114 | if ($limit != "") |
| 1115 | 1115 | { |
| 1116 | - $limit_array = explode(",", $limit); |
|
| 1116 | + $limit_array = explode(",", $limit); |
|
| 1117 | 1117 | |
| 1118 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1119 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1118 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1119 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1120 | 1120 | |
| 1121 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1122 | - { |
|
| 1121 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1122 | + { |
|
| 1123 | 1123 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1124 | 1124 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1125 | - } |
|
| 1125 | + } |
|
| 1126 | 1126 | } |
| 1127 | 1127 | |
| 1128 | 1128 | if ($sort != "") |
| 1129 | 1129 | { |
| 1130 | - $search_orderby_array = $Marine->getOrderBy(); |
|
| 1131 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1130 | + $search_orderby_array = $Marine->getOrderBy(); |
|
| 1131 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1132 | 1132 | } else { |
| 1133 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 1133 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 1134 | 1134 | } |
| 1135 | 1135 | |
| 1136 | 1136 | $query = $global_query.$filter_query." marine_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1138,18 +1138,18 @@ discard block |
||
| 1138 | 1138 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
| 1139 | 1139 | |
| 1140 | 1140 | return $spotter_array; |
| 1141 | - } |
|
| 1142 | - |
|
| 1143 | - /** |
|
| 1144 | - * Gets all number of flight over countries |
|
| 1145 | - * |
|
| 1146 | - * @param bool $limit |
|
| 1147 | - * @param int $olderthanmonths |
|
| 1148 | - * @param string $sincedate |
|
| 1149 | - * @return array the airline country list |
|
| 1150 | - */ |
|
| 1151 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1152 | - { |
|
| 1141 | + } |
|
| 1142 | + |
|
| 1143 | + /** |
|
| 1144 | + * Gets all number of flight over countries |
|
| 1145 | + * |
|
| 1146 | + * @param bool $limit |
|
| 1147 | + * @param int $olderthanmonths |
|
| 1148 | + * @param string $sincedate |
|
| 1149 | + * @return array the airline country list |
|
| 1150 | + */ |
|
| 1151 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1152 | + { |
|
| 1153 | 1153 | global $globalDBdriver; |
| 1154 | 1154 | /* |
| 1155 | 1155 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1159,14 +1159,14 @@ discard block |
||
| 1159 | 1159 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
| 1160 | 1160 | FROM countries c, marine_archive s |
| 1161 | 1161 | WHERE c.iso2 = s.over_country "; |
| 1162 | - if ($olderthanmonths > 0) { |
|
| 1163 | - if ($globalDBdriver == 'mysql') { |
|
| 1162 | + if ($olderthanmonths > 0) { |
|
| 1163 | + if ($globalDBdriver == 'mysql') { |
|
| 1164 | 1164 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
| 1165 | 1165 | } else { |
| 1166 | 1166 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1167 | 1167 | } |
| 1168 | 1168 | } |
| 1169 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1169 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1170 | 1170 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1171 | 1171 | if ($limit) $query .= " LIMIT 0,10"; |
| 1172 | 1172 | |
@@ -1179,25 +1179,25 @@ discard block |
||
| 1179 | 1179 | |
| 1180 | 1180 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 1181 | 1181 | { |
| 1182 | - $temp_array['flight_count'] = $row['nb']; |
|
| 1183 | - $temp_array['flight_country'] = $row['name']; |
|
| 1184 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1185 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1186 | - $flight_array[] = $temp_array; |
|
| 1182 | + $temp_array['flight_count'] = $row['nb']; |
|
| 1183 | + $temp_array['flight_country'] = $row['name']; |
|
| 1184 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1185 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1186 | + $flight_array[] = $temp_array; |
|
| 1187 | 1187 | } |
| 1188 | 1188 | return $flight_array; |
| 1189 | - } |
|
| 1190 | - |
|
| 1191 | - /** |
|
| 1192 | - * Gets all number of flight over countries |
|
| 1193 | - * |
|
| 1194 | - * @param bool $limit |
|
| 1195 | - * @param int $olderthanmonths |
|
| 1196 | - * @param string $sincedate |
|
| 1197 | - * @return array the airline country list |
|
| 1198 | - */ |
|
| 1199 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1200 | - { |
|
| 1189 | + } |
|
| 1190 | + |
|
| 1191 | + /** |
|
| 1192 | + * Gets all number of flight over countries |
|
| 1193 | + * |
|
| 1194 | + * @param bool $limit |
|
| 1195 | + * @param int $olderthanmonths |
|
| 1196 | + * @param string $sincedate |
|
| 1197 | + * @return array the airline country list |
|
| 1198 | + */ |
|
| 1199 | + public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1200 | + { |
|
| 1201 | 1201 | global $globalDBdriver; |
| 1202 | 1202 | /* |
| 1203 | 1203 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1207,14 +1207,14 @@ discard block |
||
| 1207 | 1207 | $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb |
| 1208 | 1208 | FROM countries c, marine_archive s, spotter_output o |
| 1209 | 1209 | WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.fammarine_id = s.fammarine_id "; |
| 1210 | - if ($olderthanmonths > 0) { |
|
| 1211 | - if ($globalDBdriver == 'mysql') { |
|
| 1210 | + if ($olderthanmonths > 0) { |
|
| 1211 | + if ($globalDBdriver == 'mysql') { |
|
| 1212 | 1212 | $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
| 1213 | 1213 | } else { |
| 1214 | 1214 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1215 | 1215 | } |
| 1216 | 1216 | } |
| 1217 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1217 | + if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1218 | 1218 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1219 | 1219 | if ($limit) $query .= " LIMIT 0,10"; |
| 1220 | 1220 | |
@@ -1227,25 +1227,25 @@ discard block |
||
| 1227 | 1227 | |
| 1228 | 1228 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 1229 | 1229 | { |
| 1230 | - $temp_array['airline_icao'] = $row['airline_icao']; |
|
| 1231 | - $temp_array['flight_count'] = $row['nb']; |
|
| 1232 | - $temp_array['flight_country'] = $row['name']; |
|
| 1233 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1234 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1235 | - $flight_array[] = $temp_array; |
|
| 1230 | + $temp_array['airline_icao'] = $row['airline_icao']; |
|
| 1231 | + $temp_array['flight_count'] = $row['nb']; |
|
| 1232 | + $temp_array['flight_country'] = $row['name']; |
|
| 1233 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1234 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1235 | + $flight_array[] = $temp_array; |
|
| 1236 | 1236 | } |
| 1237 | 1237 | return $flight_array; |
| 1238 | - } |
|
| 1239 | - |
|
| 1240 | - /** |
|
| 1241 | - * Gets last spotter information based on a particular callsign |
|
| 1242 | - * |
|
| 1243 | - * @param $id |
|
| 1244 | - * @param $date |
|
| 1245 | - * @return array the spotter information |
|
| 1246 | - */ |
|
| 1247 | - public function getDateArchiveMarineDataById($id,$date) |
|
| 1248 | - { |
|
| 1238 | + } |
|
| 1239 | + |
|
| 1240 | + /** |
|
| 1241 | + * Gets last spotter information based on a particular callsign |
|
| 1242 | + * |
|
| 1243 | + * @param $id |
|
| 1244 | + * @param $date |
|
| 1245 | + * @return array the spotter information |
|
| 1246 | + */ |
|
| 1247 | + public function getDateArchiveMarineDataById($id,$date) |
|
| 1248 | + { |
|
| 1249 | 1249 | $Marine = new Marine($this->db); |
| 1250 | 1250 | date_default_timezone_set('UTC'); |
| 1251 | 1251 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -1253,17 +1253,17 @@ discard block |
||
| 1253 | 1253 | $date = date('c',$date); |
| 1254 | 1254 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
| 1255 | 1255 | return $spotter_array; |
| 1256 | - } |
|
| 1257 | - |
|
| 1258 | - /** |
|
| 1259 | - * Gets all the spotter information based on a particular callsign |
|
| 1260 | - * |
|
| 1261 | - * @param $ident |
|
| 1262 | - * @param $date |
|
| 1263 | - * @return array the spotter information |
|
| 1264 | - */ |
|
| 1265 | - public function getDateArchiveMarineDataByIdent($ident,$date) |
|
| 1266 | - { |
|
| 1256 | + } |
|
| 1257 | + |
|
| 1258 | + /** |
|
| 1259 | + * Gets all the spotter information based on a particular callsign |
|
| 1260 | + * |
|
| 1261 | + * @param $ident |
|
| 1262 | + * @param $date |
|
| 1263 | + * @return array the spotter information |
|
| 1264 | + */ |
|
| 1265 | + public function getDateArchiveMarineDataByIdent($ident,$date) |
|
| 1266 | + { |
|
| 1267 | 1267 | $Marine = new Marine($this->db); |
| 1268 | 1268 | date_default_timezone_set('UTC'); |
| 1269 | 1269 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -1271,65 +1271,65 @@ discard block |
||
| 1271 | 1271 | $date = date('c',$date); |
| 1272 | 1272 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
| 1273 | 1273 | return $spotter_array; |
| 1274 | - } |
|
| 1275 | - |
|
| 1276 | - /** |
|
| 1277 | - * Gets all the spotter information based on the airport |
|
| 1278 | - * |
|
| 1279 | - * @param string $airport |
|
| 1280 | - * @param string $limit |
|
| 1281 | - * @param string $sort |
|
| 1282 | - * @param array $filters |
|
| 1283 | - * @return array the spotter information |
|
| 1284 | - */ |
|
| 1285 | - public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1286 | - { |
|
| 1287 | - global $global_query; |
|
| 1288 | - $Marine = new Marine($this->db); |
|
| 1289 | - date_default_timezone_set('UTC'); |
|
| 1290 | - $query_values = array(); |
|
| 1291 | - $limit_query = ''; |
|
| 1292 | - $additional_query = ''; |
|
| 1293 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1274 | + } |
|
| 1275 | + |
|
| 1276 | + /** |
|
| 1277 | + * Gets all the spotter information based on the airport |
|
| 1278 | + * |
|
| 1279 | + * @param string $airport |
|
| 1280 | + * @param string $limit |
|
| 1281 | + * @param string $sort |
|
| 1282 | + * @param array $filters |
|
| 1283 | + * @return array the spotter information |
|
| 1284 | + */ |
|
| 1285 | + public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1286 | + { |
|
| 1287 | + global $global_query; |
|
| 1288 | + $Marine = new Marine($this->db); |
|
| 1289 | + date_default_timezone_set('UTC'); |
|
| 1290 | + $query_values = array(); |
|
| 1291 | + $limit_query = ''; |
|
| 1292 | + $additional_query = ''; |
|
| 1293 | + $filter_query = $this->getFilter($filters,true,true); |
|
| 1294 | 1294 | |
| 1295 | - if ($airport != "") |
|
| 1296 | - { |
|
| 1297 | - if (!is_string($airport)) |
|
| 1298 | - { |
|
| 1299 | - return array(); |
|
| 1300 | - } else { |
|
| 1301 | - $additional_query .= " AND ((marine_archive_output.departure_airport_icao = :airport) OR (marine_archive_output.arrival_airport_icao = :airport))"; |
|
| 1302 | - $query_values = array(':airport' => $airport); |
|
| 1303 | - } |
|
| 1304 | - } |
|
| 1295 | + if ($airport != "") |
|
| 1296 | + { |
|
| 1297 | + if (!is_string($airport)) |
|
| 1298 | + { |
|
| 1299 | + return array(); |
|
| 1300 | + } else { |
|
| 1301 | + $additional_query .= " AND ((marine_archive_output.departure_airport_icao = :airport) OR (marine_archive_output.arrival_airport_icao = :airport))"; |
|
| 1302 | + $query_values = array(':airport' => $airport); |
|
| 1303 | + } |
|
| 1304 | + } |
|
| 1305 | 1305 | |
| 1306 | - if ($limit != "") |
|
| 1307 | - { |
|
| 1308 | - $limit_array = explode(",", $limit); |
|
| 1306 | + if ($limit != "") |
|
| 1307 | + { |
|
| 1308 | + $limit_array = explode(",", $limit); |
|
| 1309 | 1309 | |
| 1310 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1311 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1310 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1311 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1312 | 1312 | |
| 1313 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1314 | - { |
|
| 1315 | - //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
| 1316 | - $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
| 1317 | - } |
|
| 1318 | - } |
|
| 1313 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1314 | + { |
|
| 1315 | + //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
| 1316 | + $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
| 1317 | + } |
|
| 1318 | + } |
|
| 1319 | 1319 | |
| 1320 | - if ($sort != "") |
|
| 1321 | - { |
|
| 1322 | - $search_orderby_array = $Marine->getOrderBy(); |
|
| 1323 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1324 | - } else { |
|
| 1325 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 1326 | - } |
|
| 1320 | + if ($sort != "") |
|
| 1321 | + { |
|
| 1322 | + $search_orderby_array = $Marine->getOrderBy(); |
|
| 1323 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1324 | + } else { |
|
| 1325 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
| 1326 | + } |
|
| 1327 | 1327 | |
| 1328 | - $query = $global_query.$filter_query." marine_archive_output.ident <> '' ".$additional_query." AND ((marine_archive_output.departure_airport_icao <> 'NA') AND (marine_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
|
| 1328 | + $query = $global_query.$filter_query." marine_archive_output.ident <> '' ".$additional_query." AND ((marine_archive_output.departure_airport_icao <> 'NA') AND (marine_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
|
| 1329 | 1329 | |
| 1330 | - $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
|
| 1330 | + $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
|
| 1331 | 1331 | |
| 1332 | - return $spotter_array; |
|
| 1333 | - } |
|
| 1332 | + return $spotter_array; |
|
| 1333 | + } |
|
| 1334 | 1334 | } |
| 1335 | 1335 | ?> |
| 1336 | 1336 | \ No newline at end of file |
@@ -23,33 +23,33 @@ discard block |
||
| 23 | 23 | * @param bool $and |
| 24 | 24 | * @return string the SQL part |
| 25 | 25 | */ |
| 26 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 26 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 27 | 27 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 28 | 28 | $filters = array(); |
| 29 | 29 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 30 | 30 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 31 | 31 | $filters = $globalStatsFilters[$globalFilterName]; |
| 32 | 32 | } else { |
| 33 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 33 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | if (isset($filter[0]['source'])) { |
| 37 | - $filters = array_merge($filters,$filter); |
|
| 37 | + $filters = array_merge($filters, $filter); |
|
| 38 | 38 | } |
| 39 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 39 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 40 | 40 | $filter_query_join = ''; |
| 41 | 41 | $filter_query_where = ''; |
| 42 | - foreach($filters as $flt) { |
|
| 42 | + foreach ($filters as $flt) { |
|
| 43 | 43 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 44 | 44 | if (isset($flt['source'])) { |
| 45 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
| 45 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
| 46 | 46 | } else { |
| 47 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
| 47 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 52 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 52 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 53 | 53 | } |
| 54 | 54 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 55 | 55 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -77,15 +77,15 @@ discard block |
||
| 77 | 77 | $filter_query_date .= " AND EXTRACT(DAY FROM marine_archive_output.date) = '".$filter['day']."'"; |
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_archive.fammarine_id"; |
|
| 80 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_archive.fammarine_id"; |
|
| 81 | 81 | } |
| 82 | 82 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 83 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 83 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 84 | 84 | } |
| 85 | 85 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 86 | 86 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 87 | 87 | if ($filter_query_where != '') { |
| 88 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 88 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 89 | 89 | } |
| 90 | 90 | $filter_query = $filter_query_join.$filter_query_where; |
| 91 | 91 | return $filter_query; |
@@ -128,21 +128,21 @@ discard block |
||
| 128 | 128 | require_once(dirname(__FILE__).'/class.Marine.php'); |
| 129 | 129 | if ($over_country == '') { |
| 130 | 130 | $Marine = new Marine($this->db); |
| 131 | - $data_country = $Marine->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
| 131 | + $data_country = $Marine->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
| 132 | 132 | if (!empty($data_country)) $country = $data_country['iso2']; |
| 133 | 133 | else $country = ''; |
| 134 | 134 | } else $country = $over_country; |
| 135 | 135 | |
| 136 | 136 | //$country = $over_country; |
| 137 | 137 | // Route is not added in marine_archive |
| 138 | - $query = 'INSERT INTO marine_archive (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,type_id,status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name,distance,race_rank,race_time) |
|
| 138 | + $query = 'INSERT INTO marine_archive (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,type_id,status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name,distance,race_rank,race_time) |
|
| 139 | 139 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:type_id,:status,:status_id,:imo,:arrival_port_name,:arrival_port_date,:captain_id,:captain_name,:race_id,:race_name,:distance,:race_rank,:race_time)'; |
| 140 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $country,':mmsi' => $mmsi,':type' => $type,':type_id' => $typeid,':status' => $status,':status_id' => $statusid,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date,':captain_id' => $captain_id,':captain_name' => $captain_name,':race_id' => $race_id,':race_name' => $race_name,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time); |
|
| 140 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $country, ':mmsi' => $mmsi, ':type' => $type, ':type_id' => $typeid, ':status' => $status, ':status_id' => $statusid, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date, ':captain_id' => $captain_id, ':captain_name' => $captain_name, ':race_id' => $race_id, ':race_name' => $race_name, ':distance' => $distance, ':race_rank' => $race_rank, ':race_time' => $race_time); |
|
| 141 | 141 | try { |
| 142 | 142 | $sth = $this->db->prepare($query); |
| 143 | 143 | $sth->execute($query_values); |
| 144 | 144 | $sth->closeCursor(); |
| 145 | - } catch(PDOException $e) { |
|
| 145 | + } catch (PDOException $e) { |
|
| 146 | 146 | return "error : ".$e->getMessage(); |
| 147 | 147 | } |
| 148 | 148 | return "success"; |
@@ -162,8 +162,8 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 164 | 164 | //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
| 165 | - $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 166 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident)); |
|
| 165 | + $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 166 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident)); |
|
| 167 | 167 | return $spotter_array; |
| 168 | 168 | } |
| 169 | 169 | |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 182 | 182 | //$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id"; |
| 183 | 183 | //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
| 184 | - $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 184 | + $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 185 | 185 | |
| 186 | 186 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
| 187 | 187 | /* |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | } |
| 195 | 195 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 196 | 196 | */ |
| 197 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); |
|
| 197 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id)); |
|
| 198 | 198 | return $spotter_array; |
| 199 | 199 | } |
| 200 | 200 | |
@@ -208,14 +208,14 @@ discard block |
||
| 208 | 208 | { |
| 209 | 209 | date_default_timezone_set('UTC'); |
| 210 | 210 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 211 | - $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 211 | + $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 212 | 212 | |
| 213 | 213 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
| 214 | 214 | |
| 215 | 215 | try { |
| 216 | 216 | $sth = $this->db->prepare($query); |
| 217 | 217 | $sth->execute(array(':id' => $id)); |
| 218 | - } catch(PDOException $e) { |
|
| 218 | + } catch (PDOException $e) { |
|
| 219 | 219 | echo $e->getMessage(); |
| 220 | 220 | die; |
| 221 | 221 | } |
@@ -233,14 +233,14 @@ discard block |
||
| 233 | 233 | { |
| 234 | 234 | date_default_timezone_set('UTC'); |
| 235 | 235 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 236 | - $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
| 236 | + $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
| 237 | 237 | |
| 238 | 238 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
| 239 | 239 | |
| 240 | 240 | try { |
| 241 | 241 | $sth = $this->db->prepare($query); |
| 242 | 242 | $sth->execute(array(':id' => $id)); |
| 243 | - } catch(PDOException $e) { |
|
| 243 | + } catch (PDOException $e) { |
|
| 244 | 244 | echo $e->getMessage(); |
| 245 | 245 | die; |
| 246 | 246 | } |
@@ -262,12 +262,12 @@ discard block |
||
| 262 | 262 | date_default_timezone_set('UTC'); |
| 263 | 263 | |
| 264 | 264 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 265 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 265 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 266 | 266 | |
| 267 | 267 | try { |
| 268 | 268 | $sth = $this->db->prepare($query); |
| 269 | 269 | $sth->execute(array(':ident' => $ident)); |
| 270 | - } catch(PDOException $e) { |
|
| 270 | + } catch (PDOException $e) { |
|
| 271 | 271 | echo $e->getMessage(); |
| 272 | 272 | die; |
| 273 | 273 | } |
@@ -288,12 +288,12 @@ discard block |
||
| 288 | 288 | date_default_timezone_set('UTC'); |
| 289 | 289 | |
| 290 | 290 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 291 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 291 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 292 | 292 | |
| 293 | 293 | try { |
| 294 | 294 | $sth = $this->db->prepare($query); |
| 295 | 295 | $sth->execute(array(':id' => $id)); |
| 296 | - } catch(PDOException $e) { |
|
| 296 | + } catch (PDOException $e) { |
|
| 297 | 297 | echo $e->getMessage(); |
| 298 | 298 | die; |
| 299 | 299 | } |
@@ -313,12 +313,12 @@ discard block |
||
| 313 | 313 | date_default_timezone_set('UTC'); |
| 314 | 314 | |
| 315 | 315 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 316 | - $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 316 | + $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 317 | 317 | |
| 318 | 318 | try { |
| 319 | 319 | $sth = $this->db->prepare($query); |
| 320 | 320 | $sth->execute(array(':id' => $id)); |
| 321 | - } catch(PDOException $e) { |
|
| 321 | + } catch (PDOException $e) { |
|
| 322 | 322 | echo $e->getMessage(); |
| 323 | 323 | die; |
| 324 | 324 | } |
@@ -340,13 +340,13 @@ discard block |
||
| 340 | 340 | date_default_timezone_set('UTC'); |
| 341 | 341 | |
| 342 | 342 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 343 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
| 343 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
| 344 | 344 | // $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident"; |
| 345 | 345 | |
| 346 | 346 | try { |
| 347 | 347 | $sth = $this->db->prepare($query); |
| 348 | 348 | $sth->execute(array(':ident' => $ident)); |
| 349 | - } catch(PDOException $e) { |
|
| 349 | + } catch (PDOException $e) { |
|
| 350 | 350 | echo $e->getMessage(); |
| 351 | 351 | die; |
| 352 | 352 | } |
@@ -364,12 +364,12 @@ discard block |
||
| 364 | 364 | * @param $date |
| 365 | 365 | * @return array the spotter information |
| 366 | 366 | */ |
| 367 | - public function getMarineArchiveData($ident,$fammarine_id,$date) |
|
| 367 | + public function getMarineArchiveData($ident, $fammarine_id, $date) |
|
| 368 | 368 | { |
| 369 | 369 | $Marine = new Marine($this->db); |
| 370 | 370 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 371 | 371 | $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate"; |
| 372 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%')); |
|
| 372 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':fammarine_id' => $fammarine_id, ':date' => $date.'%')); |
|
| 373 | 373 | return $spotter_array; |
| 374 | 374 | } |
| 375 | 375 | |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | try { |
| 389 | 389 | $sth = $this->db->prepare($query); |
| 390 | 390 | $sth->execute(); |
| 391 | - } catch(PDOException $e) { |
|
| 391 | + } catch (PDOException $e) { |
|
| 392 | 392 | echo $e->getMessage(); |
| 393 | 393 | die; |
| 394 | 394 | } |
@@ -402,24 +402,24 @@ discard block |
||
| 402 | 402 | * @param array $filter |
| 403 | 403 | * @return array the spotter information |
| 404 | 404 | */ |
| 405 | - public function getMinLiveMarineData($begindate,$enddate,$filter = array()) |
|
| 405 | + public function getMinLiveMarineData($begindate, $enddate, $filter = array()) |
|
| 406 | 406 | { |
| 407 | 407 | global $globalDBdriver; |
| 408 | 408 | date_default_timezone_set('UTC'); |
| 409 | 409 | |
| 410 | 410 | $filter_query = ''; |
| 411 | 411 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 412 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 412 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 413 | 413 | } |
| 414 | 414 | // Use spotter_output also ? |
| 415 | 415 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 416 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 416 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 417 | 417 | } |
| 418 | 418 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 419 | 419 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
| 420 | 420 | } |
| 421 | 421 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 422 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 422 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -438,14 +438,14 @@ discard block |
||
| 438 | 438 | GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id |
| 439 | 439 | AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
| 440 | 440 | */ |
| 441 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 441 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 442 | 442 | FROM marine_archive |
| 443 | 443 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
| 444 | 444 | WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
| 445 | 445 | '.$filter_query.' ORDER BY fammarine_id'; |
| 446 | 446 | } else { |
| 447 | 447 | //$query = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao'; |
| 448 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 448 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 449 | 449 | FROM marine_archive |
| 450 | 450 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
| 451 | 451 | WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".' |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | try { |
| 456 | 456 | $sth = $this->db->prepare($query); |
| 457 | 457 | $sth->execute(); |
| 458 | - } catch(PDOException $e) { |
|
| 458 | + } catch (PDOException $e) { |
|
| 459 | 459 | echo $e->getMessage(); |
| 460 | 460 | die; |
| 461 | 461 | } |
@@ -472,24 +472,24 @@ discard block |
||
| 472 | 472 | * @param array $filter |
| 473 | 473 | * @return array the spotter information |
| 474 | 474 | */ |
| 475 | - public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array()) |
|
| 475 | + public function getMinLiveMarineDataPlayback($begindate, $enddate, $filter = array()) |
|
| 476 | 476 | { |
| 477 | 477 | global $globalDBdriver; |
| 478 | 478 | date_default_timezone_set('UTC'); |
| 479 | 479 | |
| 480 | 480 | $filter_query = ''; |
| 481 | 481 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 482 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 482 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 483 | 483 | } |
| 484 | 484 | // Should use spotter_output also ? |
| 485 | 485 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 486 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 486 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 487 | 487 | } |
| 488 | 488 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 489 | 489 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
| 490 | 490 | } |
| 491 | 491 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 492 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 492 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -499,7 +499,7 @@ discard block |
||
| 499 | 499 | FROM marine_archive |
| 500 | 500 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
| 501 | 501 | */ |
| 502 | - $query = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk |
|
| 502 | + $query = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk |
|
| 503 | 503 | FROM marine_archive_output |
| 504 | 504 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive_output.aircraft_icao = a.icao |
| 505 | 505 | WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -514,7 +514,7 @@ discard block |
||
| 514 | 514 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
| 515 | 515 | '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow'; |
| 516 | 516 | */ |
| 517 | - $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
| 517 | + $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
| 518 | 518 | FROM marine_archive_output |
| 519 | 519 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao |
| 520 | 520 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
@@ -526,7 +526,7 @@ discard block |
||
| 526 | 526 | try { |
| 527 | 527 | $sth = $this->db->prepare($query); |
| 528 | 528 | $sth->execute(); |
| 529 | - } catch(PDOException $e) { |
|
| 529 | + } catch (PDOException $e) { |
|
| 530 | 530 | echo $e->getMessage(); |
| 531 | 531 | die; |
| 532 | 532 | } |
@@ -543,23 +543,23 @@ discard block |
||
| 543 | 543 | * @param array $filter |
| 544 | 544 | * @return array the spotter information |
| 545 | 545 | */ |
| 546 | - public function getLiveMarineCount($begindate,$enddate,$filter = array()) |
|
| 546 | + public function getLiveMarineCount($begindate, $enddate, $filter = array()) |
|
| 547 | 547 | { |
| 548 | 548 | global $globalDBdriver, $globalLiveInterval; |
| 549 | 549 | date_default_timezone_set('UTC'); |
| 550 | 550 | |
| 551 | 551 | $filter_query = ''; |
| 552 | 552 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 553 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 553 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 554 | 554 | } |
| 555 | 555 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 556 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 556 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 557 | 557 | } |
| 558 | 558 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 559 | 559 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
| 560 | 560 | } |
| 561 | 561 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 562 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 562 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 563 | 563 | } |
| 564 | 564 | |
| 565 | 565 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -574,7 +574,7 @@ discard block |
||
| 574 | 574 | try { |
| 575 | 575 | $sth = $this->db->prepare($query); |
| 576 | 576 | $sth->execute(); |
| 577 | - } catch(PDOException $e) { |
|
| 577 | + } catch (PDOException $e) { |
|
| 578 | 578 | echo $e->getMessage(); |
| 579 | 579 | die; |
| 580 | 580 | } |
@@ -617,7 +617,7 @@ discard block |
||
| 617 | 617 | * @param array $filters |
| 618 | 618 | * @return array the spotter information |
| 619 | 619 | */ |
| 620 | - public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 620 | + public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
| 621 | 621 | { |
| 622 | 622 | global $globalTimezone, $globalDBdriver; |
| 623 | 623 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -638,7 +638,7 @@ discard block |
||
| 638 | 638 | } else { |
| 639 | 639 | $q_array = explode(" ", $q); |
| 640 | 640 | |
| 641 | - foreach ($q_array as $q_item){ |
|
| 641 | + foreach ($q_array as $q_item) { |
|
| 642 | 642 | $additional_query .= " AND ("; |
| 643 | 643 | $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR "; |
| 644 | 644 | $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -670,7 +670,7 @@ discard block |
||
| 670 | 670 | |
| 671 | 671 | if ($registration != "") |
| 672 | 672 | { |
| 673 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 673 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 674 | 674 | if (!is_string($registration)) |
| 675 | 675 | { |
| 676 | 676 | return array(); |
@@ -681,7 +681,7 @@ discard block |
||
| 681 | 681 | |
| 682 | 682 | if ($aircraft_icao != "") |
| 683 | 683 | { |
| 684 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 684 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 685 | 685 | if (!is_string($aircraft_icao)) |
| 686 | 686 | { |
| 687 | 687 | return array(); |
@@ -692,7 +692,7 @@ discard block |
||
| 692 | 692 | |
| 693 | 693 | if ($aircraft_manufacturer != "") |
| 694 | 694 | { |
| 695 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 695 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
| 696 | 696 | if (!is_string($aircraft_manufacturer)) |
| 697 | 697 | { |
| 698 | 698 | return array(); |
@@ -713,7 +713,7 @@ discard block |
||
| 713 | 713 | |
| 714 | 714 | if ($airline_icao != "") |
| 715 | 715 | { |
| 716 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 716 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 717 | 717 | if (!is_string($airline_icao)) |
| 718 | 718 | { |
| 719 | 719 | return array(); |
@@ -724,7 +724,7 @@ discard block |
||
| 724 | 724 | |
| 725 | 725 | if ($airline_country != "") |
| 726 | 726 | { |
| 727 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 727 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
| 728 | 728 | if (!is_string($airline_country)) |
| 729 | 729 | { |
| 730 | 730 | return array(); |
@@ -735,7 +735,7 @@ discard block |
||
| 735 | 735 | |
| 736 | 736 | if ($airline_type != "") |
| 737 | 737 | { |
| 738 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 738 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
| 739 | 739 | if (!is_string($airline_type)) |
| 740 | 740 | { |
| 741 | 741 | return array(); |
@@ -757,7 +757,7 @@ discard block |
||
| 757 | 757 | |
| 758 | 758 | if ($airport != "") |
| 759 | 759 | { |
| 760 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 760 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
| 761 | 761 | if (!is_string($airport)) |
| 762 | 762 | { |
| 763 | 763 | return array(); |
@@ -768,7 +768,7 @@ discard block |
||
| 768 | 768 | |
| 769 | 769 | if ($airport_country != "") |
| 770 | 770 | { |
| 771 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 771 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
| 772 | 772 | if (!is_string($airport_country)) |
| 773 | 773 | { |
| 774 | 774 | return array(); |
@@ -779,7 +779,7 @@ discard block |
||
| 779 | 779 | |
| 780 | 780 | if ($callsign != "") |
| 781 | 781 | { |
| 782 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 782 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 783 | 783 | if (!is_string($callsign)) |
| 784 | 784 | { |
| 785 | 785 | return array(); |
@@ -787,7 +787,7 @@ discard block |
||
| 787 | 787 | $translate = $Translation->ident2icao($callsign); |
| 788 | 788 | if ($translate != $callsign) { |
| 789 | 789 | $additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)"; |
| 790 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
| 790 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
| 791 | 791 | } else { |
| 792 | 792 | $additional_query .= " AND (marine_archive_output.ident = '".$callsign."')"; |
| 793 | 793 | } |
@@ -796,7 +796,7 @@ discard block |
||
| 796 | 796 | |
| 797 | 797 | if ($owner != "") |
| 798 | 798 | { |
| 799 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 799 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 800 | 800 | if (!is_string($owner)) |
| 801 | 801 | { |
| 802 | 802 | return array(); |
@@ -807,7 +807,7 @@ discard block |
||
| 807 | 807 | |
| 808 | 808 | if ($pilot_name != "") |
| 809 | 809 | { |
| 810 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 810 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
| 811 | 811 | if (!is_string($pilot_name)) |
| 812 | 812 | { |
| 813 | 813 | return array(); |
@@ -818,7 +818,7 @@ discard block |
||
| 818 | 818 | |
| 819 | 819 | if ($pilot_id != "") |
| 820 | 820 | { |
| 821 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 821 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
| 822 | 822 | if (!is_string($pilot_id)) |
| 823 | 823 | { |
| 824 | 824 | return array(); |
@@ -829,7 +829,7 @@ discard block |
||
| 829 | 829 | |
| 830 | 830 | if ($departure_airport_route != "") |
| 831 | 831 | { |
| 832 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 832 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
| 833 | 833 | if (!is_string($departure_airport_route)) |
| 834 | 834 | { |
| 835 | 835 | return array(); |
@@ -840,7 +840,7 @@ discard block |
||
| 840 | 840 | |
| 841 | 841 | if ($arrival_airport_route != "") |
| 842 | 842 | { |
| 843 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 843 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
| 844 | 844 | if (!is_string($arrival_airport_route)) |
| 845 | 845 | { |
| 846 | 846 | return array(); |
@@ -853,8 +853,8 @@ discard block |
||
| 853 | 853 | { |
| 854 | 854 | $altitude_array = explode(",", $altitude); |
| 855 | 855 | |
| 856 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 857 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 856 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 857 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 858 | 858 | |
| 859 | 859 | |
| 860 | 860 | if ($altitude_array[1] != "") |
@@ -872,8 +872,8 @@ discard block |
||
| 872 | 872 | { |
| 873 | 873 | $date_array = explode(",", $date_posted); |
| 874 | 874 | |
| 875 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 876 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 875 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
| 876 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
| 877 | 877 | |
| 878 | 878 | if ($globalTimezone != '') { |
| 879 | 879 | date_default_timezone_set($globalTimezone); |
@@ -905,8 +905,8 @@ discard block |
||
| 905 | 905 | { |
| 906 | 906 | $limit_array = explode(",", $limit); |
| 907 | 907 | |
| 908 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 909 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 908 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 909 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 910 | 910 | |
| 911 | 911 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 912 | 912 | { |
@@ -917,8 +917,8 @@ discard block |
||
| 917 | 917 | |
| 918 | 918 | |
| 919 | 919 | if ($origLat != "" && $origLon != "" && $dist != "") { |
| 920 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
| 921 | - $query="SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 920 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
| 921 | + $query = "SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 922 | 922 | FROM marine_archive_output, marine_archive WHERE spotter_output_archive.fammarine_id = marine_archive.fammarine_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 923 | 923 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
| 924 | 924 | } else { |
@@ -935,12 +935,12 @@ discard block |
||
| 935 | 935 | $additional_query .= " AND (marine_archive_output.waypoints <> '')"; |
| 936 | 936 | } |
| 937 | 937 | |
| 938 | - $query = "SELECT marine_archive_output.* FROM marine_archive_output |
|
| 938 | + $query = "SELECT marine_archive_output.* FROM marine_archive_output |
|
| 939 | 939 | WHERE marine_archive_output.ident <> '' |
| 940 | 940 | ".$additional_query." |
| 941 | 941 | ".$filter_query.$orderby_query; |
| 942 | 942 | } |
| 943 | - $spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query); |
|
| 943 | + $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
|
| 944 | 944 | |
| 945 | 945 | return $spotter_array; |
| 946 | 946 | } |
@@ -957,7 +957,7 @@ discard block |
||
| 957 | 957 | try { |
| 958 | 958 | $sth = $this->db->prepare($query); |
| 959 | 959 | $sth->execute(); |
| 960 | - } catch(PDOException $e) { |
|
| 960 | + } catch (PDOException $e) { |
|
| 961 | 961 | return "error"; |
| 962 | 962 | } |
| 963 | 963 | return ''; |
@@ -997,8 +997,8 @@ discard block |
||
| 997 | 997 | { |
| 998 | 998 | $limit_array = explode(",", $limit); |
| 999 | 999 | |
| 1000 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1001 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1000 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1001 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1002 | 1002 | |
| 1003 | 1003 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1004 | 1004 | { |
@@ -1042,7 +1042,7 @@ discard block |
||
| 1042 | 1042 | $query_values = array(); |
| 1043 | 1043 | $limit_query = ''; |
| 1044 | 1044 | $additional_query = ''; |
| 1045 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1045 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1046 | 1046 | |
| 1047 | 1047 | if ($owner != "") |
| 1048 | 1048 | { |
@@ -1059,8 +1059,8 @@ discard block |
||
| 1059 | 1059 | { |
| 1060 | 1060 | $limit_array = explode(",", $limit); |
| 1061 | 1061 | |
| 1062 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1063 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1062 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1063 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1064 | 1064 | |
| 1065 | 1065 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1066 | 1066 | { |
@@ -1103,7 +1103,7 @@ discard block |
||
| 1103 | 1103 | $query_values = array(); |
| 1104 | 1104 | $limit_query = ''; |
| 1105 | 1105 | $additional_query = ''; |
| 1106 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1106 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1107 | 1107 | |
| 1108 | 1108 | if ($pilot != "") |
| 1109 | 1109 | { |
@@ -1115,8 +1115,8 @@ discard block |
||
| 1115 | 1115 | { |
| 1116 | 1116 | $limit_array = explode(",", $limit); |
| 1117 | 1117 | |
| 1118 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1119 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1118 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1119 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1120 | 1120 | |
| 1121 | 1121 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1122 | 1122 | { |
@@ -1148,7 +1148,7 @@ discard block |
||
| 1148 | 1148 | * @param string $sincedate |
| 1149 | 1149 | * @return array the airline country list |
| 1150 | 1150 | */ |
| 1151 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1151 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1152 | 1152 | { |
| 1153 | 1153 | global $globalDBdriver; |
| 1154 | 1154 | /* |
@@ -1177,7 +1177,7 @@ discard block |
||
| 1177 | 1177 | $flight_array = array(); |
| 1178 | 1178 | $temp_array = array(); |
| 1179 | 1179 | |
| 1180 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1180 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1181 | 1181 | { |
| 1182 | 1182 | $temp_array['flight_count'] = $row['nb']; |
| 1183 | 1183 | $temp_array['flight_country'] = $row['name']; |
@@ -1196,7 +1196,7 @@ discard block |
||
| 1196 | 1196 | * @param string $sincedate |
| 1197 | 1197 | * @return array the airline country list |
| 1198 | 1198 | */ |
| 1199 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1199 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1200 | 1200 | { |
| 1201 | 1201 | global $globalDBdriver; |
| 1202 | 1202 | /* |
@@ -1225,7 +1225,7 @@ discard block |
||
| 1225 | 1225 | $flight_array = array(); |
| 1226 | 1226 | $temp_array = array(); |
| 1227 | 1227 | |
| 1228 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1228 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1229 | 1229 | { |
| 1230 | 1230 | $temp_array['airline_icao'] = $row['airline_icao']; |
| 1231 | 1231 | $temp_array['flight_count'] = $row['nb']; |
@@ -1244,14 +1244,14 @@ discard block |
||
| 1244 | 1244 | * @param $date |
| 1245 | 1245 | * @return array the spotter information |
| 1246 | 1246 | */ |
| 1247 | - public function getDateArchiveMarineDataById($id,$date) |
|
| 1247 | + public function getDateArchiveMarineDataById($id, $date) |
|
| 1248 | 1248 | { |
| 1249 | 1249 | $Marine = new Marine($this->db); |
| 1250 | 1250 | date_default_timezone_set('UTC'); |
| 1251 | 1251 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 1252 | 1252 | $query = 'SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC'; |
| 1253 | - $date = date('c',$date); |
|
| 1254 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
| 1253 | + $date = date('c', $date); |
|
| 1254 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
| 1255 | 1255 | return $spotter_array; |
| 1256 | 1256 | } |
| 1257 | 1257 | |
@@ -1262,14 +1262,14 @@ discard block |
||
| 1262 | 1262 | * @param $date |
| 1263 | 1263 | * @return array the spotter information |
| 1264 | 1264 | */ |
| 1265 | - public function getDateArchiveMarineDataByIdent($ident,$date) |
|
| 1265 | + public function getDateArchiveMarineDataByIdent($ident, $date) |
|
| 1266 | 1266 | { |
| 1267 | 1267 | $Marine = new Marine($this->db); |
| 1268 | 1268 | date_default_timezone_set('UTC'); |
| 1269 | 1269 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 1270 | 1270 | $query = 'SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC'; |
| 1271 | - $date = date('c',$date); |
|
| 1272 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 1271 | + $date = date('c', $date); |
|
| 1272 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 1273 | 1273 | return $spotter_array; |
| 1274 | 1274 | } |
| 1275 | 1275 | |
@@ -1282,7 +1282,7 @@ discard block |
||
| 1282 | 1282 | * @param array $filters |
| 1283 | 1283 | * @return array the spotter information |
| 1284 | 1284 | */ |
| 1285 | - public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1285 | + public function getMarineDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
| 1286 | 1286 | { |
| 1287 | 1287 | global $global_query; |
| 1288 | 1288 | $Marine = new Marine($this->db); |
@@ -1290,7 +1290,7 @@ discard block |
||
| 1290 | 1290 | $query_values = array(); |
| 1291 | 1291 | $limit_query = ''; |
| 1292 | 1292 | $additional_query = ''; |
| 1293 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1293 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1294 | 1294 | |
| 1295 | 1295 | if ($airport != "") |
| 1296 | 1296 | { |
@@ -1307,8 +1307,8 @@ discard block |
||
| 1307 | 1307 | { |
| 1308 | 1308 | $limit_array = explode(",", $limit); |
| 1309 | 1309 | |
| 1310 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1311 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1310 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1311 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1312 | 1312 | |
| 1313 | 1313 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1314 | 1314 | { |
@@ -1784,7 +1784,7 @@ discard block |
||
| 1784 | 1784 | /** |
| 1785 | 1785 | * Counts all hours |
| 1786 | 1786 | * |
| 1787 | - * @param $orderby |
|
| 1787 | + * @param string $orderby |
|
| 1788 | 1788 | * @param array $filters |
| 1789 | 1789 | * @return array the hour list |
| 1790 | 1790 | */ |
@@ -2263,7 +2263,7 @@ discard block |
||
| 2263 | 2263 | /** |
| 2264 | 2264 | * Parses the direction degrees to working |
| 2265 | 2265 | * |
| 2266 | - * @param Float $direction the direction in degrees |
|
| 2266 | + * @param integer $direction the direction in degrees |
|
| 2267 | 2267 | * @return array the direction information |
| 2268 | 2268 | * |
| 2269 | 2269 | */ |
@@ -20,13 +20,13 @@ discard block |
||
| 20 | 20 | if ($this->db === null) die('Error: No DB connection. (Tracker)'); |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Get SQL query part for filter used |
|
| 25 | - * @param array $filter the filter |
|
| 26 | - * @param bool $where |
|
| 27 | - * @param bool $and |
|
| 28 | - * @return string the SQL part |
|
| 29 | - */ |
|
| 23 | + /** |
|
| 24 | + * Get SQL query part for filter used |
|
| 25 | + * @param array $filter the filter |
|
| 26 | + * @param bool $where |
|
| 27 | + * @param bool $and |
|
| 28 | + * @return string the SQL part |
|
| 29 | + */ |
|
| 30 | 30 | |
| 31 | 31 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 32 | 32 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
@@ -92,15 +92,15 @@ discard block |
||
| 92 | 92 | return $filter_query; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - /** |
|
| 96 | - * Executes the SQL statements to get the tracker information |
|
| 97 | - * |
|
| 98 | - * @param String $query the SQL query |
|
| 99 | - * @param array $params parameter of the query |
|
| 100 | - * @param String $limitQuery the limit query |
|
| 101 | - * @param bool $schedules |
|
| 102 | - * @return array the tracker information |
|
| 103 | - */ |
|
| 95 | + /** |
|
| 96 | + * Executes the SQL statements to get the tracker information |
|
| 97 | + * |
|
| 98 | + * @param String $query the SQL query |
|
| 99 | + * @param array $params parameter of the query |
|
| 100 | + * @param String $limitQuery the limit query |
|
| 101 | + * @param bool $schedules |
|
| 102 | + * @return array the tracker information |
|
| 103 | + */ |
|
| 104 | 104 | public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
| 105 | 105 | { |
| 106 | 106 | date_default_timezone_set('UTC'); |
@@ -212,14 +212,14 @@ discard block |
||
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | |
| 215 | - /** |
|
| 216 | - * Gets all the tracker information based on the latest data entry |
|
| 217 | - * |
|
| 218 | - * @param string $limit |
|
| 219 | - * @param string $sort |
|
| 220 | - * @param array $filter |
|
| 221 | - * @return array the tracker information |
|
| 222 | - */ |
|
| 215 | + /** |
|
| 216 | + * Gets all the tracker information based on the latest data entry |
|
| 217 | + * |
|
| 218 | + * @param string $limit |
|
| 219 | + * @param string $sort |
|
| 220 | + * @param array $filter |
|
| 221 | + * @return array the tracker information |
|
| 222 | + */ |
|
| 223 | 223 | public function getLatestTrackerData($limit = '', $sort = '', $filter = array()) |
| 224 | 224 | { |
| 225 | 225 | global $global_tracker_query; |
@@ -276,15 +276,15 @@ discard block |
||
| 276 | 276 | return $tracker_array; |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | - /** |
|
| 280 | - * Gets all the tracker information based on the callsign |
|
| 281 | - * |
|
| 282 | - * @param string $ident |
|
| 283 | - * @param string $limit |
|
| 284 | - * @param string $sort |
|
| 285 | - * @param array $filter |
|
| 286 | - * @return array the tracker information |
|
| 287 | - */ |
|
| 279 | + /** |
|
| 280 | + * Gets all the tracker information based on the callsign |
|
| 281 | + * |
|
| 282 | + * @param string $ident |
|
| 283 | + * @param string $limit |
|
| 284 | + * @param string $sort |
|
| 285 | + * @param array $filter |
|
| 286 | + * @return array the tracker information |
|
| 287 | + */ |
|
| 288 | 288 | public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '', $filter = array()) |
| 289 | 289 | { |
| 290 | 290 | global $global_tracker_query; |
@@ -393,13 +393,13 @@ discard block |
||
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | |
| 396 | - /** |
|
| 397 | - * Gets all source name |
|
| 398 | - * |
|
| 399 | - * @param String type format of source |
|
| 400 | - * @param array $filters |
|
| 401 | - * @return array list of source name |
|
| 402 | - */ |
|
| 396 | + /** |
|
| 397 | + * Gets all source name |
|
| 398 | + * |
|
| 399 | + * @param String type format of source |
|
| 400 | + * @param array $filters |
|
| 401 | + * @return array list of source name |
|
| 402 | + */ |
|
| 403 | 403 | public function getAllSourceName($type = '',$filters = array()) |
| 404 | 404 | { |
| 405 | 405 | $filter_query = $this->getFilter($filters,true,true); |
@@ -428,12 +428,12 @@ discard block |
||
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | |
| 431 | - /** |
|
| 432 | - * Gets a list of all idents/callsigns |
|
| 433 | - * |
|
| 434 | - * @param array $filters |
|
| 435 | - * @return array list of ident/callsign names |
|
| 436 | - */ |
|
| 431 | + /** |
|
| 432 | + * Gets a list of all idents/callsigns |
|
| 433 | + * |
|
| 434 | + * @param array $filters |
|
| 435 | + * @return array list of ident/callsign names |
|
| 436 | + */ |
|
| 437 | 437 | public function getAllIdents($filters = array()) |
| 438 | 438 | { |
| 439 | 439 | $filter_query = $this->getFilter($filters,true,true); |
@@ -500,19 +500,19 @@ discard block |
||
| 500 | 500 | } |
| 501 | 501 | |
| 502 | 502 | |
| 503 | - /** |
|
| 504 | - * Update ident tracker data |
|
| 505 | - * |
|
| 506 | - * @param string $famtrackid |
|
| 507 | - * @param String $ident the flight ident |
|
| 508 | - * @param null $fromsource |
|
| 509 | - * @return String success or false |
|
| 510 | - */ |
|
| 503 | + /** |
|
| 504 | + * Update ident tracker data |
|
| 505 | + * |
|
| 506 | + * @param string $famtrackid |
|
| 507 | + * @param String $ident the flight ident |
|
| 508 | + * @param null $fromsource |
|
| 509 | + * @return String success or false |
|
| 510 | + */ |
|
| 511 | 511 | public function updateIdentTrackerData($famtrackid = '', $ident = '',$fromsource = NULL) |
| 512 | 512 | { |
| 513 | 513 | |
| 514 | 514 | $query = 'UPDATE tracker_output SET ident = :ident WHERE famtrackid = :famtrackid'; |
| 515 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident); |
|
| 515 | + $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident); |
|
| 516 | 516 | |
| 517 | 517 | try { |
| 518 | 518 | $sth = $this->db->prepare($query); |
@@ -525,22 +525,22 @@ discard block |
||
| 525 | 525 | |
| 526 | 526 | } |
| 527 | 527 | |
| 528 | - /** |
|
| 529 | - * Update latest tracker data |
|
| 530 | - * |
|
| 531 | - * @param string $famtrackid |
|
| 532 | - * @param String $ident the flight ident |
|
| 533 | - * @param string $latitude |
|
| 534 | - * @param string $longitude |
|
| 535 | - * @param string $altitude |
|
| 536 | - * @param null $groundspeed |
|
| 537 | - * @param string $date |
|
| 538 | - * @return String success or false |
|
| 539 | - */ |
|
| 528 | + /** |
|
| 529 | + * Update latest tracker data |
|
| 530 | + * |
|
| 531 | + * @param string $famtrackid |
|
| 532 | + * @param String $ident the flight ident |
|
| 533 | + * @param string $latitude |
|
| 534 | + * @param string $longitude |
|
| 535 | + * @param string $altitude |
|
| 536 | + * @param null $groundspeed |
|
| 537 | + * @param string $date |
|
| 538 | + * @return String success or false |
|
| 539 | + */ |
|
| 540 | 540 | public function updateLatestTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $groundspeed = NULL, $date = '') |
| 541 | 541 | { |
| 542 | 542 | $query = 'UPDATE tracker_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE famtrackid = :famtrackid'; |
| 543 | - $query_values = array(':famtrackid' => $famtrackid,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
| 543 | + $query_values = array(':famtrackid' => $famtrackid,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
| 544 | 544 | |
| 545 | 545 | try { |
| 546 | 546 | $sth = $this->db->prepare($query); |
@@ -553,23 +553,23 @@ discard block |
||
| 553 | 553 | |
| 554 | 554 | } |
| 555 | 555 | |
| 556 | - /** |
|
| 557 | - * Adds a new tracker data |
|
| 558 | - * |
|
| 559 | - * @param string $famtrackid |
|
| 560 | - * @param String $ident the flight ident |
|
| 561 | - * @param String $latitude latitude of flight |
|
| 562 | - * @param String $longitude latitude of flight |
|
| 563 | - * @param String $altitude altitude of flight |
|
| 564 | - * @param String $heading heading of flight |
|
| 565 | - * @param String $groundspeed speed of flight |
|
| 566 | - * @param String $date date of flight |
|
| 567 | - * @param string $comment |
|
| 568 | - * @param string $type |
|
| 569 | - * @param string $format_source |
|
| 570 | - * @param string $source_name |
|
| 571 | - * @return String success or false |
|
| 572 | - */ |
|
| 556 | + /** |
|
| 557 | + * Adds a new tracker data |
|
| 558 | + * |
|
| 559 | + * @param string $famtrackid |
|
| 560 | + * @param String $ident the flight ident |
|
| 561 | + * @param String $latitude latitude of flight |
|
| 562 | + * @param String $longitude latitude of flight |
|
| 563 | + * @param String $altitude altitude of flight |
|
| 564 | + * @param String $heading heading of flight |
|
| 565 | + * @param String $groundspeed speed of flight |
|
| 566 | + * @param String $date date of flight |
|
| 567 | + * @param string $comment |
|
| 568 | + * @param string $type |
|
| 569 | + * @param string $format_source |
|
| 570 | + * @param string $source_name |
|
| 571 | + * @return String success or false |
|
| 572 | + */ |
|
| 573 | 573 | public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '',$format_source = '', $source_name = '') |
| 574 | 574 | { |
| 575 | 575 | //$Image = new Image($this->db); |
@@ -652,16 +652,16 @@ discard block |
||
| 652 | 652 | $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
| 653 | 653 | $type = filter_var($type,FILTER_SANITIZE_STRING); |
| 654 | 654 | |
| 655 | - if ($latitude == '' && $longitude == '') { |
|
| 656 | - $latitude = 0; |
|
| 657 | - $longitude = 0; |
|
| 658 | - } |
|
| 659 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 660 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 661 | - $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) |
|
| 655 | + if ($latitude == '' && $longitude == '') { |
|
| 656 | + $latitude = 0; |
|
| 657 | + $longitude = 0; |
|
| 658 | + } |
|
| 659 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 660 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 661 | + $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) |
|
| 662 | 662 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)"; |
| 663 | 663 | |
| 664 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':comment' => $comment,':type' => $type); |
|
| 664 | + $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':comment' => $comment,':type' => $type); |
|
| 665 | 665 | |
| 666 | 666 | try { |
| 667 | 667 | |
@@ -669,7 +669,7 @@ discard block |
||
| 669 | 669 | $sth->execute($query_values); |
| 670 | 670 | $this->db = null; |
| 671 | 671 | } catch (PDOException $e) { |
| 672 | - return "error : ".$e->getMessage(); |
|
| 672 | + return "error : ".$e->getMessage(); |
|
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | return "success"; |
@@ -677,12 +677,12 @@ discard block |
||
| 677 | 677 | } |
| 678 | 678 | |
| 679 | 679 | |
| 680 | - /** |
|
| 681 | - * Gets the aircraft ident within the last hour |
|
| 682 | - * |
|
| 683 | - * @param $ident |
|
| 684 | - * @return String the ident |
|
| 685 | - */ |
|
| 680 | + /** |
|
| 681 | + * Gets the aircraft ident within the last hour |
|
| 682 | + * |
|
| 683 | + * @param $ident |
|
| 684 | + * @return String the ident |
|
| 685 | + */ |
|
| 686 | 686 | public function getIdentFromLastHour($ident) |
| 687 | 687 | { |
| 688 | 688 | global $globalDBdriver; |
@@ -698,11 +698,11 @@ discard block |
||
| 698 | 698 | AND tracker_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 699 | 699 | AND tracker_output.date < now() AT TIME ZONE 'UTC'"; |
| 700 | 700 | $query_data = array(':ident' => $ident); |
| 701 | - } |
|
| 701 | + } |
|
| 702 | 702 | |
| 703 | 703 | $sth = $this->db->prepare($query); |
| 704 | 704 | $sth->execute($query_data); |
| 705 | - $ident_result=''; |
|
| 705 | + $ident_result=''; |
|
| 706 | 706 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 707 | 707 | { |
| 708 | 708 | $ident_result = $row['ident']; |
@@ -712,12 +712,12 @@ discard block |
||
| 712 | 712 | } |
| 713 | 713 | |
| 714 | 714 | |
| 715 | - /** |
|
| 716 | - * Gets the aircraft data from the last 20 seconds |
|
| 717 | - * |
|
| 718 | - * @param string $q |
|
| 719 | - * @return array the tracker data |
|
| 720 | - */ |
|
| 715 | + /** |
|
| 716 | + * Gets the aircraft data from the last 20 seconds |
|
| 717 | + * |
|
| 718 | + * @param string $q |
|
| 719 | + * @return array the tracker data |
|
| 720 | + */ |
|
| 721 | 721 | public function getRealTimeData($q = '') |
| 722 | 722 | { |
| 723 | 723 | global $globalDBdriver; |
@@ -750,15 +750,15 @@ discard block |
||
| 750 | 750 | return $tracker_array; |
| 751 | 751 | } |
| 752 | 752 | |
| 753 | - /** |
|
| 754 | - * Gets all number of flight over countries |
|
| 755 | - * |
|
| 756 | - * @param bool $limit |
|
| 757 | - * @param int $olderthanmonths |
|
| 758 | - * @param string $sincedate |
|
| 759 | - * @param array $filters |
|
| 760 | - * @return array the airline country list |
|
| 761 | - */ |
|
| 753 | + /** |
|
| 754 | + * Gets all number of flight over countries |
|
| 755 | + * |
|
| 756 | + * @param bool $limit |
|
| 757 | + * @param int $olderthanmonths |
|
| 758 | + * @param string $sincedate |
|
| 759 | + * @param array $filters |
|
| 760 | + * @return array the airline country list |
|
| 761 | + */ |
|
| 762 | 762 | public function countAllTrackerOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
| 763 | 763 | { |
| 764 | 764 | global $globalDBdriver, $globalArchive; |
@@ -827,18 +827,18 @@ discard block |
||
| 827 | 827 | return $flight_array; |
| 828 | 828 | } |
| 829 | 829 | |
| 830 | - /** |
|
| 831 | - * Gets all callsigns that have flown over |
|
| 832 | - * |
|
| 833 | - * @param bool $limit |
|
| 834 | - * @param int $olderthanmonths |
|
| 835 | - * @param string $sincedate |
|
| 836 | - * @param array $filters |
|
| 837 | - * @param string $year |
|
| 838 | - * @param string $month |
|
| 839 | - * @param string $day |
|
| 840 | - * @return array the callsign list |
|
| 841 | - */ |
|
| 830 | + /** |
|
| 831 | + * Gets all callsigns that have flown over |
|
| 832 | + * |
|
| 833 | + * @param bool $limit |
|
| 834 | + * @param int $olderthanmonths |
|
| 835 | + * @param string $sincedate |
|
| 836 | + * @param array $filters |
|
| 837 | + * @param string $year |
|
| 838 | + * @param string $month |
|
| 839 | + * @param string $day |
|
| 840 | + * @return array the callsign list |
|
| 841 | + */ |
|
| 842 | 842 | public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
| 843 | 843 | { |
| 844 | 844 | global $globalDBdriver; |
@@ -904,12 +904,12 @@ discard block |
||
| 904 | 904 | } |
| 905 | 905 | |
| 906 | 906 | |
| 907 | - /** |
|
| 908 | - * Counts all dates |
|
| 909 | - * |
|
| 910 | - * @param array $filters |
|
| 911 | - * @return array the date list |
|
| 912 | - */ |
|
| 907 | + /** |
|
| 908 | + * Counts all dates |
|
| 909 | + * |
|
| 910 | + * @param array $filters |
|
| 911 | + * @return array the date list |
|
| 912 | + */ |
|
| 913 | 913 | public function countAllDates($filters = array()) |
| 914 | 914 | { |
| 915 | 915 | global $globalTimezone, $globalDBdriver; |
@@ -954,12 +954,12 @@ discard block |
||
| 954 | 954 | } |
| 955 | 955 | |
| 956 | 956 | |
| 957 | - /** |
|
| 958 | - * Counts all dates during the last 7 days |
|
| 959 | - * |
|
| 960 | - * @param array $filters |
|
| 961 | - * @return array the date list |
|
| 962 | - */ |
|
| 957 | + /** |
|
| 958 | + * Counts all dates during the last 7 days |
|
| 959 | + * |
|
| 960 | + * @param array $filters |
|
| 961 | + * @return array the date list |
|
| 962 | + */ |
|
| 963 | 963 | public function countAllDatesLast7Days($filters = array()) |
| 964 | 964 | { |
| 965 | 965 | global $globalTimezone, $globalDBdriver; |
@@ -981,7 +981,7 @@ discard block |
||
| 981 | 981 | $query .= " GROUP BY date_name |
| 982 | 982 | ORDER BY date_name ASC"; |
| 983 | 983 | $query_data = array(':offset' => $offset); |
| 984 | - } |
|
| 984 | + } |
|
| 985 | 985 | |
| 986 | 986 | $sth = $this->db->prepare($query); |
| 987 | 987 | $sth->execute($query_data); |
@@ -1000,12 +1000,12 @@ discard block |
||
| 1000 | 1000 | return $date_array; |
| 1001 | 1001 | } |
| 1002 | 1002 | |
| 1003 | - /** |
|
| 1004 | - * Counts all dates during the last month |
|
| 1005 | - * |
|
| 1006 | - * @param array $filters |
|
| 1007 | - * @return array the date list |
|
| 1008 | - */ |
|
| 1003 | + /** |
|
| 1004 | + * Counts all dates during the last month |
|
| 1005 | + * |
|
| 1006 | + * @param array $filters |
|
| 1007 | + * @return array the date list |
|
| 1008 | + */ |
|
| 1009 | 1009 | public function countAllDatesLastMonth($filters = array()) |
| 1010 | 1010 | { |
| 1011 | 1011 | global $globalTimezone, $globalDBdriver; |
@@ -1027,7 +1027,7 @@ discard block |
||
| 1027 | 1027 | $query .= " GROUP BY date_name |
| 1028 | 1028 | ORDER BY date_name ASC"; |
| 1029 | 1029 | $query_data = array(':offset' => $offset); |
| 1030 | - } |
|
| 1030 | + } |
|
| 1031 | 1031 | |
| 1032 | 1032 | $sth = $this->db->prepare($query); |
| 1033 | 1033 | $sth->execute($query_data); |
@@ -1047,12 +1047,12 @@ discard block |
||
| 1047 | 1047 | } |
| 1048 | 1048 | |
| 1049 | 1049 | |
| 1050 | - /** |
|
| 1051 | - * Counts all month |
|
| 1052 | - * |
|
| 1053 | - * @param array $filters |
|
| 1054 | - * @return array the month list |
|
| 1055 | - */ |
|
| 1050 | + /** |
|
| 1051 | + * Counts all month |
|
| 1052 | + * |
|
| 1053 | + * @param array $filters |
|
| 1054 | + * @return array the month list |
|
| 1055 | + */ |
|
| 1056 | 1056 | public function countAllMonths($filters = array()) |
| 1057 | 1057 | { |
| 1058 | 1058 | global $globalTimezone, $globalDBdriver; |
@@ -1094,12 +1094,12 @@ discard block |
||
| 1094 | 1094 | } |
| 1095 | 1095 | |
| 1096 | 1096 | |
| 1097 | - /** |
|
| 1098 | - * Counts all dates during the last year |
|
| 1099 | - * |
|
| 1100 | - * @param $filters |
|
| 1101 | - * @return array the date list |
|
| 1102 | - */ |
|
| 1097 | + /** |
|
| 1098 | + * Counts all dates during the last year |
|
| 1099 | + * |
|
| 1100 | + * @param $filters |
|
| 1101 | + * @return array the date list |
|
| 1102 | + */ |
|
| 1103 | 1103 | public function countAllMonthsLastYear($filters) |
| 1104 | 1104 | { |
| 1105 | 1105 | global $globalTimezone, $globalDBdriver; |
@@ -1121,7 +1121,7 @@ discard block |
||
| 1121 | 1121 | $query .= " GROUP BY year_name, month_name |
| 1122 | 1122 | ORDER BY year_name, month_name ASC"; |
| 1123 | 1123 | $query_data = array(':offset' => $offset); |
| 1124 | - } |
|
| 1124 | + } |
|
| 1125 | 1125 | |
| 1126 | 1126 | $sth = $this->db->prepare($query); |
| 1127 | 1127 | $sth->execute($query_data); |
@@ -1142,13 +1142,13 @@ discard block |
||
| 1142 | 1142 | } |
| 1143 | 1143 | |
| 1144 | 1144 | |
| 1145 | - /** |
|
| 1146 | - * Counts all hours |
|
| 1147 | - * |
|
| 1148 | - * @param $orderby |
|
| 1149 | - * @param array $filters |
|
| 1150 | - * @return array the hour list |
|
| 1151 | - */ |
|
| 1145 | + /** |
|
| 1146 | + * Counts all hours |
|
| 1147 | + * |
|
| 1148 | + * @param $orderby |
|
| 1149 | + * @param array $filters |
|
| 1150 | + * @return array the hour list |
|
| 1151 | + */ |
|
| 1152 | 1152 | public function countAllHours($orderby,$filters = array()) |
| 1153 | 1153 | { |
| 1154 | 1154 | global $globalTimezone, $globalDBdriver; |
@@ -1209,13 +1209,13 @@ discard block |
||
| 1209 | 1209 | } |
| 1210 | 1210 | |
| 1211 | 1211 | |
| 1212 | - /** |
|
| 1213 | - * Counts all hours by date |
|
| 1214 | - * |
|
| 1215 | - * @param $date |
|
| 1216 | - * @param array $filters |
|
| 1217 | - * @return array the hour list |
|
| 1218 | - */ |
|
| 1212 | + /** |
|
| 1213 | + * Counts all hours by date |
|
| 1214 | + * |
|
| 1215 | + * @param $date |
|
| 1216 | + * @param array $filters |
|
| 1217 | + * @return array the hour list |
|
| 1218 | + */ |
|
| 1219 | 1219 | public function countAllHoursByDate($date, $filters = array()) |
| 1220 | 1220 | { |
| 1221 | 1221 | global $globalTimezone, $globalDBdriver; |
@@ -1257,13 +1257,13 @@ discard block |
||
| 1257 | 1257 | } |
| 1258 | 1258 | |
| 1259 | 1259 | |
| 1260 | - /** |
|
| 1261 | - * Counts all hours by a ident/callsign |
|
| 1262 | - * |
|
| 1263 | - * @param $ident |
|
| 1264 | - * @param array $filters |
|
| 1265 | - * @return array the hour list |
|
| 1266 | - */ |
|
| 1260 | + /** |
|
| 1261 | + * Counts all hours by a ident/callsign |
|
| 1262 | + * |
|
| 1263 | + * @param $ident |
|
| 1264 | + * @param array $filters |
|
| 1265 | + * @return array the hour list |
|
| 1266 | + */ |
|
| 1267 | 1267 | public function countAllHoursByIdent($ident, $filters = array()) |
| 1268 | 1268 | { |
| 1269 | 1269 | global $globalTimezone, $globalDBdriver; |
@@ -1306,14 +1306,14 @@ discard block |
||
| 1306 | 1306 | } |
| 1307 | 1307 | |
| 1308 | 1308 | |
| 1309 | - /** |
|
| 1310 | - * Counts all trackers that have flown over |
|
| 1311 | - * |
|
| 1312 | - * @param array $filters |
|
| 1313 | - * @param string $year |
|
| 1314 | - * @param string $month |
|
| 1315 | - * @return Integer the number of trackers |
|
| 1316 | - */ |
|
| 1309 | + /** |
|
| 1310 | + * Counts all trackers that have flown over |
|
| 1311 | + * |
|
| 1312 | + * @param array $filters |
|
| 1313 | + * @param string $year |
|
| 1314 | + * @param string $month |
|
| 1315 | + * @return Integer the number of trackers |
|
| 1316 | + */ |
|
| 1317 | 1317 | public function countOverallTracker($filters = array(),$year = '',$month = '') |
| 1318 | 1318 | { |
| 1319 | 1319 | global $globalDBdriver; |
@@ -1347,14 +1347,14 @@ discard block |
||
| 1347 | 1347 | return $sth->fetchColumn(); |
| 1348 | 1348 | } |
| 1349 | 1349 | |
| 1350 | - /** |
|
| 1351 | - * Counts all trackers type that have flown over |
|
| 1352 | - * |
|
| 1353 | - * @param array $filters |
|
| 1354 | - * @param string $year |
|
| 1355 | - * @param string $month |
|
| 1356 | - * @return Integer the number of flights |
|
| 1357 | - */ |
|
| 1350 | + /** |
|
| 1351 | + * Counts all trackers type that have flown over |
|
| 1352 | + * |
|
| 1353 | + * @param array $filters |
|
| 1354 | + * @param string $year |
|
| 1355 | + * @param string $month |
|
| 1356 | + * @return Integer the number of flights |
|
| 1357 | + */ |
|
| 1358 | 1358 | public function countOverallTrackerTypes($filters = array(),$year = '',$month = '') |
| 1359 | 1359 | { |
| 1360 | 1360 | global $globalDBdriver; |
@@ -1388,12 +1388,12 @@ discard block |
||
| 1388 | 1388 | } |
| 1389 | 1389 | |
| 1390 | 1390 | |
| 1391 | - /** |
|
| 1392 | - * Counts all hours of today |
|
| 1393 | - * |
|
| 1394 | - * @param array $filters |
|
| 1395 | - * @return array the hour list |
|
| 1396 | - */ |
|
| 1391 | + /** |
|
| 1392 | + * Counts all hours of today |
|
| 1393 | + * |
|
| 1394 | + * @param array $filters |
|
| 1395 | + * @return array the hour list |
|
| 1396 | + */ |
|
| 1397 | 1397 | public function countAllHoursFromToday($filters = array()) |
| 1398 | 1398 | { |
| 1399 | 1399 | global $globalTimezone, $globalDBdriver; |
@@ -1433,12 +1433,12 @@ discard block |
||
| 1433 | 1433 | } |
| 1434 | 1434 | |
| 1435 | 1435 | |
| 1436 | - /** |
|
| 1437 | - * Gets the Barrie Spotter ID based on the FlightAware ID |
|
| 1438 | - * |
|
| 1439 | - * @param $famtrackid |
|
| 1440 | - * @return Integer the Barrie Spotter ID |
|
| 1441 | - */ |
|
| 1436 | + /** |
|
| 1437 | + * Gets the Barrie Spotter ID based on the FlightAware ID |
|
| 1438 | + * |
|
| 1439 | + * @param $famtrackid |
|
| 1440 | + * @return Integer the Barrie Spotter ID |
|
| 1441 | + */ |
|
| 1442 | 1442 | public function getTrackerIDBasedOnFamTrackID($famtrackid) |
| 1443 | 1443 | { |
| 1444 | 1444 | $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
@@ -1459,13 +1459,13 @@ discard block |
||
| 1459 | 1459 | |
| 1460 | 1460 | |
| 1461 | 1461 | /** |
| 1462 | - * Parses a date string |
|
| 1463 | - * |
|
| 1464 | - * @param String $dateString the date string |
|
| 1465 | - * @param String $timezone the timezone of a user |
|
| 1466 | - * @return array the time information |
|
| 1467 | - * |
|
| 1468 | - */ |
|
| 1462 | + * Parses a date string |
|
| 1463 | + * |
|
| 1464 | + * @param String $dateString the date string |
|
| 1465 | + * @param String $timezone the timezone of a user |
|
| 1466 | + * @return array the time information |
|
| 1467 | + * |
|
| 1468 | + */ |
|
| 1469 | 1469 | public function parseDateString($dateString, $timezone = '') |
| 1470 | 1470 | { |
| 1471 | 1471 | $time_array = array(); |
@@ -1498,12 +1498,12 @@ discard block |
||
| 1498 | 1498 | } |
| 1499 | 1499 | |
| 1500 | 1500 | /** |
| 1501 | - * Parses the direction degrees to working |
|
| 1502 | - * |
|
| 1503 | - * @param Float $direction the direction in degrees |
|
| 1504 | - * @return array the direction information |
|
| 1505 | - * |
|
| 1506 | - */ |
|
| 1501 | + * Parses the direction degrees to working |
|
| 1502 | + * |
|
| 1503 | + * @param Float $direction the direction in degrees |
|
| 1504 | + * @return array the direction information |
|
| 1505 | + * |
|
| 1506 | + */ |
|
| 1507 | 1507 | public function parseDirection($direction = 0) |
| 1508 | 1508 | { |
| 1509 | 1509 | if ($direction == '') $direction = 0; |
@@ -1582,12 +1582,12 @@ discard block |
||
| 1582 | 1582 | |
| 1583 | 1583 | |
| 1584 | 1584 | /** |
| 1585 | - * Gets Country from latitude/longitude |
|
| 1586 | - * |
|
| 1587 | - * @param Float $latitude latitute of the flight |
|
| 1588 | - * @param Float $longitude longitute of the flight |
|
| 1589 | - * @return String the countrie |
|
| 1590 | - */ |
|
| 1585 | + * Gets Country from latitude/longitude |
|
| 1586 | + * |
|
| 1587 | + * @param Float $latitude latitute of the flight |
|
| 1588 | + * @param Float $longitude longitute of the flight |
|
| 1589 | + * @return String the countrie |
|
| 1590 | + */ |
|
| 1591 | 1591 | public function getCountryFromLatitudeLongitude($latitude,$longitude) |
| 1592 | 1592 | { |
| 1593 | 1593 | global $globalDebug; |
@@ -1615,11 +1615,11 @@ discard block |
||
| 1615 | 1615 | } |
| 1616 | 1616 | |
| 1617 | 1617 | /** |
| 1618 | - * Gets Country from iso2 |
|
| 1619 | - * |
|
| 1620 | - * @param String $iso2 ISO2 country code |
|
| 1621 | - * @return String the countrie |
|
| 1622 | - */ |
|
| 1618 | + * Gets Country from iso2 |
|
| 1619 | + * |
|
| 1620 | + * @param String $iso2 ISO2 country code |
|
| 1621 | + * @return String the countrie |
|
| 1622 | + */ |
|
| 1623 | 1623 | public function getCountryFromISO2($iso2) |
| 1624 | 1624 | { |
| 1625 | 1625 | global $globalDebug; |
@@ -1646,18 +1646,18 @@ discard block |
||
| 1646 | 1646 | |
| 1647 | 1647 | } |
| 1648 | 1648 | |
| 1649 | - /** |
|
| 1650 | - * Gets all vessels types that have flown over |
|
| 1651 | - * |
|
| 1652 | - * @param bool $limit |
|
| 1653 | - * @param int $olderthanmonths |
|
| 1654 | - * @param string $sincedate |
|
| 1655 | - * @param array $filters |
|
| 1656 | - * @param string $year |
|
| 1657 | - * @param string $month |
|
| 1658 | - * @param string $day |
|
| 1659 | - * @return array the vessel type list |
|
| 1660 | - */ |
|
| 1649 | + /** |
|
| 1650 | + * Gets all vessels types that have flown over |
|
| 1651 | + * |
|
| 1652 | + * @param bool $limit |
|
| 1653 | + * @param int $olderthanmonths |
|
| 1654 | + * @param string $sincedate |
|
| 1655 | + * @param array $filters |
|
| 1656 | + * @param string $year |
|
| 1657 | + * @param string $month |
|
| 1658 | + * @param string $day |
|
| 1659 | + * @return array the vessel type list |
|
| 1660 | + */ |
|
| 1661 | 1661 | public function countAllTrackerTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
| 1662 | 1662 | { |
| 1663 | 1663 | global $globalDBdriver; |
@@ -1721,21 +1721,21 @@ discard block |
||
| 1721 | 1721 | return $tracker_array; |
| 1722 | 1722 | } |
| 1723 | 1723 | |
| 1724 | - /** |
|
| 1725 | - * Gets all the tracker information |
|
| 1726 | - * |
|
| 1727 | - * @param string $q |
|
| 1728 | - * @param string $callsign |
|
| 1729 | - * @param string $date_posted |
|
| 1730 | - * @param string $limit |
|
| 1731 | - * @param string $sort |
|
| 1732 | - * @param string $includegeodata |
|
| 1733 | - * @param string $origLat |
|
| 1734 | - * @param string $origLon |
|
| 1735 | - * @param string $dist |
|
| 1736 | - * @param array $filters |
|
| 1737 | - * @return array the tracker information |
|
| 1738 | - */ |
|
| 1724 | + /** |
|
| 1725 | + * Gets all the tracker information |
|
| 1726 | + * |
|
| 1727 | + * @param string $q |
|
| 1728 | + * @param string $callsign |
|
| 1729 | + * @param string $date_posted |
|
| 1730 | + * @param string $limit |
|
| 1731 | + * @param string $sort |
|
| 1732 | + * @param string $includegeodata |
|
| 1733 | + * @param string $origLat |
|
| 1734 | + * @param string $origLon |
|
| 1735 | + * @param string $dist |
|
| 1736 | + * @param array $filters |
|
| 1737 | + * @return array the tracker information |
|
| 1738 | + */ |
|
| 1739 | 1739 | public function searchTrackerData($q = '', $callsign = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array()) |
| 1740 | 1740 | { |
| 1741 | 1741 | global $globalTimezone, $globalDBdriver; |
@@ -1840,12 +1840,12 @@ discard block |
||
| 1840 | 1840 | } |
| 1841 | 1841 | |
| 1842 | 1842 | /** |
| 1843 | - * Gets the short url from bit.ly |
|
| 1844 | - * |
|
| 1845 | - * @param String $url the full url |
|
| 1846 | - * @return String the bit.ly url |
|
| 1847 | - * |
|
| 1848 | - */ |
|
| 1843 | + * Gets the short url from bit.ly |
|
| 1844 | + * |
|
| 1845 | + * @param String $url the full url |
|
| 1846 | + * @return String the bit.ly url |
|
| 1847 | + * |
|
| 1848 | + */ |
|
| 1849 | 1849 | public function getBitlyURL($url) |
| 1850 | 1850 | { |
| 1851 | 1851 | global $globalBitlyAccessToken; |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | require_once(dirname(__FILE__).'/class.Image.php'); |
| 12 | 12 | $global_tracker_query = "SELECT tracker_output.* FROM tracker_output"; |
| 13 | 13 | |
| 14 | -class Tracker{ |
|
| 14 | +class Tracker { |
|
| 15 | 15 | public $db; |
| 16 | 16 | |
| 17 | 17 | public function __construct($dbc = null) { |
@@ -28,33 +28,33 @@ discard block |
||
| 28 | 28 | * @return string the SQL part |
| 29 | 29 | */ |
| 30 | 30 | |
| 31 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 31 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 32 | 32 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 33 | 33 | $filters = array(); |
| 34 | 34 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 35 | 35 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 36 | 36 | $filters = $globalStatsFilters[$globalFilterName]; |
| 37 | 37 | } else { |
| 38 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 38 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | if (isset($filter[0]['source'])) { |
| 42 | - $filters = array_merge($filters,$filter); |
|
| 42 | + $filters = array_merge($filters, $filter); |
|
| 43 | 43 | } |
| 44 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 44 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 45 | 45 | $filter_query_join = ''; |
| 46 | 46 | $filter_query_where = ''; |
| 47 | - foreach($filters as $flt) { |
|
| 47 | + foreach ($filters as $flt) { |
|
| 48 | 48 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 49 | 49 | if (isset($flt['source'])) { |
| 50 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid"; |
|
| 50 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."') AND tracker_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid"; |
|
| 51 | 51 | } else { |
| 52 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid"; |
|
| 52 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid"; |
|
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 57 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 57 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 58 | 58 | } |
| 59 | 59 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 60 | 60 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 87 | 87 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 88 | 88 | if ($filter_query_where != '') { |
| 89 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 89 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 90 | 90 | } |
| 91 | 91 | $filter_query = $filter_query_join.$filter_query_where; |
| 92 | 92 | return $filter_query; |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * @param bool $schedules |
| 102 | 102 | * @return array the tracker information |
| 103 | 103 | */ |
| 104 | - public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
|
| 104 | + public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false) |
|
| 105 | 105 | { |
| 106 | 106 | date_default_timezone_set('UTC'); |
| 107 | 107 | if (!is_string($query)) |
@@ -121,13 +121,13 @@ discard block |
||
| 121 | 121 | $sth = $this->db->prepare($query.$limitQuery); |
| 122 | 122 | $sth->execute($params); |
| 123 | 123 | } catch (PDOException $e) { |
| 124 | - printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); |
|
| 124 | + printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery); |
|
| 125 | 125 | exit(); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | $num_rows = 0; |
| 129 | 129 | $tracker_array = array(); |
| 130 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 130 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 131 | 131 | { |
| 132 | 132 | $num_rows++; |
| 133 | 133 | $temp_array = array(); |
@@ -183,17 +183,17 @@ discard block |
||
| 183 | 183 | { |
| 184 | 184 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
| 185 | 185 | } else { |
| 186 | - $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
|
| 186 | + $temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC")); |
|
| 187 | 187 | } |
| 188 | 188 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
| 189 | - $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
|
| 190 | - $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
|
| 189 | + $temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC")); |
|
| 190 | + $temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC")); |
|
| 191 | 191 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
| 192 | 192 | if (isset($row['last_seen']) && $row['last_seen'] != '') { |
| 193 | 193 | if (strtotime($row['last_seen']) > strtotime($row['date'])) { |
| 194 | 194 | $temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']); |
| 195 | - $temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC")); |
|
| 196 | - $temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC")); |
|
| 195 | + $temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC")); |
|
| 196 | + $temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC")); |
|
| 197 | 197 | $temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC"); |
| 198 | 198 | } |
| 199 | 199 | } |
@@ -232,8 +232,8 @@ discard block |
||
| 232 | 232 | { |
| 233 | 233 | $limit_array = explode(",", $limit); |
| 234 | 234 | |
| 235 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 236 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 235 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 236 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 237 | 237 | |
| 238 | 238 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 239 | 239 | { |
@@ -250,9 +250,9 @@ discard block |
||
| 250 | 250 | $orderby_query = " ORDER BY tracker_output.date DESC"; |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - $query = $global_tracker_query.$filter_query." ".$orderby_query; |
|
| 253 | + $query = $global_tracker_query.$filter_query." ".$orderby_query; |
|
| 254 | 254 | |
| 255 | - $tracker_array = $this->getDataFromDB($query, array(),$limit_query,true); |
|
| 255 | + $tracker_array = $this->getDataFromDB($query, array(), $limit_query, true); |
|
| 256 | 256 | |
| 257 | 257 | return $tracker_array; |
| 258 | 258 | } |
@@ -271,8 +271,8 @@ discard block |
||
| 271 | 271 | if ($id == '') return array(); |
| 272 | 272 | $additional_query = "tracker_output.famtrackid = :id"; |
| 273 | 273 | $query_values = array(':id' => $id); |
| 274 | - $query = $global_tracker_query." WHERE ".$additional_query." "; |
|
| 275 | - $tracker_array = $this->getDataFromDB($query,$query_values); |
|
| 274 | + $query = $global_tracker_query." WHERE ".$additional_query." "; |
|
| 275 | + $tracker_array = $this->getDataFromDB($query, $query_values); |
|
| 276 | 276 | return $tracker_array; |
| 277 | 277 | } |
| 278 | 278 | |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | $query_values = array(); |
| 295 | 295 | $limit_query = ''; |
| 296 | 296 | $additional_query = ''; |
| 297 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 297 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 298 | 298 | if ($ident != "") |
| 299 | 299 | { |
| 300 | 300 | if (!is_string($ident)) |
@@ -310,8 +310,8 @@ discard block |
||
| 310 | 310 | { |
| 311 | 311 | $limit_array = explode(",", $limit); |
| 312 | 312 | |
| 313 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 314 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 313 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 314 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 315 | 315 | |
| 316 | 316 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 317 | 317 | { |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | return $tracker_array; |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | - public function getTrackerDataByDate($date = '', $limit = '', $sort = '',$filter = array()) |
|
| 338 | + public function getTrackerDataByDate($date = '', $limit = '', $sort = '', $filter = array()) |
|
| 339 | 339 | { |
| 340 | 340 | global $global_tracker_query, $globalTimezone, $globalDBdriver; |
| 341 | 341 | |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | $limit_query = ''; |
| 344 | 344 | $additional_query = ''; |
| 345 | 345 | |
| 346 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 346 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 347 | 347 | |
| 348 | 348 | if ($date != "") |
| 349 | 349 | { |
@@ -369,8 +369,8 @@ discard block |
||
| 369 | 369 | { |
| 370 | 370 | $limit_array = explode(",", $limit); |
| 371 | 371 | |
| 372 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 373 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 372 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 373 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 374 | 374 | |
| 375 | 375 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 376 | 376 | { |
@@ -400,11 +400,11 @@ discard block |
||
| 400 | 400 | * @param array $filters |
| 401 | 401 | * @return array list of source name |
| 402 | 402 | */ |
| 403 | - public function getAllSourceName($type = '',$filters = array()) |
|
| 403 | + public function getAllSourceName($type = '', $filters = array()) |
|
| 404 | 404 | { |
| 405 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 405 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 406 | 406 | $query_values = array(); |
| 407 | - $query = "SELECT DISTINCT tracker_output.source_name |
|
| 407 | + $query = "SELECT DISTINCT tracker_output.source_name |
|
| 408 | 408 | FROM tracker_output".$filter_query." tracker_output.source_name <> ''"; |
| 409 | 409 | if ($type != '') { |
| 410 | 410 | $query_values = array(':type' => $type); |
@@ -419,7 +419,7 @@ discard block |
||
| 419 | 419 | $source_array = array(); |
| 420 | 420 | $temp_array = array(); |
| 421 | 421 | |
| 422 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 422 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 423 | 423 | { |
| 424 | 424 | $temp_array['source_name'] = $row['source_name']; |
| 425 | 425 | $source_array[] = $temp_array; |
@@ -436,8 +436,8 @@ discard block |
||
| 436 | 436 | */ |
| 437 | 437 | public function getAllIdents($filters = array()) |
| 438 | 438 | { |
| 439 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 440 | - $query = "SELECT DISTINCT tracker_output.ident |
|
| 439 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 440 | + $query = "SELECT DISTINCT tracker_output.ident |
|
| 441 | 441 | FROM tracker_output".$filter_query." tracker_output.ident <> '' |
| 442 | 442 | ORDER BY tracker_output.date ASC LIMIT 700 OFFSET 0"; |
| 443 | 443 | |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | $ident_array = array(); |
| 448 | 448 | $temp_array = array(); |
| 449 | 449 | |
| 450 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 450 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 451 | 451 | { |
| 452 | 452 | $temp_array['ident'] = $row['ident']; |
| 453 | 453 | $ident_array[] = $temp_array; |
@@ -472,12 +472,12 @@ discard block |
||
| 472 | 472 | } else $offset = '+00:00'; |
| 473 | 473 | |
| 474 | 474 | if ($globalDBdriver == 'mysql') { |
| 475 | - $query = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date |
|
| 475 | + $query = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date |
|
| 476 | 476 | FROM tracker_output |
| 477 | 477 | WHERE tracker_output.date <> '' |
| 478 | 478 | ORDER BY tracker_output.date ASC LIMIT 0,100"; |
| 479 | 479 | } else { |
| 480 | - $query = "SELECT DISTINCT to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
| 480 | + $query = "SELECT DISTINCT to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
| 481 | 481 | FROM tracker_output |
| 482 | 482 | WHERE tracker_output.date <> '' |
| 483 | 483 | ORDER BY tracker_output.date ASC LIMIT 0,100"; |
@@ -489,7 +489,7 @@ discard block |
||
| 489 | 489 | $date_array = array(); |
| 490 | 490 | $temp_array = array(); |
| 491 | 491 | |
| 492 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 492 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 493 | 493 | { |
| 494 | 494 | $temp_array['date'] = $row['date']; |
| 495 | 495 | |
@@ -508,11 +508,11 @@ discard block |
||
| 508 | 508 | * @param null $fromsource |
| 509 | 509 | * @return String success or false |
| 510 | 510 | */ |
| 511 | - public function updateIdentTrackerData($famtrackid = '', $ident = '',$fromsource = NULL) |
|
| 511 | + public function updateIdentTrackerData($famtrackid = '', $ident = '', $fromsource = NULL) |
|
| 512 | 512 | { |
| 513 | 513 | |
| 514 | 514 | $query = 'UPDATE tracker_output SET ident = :ident WHERE famtrackid = :famtrackid'; |
| 515 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident); |
|
| 515 | + $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident); |
|
| 516 | 516 | |
| 517 | 517 | try { |
| 518 | 518 | $sth = $this->db->prepare($query); |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | public function updateLatestTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $groundspeed = NULL, $date = '') |
| 541 | 541 | { |
| 542 | 542 | $query = 'UPDATE tracker_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE famtrackid = :famtrackid'; |
| 543 | - $query_values = array(':famtrackid' => $famtrackid,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
| 543 | + $query_values = array(':famtrackid' => $famtrackid, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_altitude' => $altitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident); |
|
| 544 | 544 | |
| 545 | 545 | try { |
| 546 | 546 | $sth = $this->db->prepare($query); |
@@ -570,7 +570,7 @@ discard block |
||
| 570 | 570 | * @param string $source_name |
| 571 | 571 | * @return String success or false |
| 572 | 572 | */ |
| 573 | - public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '',$format_source = '', $source_name = '') |
|
| 573 | + public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '', $format_source = '', $source_name = '') |
|
| 574 | 574 | { |
| 575 | 575 | //$Image = new Image($this->db); |
| 576 | 576 | $Common = new Common(); |
@@ -636,21 +636,21 @@ discard block |
||
| 636 | 636 | } |
| 637 | 637 | |
| 638 | 638 | |
| 639 | - if ($date == "" || strtotime($date) < time()-20*60) |
|
| 639 | + if ($date == "" || strtotime($date) < time() - 20*60) |
|
| 640 | 640 | { |
| 641 | 641 | $date = date("Y-m-d H:i:s", time()); |
| 642 | 642 | } |
| 643 | 643 | |
| 644 | - $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
|
| 645 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 646 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 647 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 648 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 649 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 650 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 651 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 652 | - $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
|
| 653 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
| 644 | + $famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING); |
|
| 645 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 646 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 647 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 648 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 649 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 650 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 651 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 652 | + $comment = filter_var($comment, FILTER_SANITIZE_STRING); |
|
| 653 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
| 654 | 654 | |
| 655 | 655 | if ($latitude == '' && $longitude == '') { |
| 656 | 656 | $latitude = 0; |
@@ -658,10 +658,10 @@ discard block |
||
| 658 | 658 | } |
| 659 | 659 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
| 660 | 660 | if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
| 661 | - $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) |
|
| 661 | + $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) |
|
| 662 | 662 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)"; |
| 663 | 663 | |
| 664 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':comment' => $comment,':type' => $type); |
|
| 664 | + $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':comment' => $comment, ':type' => $type); |
|
| 665 | 665 | |
| 666 | 666 | try { |
| 667 | 667 | |
@@ -687,13 +687,13 @@ discard block |
||
| 687 | 687 | { |
| 688 | 688 | global $globalDBdriver; |
| 689 | 689 | if ($globalDBdriver == 'mysql') { |
| 690 | - $query = "SELECT tracker_output.ident FROM tracker_output |
|
| 690 | + $query = "SELECT tracker_output.ident FROM tracker_output |
|
| 691 | 691 | WHERE tracker_output.ident = :ident |
| 692 | 692 | AND tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 693 | 693 | AND tracker_output.date < UTC_TIMESTAMP()"; |
| 694 | 694 | $query_data = array(':ident' => $ident); |
| 695 | 695 | } else { |
| 696 | - $query = "SELECT tracker_output.ident FROM tracker_output |
|
| 696 | + $query = "SELECT tracker_output.ident FROM tracker_output |
|
| 697 | 697 | WHERE tracker_output.ident = :ident |
| 698 | 698 | AND tracker_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 699 | 699 | AND tracker_output.date < now() AT TIME ZONE 'UTC'"; |
@@ -702,8 +702,8 @@ discard block |
||
| 702 | 702 | |
| 703 | 703 | $sth = $this->db->prepare($query); |
| 704 | 704 | $sth->execute($query_data); |
| 705 | - $ident_result=''; |
|
| 706 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 705 | + $ident_result = ''; |
|
| 706 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 707 | 707 | { |
| 708 | 708 | $ident_result = $row['ident']; |
| 709 | 709 | } |
@@ -729,8 +729,8 @@ discard block |
||
| 729 | 729 | return array(); |
| 730 | 730 | } else { |
| 731 | 731 | $q_array = explode(" ", $q); |
| 732 | - foreach ($q_array as $q_item){ |
|
| 733 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
| 732 | + foreach ($q_array as $q_item) { |
|
| 733 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
| 734 | 734 | $additional_query .= " AND ("; |
| 735 | 735 | $additional_query .= "(tracker_output.ident like '%".$q_item."%')"; |
| 736 | 736 | $additional_query .= ")"; |
@@ -738,11 +738,11 @@ discard block |
||
| 738 | 738 | } |
| 739 | 739 | } |
| 740 | 740 | if ($globalDBdriver == 'mysql') { |
| 741 | - $query = "SELECT tracker_output.* FROM tracker_output |
|
| 741 | + $query = "SELECT tracker_output.* FROM tracker_output |
|
| 742 | 742 | WHERE tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
| 743 | 743 | AND tracker_output.date < UTC_TIMESTAMP()"; |
| 744 | 744 | } else { |
| 745 | - $query = "SELECT tracker_output.* FROM tracker_output |
|
| 745 | + $query = "SELECT tracker_output.* FROM tracker_output |
|
| 746 | 746 | WHERE tracker_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
| 747 | 747 | AND tracker_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
| 748 | 748 | } |
@@ -759,16 +759,16 @@ discard block |
||
| 759 | 759 | * @param array $filters |
| 760 | 760 | * @return array the airline country list |
| 761 | 761 | */ |
| 762 | - public function countAllTrackerOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
| 762 | + public function countAllTrackerOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
| 763 | 763 | { |
| 764 | 764 | global $globalDBdriver, $globalArchive; |
| 765 | 765 | //$filter_query = $this->getFilter($filters,true,true); |
| 766 | - $Connection= new Connection($this->db); |
|
| 766 | + $Connection = new Connection($this->db); |
|
| 767 | 767 | if (!$Connection->tableExists('countries')) return array(); |
| 768 | 768 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
| 769 | 769 | require_once('class.TrackerLive.php'); |
| 770 | 770 | $TrackerLive = new TrackerLive($this->db); |
| 771 | - $filter_query = $TrackerLive->getFilter($filters,true,true); |
|
| 771 | + $filter_query = $TrackerLive->getFilter($filters, true, true); |
|
| 772 | 772 | $filter_query .= " over_country IS NOT NULL AND over_country <> ''"; |
| 773 | 773 | if ($olderthanmonths > 0) { |
| 774 | 774 | if ($globalDBdriver == 'mysql') { |
@@ -788,7 +788,7 @@ discard block |
||
| 788 | 788 | } else { |
| 789 | 789 | require_once('class.TrackerArchive.php'); |
| 790 | 790 | $TrackerArchive = new TrackerArchive($this->db); |
| 791 | - $filter_query = $TrackerArchive->getFilter($filters,true,true); |
|
| 791 | + $filter_query = $TrackerArchive->getFilter($filters, true, true); |
|
| 792 | 792 | $filter_query .= " over_country IS NOT NULL AND over_country <> ''"; |
| 793 | 793 | if ($olderthanmonths > 0) { |
| 794 | 794 | if ($globalDBdriver == 'mysql') { |
@@ -816,7 +816,7 @@ discard block |
||
| 816 | 816 | $flight_array = array(); |
| 817 | 817 | $temp_array = array(); |
| 818 | 818 | |
| 819 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 819 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 820 | 820 | { |
| 821 | 821 | $temp_array['tracker_count'] = $row['nb']; |
| 822 | 822 | $temp_array['tracker_country'] = $row['name']; |
@@ -839,11 +839,11 @@ discard block |
||
| 839 | 839 | * @param string $day |
| 840 | 840 | * @return array the callsign list |
| 841 | 841 | */ |
| 842 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
| 842 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 843 | 843 | { |
| 844 | 844 | global $globalDBdriver; |
| 845 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 846 | - $query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count |
|
| 845 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 846 | + $query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count |
|
| 847 | 847 | FROM tracker_output".$filter_query." tracker_output.ident <> ''"; |
| 848 | 848 | if ($olderthanmonths > 0) { |
| 849 | 849 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -857,28 +857,28 @@ discard block |
||
| 857 | 857 | if ($year != '') { |
| 858 | 858 | if ($globalDBdriver == 'mysql') { |
| 859 | 859 | $query .= " AND YEAR(tracker_output.date) = :year"; |
| 860 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 860 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 861 | 861 | } else { |
| 862 | 862 | $query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year"; |
| 863 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 863 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 864 | 864 | } |
| 865 | 865 | } |
| 866 | 866 | if ($month != '') { |
| 867 | 867 | if ($globalDBdriver == 'mysql') { |
| 868 | 868 | $query .= " AND MONTH(tracker_output.date) = :month"; |
| 869 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 869 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 870 | 870 | } else { |
| 871 | 871 | $query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month"; |
| 872 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 872 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 873 | 873 | } |
| 874 | 874 | } |
| 875 | 875 | if ($day != '') { |
| 876 | 876 | if ($globalDBdriver == 'mysql') { |
| 877 | 877 | $query .= " AND DAY(tracker_output.date) = :day"; |
| 878 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 878 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 879 | 879 | } else { |
| 880 | 880 | $query .= " AND EXTRACT(DAY FROM tracker_output.date) = :day"; |
| 881 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 881 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 882 | 882 | } |
| 883 | 883 | } |
| 884 | 884 | $query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC"; |
@@ -890,7 +890,7 @@ discard block |
||
| 890 | 890 | $callsign_array = array(); |
| 891 | 891 | $temp_array = array(); |
| 892 | 892 | |
| 893 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 893 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 894 | 894 | { |
| 895 | 895 | $temp_array['callsign_icao'] = $row['ident']; |
| 896 | 896 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -942,7 +942,7 @@ discard block |
||
| 942 | 942 | $date_array = array(); |
| 943 | 943 | $temp_array = array(); |
| 944 | 944 | |
| 945 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 945 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 946 | 946 | { |
| 947 | 947 | $temp_array['date_name'] = $row['date_name']; |
| 948 | 948 | $temp_array['date_count'] = $row['date_count']; |
@@ -968,7 +968,7 @@ discard block |
||
| 968 | 968 | $datetime = new DateTime(); |
| 969 | 969 | $offset = $datetime->format('P'); |
| 970 | 970 | } else $offset = '+00:00'; |
| 971 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 971 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 972 | 972 | if ($globalDBdriver == 'mysql') { |
| 973 | 973 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
| 974 | 974 | FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -989,7 +989,7 @@ discard block |
||
| 989 | 989 | $date_array = array(); |
| 990 | 990 | $temp_array = array(); |
| 991 | 991 | |
| 992 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 992 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 993 | 993 | { |
| 994 | 994 | $temp_array['date_name'] = $row['date_name']; |
| 995 | 995 | $temp_array['date_count'] = $row['date_count']; |
@@ -1014,7 +1014,7 @@ discard block |
||
| 1014 | 1014 | $datetime = new DateTime(); |
| 1015 | 1015 | $offset = $datetime->format('P'); |
| 1016 | 1016 | } else $offset = '+00:00'; |
| 1017 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1017 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1018 | 1018 | if ($globalDBdriver == 'mysql') { |
| 1019 | 1019 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
| 1020 | 1020 | FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -1035,7 +1035,7 @@ discard block |
||
| 1035 | 1035 | $date_array = array(); |
| 1036 | 1036 | $temp_array = array(); |
| 1037 | 1037 | |
| 1038 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1038 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1039 | 1039 | { |
| 1040 | 1040 | $temp_array['date_name'] = $row['date_name']; |
| 1041 | 1041 | $temp_array['date_count'] = $row['date_count']; |
@@ -1081,7 +1081,7 @@ discard block |
||
| 1081 | 1081 | $date_array = array(); |
| 1082 | 1082 | $temp_array = array(); |
| 1083 | 1083 | |
| 1084 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1084 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1085 | 1085 | { |
| 1086 | 1086 | $temp_array['month_name'] = $row['month_name']; |
| 1087 | 1087 | $temp_array['year_name'] = $row['year_name']; |
@@ -1108,7 +1108,7 @@ discard block |
||
| 1108 | 1108 | $datetime = new DateTime(); |
| 1109 | 1109 | $offset = $datetime->format('P'); |
| 1110 | 1110 | } else $offset = '+00:00'; |
| 1111 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1111 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1112 | 1112 | if ($globalDBdriver == 'mysql') { |
| 1113 | 1113 | $query = "SELECT MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
| 1114 | 1114 | FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -1129,7 +1129,7 @@ discard block |
||
| 1129 | 1129 | $date_array = array(); |
| 1130 | 1130 | $temp_array = array(); |
| 1131 | 1131 | |
| 1132 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1132 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1133 | 1133 | { |
| 1134 | 1134 | $temp_array['year_name'] = $row['year_name']; |
| 1135 | 1135 | $temp_array['month_name'] = $row['month_name']; |
@@ -1149,7 +1149,7 @@ discard block |
||
| 1149 | 1149 | * @param array $filters |
| 1150 | 1150 | * @return array the hour list |
| 1151 | 1151 | */ |
| 1152 | - public function countAllHours($orderby,$filters = array()) |
|
| 1152 | + public function countAllHours($orderby, $filters = array()) |
|
| 1153 | 1153 | { |
| 1154 | 1154 | global $globalTimezone, $globalDBdriver; |
| 1155 | 1155 | if ($globalTimezone != '') { |
@@ -1197,7 +1197,7 @@ discard block |
||
| 1197 | 1197 | $hour_array = array(); |
| 1198 | 1198 | $temp_array = array(); |
| 1199 | 1199 | |
| 1200 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1200 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1201 | 1201 | { |
| 1202 | 1202 | $temp_array['hour_name'] = $row['hour_name']; |
| 1203 | 1203 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1219,8 +1219,8 @@ discard block |
||
| 1219 | 1219 | public function countAllHoursByDate($date, $filters = array()) |
| 1220 | 1220 | { |
| 1221 | 1221 | global $globalTimezone, $globalDBdriver; |
| 1222 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1223 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
| 1222 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1223 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
| 1224 | 1224 | if ($globalTimezone != '') { |
| 1225 | 1225 | date_default_timezone_set($globalTimezone); |
| 1226 | 1226 | $datetime = new DateTime($date); |
@@ -1228,12 +1228,12 @@ discard block |
||
| 1228 | 1228 | } else $offset = '+00:00'; |
| 1229 | 1229 | |
| 1230 | 1230 | if ($globalDBdriver == 'mysql') { |
| 1231 | - $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1231 | + $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1232 | 1232 | FROM tracker_output".$filter_query." DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) = :date |
| 1233 | 1233 | GROUP BY hour_name |
| 1234 | 1234 | ORDER BY hour_name ASC"; |
| 1235 | 1235 | } else { |
| 1236 | - $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1236 | + $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1237 | 1237 | FROM tracker_output".$filter_query." to_char(tracker_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
| 1238 | 1238 | GROUP BY hour_name |
| 1239 | 1239 | ORDER BY hour_name ASC"; |
@@ -1245,7 +1245,7 @@ discard block |
||
| 1245 | 1245 | $hour_array = array(); |
| 1246 | 1246 | $temp_array = array(); |
| 1247 | 1247 | |
| 1248 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1248 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1249 | 1249 | { |
| 1250 | 1250 | $temp_array['hour_name'] = $row['hour_name']; |
| 1251 | 1251 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1267,8 +1267,8 @@ discard block |
||
| 1267 | 1267 | public function countAllHoursByIdent($ident, $filters = array()) |
| 1268 | 1268 | { |
| 1269 | 1269 | global $globalTimezone, $globalDBdriver; |
| 1270 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1271 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 1270 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1271 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 1272 | 1272 | if ($globalTimezone != '') { |
| 1273 | 1273 | date_default_timezone_set($globalTimezone); |
| 1274 | 1274 | $datetime = new DateTime(); |
@@ -1276,12 +1276,12 @@ discard block |
||
| 1276 | 1276 | } else $offset = '+00:00'; |
| 1277 | 1277 | |
| 1278 | 1278 | if ($globalDBdriver == 'mysql') { |
| 1279 | - $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1279 | + $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1280 | 1280 | FROM tracker_output".$filter_query." tracker_output.ident = :ident |
| 1281 | 1281 | GROUP BY hour_name |
| 1282 | 1282 | ORDER BY hour_name ASC"; |
| 1283 | 1283 | } else { |
| 1284 | - $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1284 | + $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1285 | 1285 | FROM tracker_output".$filter_query." tracker_output.ident = :ident |
| 1286 | 1286 | GROUP BY hour_name |
| 1287 | 1287 | ORDER BY hour_name ASC"; |
@@ -1289,12 +1289,12 @@ discard block |
||
| 1289 | 1289 | |
| 1290 | 1290 | |
| 1291 | 1291 | $sth = $this->db->prepare($query); |
| 1292 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
| 1292 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
| 1293 | 1293 | |
| 1294 | 1294 | $hour_array = array(); |
| 1295 | 1295 | $temp_array = array(); |
| 1296 | 1296 | |
| 1297 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1297 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1298 | 1298 | { |
| 1299 | 1299 | $temp_array['hour_name'] = $row['hour_name']; |
| 1300 | 1300 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1314,33 +1314,33 @@ discard block |
||
| 1314 | 1314 | * @param string $month |
| 1315 | 1315 | * @return Integer the number of trackers |
| 1316 | 1316 | */ |
| 1317 | - public function countOverallTracker($filters = array(),$year = '',$month = '') |
|
| 1317 | + public function countOverallTracker($filters = array(), $year = '', $month = '') |
|
| 1318 | 1318 | { |
| 1319 | 1319 | global $globalDBdriver; |
| 1320 | 1320 | //$queryi = "SELECT COUNT(tracker_output.tracker_id) AS flight_count FROM tracker_output"; |
| 1321 | - $queryi = "SELECT COUNT(DISTINCT tracker_output.ident) AS tracker_count FROM tracker_output"; |
|
| 1321 | + $queryi = "SELECT COUNT(DISTINCT tracker_output.ident) AS tracker_count FROM tracker_output"; |
|
| 1322 | 1322 | $query_values = array(); |
| 1323 | 1323 | $query = ''; |
| 1324 | 1324 | if ($year != '') { |
| 1325 | 1325 | if ($globalDBdriver == 'mysql') { |
| 1326 | 1326 | $query .= " AND YEAR(tracker_output.date) = :year"; |
| 1327 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1327 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1328 | 1328 | } else { |
| 1329 | 1329 | $query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year"; |
| 1330 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1330 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1331 | 1331 | } |
| 1332 | 1332 | } |
| 1333 | 1333 | if ($month != '') { |
| 1334 | 1334 | if ($globalDBdriver == 'mysql') { |
| 1335 | 1335 | $query .= " AND MONTH(tracker_output.date) = :month"; |
| 1336 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1336 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1337 | 1337 | } else { |
| 1338 | 1338 | $query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month"; |
| 1339 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1339 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1340 | 1340 | } |
| 1341 | 1341 | } |
| 1342 | 1342 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
| 1343 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1343 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
| 1344 | 1344 | |
| 1345 | 1345 | $sth = $this->db->prepare($queryi); |
| 1346 | 1346 | $sth->execute($query_values); |
@@ -1355,32 +1355,32 @@ discard block |
||
| 1355 | 1355 | * @param string $month |
| 1356 | 1356 | * @return Integer the number of flights |
| 1357 | 1357 | */ |
| 1358 | - public function countOverallTrackerTypes($filters = array(),$year = '',$month = '') |
|
| 1358 | + public function countOverallTrackerTypes($filters = array(), $year = '', $month = '') |
|
| 1359 | 1359 | { |
| 1360 | 1360 | global $globalDBdriver; |
| 1361 | - $queryi = "SELECT COUNT(DISTINCT tracker_output.type) AS tracker_count FROM tracker_output"; |
|
| 1361 | + $queryi = "SELECT COUNT(DISTINCT tracker_output.type) AS tracker_count FROM tracker_output"; |
|
| 1362 | 1362 | $query_values = array(); |
| 1363 | 1363 | $query = ''; |
| 1364 | 1364 | if ($year != '') { |
| 1365 | 1365 | if ($globalDBdriver == 'mysql') { |
| 1366 | 1366 | $query .= " AND YEAR(tracker_output.date) = :year"; |
| 1367 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1367 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1368 | 1368 | } else { |
| 1369 | 1369 | $query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year"; |
| 1370 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1370 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1371 | 1371 | } |
| 1372 | 1372 | } |
| 1373 | 1373 | if ($month != '') { |
| 1374 | 1374 | if ($globalDBdriver == 'mysql') { |
| 1375 | 1375 | $query .= " AND MONTH(tracker_output.date) = :month"; |
| 1376 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1376 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1377 | 1377 | } else { |
| 1378 | 1378 | $query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month"; |
| 1379 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1379 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1380 | 1380 | } |
| 1381 | 1381 | } |
| 1382 | 1382 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
| 1383 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1383 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
| 1384 | 1384 | |
| 1385 | 1385 | $sth = $this->db->prepare($queryi); |
| 1386 | 1386 | $sth->execute($query_values); |
@@ -1397,7 +1397,7 @@ discard block |
||
| 1397 | 1397 | public function countAllHoursFromToday($filters = array()) |
| 1398 | 1398 | { |
| 1399 | 1399 | global $globalTimezone, $globalDBdriver; |
| 1400 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1400 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1401 | 1401 | if ($globalTimezone != '') { |
| 1402 | 1402 | date_default_timezone_set($globalTimezone); |
| 1403 | 1403 | $datetime = new DateTime(); |
@@ -1405,12 +1405,12 @@ discard block |
||
| 1405 | 1405 | } else $offset = '+00:00'; |
| 1406 | 1406 | |
| 1407 | 1407 | if ($globalDBdriver == 'mysql') { |
| 1408 | - $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1408 | + $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1409 | 1409 | FROM tracker_output".$filter_query." DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) = CURDATE() |
| 1410 | 1410 | GROUP BY hour_name |
| 1411 | 1411 | ORDER BY hour_name ASC"; |
| 1412 | 1412 | } else { |
| 1413 | - $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1413 | + $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1414 | 1414 | FROM tracker_output".$filter_query." to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
| 1415 | 1415 | GROUP BY hour_name |
| 1416 | 1416 | ORDER BY hour_name ASC"; |
@@ -1422,7 +1422,7 @@ discard block |
||
| 1422 | 1422 | $hour_array = array(); |
| 1423 | 1423 | $temp_array = array(); |
| 1424 | 1424 | |
| 1425 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1425 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1426 | 1426 | { |
| 1427 | 1427 | $temp_array['hour_name'] = $row['hour_name']; |
| 1428 | 1428 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1441,9 +1441,9 @@ discard block |
||
| 1441 | 1441 | */ |
| 1442 | 1442 | public function getTrackerIDBasedOnFamTrackID($famtrackid) |
| 1443 | 1443 | { |
| 1444 | - $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
|
| 1444 | + $famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING); |
|
| 1445 | 1445 | |
| 1446 | - $query = "SELECT tracker_output.tracker_id |
|
| 1446 | + $query = "SELECT tracker_output.tracker_id |
|
| 1447 | 1447 | FROM tracker_output |
| 1448 | 1448 | WHERE tracker_output.famtrackid = '".$famtrackid."'"; |
| 1449 | 1449 | |
@@ -1451,7 +1451,7 @@ discard block |
||
| 1451 | 1451 | $sth = $this->db->prepare($query); |
| 1452 | 1452 | $sth->execute(); |
| 1453 | 1453 | |
| 1454 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1454 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1455 | 1455 | { |
| 1456 | 1456 | return $row['tracker_id']; |
| 1457 | 1457 | } |
@@ -1476,23 +1476,23 @@ discard block |
||
| 1476 | 1476 | } |
| 1477 | 1477 | |
| 1478 | 1478 | $current_date = date("Y-m-d H:i:s"); |
| 1479 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
| 1479 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
| 1480 | 1480 | |
| 1481 | 1481 | $diff = abs(strtotime($current_date) - strtotime($date)); |
| 1482 | 1482 | |
| 1483 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
| 1483 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
| 1484 | 1484 | $years = $time_array['years']; |
| 1485 | 1485 | |
| 1486 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
| 1486 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
| 1487 | 1487 | $months = $time_array['months']; |
| 1488 | 1488 | |
| 1489 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
| 1489 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
| 1490 | 1490 | $days = $time_array['days']; |
| 1491 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
| 1491 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
| 1492 | 1492 | $hours = $time_array['hours']; |
| 1493 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
| 1493 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
| 1494 | 1494 | $minutes = $time_array['minutes']; |
| 1495 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
| 1495 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
| 1496 | 1496 | |
| 1497 | 1497 | return $time_array; |
| 1498 | 1498 | } |
@@ -1515,63 +1515,63 @@ discard block |
||
| 1515 | 1515 | $temp_array['direction_degree'] = $direction; |
| 1516 | 1516 | $temp_array['direction_shortname'] = "N"; |
| 1517 | 1517 | $temp_array['direction_fullname'] = "North"; |
| 1518 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
| 1518 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
| 1519 | 1519 | $temp_array['direction_degree'] = $direction; |
| 1520 | 1520 | $temp_array['direction_shortname'] = "NNE"; |
| 1521 | 1521 | $temp_array['direction_fullname'] = "North-Northeast"; |
| 1522 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
| 1522 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
| 1523 | 1523 | $temp_array['direction_degree'] = $direction; |
| 1524 | 1524 | $temp_array['direction_shortname'] = "NE"; |
| 1525 | 1525 | $temp_array['direction_fullname'] = "Northeast"; |
| 1526 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
| 1526 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
| 1527 | 1527 | $temp_array['direction_degree'] = $direction; |
| 1528 | 1528 | $temp_array['direction_shortname'] = "ENE"; |
| 1529 | 1529 | $temp_array['direction_fullname'] = "East-Northeast"; |
| 1530 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
| 1530 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
| 1531 | 1531 | $temp_array['direction_degree'] = $direction; |
| 1532 | 1532 | $temp_array['direction_shortname'] = "E"; |
| 1533 | 1533 | $temp_array['direction_fullname'] = "East"; |
| 1534 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
| 1534 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
| 1535 | 1535 | $temp_array['direction_degree'] = $direction; |
| 1536 | 1536 | $temp_array['direction_shortname'] = "ESE"; |
| 1537 | 1537 | $temp_array['direction_fullname'] = "East-Southeast"; |
| 1538 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
| 1538 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
| 1539 | 1539 | $temp_array['direction_degree'] = $direction; |
| 1540 | 1540 | $temp_array['direction_shortname'] = "SE"; |
| 1541 | 1541 | $temp_array['direction_fullname'] = "Southeast"; |
| 1542 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
| 1542 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
| 1543 | 1543 | $temp_array['direction_degree'] = $direction; |
| 1544 | 1544 | $temp_array['direction_shortname'] = "SSE"; |
| 1545 | 1545 | $temp_array['direction_fullname'] = "South-Southeast"; |
| 1546 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
| 1546 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
| 1547 | 1547 | $temp_array['direction_degree'] = $direction; |
| 1548 | 1548 | $temp_array['direction_shortname'] = "S"; |
| 1549 | 1549 | $temp_array['direction_fullname'] = "South"; |
| 1550 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
| 1550 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
| 1551 | 1551 | $temp_array['direction_degree'] = $direction; |
| 1552 | 1552 | $temp_array['direction_shortname'] = "SSW"; |
| 1553 | 1553 | $temp_array['direction_fullname'] = "South-Southwest"; |
| 1554 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
| 1554 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
| 1555 | 1555 | $temp_array['direction_degree'] = $direction; |
| 1556 | 1556 | $temp_array['direction_shortname'] = "SW"; |
| 1557 | 1557 | $temp_array['direction_fullname'] = "Southwest"; |
| 1558 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
| 1558 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
| 1559 | 1559 | $temp_array['direction_degree'] = $direction; |
| 1560 | 1560 | $temp_array['direction_shortname'] = "WSW"; |
| 1561 | 1561 | $temp_array['direction_fullname'] = "West-Southwest"; |
| 1562 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
| 1562 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
| 1563 | 1563 | $temp_array['direction_degree'] = $direction; |
| 1564 | 1564 | $temp_array['direction_shortname'] = "W"; |
| 1565 | 1565 | $temp_array['direction_fullname'] = "West"; |
| 1566 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
| 1566 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
| 1567 | 1567 | $temp_array['direction_degree'] = $direction; |
| 1568 | 1568 | $temp_array['direction_shortname'] = "WNW"; |
| 1569 | 1569 | $temp_array['direction_fullname'] = "West-Northwest"; |
| 1570 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
| 1570 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
| 1571 | 1571 | $temp_array['direction_degree'] = $direction; |
| 1572 | 1572 | $temp_array['direction_shortname'] = "NW"; |
| 1573 | 1573 | $temp_array['direction_fullname'] = "Northwest"; |
| 1574 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
| 1574 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
| 1575 | 1575 | $temp_array['direction_degree'] = $direction; |
| 1576 | 1576 | $temp_array['direction_shortname'] = "NNW"; |
| 1577 | 1577 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -1588,11 +1588,11 @@ discard block |
||
| 1588 | 1588 | * @param Float $longitude longitute of the flight |
| 1589 | 1589 | * @return String the countrie |
| 1590 | 1590 | */ |
| 1591 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
| 1591 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
| 1592 | 1592 | { |
| 1593 | 1593 | global $globalDebug; |
| 1594 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1595 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1594 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1595 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1596 | 1596 | |
| 1597 | 1597 | $Connection = new Connection($this->db); |
| 1598 | 1598 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1623,7 +1623,7 @@ discard block |
||
| 1623 | 1623 | public function getCountryFromISO2($iso2) |
| 1624 | 1624 | { |
| 1625 | 1625 | global $globalDebug; |
| 1626 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
| 1626 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
| 1627 | 1627 | |
| 1628 | 1628 | $Connection = new Connection($this->db); |
| 1629 | 1629 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1658,11 +1658,11 @@ discard block |
||
| 1658 | 1658 | * @param string $day |
| 1659 | 1659 | * @return array the vessel type list |
| 1660 | 1660 | */ |
| 1661 | - public function countAllTrackerTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
|
| 1661 | + public function countAllTrackerTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 1662 | 1662 | { |
| 1663 | 1663 | global $globalDBdriver; |
| 1664 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1665 | - $query = "SELECT tracker_output.type AS tracker_type, COUNT(tracker_output.type) AS tracker_type_count |
|
| 1664 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1665 | + $query = "SELECT tracker_output.type AS tracker_type, COUNT(tracker_output.type) AS tracker_type_count |
|
| 1666 | 1666 | FROM tracker_output ".$filter_query." tracker_output.type <> ''"; |
| 1667 | 1667 | if ($olderthanmonths > 0) { |
| 1668 | 1668 | if ($globalDBdriver == 'mysql') { |
@@ -1682,28 +1682,28 @@ discard block |
||
| 1682 | 1682 | if ($year != '') { |
| 1683 | 1683 | if ($globalDBdriver == 'mysql') { |
| 1684 | 1684 | $query .= " AND YEAR(tracker_output.date) = :year"; |
| 1685 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1685 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1686 | 1686 | } else { |
| 1687 | 1687 | $query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year"; |
| 1688 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1688 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1689 | 1689 | } |
| 1690 | 1690 | } |
| 1691 | 1691 | if ($month != '') { |
| 1692 | 1692 | if ($globalDBdriver == 'mysql') { |
| 1693 | 1693 | $query .= " AND MONTH(tracker_output.date) = :month"; |
| 1694 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1694 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1695 | 1695 | } else { |
| 1696 | 1696 | $query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month"; |
| 1697 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1697 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1698 | 1698 | } |
| 1699 | 1699 | } |
| 1700 | 1700 | if ($day != '') { |
| 1701 | 1701 | if ($globalDBdriver == 'mysql') { |
| 1702 | 1702 | $query .= " AND DAY(tracker_output.date) = :day"; |
| 1703 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 1703 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 1704 | 1704 | } else { |
| 1705 | 1705 | $query .= " AND EXTRACT(DAY FROM tracker_output.date) = :day"; |
| 1706 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 1706 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 1707 | 1707 | } |
| 1708 | 1708 | } |
| 1709 | 1709 | $query .= " GROUP BY tracker_output.type ORDER BY tracker_type_count DESC"; |
@@ -1712,7 +1712,7 @@ discard block |
||
| 1712 | 1712 | $sth->execute($query_values); |
| 1713 | 1713 | $tracker_array = array(); |
| 1714 | 1714 | $temp_array = array(); |
| 1715 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1715 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1716 | 1716 | { |
| 1717 | 1717 | $temp_array['tracker_type'] = $row['tracker_type']; |
| 1718 | 1718 | $temp_array['tracker_type_count'] = $row['tracker_type_count']; |
@@ -1736,13 +1736,13 @@ discard block |
||
| 1736 | 1736 | * @param array $filters |
| 1737 | 1737 | * @return array the tracker information |
| 1738 | 1738 | */ |
| 1739 | - public function searchTrackerData($q = '', $callsign = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array()) |
|
| 1739 | + public function searchTrackerData($q = '', $callsign = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
| 1740 | 1740 | { |
| 1741 | 1741 | global $globalTimezone, $globalDBdriver; |
| 1742 | 1742 | date_default_timezone_set('UTC'); |
| 1743 | 1743 | $query_values = array(); |
| 1744 | 1744 | $additional_query = ''; |
| 1745 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1745 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1746 | 1746 | if ($q != "") |
| 1747 | 1747 | { |
| 1748 | 1748 | if (!is_string($q)) |
@@ -1750,8 +1750,8 @@ discard block |
||
| 1750 | 1750 | return array(); |
| 1751 | 1751 | } else { |
| 1752 | 1752 | $q_array = explode(" ", $q); |
| 1753 | - foreach ($q_array as $q_item){ |
|
| 1754 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
| 1753 | + foreach ($q_array as $q_item) { |
|
| 1754 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
| 1755 | 1755 | $additional_query .= " AND ("; |
| 1756 | 1756 | if (is_int($q_item)) $additional_query .= "(tracker_output.tracker_id = '".$q_item."') OR "; |
| 1757 | 1757 | $additional_query .= "(tracker_output.ident like '%".$q_item."%') OR "; |
@@ -1761,20 +1761,20 @@ discard block |
||
| 1761 | 1761 | } |
| 1762 | 1762 | if ($callsign != "") |
| 1763 | 1763 | { |
| 1764 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 1764 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 1765 | 1765 | if (!is_string($callsign)) |
| 1766 | 1766 | { |
| 1767 | 1767 | return array(); |
| 1768 | 1768 | } else { |
| 1769 | 1769 | $additional_query .= " AND tracker_output.ident = :callsign"; |
| 1770 | - $query_values = array_merge($query_values,array(':callsign' => $callsign)); |
|
| 1770 | + $query_values = array_merge($query_values, array(':callsign' => $callsign)); |
|
| 1771 | 1771 | } |
| 1772 | 1772 | } |
| 1773 | 1773 | if ($date_posted != "") |
| 1774 | 1774 | { |
| 1775 | 1775 | $date_array = explode(",", $date_posted); |
| 1776 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 1777 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 1776 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
| 1777 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
| 1778 | 1778 | if ($globalTimezone != '') { |
| 1779 | 1779 | date_default_timezone_set($globalTimezone); |
| 1780 | 1780 | $datetime = new DateTime(); |
@@ -1801,8 +1801,8 @@ discard block |
||
| 1801 | 1801 | if ($limit != "") |
| 1802 | 1802 | { |
| 1803 | 1803 | $limit_array = explode(",", $limit); |
| 1804 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1805 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1804 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1805 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1806 | 1806 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1807 | 1807 | { |
| 1808 | 1808 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -1820,22 +1820,22 @@ discard block |
||
| 1820 | 1820 | } |
| 1821 | 1821 | } |
| 1822 | 1822 | if ($origLat != "" && $origLon != "" && $dist != "") { |
| 1823 | - $dist = number_format($dist*0.621371,2,'.',''); // convert km to mile |
|
| 1823 | + $dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile |
|
| 1824 | 1824 | if ($globalDBdriver == 'mysql') { |
| 1825 | - $query="SELECT tracker_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - tracker_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(tracker_archive.latitude*pi()/180)*POWER(SIN(($origLon-tracker_archive.longitude)*pi()/180/2),2))) as distance |
|
| 1825 | + $query = "SELECT tracker_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - tracker_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(tracker_archive.latitude*pi()/180)*POWER(SIN(($origLon-tracker_archive.longitude)*pi()/180/2),2))) as distance |
|
| 1826 | 1826 | FROM tracker_archive,tracker_output".$filter_query." tracker_output.famtrackid = tracker_archive.famtrackid AND tracker_output.ident <> '' ".$additional_query."AND tracker_archive.longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and tracker_archive.latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 1827 | 1827 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - tracker_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(tracker_archive.latitude*pi()/180)*POWER(SIN(($origLon-tracker_archive.longitude)*pi()/180/2),2)))) < $dist".$orderby_query; |
| 1828 | 1828 | } else { |
| 1829 | - $query="SELECT tracker_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(tracker_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(tracker_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 1829 | + $query = "SELECT tracker_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(tracker_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(tracker_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 1830 | 1830 | FROM tracker_archive,tracker_output".$filter_query." tracker_output.famtrackid = tracker_archive.famtrackid AND tracker_output.ident <> '' ".$additional_query."AND CAST(tracker_archive.longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(tracker_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 1831 | 1831 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(tracker_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(tracker_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query.$orderby_query; |
| 1832 | 1832 | } |
| 1833 | 1833 | } else { |
| 1834 | - $query = "SELECT tracker_output.* FROM tracker_output".$filter_query." tracker_output.ident <> '' |
|
| 1834 | + $query = "SELECT tracker_output.* FROM tracker_output".$filter_query." tracker_output.ident <> '' |
|
| 1835 | 1835 | ".$additional_query." |
| 1836 | 1836 | ".$orderby_query; |
| 1837 | 1837 | } |
| 1838 | - $tracker_array = $this->getDataFromDB($query, $query_values,$limit_query); |
|
| 1838 | + $tracker_array = $this->getDataFromDB($query, $query_values, $limit_query); |
|
| 1839 | 1839 | return $tracker_array; |
| 1840 | 1840 | } |
| 1841 | 1841 | |
@@ -1860,7 +1860,7 @@ discard block |
||
| 1860 | 1860 | curl_close($ch); |
| 1861 | 1861 | $bitly_data = json_decode($bitly_data); |
| 1862 | 1862 | $bitly_url = ''; |
| 1863 | - if ($bitly_data->status_txt = "OK"){ |
|
| 1863 | + if ($bitly_data->status_txt = "OK") { |
|
| 1864 | 1864 | $bitly_url = $bitly_data->data->url; |
| 1865 | 1865 | } |
| 1866 | 1866 | return $bitly_url; |
@@ -1868,7 +1868,7 @@ discard block |
||
| 1868 | 1868 | |
| 1869 | 1869 | public function getOrderBy() |
| 1870 | 1870 | { |
| 1871 | - $orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY tracker_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY tracker_output.type DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC")); |
|
| 1871 | + $orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY tracker_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY tracker_output.type DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC")); |
|
| 1872 | 1872 | |
| 1873 | 1873 | return $orderby; |
| 1874 | 1874 | |
@@ -17,7 +17,9 @@ discard block |
||
| 17 | 17 | public function __construct($dbc = null) { |
| 18 | 18 | $Connection = new Connection($dbc); |
| 19 | 19 | $this->db = $Connection->db(); |
| 20 | - if ($this->db === null) die('Error: No DB connection. (Tracker)'); |
|
| 20 | + if ($this->db === null) { |
|
| 21 | + die('Error: No DB connection. (Tracker)'); |
|
| 22 | + } |
|
| 21 | 23 | } |
| 22 | 24 | |
| 23 | 25 | /** |
@@ -41,7 +43,9 @@ discard block |
||
| 41 | 43 | if (isset($filter[0]['source'])) { |
| 42 | 44 | $filters = array_merge($filters,$filter); |
| 43 | 45 | } |
| 44 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 46 | + if (is_array($globalFilter)) { |
|
| 47 | + $filter = array_merge($filter,$globalFilter); |
|
| 48 | + } |
|
| 45 | 49 | $filter_query_join = ''; |
| 46 | 50 | $filter_query_where = ''; |
| 47 | 51 | foreach($filters as $flt) { |
@@ -83,8 +87,11 @@ discard block |
||
| 83 | 87 | $filter_query_where .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'"; |
| 84 | 88 | } |
| 85 | 89 | } |
| 86 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 87 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 90 | + if ($filter_query_where == '' && $where) { |
|
| 91 | + $filter_query_where = ' WHERE'; |
|
| 92 | + } elseif ($filter_query_where != '' && $and) { |
|
| 93 | + $filter_query_where .= ' AND'; |
|
| 94 | + } |
|
| 88 | 95 | if ($filter_query_where != '') { |
| 89 | 96 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 90 | 97 | } |
@@ -138,26 +145,43 @@ discard block |
||
| 138 | 145 | $temp_array['tracker_id'] = $row['tracker_archive_id']; |
| 139 | 146 | } elseif (isset($row['tracker_archive_output_id'])) { |
| 140 | 147 | $temp_array['tracker_id'] = $row['tracker_archive_output_id']; |
| 141 | - */} |
|
| 142 | - elseif (isset($row['trackerid'])) { |
|
| 148 | + */} elseif (isset($row['trackerid'])) { |
|
| 143 | 149 | $temp_array['trackerid'] = $row['trackerid']; |
| 144 | 150 | } else { |
| 145 | 151 | $temp_array['trackerid'] = ''; |
| 146 | 152 | } |
| 147 | - if (isset($row['famtrackid'])) $temp_array['famtrackid'] = $row['famtrackid']; |
|
| 148 | - if (isset($row['type'])) $temp_array['type'] = $row['type']; |
|
| 149 | - if (isset($row['comment'])) $temp_array['comment'] = $row['comment']; |
|
| 153 | + if (isset($row['famtrackid'])) { |
|
| 154 | + $temp_array['famtrackid'] = $row['famtrackid']; |
|
| 155 | + } |
|
| 156 | + if (isset($row['type'])) { |
|
| 157 | + $temp_array['type'] = $row['type']; |
|
| 158 | + } |
|
| 159 | + if (isset($row['comment'])) { |
|
| 160 | + $temp_array['comment'] = $row['comment']; |
|
| 161 | + } |
|
| 150 | 162 | $temp_array['ident'] = $row['ident']; |
| 151 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
| 152 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
| 153 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
| 154 | - if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude']; |
|
| 163 | + if (isset($row['latitude'])) { |
|
| 164 | + $temp_array['latitude'] = $row['latitude']; |
|
| 165 | + } |
|
| 166 | + if (isset($row['longitude'])) { |
|
| 167 | + $temp_array['longitude'] = $row['longitude']; |
|
| 168 | + } |
|
| 169 | + if (isset($row['format_source'])) { |
|
| 170 | + $temp_array['format_source'] = $row['format_source']; |
|
| 171 | + } |
|
| 172 | + if (isset($row['altitude'])) { |
|
| 173 | + $temp_array['altitude'] = $row['altitude']; |
|
| 174 | + } |
|
| 155 | 175 | if (isset($row['heading'])) { |
| 156 | 176 | $temp_array['heading'] = $row['heading']; |
| 157 | 177 | $heading_direction = $this->parseDirection($row['heading']); |
| 158 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
| 178 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
| 179 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
| 180 | + } |
|
| 181 | + } |
|
| 182 | + if (isset($row['ground_speed'])) { |
|
| 183 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
| 159 | 184 | } |
| 160 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
| 161 | 185 | |
| 162 | 186 | if (isset($row['date'])) { |
| 163 | 187 | $dateArray = $this->parseDateString($row['date']); |
@@ -200,13 +224,21 @@ discard block |
||
| 200 | 224 | } |
| 201 | 225 | |
| 202 | 226 | $fromsource = NULL; |
| 203 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
| 204 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
| 205 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
| 227 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
| 228 | + $temp_array['source_name'] = $row['source_name']; |
|
| 229 | + } |
|
| 230 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
| 231 | + $temp_array['over_country'] = $row['over_country']; |
|
| 232 | + } |
|
| 233 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
| 234 | + $temp_array['distance'] = $row['distance']; |
|
| 235 | + } |
|
| 206 | 236 | $temp_array['query_number_rows'] = $num_rows; |
| 207 | 237 | $tracker_array[] = $temp_array; |
| 208 | 238 | } |
| 209 | - if ($num_rows == 0) return array(); |
|
| 239 | + if ($num_rows == 0) { |
|
| 240 | + return array(); |
|
| 241 | + } |
|
| 210 | 242 | $tracker_array[0]['query_number_rows'] = $num_rows; |
| 211 | 243 | return $tracker_array; |
| 212 | 244 | } |
@@ -239,8 +271,12 @@ discard block |
||
| 239 | 271 | { |
| 240 | 272 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 241 | 273 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 242 | - } else $limit_query = ""; |
|
| 243 | - } else $limit_query = ""; |
|
| 274 | + } else { |
|
| 275 | + $limit_query = ""; |
|
| 276 | + } |
|
| 277 | + } else { |
|
| 278 | + $limit_query = ""; |
|
| 279 | + } |
|
| 244 | 280 | |
| 245 | 281 | if ($sort != "") |
| 246 | 282 | { |
@@ -268,7 +304,9 @@ discard block |
||
| 268 | 304 | global $global_tracker_query; |
| 269 | 305 | |
| 270 | 306 | date_default_timezone_set('UTC'); |
| 271 | - if ($id == '') return array(); |
|
| 307 | + if ($id == '') { |
|
| 308 | + return array(); |
|
| 309 | + } |
|
| 272 | 310 | $additional_query = "tracker_output.famtrackid = :id"; |
| 273 | 311 | $query_values = array(':id' => $id); |
| 274 | 312 | $query = $global_tracker_query." WHERE ".$additional_query." "; |
@@ -413,8 +451,11 @@ discard block |
||
| 413 | 451 | $query .= " ORDER BY tracker_output.source_name ASC"; |
| 414 | 452 | |
| 415 | 453 | $sth = $this->db->prepare($query); |
| 416 | - if (!empty($query_values)) $sth->execute($query_values); |
|
| 417 | - else $sth->execute(); |
|
| 454 | + if (!empty($query_values)) { |
|
| 455 | + $sth->execute($query_values); |
|
| 456 | + } else { |
|
| 457 | + $sth->execute(); |
|
| 458 | + } |
|
| 418 | 459 | |
| 419 | 460 | $source_array = array(); |
| 420 | 461 | $temp_array = array(); |
@@ -469,7 +510,9 @@ discard block |
||
| 469 | 510 | date_default_timezone_set($globalTimezone); |
| 470 | 511 | $datetime = new DateTime(); |
| 471 | 512 | $offset = $datetime->format('P'); |
| 472 | - } else $offset = '+00:00'; |
|
| 513 | + } else { |
|
| 514 | + $offset = '+00:00'; |
|
| 515 | + } |
|
| 473 | 516 | |
| 474 | 517 | if ($globalDBdriver == 'mysql') { |
| 475 | 518 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date |
@@ -617,7 +660,9 @@ discard block |
||
| 617 | 660 | { |
| 618 | 661 | return false; |
| 619 | 662 | } |
| 620 | - } else $altitude = 0; |
|
| 663 | + } else { |
|
| 664 | + $altitude = 0; |
|
| 665 | + } |
|
| 621 | 666 | |
| 622 | 667 | if ($heading != "") |
| 623 | 668 | { |
@@ -656,8 +701,12 @@ discard block |
||
| 656 | 701 | $latitude = 0; |
| 657 | 702 | $longitude = 0; |
| 658 | 703 | } |
| 659 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 660 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 704 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
| 705 | + $heading = 0; |
|
| 706 | + } |
|
| 707 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) { |
|
| 708 | + $groundspeed = 0; |
|
| 709 | + } |
|
| 661 | 710 | $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) |
| 662 | 711 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)"; |
| 663 | 712 | |
@@ -764,7 +813,9 @@ discard block |
||
| 764 | 813 | global $globalDBdriver, $globalArchive; |
| 765 | 814 | //$filter_query = $this->getFilter($filters,true,true); |
| 766 | 815 | $Connection= new Connection($this->db); |
| 767 | - if (!$Connection->tableExists('countries')) return array(); |
|
| 816 | + if (!$Connection->tableExists('countries')) { |
|
| 817 | + return array(); |
|
| 818 | + } |
|
| 768 | 819 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
| 769 | 820 | require_once('class.TrackerLive.php'); |
| 770 | 821 | $TrackerLive = new TrackerLive($this->db); |
@@ -807,7 +858,9 @@ discard block |
||
| 807 | 858 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT famtrackid,over_country FROM tracker_archive".$filter_query.") l ON c.iso2 = l.over_country "; |
| 808 | 859 | } |
| 809 | 860 | $query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; |
| 810 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 861 | + if ($limit) { |
|
| 862 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 863 | + } |
|
| 811 | 864 | |
| 812 | 865 | |
| 813 | 866 | $sth = $this->db->prepare($query); |
@@ -846,12 +899,18 @@ discard block |
||
| 846 | 899 | $query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count |
| 847 | 900 | FROM tracker_output".$filter_query." tracker_output.ident <> ''"; |
| 848 | 901 | if ($olderthanmonths > 0) { |
| 849 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
| 850 | - else $query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 902 | + if ($globalDBdriver == 'mysql') { |
|
| 903 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
| 904 | + } else { |
|
| 905 | + $query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 906 | + } |
|
| 851 | 907 | } |
| 852 | 908 | if ($sincedate != '') { |
| 853 | - if ($globalDBdriver == 'mysql') $query .= " AND tracker_output.date > '".$sincedate."'"; |
|
| 854 | - else $query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
| 909 | + if ($globalDBdriver == 'mysql') { |
|
| 910 | + $query .= " AND tracker_output.date > '".$sincedate."'"; |
|
| 911 | + } else { |
|
| 912 | + $query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
| 913 | + } |
|
| 855 | 914 | } |
| 856 | 915 | $query_values = array(); |
| 857 | 916 | if ($year != '') { |
@@ -882,7 +941,9 @@ discard block |
||
| 882 | 941 | } |
| 883 | 942 | } |
| 884 | 943 | $query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC"; |
| 885 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 944 | + if ($limit) { |
|
| 945 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 946 | + } |
|
| 886 | 947 | |
| 887 | 948 | $sth = $this->db->prepare($query); |
| 888 | 949 | $sth->execute($query_values); |
@@ -917,7 +978,9 @@ discard block |
||
| 917 | 978 | date_default_timezone_set($globalTimezone); |
| 918 | 979 | $datetime = new DateTime(); |
| 919 | 980 | $offset = $datetime->format('P'); |
| 920 | - } else $offset = '+00:00'; |
|
| 981 | + } else { |
|
| 982 | + $offset = '+00:00'; |
|
| 983 | + } |
|
| 921 | 984 | |
| 922 | 985 | if ($globalDBdriver == 'mysql') { |
| 923 | 986 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -967,7 +1030,9 @@ discard block |
||
| 967 | 1030 | date_default_timezone_set($globalTimezone); |
| 968 | 1031 | $datetime = new DateTime(); |
| 969 | 1032 | $offset = $datetime->format('P'); |
| 970 | - } else $offset = '+00:00'; |
|
| 1033 | + } else { |
|
| 1034 | + $offset = '+00:00'; |
|
| 1035 | + } |
|
| 971 | 1036 | $filter_query = $this->getFilter($filters,true,true); |
| 972 | 1037 | if ($globalDBdriver == 'mysql') { |
| 973 | 1038 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1013,7 +1078,9 @@ discard block |
||
| 1013 | 1078 | date_default_timezone_set($globalTimezone); |
| 1014 | 1079 | $datetime = new DateTime(); |
| 1015 | 1080 | $offset = $datetime->format('P'); |
| 1016 | - } else $offset = '+00:00'; |
|
| 1081 | + } else { |
|
| 1082 | + $offset = '+00:00'; |
|
| 1083 | + } |
|
| 1017 | 1084 | $filter_query = $this->getFilter($filters,true,true); |
| 1018 | 1085 | if ($globalDBdriver == 'mysql') { |
| 1019 | 1086 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1060,7 +1127,9 @@ discard block |
||
| 1060 | 1127 | date_default_timezone_set($globalTimezone); |
| 1061 | 1128 | $datetime = new DateTime(); |
| 1062 | 1129 | $offset = $datetime->format('P'); |
| 1063 | - } else $offset = '+00:00'; |
|
| 1130 | + } else { |
|
| 1131 | + $offset = '+00:00'; |
|
| 1132 | + } |
|
| 1064 | 1133 | |
| 1065 | 1134 | if ($globalDBdriver == 'mysql') { |
| 1066 | 1135 | $query = "SELECT YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
@@ -1107,7 +1176,9 @@ discard block |
||
| 1107 | 1176 | date_default_timezone_set($globalTimezone); |
| 1108 | 1177 | $datetime = new DateTime(); |
| 1109 | 1178 | $offset = $datetime->format('P'); |
| 1110 | - } else $offset = '+00:00'; |
|
| 1179 | + } else { |
|
| 1180 | + $offset = '+00:00'; |
|
| 1181 | + } |
|
| 1111 | 1182 | $filter_query = $this->getFilter($filters,true,true); |
| 1112 | 1183 | if ($globalDBdriver == 'mysql') { |
| 1113 | 1184 | $query = "SELECT MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
@@ -1156,7 +1227,9 @@ discard block |
||
| 1156 | 1227 | date_default_timezone_set($globalTimezone); |
| 1157 | 1228 | $datetime = new DateTime(); |
| 1158 | 1229 | $offset = $datetime->format('P'); |
| 1159 | - } else $offset = '+00:00'; |
|
| 1230 | + } else { |
|
| 1231 | + $offset = '+00:00'; |
|
| 1232 | + } |
|
| 1160 | 1233 | |
| 1161 | 1234 | $orderby_sql = ''; |
| 1162 | 1235 | if ($orderby == "hour") |
@@ -1225,7 +1298,9 @@ discard block |
||
| 1225 | 1298 | date_default_timezone_set($globalTimezone); |
| 1226 | 1299 | $datetime = new DateTime($date); |
| 1227 | 1300 | $offset = $datetime->format('P'); |
| 1228 | - } else $offset = '+00:00'; |
|
| 1301 | + } else { |
|
| 1302 | + $offset = '+00:00'; |
|
| 1303 | + } |
|
| 1229 | 1304 | |
| 1230 | 1305 | if ($globalDBdriver == 'mysql') { |
| 1231 | 1306 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1273,7 +1348,9 @@ discard block |
||
| 1273 | 1348 | date_default_timezone_set($globalTimezone); |
| 1274 | 1349 | $datetime = new DateTime(); |
| 1275 | 1350 | $offset = $datetime->format('P'); |
| 1276 | - } else $offset = '+00:00'; |
|
| 1351 | + } else { |
|
| 1352 | + $offset = '+00:00'; |
|
| 1353 | + } |
|
| 1277 | 1354 | |
| 1278 | 1355 | if ($globalDBdriver == 'mysql') { |
| 1279 | 1356 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1339,8 +1416,11 @@ discard block |
||
| 1339 | 1416 | $query_values = array_merge($query_values,array(':month' => $month)); |
| 1340 | 1417 | } |
| 1341 | 1418 | } |
| 1342 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
| 1343 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1419 | + if (empty($query_values)) { |
|
| 1420 | + $queryi .= $this->getFilter($filters); |
|
| 1421 | + } else { |
|
| 1422 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1423 | + } |
|
| 1344 | 1424 | |
| 1345 | 1425 | $sth = $this->db->prepare($queryi); |
| 1346 | 1426 | $sth->execute($query_values); |
@@ -1379,8 +1459,11 @@ discard block |
||
| 1379 | 1459 | $query_values = array_merge($query_values,array(':month' => $month)); |
| 1380 | 1460 | } |
| 1381 | 1461 | } |
| 1382 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
| 1383 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1462 | + if (empty($query_values)) { |
|
| 1463 | + $queryi .= $this->getFilter($filters); |
|
| 1464 | + } else { |
|
| 1465 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1466 | + } |
|
| 1384 | 1467 | |
| 1385 | 1468 | $sth = $this->db->prepare($queryi); |
| 1386 | 1469 | $sth->execute($query_values); |
@@ -1402,7 +1485,9 @@ discard block |
||
| 1402 | 1485 | date_default_timezone_set($globalTimezone); |
| 1403 | 1486 | $datetime = new DateTime(); |
| 1404 | 1487 | $offset = $datetime->format('P'); |
| 1405 | - } else $offset = '+00:00'; |
|
| 1488 | + } else { |
|
| 1489 | + $offset = '+00:00'; |
|
| 1490 | + } |
|
| 1406 | 1491 | |
| 1407 | 1492 | if ($globalDBdriver == 'mysql') { |
| 1408 | 1493 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1506,7 +1591,9 @@ discard block |
||
| 1506 | 1591 | */ |
| 1507 | 1592 | public function parseDirection($direction = 0) |
| 1508 | 1593 | { |
| 1509 | - if ($direction == '') $direction = 0; |
|
| 1594 | + if ($direction == '') { |
|
| 1595 | + $direction = 0; |
|
| 1596 | + } |
|
| 1510 | 1597 | $direction_array = array(); |
| 1511 | 1598 | $temp_array = array(); |
| 1512 | 1599 | |
@@ -1595,7 +1682,9 @@ discard block |
||
| 1595 | 1682 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 1596 | 1683 | |
| 1597 | 1684 | $Connection = new Connection($this->db); |
| 1598 | - if (!$Connection->tableExists('countries')) return ''; |
|
| 1685 | + if (!$Connection->tableExists('countries')) { |
|
| 1686 | + return ''; |
|
| 1687 | + } |
|
| 1599 | 1688 | |
| 1600 | 1689 | try { |
| 1601 | 1690 | $query = "SELECT name,iso2,iso3 FROM countries WHERE ST_Within(ST_GeomFromText('POINT(".$longitude." ".$latitude.")',4326), ogc_geom) LIMIT 1"; |
@@ -1606,9 +1695,13 @@ discard block |
||
| 1606 | 1695 | $sth->closeCursor(); |
| 1607 | 1696 | if (count($row) > 0) { |
| 1608 | 1697 | return $row; |
| 1609 | - } else return ''; |
|
| 1698 | + } else { |
|
| 1699 | + return ''; |
|
| 1700 | + } |
|
| 1610 | 1701 | } catch (PDOException $e) { |
| 1611 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
| 1702 | + if (isset($globalDebug) && $globalDebug) { |
|
| 1703 | + echo 'Error : '.$e->getMessage()."\n"; |
|
| 1704 | + } |
|
| 1612 | 1705 | return ''; |
| 1613 | 1706 | } |
| 1614 | 1707 | |
@@ -1626,7 +1719,9 @@ discard block |
||
| 1626 | 1719 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
| 1627 | 1720 | |
| 1628 | 1721 | $Connection = new Connection($this->db); |
| 1629 | - if (!$Connection->tableExists('countries')) return ''; |
|
| 1722 | + if (!$Connection->tableExists('countries')) { |
|
| 1723 | + return ''; |
|
| 1724 | + } |
|
| 1630 | 1725 | |
| 1631 | 1726 | try { |
| 1632 | 1727 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -1638,9 +1733,13 @@ discard block |
||
| 1638 | 1733 | $sth->closeCursor(); |
| 1639 | 1734 | if (count($row) > 0) { |
| 1640 | 1735 | return $row; |
| 1641 | - } else return ''; |
|
| 1736 | + } else { |
|
| 1737 | + return ''; |
|
| 1738 | + } |
|
| 1642 | 1739 | } catch (PDOException $e) { |
| 1643 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
| 1740 | + if (isset($globalDebug) && $globalDebug) { |
|
| 1741 | + echo 'Error : '.$e->getMessage()."\n"; |
|
| 1742 | + } |
|
| 1644 | 1743 | return ''; |
| 1645 | 1744 | } |
| 1646 | 1745 | |
@@ -1707,7 +1806,9 @@ discard block |
||
| 1707 | 1806 | } |
| 1708 | 1807 | } |
| 1709 | 1808 | $query .= " GROUP BY tracker_output.type ORDER BY tracker_type_count DESC"; |
| 1710 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 1809 | + if ($limit) { |
|
| 1810 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 1811 | + } |
|
| 1711 | 1812 | $sth = $this->db->prepare($query); |
| 1712 | 1813 | $sth->execute($query_values); |
| 1713 | 1814 | $tracker_array = array(); |
@@ -1753,7 +1854,9 @@ discard block |
||
| 1753 | 1854 | foreach ($q_array as $q_item){ |
| 1754 | 1855 | $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
| 1755 | 1856 | $additional_query .= " AND ("; |
| 1756 | - if (is_int($q_item)) $additional_query .= "(tracker_output.tracker_id = '".$q_item."') OR "; |
|
| 1857 | + if (is_int($q_item)) { |
|
| 1858 | + $additional_query .= "(tracker_output.tracker_id = '".$q_item."') OR "; |
|
| 1859 | + } |
|
| 1757 | 1860 | $additional_query .= "(tracker_output.ident like '%".$q_item."%') OR "; |
| 1758 | 1861 | $additional_query .= ")"; |
| 1759 | 1862 | } |
@@ -1779,7 +1882,9 @@ discard block |
||
| 1779 | 1882 | date_default_timezone_set($globalTimezone); |
| 1780 | 1883 | $datetime = new DateTime(); |
| 1781 | 1884 | $offset = $datetime->format('P'); |
| 1782 | - } else $offset = '+00:00'; |
|
| 1885 | + } else { |
|
| 1886 | + $offset = '+00:00'; |
|
| 1887 | + } |
|
| 1783 | 1888 | if ($date_array[1] != "") |
| 1784 | 1889 | { |
| 1785 | 1890 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
@@ -1806,8 +1911,12 @@ discard block |
||
| 1806 | 1911 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1807 | 1912 | { |
| 1808 | 1913 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1809 | - } else $limit_query = ""; |
|
| 1810 | - } else $limit_query = ""; |
|
| 1914 | + } else { |
|
| 1915 | + $limit_query = ""; |
|
| 1916 | + } |
|
| 1917 | + } else { |
|
| 1918 | + $limit_query = ""; |
|
| 1919 | + } |
|
| 1811 | 1920 | if ($sort != "") |
| 1812 | 1921 | { |
| 1813 | 1922 | $search_orderby_array = $this->getOrderBy(); |
@@ -1850,7 +1959,9 @@ discard block |
||
| 1850 | 1959 | { |
| 1851 | 1960 | global $globalBitlyAccessToken; |
| 1852 | 1961 | |
| 1853 | - if ($globalBitlyAccessToken == '') return $url; |
|
| 1962 | + if ($globalBitlyAccessToken == '') { |
|
| 1963 | + return $url; |
|
| 1964 | + } |
|
| 1854 | 1965 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
| 1855 | 1966 | $ch = curl_init(); |
| 1856 | 1967 | curl_setopt($ch, CURLOPT_HEADER, 0); |
@@ -74,8 +74,8 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | /** |
| 76 | 76 | * @param $ident |
| 77 | - * @param $correct_ident |
|
| 78 | - * @param $source |
|
| 77 | + * @param string $correct_ident |
|
| 78 | + * @param string $source |
|
| 79 | 79 | * @return string |
| 80 | 80 | */ |
| 81 | 81 | public function addOperator($ident, $correct_ident, $source) { |
@@ -91,8 +91,8 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | /** |
| 93 | 93 | * @param $ident |
| 94 | - * @param $correct_ident |
|
| 95 | - * @param $source |
|
| 94 | + * @param string $correct_ident |
|
| 95 | + * @param string $source |
|
| 96 | 96 | * @return string |
| 97 | 97 | */ |
| 98 | 98 | public function updateOperator($ident, $correct_ident, $source) { |
@@ -25,11 +25,11 @@ discard block |
||
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | - * Change IATA to ICAO value for ident |
|
| 29 | - * |
|
| 30 | - * @param string $ident ident |
|
| 31 | - * @return string the icao |
|
| 32 | - */ |
|
| 28 | + * Change IATA to ICAO value for ident |
|
| 29 | + * |
|
| 30 | + * @param string $ident ident |
|
| 31 | + * @return string the icao |
|
| 32 | + */ |
|
| 33 | 33 | public function ident2icao($ident) { |
| 34 | 34 | $Spotter = new Spotter(); |
| 35 | 35 | if (!is_numeric(substr($ident, 0, 3))) { |
@@ -52,11 +52,11 @@ discard block |
||
| 52 | 52 | return $icao; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * @param $ident |
|
| 57 | - * @return string |
|
| 58 | - */ |
|
| 59 | - public function getOperator($ident) { |
|
| 55 | + /** |
|
| 56 | + * @param $ident |
|
| 57 | + * @return string |
|
| 58 | + */ |
|
| 59 | + public function getOperator($ident) { |
|
| 60 | 60 | $query = "SELECT * FROM translation WHERE Operator = :ident LIMIT 1"; |
| 61 | 61 | $query_values = array(':ident' => $ident); |
| 62 | 62 | try { |
@@ -72,13 +72,13 @@ discard block |
||
| 72 | 72 | } else return $ident; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * @param $ident |
|
| 77 | - * @param $correct_ident |
|
| 78 | - * @param $source |
|
| 79 | - * @return string |
|
| 80 | - */ |
|
| 81 | - public function addOperator($ident, $correct_ident, $source) { |
|
| 75 | + /** |
|
| 76 | + * @param $ident |
|
| 77 | + * @param $correct_ident |
|
| 78 | + * @param $source |
|
| 79 | + * @return string |
|
| 80 | + */ |
|
| 81 | + public function addOperator($ident, $correct_ident, $source) { |
|
| 82 | 82 | $query = "INSERT INTO translation (Operator,Operator_correct,Source) VALUES (:ident,:correct_ident,:source)"; |
| 83 | 83 | $query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source); |
| 84 | 84 | try { |
@@ -89,13 +89,13 @@ discard block |
||
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - /** |
|
| 93 | - * @param $ident |
|
| 94 | - * @param $correct_ident |
|
| 95 | - * @param $source |
|
| 96 | - * @return string |
|
| 97 | - */ |
|
| 98 | - public function updateOperator($ident, $correct_ident, $source) { |
|
| 92 | + /** |
|
| 93 | + * @param $ident |
|
| 94 | + * @param $correct_ident |
|
| 95 | + * @param $source |
|
| 96 | + * @return string |
|
| 97 | + */ |
|
| 98 | + public function updateOperator($ident, $correct_ident, $source) { |
|
| 99 | 99 | $query = "UPDATE translation SET Operator_correct = :correct_ident,Source = :source WHERE Operator = :ident"; |
| 100 | 100 | $query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source); |
| 101 | 101 | try { |
@@ -106,12 +106,12 @@ discard block |
||
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * @param $ident |
|
| 111 | - * @param bool $web |
|
| 112 | - * @return string |
|
| 113 | - */ |
|
| 114 | - public function checkTranslation($ident, $web = false) { |
|
| 109 | + /** |
|
| 110 | + * @param $ident |
|
| 111 | + * @param bool $web |
|
| 112 | + * @return string |
|
| 113 | + */ |
|
| 114 | + public function checkTranslation($ident, $web = false) { |
|
| 115 | 115 | global $globalTranslationSources, $globalTranslationFetch; |
| 116 | 116 | //if (!isset($globalTranslationSources)) $globalTranslationSources = array('planefinder'); |
| 117 | 117 | $globalTranslationSources = array(); |
@@ -41,12 +41,12 @@ discard block |
||
| 41 | 41 | } else return $ident; |
| 42 | 42 | } else return $ident; |
| 43 | 43 | if ($airline_icao == 'AF') { |
| 44 | - if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
| 45 | - else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
| 44 | + if (filter_var(substr($ident, 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
| 45 | + else $icao = 'AFR'.ltrim(substr($ident, 2), '0'); |
|
| 46 | 46 | } else { |
| 47 | 47 | $identicao = $Spotter->getAllAirlineInfo($airline_icao); |
| 48 | 48 | if (isset($identicao[0])) { |
| 49 | - $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
|
| 49 | + $icao = $identicao[0]['icao'].ltrim(substr($ident, 2), '0'); |
|
| 50 | 50 | } else $icao = $ident; |
| 51 | 51 | } |
| 52 | 52 | return $icao; |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | try { |
| 63 | 63 | $sth = $this->db->prepare($query); |
| 64 | 64 | $sth->execute($query_values); |
| 65 | - } catch(PDOException $e) { |
|
| 65 | + } catch (PDOException $e) { |
|
| 66 | 66 | return "error : ".$e->getMessage(); |
| 67 | 67 | } |
| 68 | 68 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -80,11 +80,11 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public function addOperator($ident, $correct_ident, $source) { |
| 82 | 82 | $query = "INSERT INTO translation (Operator,Operator_correct,Source) VALUES (:ident,:correct_ident,:source)"; |
| 83 | - $query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source); |
|
| 83 | + $query_values = array(':ident' => $ident, ':correct_ident' => $correct_ident, ':source' => $source); |
|
| 84 | 84 | try { |
| 85 | 85 | $sth = $this->db->prepare($query); |
| 86 | 86 | $sth->execute($query_values); |
| 87 | - } catch(PDOException $e) { |
|
| 87 | + } catch (PDOException $e) { |
|
| 88 | 88 | return "error : ".$e->getMessage(); |
| 89 | 89 | } |
| 90 | 90 | } |
@@ -97,11 +97,11 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | public function updateOperator($ident, $correct_ident, $source) { |
| 99 | 99 | $query = "UPDATE translation SET Operator_correct = :correct_ident,Source = :source WHERE Operator = :ident"; |
| 100 | - $query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source); |
|
| 100 | + $query_values = array(':ident' => $ident, ':correct_ident' => $correct_ident, ':source' => $source); |
|
| 101 | 101 | try { |
| 102 | 102 | $sth = $this->db->prepare($query); |
| 103 | 103 | $sth->execute($query_values); |
| 104 | - } catch(PDOException $e) { |
|
| 104 | + } catch (PDOException $e) { |
|
| 105 | 105 | return "error : ".$e->getMessage(); |
| 106 | 106 | } |
| 107 | 107 | } |
@@ -38,16 +38,25 @@ discard block |
||
| 38 | 38 | } elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) { |
| 39 | 39 | //$airline_icao = substr($ident, 0, 3); |
| 40 | 40 | return $ident; |
| 41 | - } else return $ident; |
|
| 42 | - } else return $ident; |
|
| 41 | + } else { |
|
| 42 | + return $ident; |
|
| 43 | + } |
|
| 44 | + } else { |
|
| 45 | + return $ident; |
|
| 46 | + } |
|
| 43 | 47 | if ($airline_icao == 'AF') { |
| 44 | - if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
| 45 | - else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
| 48 | + if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
| 49 | + $icao = $ident; |
|
| 50 | + } else { |
|
| 51 | + $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
| 52 | + } |
|
| 46 | 53 | } else { |
| 47 | 54 | $identicao = $Spotter->getAllAirlineInfo($airline_icao); |
| 48 | 55 | if (isset($identicao[0])) { |
| 49 | 56 | $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
| 50 | - } else $icao = $ident; |
|
| 57 | + } else { |
|
| 58 | + $icao = $ident; |
|
| 59 | + } |
|
| 51 | 60 | } |
| 52 | 61 | return $icao; |
| 53 | 62 | } |
@@ -69,7 +78,9 @@ discard block |
||
| 69 | 78 | $sth->closeCursor(); |
| 70 | 79 | if (isset($row['operator_correct'])) { |
| 71 | 80 | return $row['operator_correct']; |
| 72 | - } else return $ident; |
|
| 81 | + } else { |
|
| 82 | + return $ident; |
|
| 83 | + } |
|
| 73 | 84 | } |
| 74 | 85 | |
| 75 | 86 | /** |
@@ -115,7 +126,9 @@ discard block |
||
| 115 | 126 | global $globalTranslationSources, $globalTranslationFetch; |
| 116 | 127 | //if (!isset($globalTranslationSources)) $globalTranslationSources = array('planefinder'); |
| 117 | 128 | $globalTranslationSources = array(); |
| 118 | - if (!isset($globalTranslationFetch)) $globalTranslationFetch = TRUE; |
|
| 129 | + if (!isset($globalTranslationFetch)) { |
|
| 130 | + $globalTranslationFetch = TRUE; |
|
| 131 | + } |
|
| 119 | 132 | //echo "Check Translation for ".$ident."..."; |
| 120 | 133 | $correct = $this->getOperator($ident); |
| 121 | 134 | if ($correct != '' && $correct != $ident) { |
@@ -16,13 +16,13 @@ discard block |
||
| 16 | 16 | if ($this->db === null) die('Error: No DB connection. (TrackerArchive)'); |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Get SQL query part for filter used |
|
| 21 | - * @param array $filter the filter |
|
| 22 | - * @param bool $where |
|
| 23 | - * @param bool $and |
|
| 24 | - * @return string the SQL part |
|
| 25 | - */ |
|
| 19 | + /** |
|
| 20 | + * Get SQL query part for filter used |
|
| 21 | + * @param array $filter the filter |
|
| 22 | + * @param bool $where |
|
| 23 | + * @param bool $and |
|
| 24 | + * @return string the SQL part |
|
| 25 | + */ |
|
| 26 | 26 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 27 | 27 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 28 | 28 | $filters = array(); |
@@ -91,27 +91,27 @@ discard block |
||
| 91 | 91 | return $filter_query; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * Add to tracker_archive |
|
| 96 | - * |
|
| 97 | - * @param string $famtrackid |
|
| 98 | - * @param string $ident |
|
| 99 | - * @param string $latitude |
|
| 100 | - * @param string $longitude |
|
| 101 | - * @param string $altitude |
|
| 102 | - * @param string $heading |
|
| 103 | - * @param string $groundspeed |
|
| 104 | - * @param string $date |
|
| 105 | - * @param bool $putinarchive |
|
| 106 | - * @param string $comment |
|
| 107 | - * @param string $type |
|
| 108 | - * @param bool $noarchive |
|
| 109 | - * @param string $format_source |
|
| 110 | - * @param string $source_name |
|
| 111 | - * @param string $over_country |
|
| 112 | - * @return string |
|
| 113 | - */ |
|
| 114 | - public function addTrackerArchiveData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') { |
|
| 94 | + /** |
|
| 95 | + * Add to tracker_archive |
|
| 96 | + * |
|
| 97 | + * @param string $famtrackid |
|
| 98 | + * @param string $ident |
|
| 99 | + * @param string $latitude |
|
| 100 | + * @param string $longitude |
|
| 101 | + * @param string $altitude |
|
| 102 | + * @param string $heading |
|
| 103 | + * @param string $groundspeed |
|
| 104 | + * @param string $date |
|
| 105 | + * @param bool $putinarchive |
|
| 106 | + * @param string $comment |
|
| 107 | + * @param string $type |
|
| 108 | + * @param bool $noarchive |
|
| 109 | + * @param string $format_source |
|
| 110 | + * @param string $source_name |
|
| 111 | + * @param string $over_country |
|
| 112 | + * @return string |
|
| 113 | + */ |
|
| 114 | + public function addTrackerArchiveData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') { |
|
| 115 | 115 | require_once(dirname(__FILE__).'/class.Tracker.php'); |
| 116 | 116 | if ($over_country == '') { |
| 117 | 117 | $Tracker = new Tracker($this->db); |
@@ -134,40 +134,40 @@ discard block |
||
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | |
| 137 | - /** |
|
| 138 | - * Gets all the spotter information based on a particular callsign |
|
| 139 | - * |
|
| 140 | - * @param $ident |
|
| 141 | - * @return array the spotter information |
|
| 142 | - */ |
|
| 143 | - public function getLastArchiveTrackerDataByIdent($ident) |
|
| 144 | - { |
|
| 145 | - $Tracker = new Tracker($this->db); |
|
| 146 | - date_default_timezone_set('UTC'); |
|
| 147 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 148 | - $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 149 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident)); |
|
| 150 | - return $spotter_array; |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * Gets last the spotter information based on a particular id |
|
| 156 | - * |
|
| 157 | - * @param $id |
|
| 158 | - * @return array the spotter information |
|
| 159 | - */ |
|
| 160 | - public function getLastArchiveTrackerDataById($id) |
|
| 161 | - { |
|
| 162 | - $Tracker = new Tracker($this->db); |
|
| 163 | - date_default_timezone_set('UTC'); |
|
| 164 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 165 | - //$query = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id"; |
|
| 166 | - //$query = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
| 167 | - $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1"; |
|
| 137 | + /** |
|
| 138 | + * Gets all the spotter information based on a particular callsign |
|
| 139 | + * |
|
| 140 | + * @param $ident |
|
| 141 | + * @return array the spotter information |
|
| 142 | + */ |
|
| 143 | + public function getLastArchiveTrackerDataByIdent($ident) |
|
| 144 | + { |
|
| 145 | + $Tracker = new Tracker($this->db); |
|
| 146 | + date_default_timezone_set('UTC'); |
|
| 147 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 148 | + $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 149 | + $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident)); |
|
| 150 | + return $spotter_array; |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + |
|
| 154 | + /** |
|
| 155 | + * Gets last the spotter information based on a particular id |
|
| 156 | + * |
|
| 157 | + * @param $id |
|
| 158 | + * @return array the spotter information |
|
| 159 | + */ |
|
| 160 | + public function getLastArchiveTrackerDataById($id) |
|
| 161 | + { |
|
| 162 | + $Tracker = new Tracker($this->db); |
|
| 163 | + date_default_timezone_set('UTC'); |
|
| 164 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 165 | + //$query = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id"; |
|
| 166 | + //$query = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
| 167 | + $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1"; |
|
| 168 | 168 | |
| 169 | 169 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
| 170 | - /* |
|
| 170 | + /* |
|
| 171 | 171 | try { |
| 172 | 172 | $Connection = new Connection(); |
| 173 | 173 | $sth = Connection->$db->prepare($query); |
@@ -177,245 +177,245 @@ discard block |
||
| 177 | 177 | } |
| 178 | 178 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 179 | 179 | */ |
| 180 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id)); |
|
| 181 | - |
|
| 182 | - return $spotter_array; |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - /** |
|
| 186 | - * Gets all the spotter information based on a particular id |
|
| 187 | - * |
|
| 188 | - * @param $id |
|
| 189 | - * @param string $date |
|
| 190 | - * @return array the spotter information |
|
| 191 | - */ |
|
| 192 | - public function getAllArchiveTrackerDataById($id,$date = '') |
|
| 193 | - { |
|
| 194 | - date_default_timezone_set('UTC'); |
|
| 195 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 196 | - if ($date == '') $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 197 | - else $query = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date"; |
|
| 180 | + $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id)); |
|
| 181 | + |
|
| 182 | + return $spotter_array; |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + /** |
|
| 186 | + * Gets all the spotter information based on a particular id |
|
| 187 | + * |
|
| 188 | + * @param $id |
|
| 189 | + * @param string $date |
|
| 190 | + * @return array the spotter information |
|
| 191 | + */ |
|
| 192 | + public function getAllArchiveTrackerDataById($id,$date = '') |
|
| 193 | + { |
|
| 194 | + date_default_timezone_set('UTC'); |
|
| 195 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 196 | + if ($date == '') $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 197 | + else $query = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date"; |
|
| 198 | 198 | |
| 199 | 199 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
| 200 | 200 | |
| 201 | - try { |
|
| 202 | - $sth = $this->db->prepare($query); |
|
| 203 | - $sth->execute(array(':id' => $id)); |
|
| 204 | - } catch(PDOException $e) { |
|
| 205 | - echo $e->getMessage(); |
|
| 206 | - die; |
|
| 207 | - } |
|
| 208 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 209 | - |
|
| 210 | - return $spotter_array; |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - /** |
|
| 214 | - * Gets coordinate & time spotter information based on a particular id |
|
| 215 | - * |
|
| 216 | - * @param $id |
|
| 217 | - * @return array the spotter information |
|
| 218 | - */ |
|
| 219 | - public function getCoordArchiveTrackerDataById($id) |
|
| 220 | - { |
|
| 221 | - date_default_timezone_set('UTC'); |
|
| 222 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 223 | - $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id"; |
|
| 201 | + try { |
|
| 202 | + $sth = $this->db->prepare($query); |
|
| 203 | + $sth->execute(array(':id' => $id)); |
|
| 204 | + } catch(PDOException $e) { |
|
| 205 | + echo $e->getMessage(); |
|
| 206 | + die; |
|
| 207 | + } |
|
| 208 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 209 | + |
|
| 210 | + return $spotter_array; |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + /** |
|
| 214 | + * Gets coordinate & time spotter information based on a particular id |
|
| 215 | + * |
|
| 216 | + * @param $id |
|
| 217 | + * @return array the spotter information |
|
| 218 | + */ |
|
| 219 | + public function getCoordArchiveTrackerDataById($id) |
|
| 220 | + { |
|
| 221 | + date_default_timezone_set('UTC'); |
|
| 222 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 223 | + $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id"; |
|
| 224 | 224 | |
| 225 | 225 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
| 226 | 226 | |
| 227 | - try { |
|
| 228 | - $sth = $this->db->prepare($query); |
|
| 229 | - $sth->execute(array(':id' => $id)); |
|
| 230 | - } catch(PDOException $e) { |
|
| 231 | - echo $e->getMessage(); |
|
| 232 | - die; |
|
| 233 | - } |
|
| 234 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 235 | - |
|
| 236 | - return $spotter_array; |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - |
|
| 240 | - /** |
|
| 241 | - * Gets altitude information based on a particular callsign |
|
| 242 | - * |
|
| 243 | - * @param $ident |
|
| 244 | - * @return array the spotter information |
|
| 245 | - */ |
|
| 246 | - public function getAltitudeArchiveTrackerDataByIdent($ident) |
|
| 247 | - { |
|
| 248 | - |
|
| 249 | - date_default_timezone_set('UTC'); |
|
| 250 | - |
|
| 251 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 252 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
| 253 | - |
|
| 254 | - try { |
|
| 255 | - $sth = $this->db->prepare($query); |
|
| 256 | - $sth->execute(array(':ident' => $ident)); |
|
| 257 | - } catch(PDOException $e) { |
|
| 258 | - echo $e->getMessage(); |
|
| 259 | - die; |
|
| 260 | - } |
|
| 261 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 262 | - |
|
| 263 | - return $spotter_array; |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - /** |
|
| 267 | - * Gets altitude information based on a particular id |
|
| 268 | - * |
|
| 269 | - * @param $id |
|
| 270 | - * @return array the spotter information |
|
| 271 | - */ |
|
| 272 | - public function getAltitudeArchiveTrackerDataById($id) |
|
| 273 | - { |
|
| 274 | - |
|
| 275 | - date_default_timezone_set('UTC'); |
|
| 276 | - |
|
| 277 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 278 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
| 279 | - |
|
| 280 | - try { |
|
| 281 | - $sth = $this->db->prepare($query); |
|
| 282 | - $sth->execute(array(':id' => $id)); |
|
| 283 | - } catch(PDOException $e) { |
|
| 284 | - echo $e->getMessage(); |
|
| 285 | - die; |
|
| 286 | - } |
|
| 287 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 288 | - |
|
| 289 | - return $spotter_array; |
|
| 290 | - } |
|
| 291 | - |
|
| 292 | - /** |
|
| 293 | - * Gets altitude & speed information based on a particular id |
|
| 294 | - * |
|
| 295 | - * @param $id |
|
| 296 | - * @return array the spotter information |
|
| 297 | - */ |
|
| 298 | - public function getAltitudeSpeedArchiveTrackerDataById($id) |
|
| 299 | - { |
|
| 300 | - |
|
| 301 | - date_default_timezone_set('UTC'); |
|
| 302 | - |
|
| 303 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 304 | - $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 305 | - |
|
| 306 | - try { |
|
| 307 | - $sth = $this->db->prepare($query); |
|
| 308 | - $sth->execute(array(':id' => $id)); |
|
| 309 | - } catch(PDOException $e) { |
|
| 310 | - echo $e->getMessage(); |
|
| 311 | - die; |
|
| 312 | - } |
|
| 313 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 314 | - |
|
| 315 | - return $spotter_array; |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - |
|
| 319 | - /** |
|
| 320 | - * Gets altitude information based on a particular callsign |
|
| 321 | - * |
|
| 322 | - * @param $ident |
|
| 323 | - * @return array the spotter information |
|
| 324 | - */ |
|
| 325 | - public function getLastAltitudeArchiveTrackerDataByIdent($ident) |
|
| 326 | - { |
|
| 327 | - |
|
| 328 | - date_default_timezone_set('UTC'); |
|
| 329 | - |
|
| 330 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 331 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
| 227 | + try { |
|
| 228 | + $sth = $this->db->prepare($query); |
|
| 229 | + $sth->execute(array(':id' => $id)); |
|
| 230 | + } catch(PDOException $e) { |
|
| 231 | + echo $e->getMessage(); |
|
| 232 | + die; |
|
| 233 | + } |
|
| 234 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 235 | + |
|
| 236 | + return $spotter_array; |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + |
|
| 240 | + /** |
|
| 241 | + * Gets altitude information based on a particular callsign |
|
| 242 | + * |
|
| 243 | + * @param $ident |
|
| 244 | + * @return array the spotter information |
|
| 245 | + */ |
|
| 246 | + public function getAltitudeArchiveTrackerDataByIdent($ident) |
|
| 247 | + { |
|
| 248 | + |
|
| 249 | + date_default_timezone_set('UTC'); |
|
| 250 | + |
|
| 251 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 252 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
| 253 | + |
|
| 254 | + try { |
|
| 255 | + $sth = $this->db->prepare($query); |
|
| 256 | + $sth->execute(array(':ident' => $ident)); |
|
| 257 | + } catch(PDOException $e) { |
|
| 258 | + echo $e->getMessage(); |
|
| 259 | + die; |
|
| 260 | + } |
|
| 261 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 262 | + |
|
| 263 | + return $spotter_array; |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + /** |
|
| 267 | + * Gets altitude information based on a particular id |
|
| 268 | + * |
|
| 269 | + * @param $id |
|
| 270 | + * @return array the spotter information |
|
| 271 | + */ |
|
| 272 | + public function getAltitudeArchiveTrackerDataById($id) |
|
| 273 | + { |
|
| 274 | + |
|
| 275 | + date_default_timezone_set('UTC'); |
|
| 276 | + |
|
| 277 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 278 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
| 279 | + |
|
| 280 | + try { |
|
| 281 | + $sth = $this->db->prepare($query); |
|
| 282 | + $sth->execute(array(':id' => $id)); |
|
| 283 | + } catch(PDOException $e) { |
|
| 284 | + echo $e->getMessage(); |
|
| 285 | + die; |
|
| 286 | + } |
|
| 287 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 288 | + |
|
| 289 | + return $spotter_array; |
|
| 290 | + } |
|
| 291 | + |
|
| 292 | + /** |
|
| 293 | + * Gets altitude & speed information based on a particular id |
|
| 294 | + * |
|
| 295 | + * @param $id |
|
| 296 | + * @return array the spotter information |
|
| 297 | + */ |
|
| 298 | + public function getAltitudeSpeedArchiveTrackerDataById($id) |
|
| 299 | + { |
|
| 300 | + |
|
| 301 | + date_default_timezone_set('UTC'); |
|
| 302 | + |
|
| 303 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 304 | + $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 305 | + |
|
| 306 | + try { |
|
| 307 | + $sth = $this->db->prepare($query); |
|
| 308 | + $sth->execute(array(':id' => $id)); |
|
| 309 | + } catch(PDOException $e) { |
|
| 310 | + echo $e->getMessage(); |
|
| 311 | + die; |
|
| 312 | + } |
|
| 313 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 314 | + |
|
| 315 | + return $spotter_array; |
|
| 316 | + } |
|
| 317 | + |
|
| 318 | + |
|
| 319 | + /** |
|
| 320 | + * Gets altitude information based on a particular callsign |
|
| 321 | + * |
|
| 322 | + * @param $ident |
|
| 323 | + * @return array the spotter information |
|
| 324 | + */ |
|
| 325 | + public function getLastAltitudeArchiveTrackerDataByIdent($ident) |
|
| 326 | + { |
|
| 327 | + |
|
| 328 | + date_default_timezone_set('UTC'); |
|
| 329 | + |
|
| 330 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 331 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
| 332 | 332 | // $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident"; |
| 333 | 333 | |
| 334 | - try { |
|
| 335 | - $sth = $this->db->prepare($query); |
|
| 336 | - $sth->execute(array(':ident' => $ident)); |
|
| 337 | - } catch(PDOException $e) { |
|
| 338 | - echo $e->getMessage(); |
|
| 339 | - die; |
|
| 340 | - } |
|
| 341 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 342 | - |
|
| 343 | - return $spotter_array; |
|
| 344 | - } |
|
| 345 | - |
|
| 346 | - |
|
| 347 | - /** |
|
| 348 | - * Gets all the archive spotter information |
|
| 349 | - * |
|
| 350 | - * @param $ident |
|
| 351 | - * @param $famtrackid |
|
| 352 | - * @param $date |
|
| 353 | - * @return array the spotter information |
|
| 354 | - */ |
|
| 355 | - public function getTrackerArchiveData($ident,$famtrackid,$date) |
|
| 356 | - { |
|
| 357 | - $Tracker = new Tracker($this->db); |
|
| 358 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 359 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate"; |
|
| 360 | - |
|
| 361 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%')); |
|
| 362 | - |
|
| 363 | - return $spotter_array; |
|
| 364 | - } |
|
| 365 | - |
|
| 366 | - public function deleteTrackerArchiveTrackData() |
|
| 367 | - { |
|
| 368 | - global $globalArchiveKeepTrackMonths, $globalDBdriver; |
|
| 369 | - if ($globalDBdriver == 'mysql') { |
|
| 370 | - $query = 'DELETE FROM tracker_archive WHERE tracker_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)'; |
|
| 371 | - } else { |
|
| 372 | - $query = "DELETE FROM tracker_archive WHERE tracker_archive_id IN (SELECT tracker_archive_id FROM tracker_archive WHERE tracker_archive.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepTrackMonths." MONTH' LIMIT 10000)"; |
|
| 373 | - } |
|
| 374 | - try { |
|
| 375 | - $sth = $this->db->prepare($query); |
|
| 376 | - $sth->execute(); |
|
| 377 | - } catch(PDOException $e) { |
|
| 378 | - echo $e->getMessage(); |
|
| 379 | - die; |
|
| 380 | - } |
|
| 381 | - } |
|
| 382 | - |
|
| 383 | - /** |
|
| 384 | - * Gets Minimal Live Tracker data |
|
| 385 | - * |
|
| 386 | - * @param $begindate |
|
| 387 | - * @param $enddate |
|
| 388 | - * @param array $filter |
|
| 389 | - * @return array the spotter information |
|
| 390 | - */ |
|
| 391 | - public function getMinLiveTrackerData($begindate,$enddate,$filter = array()) |
|
| 392 | - { |
|
| 393 | - global $globalDBdriver; |
|
| 394 | - date_default_timezone_set('UTC'); |
|
| 395 | - |
|
| 396 | - $filter_query = ''; |
|
| 397 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 398 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 399 | - } |
|
| 400 | - // Use spotter_output also ? |
|
| 401 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 402 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 403 | - } |
|
| 404 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 405 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
| 406 | - } |
|
| 407 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 408 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 409 | - } |
|
| 410 | - |
|
| 411 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 412 | - if ($globalDBdriver == 'mysql') { |
|
| 413 | - /* |
|
| 334 | + try { |
|
| 335 | + $sth = $this->db->prepare($query); |
|
| 336 | + $sth->execute(array(':ident' => $ident)); |
|
| 337 | + } catch(PDOException $e) { |
|
| 338 | + echo $e->getMessage(); |
|
| 339 | + die; |
|
| 340 | + } |
|
| 341 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 342 | + |
|
| 343 | + return $spotter_array; |
|
| 344 | + } |
|
| 345 | + |
|
| 346 | + |
|
| 347 | + /** |
|
| 348 | + * Gets all the archive spotter information |
|
| 349 | + * |
|
| 350 | + * @param $ident |
|
| 351 | + * @param $famtrackid |
|
| 352 | + * @param $date |
|
| 353 | + * @return array the spotter information |
|
| 354 | + */ |
|
| 355 | + public function getTrackerArchiveData($ident,$famtrackid,$date) |
|
| 356 | + { |
|
| 357 | + $Tracker = new Tracker($this->db); |
|
| 358 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 359 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate"; |
|
| 360 | + |
|
| 361 | + $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%')); |
|
| 362 | + |
|
| 363 | + return $spotter_array; |
|
| 364 | + } |
|
| 365 | + |
|
| 366 | + public function deleteTrackerArchiveTrackData() |
|
| 367 | + { |
|
| 368 | + global $globalArchiveKeepTrackMonths, $globalDBdriver; |
|
| 369 | + if ($globalDBdriver == 'mysql') { |
|
| 370 | + $query = 'DELETE FROM tracker_archive WHERE tracker_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)'; |
|
| 371 | + } else { |
|
| 372 | + $query = "DELETE FROM tracker_archive WHERE tracker_archive_id IN (SELECT tracker_archive_id FROM tracker_archive WHERE tracker_archive.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepTrackMonths." MONTH' LIMIT 10000)"; |
|
| 373 | + } |
|
| 374 | + try { |
|
| 375 | + $sth = $this->db->prepare($query); |
|
| 376 | + $sth->execute(); |
|
| 377 | + } catch(PDOException $e) { |
|
| 378 | + echo $e->getMessage(); |
|
| 379 | + die; |
|
| 380 | + } |
|
| 381 | + } |
|
| 382 | + |
|
| 383 | + /** |
|
| 384 | + * Gets Minimal Live Tracker data |
|
| 385 | + * |
|
| 386 | + * @param $begindate |
|
| 387 | + * @param $enddate |
|
| 388 | + * @param array $filter |
|
| 389 | + * @return array the spotter information |
|
| 390 | + */ |
|
| 391 | + public function getMinLiveTrackerData($begindate,$enddate,$filter = array()) |
|
| 392 | + { |
|
| 393 | + global $globalDBdriver; |
|
| 394 | + date_default_timezone_set('UTC'); |
|
| 395 | + |
|
| 396 | + $filter_query = ''; |
|
| 397 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 398 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 399 | + } |
|
| 400 | + // Use spotter_output also ? |
|
| 401 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 402 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 403 | + } |
|
| 404 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 405 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
| 406 | + } |
|
| 407 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 408 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 409 | + } |
|
| 410 | + |
|
| 411 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 412 | + if ($globalDBdriver == 'mysql') { |
|
| 413 | + /* |
|
| 414 | 414 | $query = 'SELECT a.aircraft_shadow, tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk |
| 415 | 415 | FROM tracker_archive |
| 416 | 416 | INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao'; |
| 417 | 417 | */ |
| 418 | - /* |
|
| 418 | + /* |
|
| 419 | 419 | $query = 'SELECT a.aircraft_shadow, tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk |
| 420 | 420 | FROM tracker_archive |
| 421 | 421 | INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate |
@@ -424,900 +424,900 @@ discard block |
||
| 424 | 424 | GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid |
| 425 | 425 | AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao'; |
| 426 | 426 | */ |
| 427 | - $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 427 | + $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 428 | 428 | FROM tracker_archive |
| 429 | 429 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
| 430 | 430 | WHERE tracker_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
| 431 | 431 | '.$filter_query.' ORDER BY famtrackid'; |
| 432 | - } else { |
|
| 433 | - //$query = 'SELECT tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao'; |
|
| 434 | - $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 432 | + } else { |
|
| 433 | + //$query = 'SELECT tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao'; |
|
| 434 | + $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 435 | 435 | FROM tracker_archive |
| 436 | 436 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
| 437 | 437 | WHERE tracker_archive.date >= '."'".$begindate."'".' AND tracker_archive.date <= '."'".$enddate."'".' |
| 438 | 438 | '.$filter_query.' ORDER BY famtrackid'; |
| 439 | - } |
|
| 440 | - //echo $query; |
|
| 441 | - try { |
|
| 442 | - $sth = $this->db->prepare($query); |
|
| 443 | - $sth->execute(); |
|
| 444 | - } catch(PDOException $e) { |
|
| 445 | - echo $e->getMessage(); |
|
| 446 | - die; |
|
| 447 | - } |
|
| 448 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 449 | - |
|
| 450 | - return $spotter_array; |
|
| 451 | - } |
|
| 452 | - |
|
| 453 | - /** |
|
| 454 | - * Gets Minimal Live Tracker data |
|
| 455 | - * |
|
| 456 | - * @param $begindate |
|
| 457 | - * @param $enddate |
|
| 458 | - * @param array $filter |
|
| 459 | - * @return array the spotter information |
|
| 460 | - */ |
|
| 461 | - public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array()) |
|
| 462 | - { |
|
| 463 | - global $globalDBdriver; |
|
| 464 | - date_default_timezone_set('UTC'); |
|
| 465 | - |
|
| 466 | - $filter_query = ''; |
|
| 467 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 468 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 469 | - } |
|
| 470 | - // Should use spotter_output also ? |
|
| 471 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 472 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 473 | - } |
|
| 474 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 475 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
| 476 | - } |
|
| 477 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 478 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 479 | - } |
|
| 480 | - |
|
| 481 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 482 | - if ($globalDBdriver == 'mysql') { |
|
| 483 | - /* |
|
| 439 | + } |
|
| 440 | + //echo $query; |
|
| 441 | + try { |
|
| 442 | + $sth = $this->db->prepare($query); |
|
| 443 | + $sth->execute(); |
|
| 444 | + } catch(PDOException $e) { |
|
| 445 | + echo $e->getMessage(); |
|
| 446 | + die; |
|
| 447 | + } |
|
| 448 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 449 | + |
|
| 450 | + return $spotter_array; |
|
| 451 | + } |
|
| 452 | + |
|
| 453 | + /** |
|
| 454 | + * Gets Minimal Live Tracker data |
|
| 455 | + * |
|
| 456 | + * @param $begindate |
|
| 457 | + * @param $enddate |
|
| 458 | + * @param array $filter |
|
| 459 | + * @return array the spotter information |
|
| 460 | + */ |
|
| 461 | + public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array()) |
|
| 462 | + { |
|
| 463 | + global $globalDBdriver; |
|
| 464 | + date_default_timezone_set('UTC'); |
|
| 465 | + |
|
| 466 | + $filter_query = ''; |
|
| 467 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 468 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 469 | + } |
|
| 470 | + // Should use spotter_output also ? |
|
| 471 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 472 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 473 | + } |
|
| 474 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 475 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
| 476 | + } |
|
| 477 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 478 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 479 | + } |
|
| 480 | + |
|
| 481 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 482 | + if ($globalDBdriver == 'mysql') { |
|
| 483 | + /* |
|
| 484 | 484 | $query = 'SELECT a.aircraft_shadow, tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk |
| 485 | 485 | FROM tracker_archive |
| 486 | 486 | INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao'; |
| 487 | 487 | */ |
| 488 | - $query = 'SELECT a.aircraft_shadow, tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk |
|
| 488 | + $query = 'SELECT a.aircraft_shadow, tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk |
|
| 489 | 489 | FROM tracker_archive_output |
| 490 | 490 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive_output.aircraft_icao = a.icao |
| 491 | 491 | WHERE (tracker_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
| 492 | 492 | '.$filter_query.' GROUP BY tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao, tracker_archive_output.arrival_airport_icao, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow'; |
| 493 | 493 | |
| 494 | - } else { |
|
| 495 | - //$query = 'SELECT tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow FROM tracker_archive_output INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive_output.famtrackid = s.famtrackid AND tracker_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao'; |
|
| 496 | - /* |
|
| 494 | + } else { |
|
| 495 | + //$query = 'SELECT tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow FROM tracker_archive_output INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive_output.famtrackid = s.famtrackid AND tracker_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao'; |
|
| 496 | + /* |
|
| 497 | 497 | $query = 'SELECT tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow |
| 498 | 498 | FROM tracker_archive_output |
| 499 | 499 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao |
| 500 | 500 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
| 501 | 501 | '.$filter_query.' GROUP BY tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao, tracker_archive_output.arrival_airport_icao, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow'; |
| 502 | 502 | */ |
| 503 | - $query = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow |
|
| 503 | + $query = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow |
|
| 504 | 504 | FROM tracker_archive_output |
| 505 | 505 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao |
| 506 | 506 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
| 507 | 507 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
| 508 | 508 | // .' GROUP BY spotter_output.famtrackid, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow'; |
| 509 | 509 | |
| 510 | - } |
|
| 511 | - //echo $query; |
|
| 512 | - try { |
|
| 513 | - $sth = $this->db->prepare($query); |
|
| 514 | - $sth->execute(); |
|
| 515 | - } catch(PDOException $e) { |
|
| 516 | - echo $e->getMessage(); |
|
| 517 | - die; |
|
| 518 | - } |
|
| 519 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 520 | - |
|
| 521 | - return $spotter_array; |
|
| 522 | - } |
|
| 523 | - |
|
| 524 | - /** |
|
| 525 | - * Gets count Live Tracker data |
|
| 526 | - * |
|
| 527 | - * @param $begindate |
|
| 528 | - * @param $enddate |
|
| 529 | - * @param array $filter |
|
| 530 | - * @return array the spotter information |
|
| 531 | - */ |
|
| 532 | - public function getLiveTrackerCount($begindate,$enddate,$filter = array()) |
|
| 533 | - { |
|
| 534 | - global $globalDBdriver, $globalLiveInterval; |
|
| 535 | - date_default_timezone_set('UTC'); |
|
| 536 | - |
|
| 537 | - $filter_query = ''; |
|
| 538 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 539 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 540 | - } |
|
| 541 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 542 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 543 | - } |
|
| 544 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 545 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
| 546 | - } |
|
| 547 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 548 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 549 | - } |
|
| 550 | - |
|
| 551 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 552 | - if ($globalDBdriver == 'mysql') { |
|
| 553 | - $query = 'SELECT COUNT(DISTINCT famtrackid) as nb |
|
| 510 | + } |
|
| 511 | + //echo $query; |
|
| 512 | + try { |
|
| 513 | + $sth = $this->db->prepare($query); |
|
| 514 | + $sth->execute(); |
|
| 515 | + } catch(PDOException $e) { |
|
| 516 | + echo $e->getMessage(); |
|
| 517 | + die; |
|
| 518 | + } |
|
| 519 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 520 | + |
|
| 521 | + return $spotter_array; |
|
| 522 | + } |
|
| 523 | + |
|
| 524 | + /** |
|
| 525 | + * Gets count Live Tracker data |
|
| 526 | + * |
|
| 527 | + * @param $begindate |
|
| 528 | + * @param $enddate |
|
| 529 | + * @param array $filter |
|
| 530 | + * @return array the spotter information |
|
| 531 | + */ |
|
| 532 | + public function getLiveTrackerCount($begindate,$enddate,$filter = array()) |
|
| 533 | + { |
|
| 534 | + global $globalDBdriver, $globalLiveInterval; |
|
| 535 | + date_default_timezone_set('UTC'); |
|
| 536 | + |
|
| 537 | + $filter_query = ''; |
|
| 538 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 539 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 540 | + } |
|
| 541 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 542 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 543 | + } |
|
| 544 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 545 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
| 546 | + } |
|
| 547 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 548 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 549 | + } |
|
| 550 | + |
|
| 551 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 552 | + if ($globalDBdriver == 'mysql') { |
|
| 553 | + $query = 'SELECT COUNT(DISTINCT famtrackid) as nb |
|
| 554 | 554 | FROM tracker_archive l |
| 555 | 555 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
| 556 | - } else { |
|
| 557 | - $query = 'SELECT COUNT(DISTINCT famtrackid) as nb FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
|
| 558 | - } |
|
| 559 | - //echo $query; |
|
| 560 | - try { |
|
| 561 | - $sth = $this->db->prepare($query); |
|
| 562 | - $sth->execute(); |
|
| 563 | - } catch(PDOException $e) { |
|
| 564 | - echo $e->getMessage(); |
|
| 565 | - die; |
|
| 566 | - } |
|
| 567 | - $result = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 568 | - $sth->closeCursor(); |
|
| 569 | - return $result['nb']; |
|
| 570 | - |
|
| 571 | - } |
|
| 572 | - |
|
| 573 | - |
|
| 574 | - |
|
| 575 | - // tracker_archive_output |
|
| 576 | - |
|
| 577 | - /** |
|
| 578 | - * Gets all the spotter information |
|
| 579 | - * |
|
| 580 | - * @param string $q |
|
| 581 | - * @param string $registration |
|
| 582 | - * @param string $aircraft_icao |
|
| 583 | - * @param string $aircraft_manufacturer |
|
| 584 | - * @param string $highlights |
|
| 585 | - * @param string $airline_icao |
|
| 586 | - * @param string $airline_country |
|
| 587 | - * @param string $airline_type |
|
| 588 | - * @param string $airport |
|
| 589 | - * @param string $airport_country |
|
| 590 | - * @param string $callsign |
|
| 591 | - * @param string $departure_airport_route |
|
| 592 | - * @param string $arrival_airport_route |
|
| 593 | - * @param string $owner |
|
| 594 | - * @param string $pilot_id |
|
| 595 | - * @param string $pilot_name |
|
| 596 | - * @param string $altitude |
|
| 597 | - * @param string $date_posted |
|
| 598 | - * @param string $limit |
|
| 599 | - * @param string $sort |
|
| 600 | - * @param string $includegeodata |
|
| 601 | - * @param string $origLat |
|
| 602 | - * @param string $origLon |
|
| 603 | - * @param string $dist |
|
| 604 | - * @param array $filters |
|
| 605 | - * @return array the spotter information |
|
| 606 | - */ |
|
| 607 | - public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 608 | - { |
|
| 609 | - global $globalTimezone, $globalDBdriver; |
|
| 610 | - require_once(dirname(__FILE__).'/class.Translation.php'); |
|
| 611 | - $Translation = new Translation($this->db); |
|
| 612 | - $Tracker = new Tracker($this->db); |
|
| 613 | - |
|
| 614 | - date_default_timezone_set('UTC'); |
|
| 556 | + } else { |
|
| 557 | + $query = 'SELECT COUNT(DISTINCT famtrackid) as nb FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
|
| 558 | + } |
|
| 559 | + //echo $query; |
|
| 560 | + try { |
|
| 561 | + $sth = $this->db->prepare($query); |
|
| 562 | + $sth->execute(); |
|
| 563 | + } catch(PDOException $e) { |
|
| 564 | + echo $e->getMessage(); |
|
| 565 | + die; |
|
| 566 | + } |
|
| 567 | + $result = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 568 | + $sth->closeCursor(); |
|
| 569 | + return $result['nb']; |
|
| 570 | + |
|
| 571 | + } |
|
| 572 | + |
|
| 573 | + |
|
| 574 | + |
|
| 575 | + // tracker_archive_output |
|
| 576 | + |
|
| 577 | + /** |
|
| 578 | + * Gets all the spotter information |
|
| 579 | + * |
|
| 580 | + * @param string $q |
|
| 581 | + * @param string $registration |
|
| 582 | + * @param string $aircraft_icao |
|
| 583 | + * @param string $aircraft_manufacturer |
|
| 584 | + * @param string $highlights |
|
| 585 | + * @param string $airline_icao |
|
| 586 | + * @param string $airline_country |
|
| 587 | + * @param string $airline_type |
|
| 588 | + * @param string $airport |
|
| 589 | + * @param string $airport_country |
|
| 590 | + * @param string $callsign |
|
| 591 | + * @param string $departure_airport_route |
|
| 592 | + * @param string $arrival_airport_route |
|
| 593 | + * @param string $owner |
|
| 594 | + * @param string $pilot_id |
|
| 595 | + * @param string $pilot_name |
|
| 596 | + * @param string $altitude |
|
| 597 | + * @param string $date_posted |
|
| 598 | + * @param string $limit |
|
| 599 | + * @param string $sort |
|
| 600 | + * @param string $includegeodata |
|
| 601 | + * @param string $origLat |
|
| 602 | + * @param string $origLon |
|
| 603 | + * @param string $dist |
|
| 604 | + * @param array $filters |
|
| 605 | + * @return array the spotter information |
|
| 606 | + */ |
|
| 607 | + public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 608 | + { |
|
| 609 | + global $globalTimezone, $globalDBdriver; |
|
| 610 | + require_once(dirname(__FILE__).'/class.Translation.php'); |
|
| 611 | + $Translation = new Translation($this->db); |
|
| 612 | + $Tracker = new Tracker($this->db); |
|
| 613 | + |
|
| 614 | + date_default_timezone_set('UTC'); |
|
| 615 | 615 | |
| 616 | - $query_values = array(); |
|
| 617 | - $additional_query = ''; |
|
| 618 | - $limit_query = ''; |
|
| 619 | - $filter_query = $this->getFilter($filters); |
|
| 620 | - if ($q != "") |
|
| 621 | - { |
|
| 622 | - if (!is_string($q)) |
|
| 623 | - { |
|
| 624 | - return array(); |
|
| 625 | - } else { |
|
| 616 | + $query_values = array(); |
|
| 617 | + $additional_query = ''; |
|
| 618 | + $limit_query = ''; |
|
| 619 | + $filter_query = $this->getFilter($filters); |
|
| 620 | + if ($q != "") |
|
| 621 | + { |
|
| 622 | + if (!is_string($q)) |
|
| 623 | + { |
|
| 624 | + return array(); |
|
| 625 | + } else { |
|
| 626 | 626 | |
| 627 | - $q_array = explode(" ", $q); |
|
| 627 | + $q_array = explode(" ", $q); |
|
| 628 | 628 | |
| 629 | - foreach ($q_array as $q_item){ |
|
| 630 | - $additional_query .= " AND ("; |
|
| 631 | - $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
| 632 | - $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
| 633 | - $additional_query .= "(tracker_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
| 634 | - $additional_query .= "(tracker_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
| 635 | - $additional_query .= "(tracker_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
| 636 | - $additional_query .= "(tracker_archive_output.airline_name like '%".$q_item."%') OR "; |
|
| 637 | - $additional_query .= "(tracker_archive_output.airline_country like '%".$q_item."%') OR "; |
|
| 638 | - $additional_query .= "(tracker_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
| 639 | - $additional_query .= "(tracker_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
| 640 | - $additional_query .= "(tracker_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
| 641 | - $additional_query .= "(tracker_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
| 642 | - $additional_query .= "(tracker_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
| 643 | - $additional_query .= "(tracker_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
| 644 | - $additional_query .= "(tracker_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
| 645 | - $additional_query .= "(tracker_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
| 646 | - $additional_query .= "(tracker_archive_output.registration like '%".$q_item."%') OR "; |
|
| 647 | - $additional_query .= "(tracker_archive_output.owner_name like '%".$q_item."%') OR "; |
|
| 648 | - $additional_query .= "(tracker_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
| 649 | - $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
| 650 | - $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR "; |
|
| 651 | - $translate = $Translation->ident2icao($q_item); |
|
| 652 | - if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR "; |
|
| 653 | - $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')"; |
|
| 654 | - $additional_query .= ")"; |
|
| 655 | - } |
|
| 656 | - } |
|
| 657 | - } |
|
| 629 | + foreach ($q_array as $q_item){ |
|
| 630 | + $additional_query .= " AND ("; |
|
| 631 | + $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
| 632 | + $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
| 633 | + $additional_query .= "(tracker_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
| 634 | + $additional_query .= "(tracker_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
| 635 | + $additional_query .= "(tracker_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
| 636 | + $additional_query .= "(tracker_archive_output.airline_name like '%".$q_item."%') OR "; |
|
| 637 | + $additional_query .= "(tracker_archive_output.airline_country like '%".$q_item."%') OR "; |
|
| 638 | + $additional_query .= "(tracker_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
| 639 | + $additional_query .= "(tracker_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
| 640 | + $additional_query .= "(tracker_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
| 641 | + $additional_query .= "(tracker_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
| 642 | + $additional_query .= "(tracker_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
| 643 | + $additional_query .= "(tracker_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
| 644 | + $additional_query .= "(tracker_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
| 645 | + $additional_query .= "(tracker_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
| 646 | + $additional_query .= "(tracker_archive_output.registration like '%".$q_item."%') OR "; |
|
| 647 | + $additional_query .= "(tracker_archive_output.owner_name like '%".$q_item."%') OR "; |
|
| 648 | + $additional_query .= "(tracker_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
| 649 | + $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
| 650 | + $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR "; |
|
| 651 | + $translate = $Translation->ident2icao($q_item); |
|
| 652 | + if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR "; |
|
| 653 | + $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')"; |
|
| 654 | + $additional_query .= ")"; |
|
| 655 | + } |
|
| 656 | + } |
|
| 657 | + } |
|
| 658 | 658 | |
| 659 | - if ($registration != "") |
|
| 660 | - { |
|
| 661 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 662 | - if (!is_string($registration)) |
|
| 663 | - { |
|
| 664 | - return array(); |
|
| 665 | - } else { |
|
| 666 | - $additional_query .= " AND (tracker_archive_output.registration = '".$registration."')"; |
|
| 667 | - } |
|
| 668 | - } |
|
| 659 | + if ($registration != "") |
|
| 660 | + { |
|
| 661 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 662 | + if (!is_string($registration)) |
|
| 663 | + { |
|
| 664 | + return array(); |
|
| 665 | + } else { |
|
| 666 | + $additional_query .= " AND (tracker_archive_output.registration = '".$registration."')"; |
|
| 667 | + } |
|
| 668 | + } |
|
| 669 | 669 | |
| 670 | - if ($aircraft_icao != "") |
|
| 671 | - { |
|
| 672 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 673 | - if (!is_string($aircraft_icao)) |
|
| 674 | - { |
|
| 675 | - return array(); |
|
| 676 | - } else { |
|
| 677 | - $additional_query .= " AND (tracker_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
|
| 678 | - } |
|
| 679 | - } |
|
| 670 | + if ($aircraft_icao != "") |
|
| 671 | + { |
|
| 672 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 673 | + if (!is_string($aircraft_icao)) |
|
| 674 | + { |
|
| 675 | + return array(); |
|
| 676 | + } else { |
|
| 677 | + $additional_query .= " AND (tracker_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
|
| 678 | + } |
|
| 679 | + } |
|
| 680 | 680 | |
| 681 | - if ($aircraft_manufacturer != "") |
|
| 682 | - { |
|
| 683 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 684 | - if (!is_string($aircraft_manufacturer)) |
|
| 685 | - { |
|
| 686 | - return array(); |
|
| 687 | - } else { |
|
| 688 | - $additional_query .= " AND (tracker_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
|
| 689 | - } |
|
| 690 | - } |
|
| 681 | + if ($aircraft_manufacturer != "") |
|
| 682 | + { |
|
| 683 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 684 | + if (!is_string($aircraft_manufacturer)) |
|
| 685 | + { |
|
| 686 | + return array(); |
|
| 687 | + } else { |
|
| 688 | + $additional_query .= " AND (tracker_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
|
| 689 | + } |
|
| 690 | + } |
|
| 691 | 691 | |
| 692 | - if ($highlights == "true") |
|
| 693 | - { |
|
| 694 | - if (!is_string($highlights)) |
|
| 695 | - { |
|
| 696 | - return array(); |
|
| 697 | - } else { |
|
| 698 | - $additional_query .= " AND (tracker_archive_output.highlight <> '')"; |
|
| 699 | - } |
|
| 700 | - } |
|
| 692 | + if ($highlights == "true") |
|
| 693 | + { |
|
| 694 | + if (!is_string($highlights)) |
|
| 695 | + { |
|
| 696 | + return array(); |
|
| 697 | + } else { |
|
| 698 | + $additional_query .= " AND (tracker_archive_output.highlight <> '')"; |
|
| 699 | + } |
|
| 700 | + } |
|
| 701 | 701 | |
| 702 | - if ($airline_icao != "") |
|
| 703 | - { |
|
| 704 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 705 | - if (!is_string($airline_icao)) |
|
| 706 | - { |
|
| 707 | - return array(); |
|
| 708 | - } else { |
|
| 709 | - $additional_query .= " AND (tracker_archive_output.airline_icao = '".$airline_icao."')"; |
|
| 710 | - } |
|
| 711 | - } |
|
| 702 | + if ($airline_icao != "") |
|
| 703 | + { |
|
| 704 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 705 | + if (!is_string($airline_icao)) |
|
| 706 | + { |
|
| 707 | + return array(); |
|
| 708 | + } else { |
|
| 709 | + $additional_query .= " AND (tracker_archive_output.airline_icao = '".$airline_icao."')"; |
|
| 710 | + } |
|
| 711 | + } |
|
| 712 | 712 | |
| 713 | - if ($airline_country != "") |
|
| 714 | - { |
|
| 715 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 716 | - if (!is_string($airline_country)) |
|
| 717 | - { |
|
| 718 | - return array(); |
|
| 719 | - } else { |
|
| 720 | - $additional_query .= " AND (tracker_archive_output.airline_country = '".$airline_country."')"; |
|
| 721 | - } |
|
| 722 | - } |
|
| 713 | + if ($airline_country != "") |
|
| 714 | + { |
|
| 715 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 716 | + if (!is_string($airline_country)) |
|
| 717 | + { |
|
| 718 | + return array(); |
|
| 719 | + } else { |
|
| 720 | + $additional_query .= " AND (tracker_archive_output.airline_country = '".$airline_country."')"; |
|
| 721 | + } |
|
| 722 | + } |
|
| 723 | 723 | |
| 724 | - if ($airline_type != "") |
|
| 725 | - { |
|
| 726 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 727 | - if (!is_string($airline_type)) |
|
| 728 | - { |
|
| 729 | - return array(); |
|
| 730 | - } else { |
|
| 731 | - if ($airline_type == "passenger") |
|
| 732 | - { |
|
| 733 | - $additional_query .= " AND (tracker_archive_output.airline_type = 'passenger')"; |
|
| 734 | - } |
|
| 735 | - if ($airline_type == "cargo") |
|
| 736 | - { |
|
| 737 | - $additional_query .= " AND (tracker_archive_output.airline_type = 'cargo')"; |
|
| 738 | - } |
|
| 739 | - if ($airline_type == "military") |
|
| 740 | - { |
|
| 741 | - $additional_query .= " AND (tracker_archive_output.airline_type = 'military')"; |
|
| 742 | - } |
|
| 743 | - } |
|
| 744 | - } |
|
| 724 | + if ($airline_type != "") |
|
| 725 | + { |
|
| 726 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 727 | + if (!is_string($airline_type)) |
|
| 728 | + { |
|
| 729 | + return array(); |
|
| 730 | + } else { |
|
| 731 | + if ($airline_type == "passenger") |
|
| 732 | + { |
|
| 733 | + $additional_query .= " AND (tracker_archive_output.airline_type = 'passenger')"; |
|
| 734 | + } |
|
| 735 | + if ($airline_type == "cargo") |
|
| 736 | + { |
|
| 737 | + $additional_query .= " AND (tracker_archive_output.airline_type = 'cargo')"; |
|
| 738 | + } |
|
| 739 | + if ($airline_type == "military") |
|
| 740 | + { |
|
| 741 | + $additional_query .= " AND (tracker_archive_output.airline_type = 'military')"; |
|
| 742 | + } |
|
| 743 | + } |
|
| 744 | + } |
|
| 745 | 745 | |
| 746 | - if ($airport != "") |
|
| 747 | - { |
|
| 748 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 749 | - if (!is_string($airport)) |
|
| 750 | - { |
|
| 751 | - return array(); |
|
| 752 | - } else { |
|
| 753 | - $additional_query .= " AND ((tracker_archive_output.departure_airport_icao = '".$airport."') OR (tracker_archive_output.arrival_airport_icao = '".$airport."'))"; |
|
| 754 | - } |
|
| 755 | - } |
|
| 746 | + if ($airport != "") |
|
| 747 | + { |
|
| 748 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 749 | + if (!is_string($airport)) |
|
| 750 | + { |
|
| 751 | + return array(); |
|
| 752 | + } else { |
|
| 753 | + $additional_query .= " AND ((tracker_archive_output.departure_airport_icao = '".$airport."') OR (tracker_archive_output.arrival_airport_icao = '".$airport."'))"; |
|
| 754 | + } |
|
| 755 | + } |
|
| 756 | 756 | |
| 757 | - if ($airport_country != "") |
|
| 758 | - { |
|
| 759 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 760 | - if (!is_string($airport_country)) |
|
| 761 | - { |
|
| 762 | - return array(); |
|
| 763 | - } else { |
|
| 764 | - $additional_query .= " AND ((tracker_archive_output.departure_airport_country = '".$airport_country."') OR (tracker_archive_output.arrival_airport_country = '".$airport_country."'))"; |
|
| 765 | - } |
|
| 766 | - } |
|
| 757 | + if ($airport_country != "") |
|
| 758 | + { |
|
| 759 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 760 | + if (!is_string($airport_country)) |
|
| 761 | + { |
|
| 762 | + return array(); |
|
| 763 | + } else { |
|
| 764 | + $additional_query .= " AND ((tracker_archive_output.departure_airport_country = '".$airport_country."') OR (tracker_archive_output.arrival_airport_country = '".$airport_country."'))"; |
|
| 765 | + } |
|
| 766 | + } |
|
| 767 | 767 | |
| 768 | - if ($callsign != "") |
|
| 769 | - { |
|
| 770 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 771 | - if (!is_string($callsign)) |
|
| 772 | - { |
|
| 773 | - return array(); |
|
| 774 | - } else { |
|
| 775 | - $translate = $Translation->ident2icao($callsign); |
|
| 776 | - if ($translate != $callsign) { |
|
| 777 | - $additional_query .= " AND (tracker_archive_output.ident = :callsign OR tracker_archive_output.ident = :translate)"; |
|
| 778 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
| 779 | - } else { |
|
| 780 | - $additional_query .= " AND (tracker_archive_output.ident = '".$callsign."')"; |
|
| 781 | - } |
|
| 782 | - } |
|
| 783 | - } |
|
| 784 | - |
|
| 785 | - if ($owner != "") |
|
| 786 | - { |
|
| 787 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 788 | - if (!is_string($owner)) |
|
| 789 | - { |
|
| 790 | - return array(); |
|
| 791 | - } else { |
|
| 792 | - $additional_query .= " AND (tracker_archive_output.owner_name = '".$owner."')"; |
|
| 793 | - } |
|
| 794 | - } |
|
| 795 | - |
|
| 796 | - if ($pilot_name != "") |
|
| 797 | - { |
|
| 798 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 799 | - if (!is_string($pilot_name)) |
|
| 800 | - { |
|
| 801 | - return array(); |
|
| 802 | - } else { |
|
| 803 | - $additional_query .= " AND (tracker_archive_output.pilot_name = '".$pilot_name."')"; |
|
| 804 | - } |
|
| 805 | - } |
|
| 768 | + if ($callsign != "") |
|
| 769 | + { |
|
| 770 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 771 | + if (!is_string($callsign)) |
|
| 772 | + { |
|
| 773 | + return array(); |
|
| 774 | + } else { |
|
| 775 | + $translate = $Translation->ident2icao($callsign); |
|
| 776 | + if ($translate != $callsign) { |
|
| 777 | + $additional_query .= " AND (tracker_archive_output.ident = :callsign OR tracker_archive_output.ident = :translate)"; |
|
| 778 | + $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
| 779 | + } else { |
|
| 780 | + $additional_query .= " AND (tracker_archive_output.ident = '".$callsign."')"; |
|
| 781 | + } |
|
| 782 | + } |
|
| 783 | + } |
|
| 784 | + |
|
| 785 | + if ($owner != "") |
|
| 786 | + { |
|
| 787 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 788 | + if (!is_string($owner)) |
|
| 789 | + { |
|
| 790 | + return array(); |
|
| 791 | + } else { |
|
| 792 | + $additional_query .= " AND (tracker_archive_output.owner_name = '".$owner."')"; |
|
| 793 | + } |
|
| 794 | + } |
|
| 795 | + |
|
| 796 | + if ($pilot_name != "") |
|
| 797 | + { |
|
| 798 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 799 | + if (!is_string($pilot_name)) |
|
| 800 | + { |
|
| 801 | + return array(); |
|
| 802 | + } else { |
|
| 803 | + $additional_query .= " AND (tracker_archive_output.pilot_name = '".$pilot_name."')"; |
|
| 804 | + } |
|
| 805 | + } |
|
| 806 | 806 | |
| 807 | - if ($pilot_id != "") |
|
| 808 | - { |
|
| 809 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 810 | - if (!is_string($pilot_id)) |
|
| 811 | - { |
|
| 812 | - return array(); |
|
| 813 | - } else { |
|
| 814 | - $additional_query .= " AND (tracker_archive_output.pilot_id = '".$pilot_id."')"; |
|
| 815 | - } |
|
| 816 | - } |
|
| 807 | + if ($pilot_id != "") |
|
| 808 | + { |
|
| 809 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 810 | + if (!is_string($pilot_id)) |
|
| 811 | + { |
|
| 812 | + return array(); |
|
| 813 | + } else { |
|
| 814 | + $additional_query .= " AND (tracker_archive_output.pilot_id = '".$pilot_id."')"; |
|
| 815 | + } |
|
| 816 | + } |
|
| 817 | 817 | |
| 818 | - if ($departure_airport_route != "") |
|
| 819 | - { |
|
| 820 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 821 | - if (!is_string($departure_airport_route)) |
|
| 822 | - { |
|
| 823 | - return array(); |
|
| 824 | - } else { |
|
| 825 | - $additional_query .= " AND (tracker_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
|
| 826 | - } |
|
| 827 | - } |
|
| 818 | + if ($departure_airport_route != "") |
|
| 819 | + { |
|
| 820 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 821 | + if (!is_string($departure_airport_route)) |
|
| 822 | + { |
|
| 823 | + return array(); |
|
| 824 | + } else { |
|
| 825 | + $additional_query .= " AND (tracker_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
|
| 826 | + } |
|
| 827 | + } |
|
| 828 | 828 | |
| 829 | - if ($arrival_airport_route != "") |
|
| 830 | - { |
|
| 831 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 832 | - if (!is_string($arrival_airport_route)) |
|
| 833 | - { |
|
| 834 | - return array(); |
|
| 835 | - } else { |
|
| 836 | - $additional_query .= " AND (tracker_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
|
| 837 | - } |
|
| 838 | - } |
|
| 829 | + if ($arrival_airport_route != "") |
|
| 830 | + { |
|
| 831 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 832 | + if (!is_string($arrival_airport_route)) |
|
| 833 | + { |
|
| 834 | + return array(); |
|
| 835 | + } else { |
|
| 836 | + $additional_query .= " AND (tracker_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
|
| 837 | + } |
|
| 838 | + } |
|
| 839 | 839 | |
| 840 | - if ($altitude != "") |
|
| 841 | - { |
|
| 842 | - $altitude_array = explode(",", $altitude); |
|
| 840 | + if ($altitude != "") |
|
| 841 | + { |
|
| 842 | + $altitude_array = explode(",", $altitude); |
|
| 843 | 843 | |
| 844 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 845 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 844 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 845 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 846 | 846 | |
| 847 | 847 | |
| 848 | - if ($altitude_array[1] != "") |
|
| 849 | - { |
|
| 850 | - $altitude_array[0] = substr($altitude_array[0], 0, -2); |
|
| 851 | - $altitude_array[1] = substr($altitude_array[1], 0, -2); |
|
| 852 | - $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
|
| 853 | - } else { |
|
| 854 | - $altitude_array[0] = substr($altitude_array[0], 0, -2); |
|
| 855 | - $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
|
| 856 | - } |
|
| 857 | - } |
|
| 848 | + if ($altitude_array[1] != "") |
|
| 849 | + { |
|
| 850 | + $altitude_array[0] = substr($altitude_array[0], 0, -2); |
|
| 851 | + $altitude_array[1] = substr($altitude_array[1], 0, -2); |
|
| 852 | + $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
|
| 853 | + } else { |
|
| 854 | + $altitude_array[0] = substr($altitude_array[0], 0, -2); |
|
| 855 | + $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
|
| 856 | + } |
|
| 857 | + } |
|
| 858 | 858 | |
| 859 | - if ($date_posted != "") |
|
| 860 | - { |
|
| 861 | - $date_array = explode(",", $date_posted); |
|
| 859 | + if ($date_posted != "") |
|
| 860 | + { |
|
| 861 | + $date_array = explode(",", $date_posted); |
|
| 862 | 862 | |
| 863 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 864 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 863 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 864 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 865 | 865 | |
| 866 | - if ($globalTimezone != '') { |
|
| 867 | - date_default_timezone_set($globalTimezone); |
|
| 868 | - $datetime = new DateTime(); |
|
| 869 | - $offset = $datetime->format('P'); |
|
| 870 | - } else $offset = '+00:00'; |
|
| 871 | - |
|
| 872 | - |
|
| 873 | - if ($date_array[1] != "") |
|
| 874 | - { |
|
| 875 | - $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
|
| 876 | - $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
|
| 877 | - if ($globalDBdriver == 'mysql') { |
|
| 878 | - $additional_query .= " AND TIMESTAMP(CONVERT_TZ(tracker_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' AND TIMESTAMP(CONVERT_TZ(tracker_archive_output.date,'+00:00', '".$offset."')) <= '".$date_array[1]."' "; |
|
| 879 | - } else { |
|
| 880 | - $additional_query .= " AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) "; |
|
| 881 | - } |
|
| 882 | - } else { |
|
| 883 | - $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
|
| 884 | - if ($globalDBdriver == 'mysql') { |
|
| 885 | - $additional_query .= " AND TIMESTAMP(CONVERT_TZ(tracker_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
|
| 886 | - } else { |
|
| 887 | - $additional_query .= " AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
|
| 888 | - } |
|
| 889 | - } |
|
| 890 | - } |
|
| 866 | + if ($globalTimezone != '') { |
|
| 867 | + date_default_timezone_set($globalTimezone); |
|
| 868 | + $datetime = new DateTime(); |
|
| 869 | + $offset = $datetime->format('P'); |
|
| 870 | + } else $offset = '+00:00'; |
|
| 871 | + |
|
| 872 | + |
|
| 873 | + if ($date_array[1] != "") |
|
| 874 | + { |
|
| 875 | + $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
|
| 876 | + $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
|
| 877 | + if ($globalDBdriver == 'mysql') { |
|
| 878 | + $additional_query .= " AND TIMESTAMP(CONVERT_TZ(tracker_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' AND TIMESTAMP(CONVERT_TZ(tracker_archive_output.date,'+00:00', '".$offset."')) <= '".$date_array[1]."' "; |
|
| 879 | + } else { |
|
| 880 | + $additional_query .= " AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) "; |
|
| 881 | + } |
|
| 882 | + } else { |
|
| 883 | + $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
|
| 884 | + if ($globalDBdriver == 'mysql') { |
|
| 885 | + $additional_query .= " AND TIMESTAMP(CONVERT_TZ(tracker_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
|
| 886 | + } else { |
|
| 887 | + $additional_query .= " AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
|
| 888 | + } |
|
| 889 | + } |
|
| 890 | + } |
|
| 891 | 891 | |
| 892 | - if ($limit != "") |
|
| 893 | - { |
|
| 894 | - $limit_array = explode(",", $limit); |
|
| 892 | + if ($limit != "") |
|
| 893 | + { |
|
| 894 | + $limit_array = explode(",", $limit); |
|
| 895 | 895 | |
| 896 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 897 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 896 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 897 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 898 | 898 | |
| 899 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 900 | - { |
|
| 901 | - //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
| 902 | - $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
| 903 | - } |
|
| 904 | - } |
|
| 899 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 900 | + { |
|
| 901 | + //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
| 902 | + $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
| 903 | + } |
|
| 904 | + } |
|
| 905 | 905 | |
| 906 | 906 | |
| 907 | - if ($origLat != "" && $origLon != "" && $dist != "") { |
|
| 908 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
| 909 | - $query="SELECT tracker_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 907 | + if ($origLat != "" && $origLon != "" && $dist != "") { |
|
| 908 | + $dist = number_format($dist*0.621371,2,'.',''); |
|
| 909 | + $query="SELECT tracker_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 910 | 910 | FROM tracker_archive_output, tracker_archive WHERE spotter_output_archive.famtrackid = tracker_archive.famtrackid AND spotter_output.ident <> '' ".$additional_query."AND CAST(tracker_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(tracker_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 911 | 911 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
| 912 | - } else { |
|
| 913 | - if ($sort != "") |
|
| 914 | - { |
|
| 915 | - $search_orderby_array = $Tracker->getOrderBy(); |
|
| 916 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 917 | - } else { |
|
| 918 | - $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
| 919 | - } |
|
| 912 | + } else { |
|
| 913 | + if ($sort != "") |
|
| 914 | + { |
|
| 915 | + $search_orderby_array = $Tracker->getOrderBy(); |
|
| 916 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 917 | + } else { |
|
| 918 | + $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
| 919 | + } |
|
| 920 | 920 | |
| 921 | - if ($includegeodata == "true") |
|
| 922 | - { |
|
| 923 | - $additional_query .= " AND (tracker_archive_output.waypoints <> '')"; |
|
| 924 | - } |
|
| 921 | + if ($includegeodata == "true") |
|
| 922 | + { |
|
| 923 | + $additional_query .= " AND (tracker_archive_output.waypoints <> '')"; |
|
| 924 | + } |
|
| 925 | 925 | |
| 926 | - $query = "SELECT tracker_archive_output.* FROM tracker_archive_output |
|
| 926 | + $query = "SELECT tracker_archive_output.* FROM tracker_archive_output |
|
| 927 | 927 | WHERE tracker_archive_output.ident <> '' |
| 928 | 928 | ".$additional_query." |
| 929 | 929 | ".$filter_query.$orderby_query; |
| 930 | - } |
|
| 931 | - $spotter_array = $Tracker->getDataFromDB($query, $query_values,$limit_query); |
|
| 932 | - |
|
| 933 | - return $spotter_array; |
|
| 934 | - } |
|
| 935 | - |
|
| 936 | - public function deleteTrackerArchiveData() |
|
| 937 | - { |
|
| 938 | - global $globalArchiveKeepMonths, $globalDBdriver; |
|
| 939 | - date_default_timezone_set('UTC'); |
|
| 940 | - if ($globalDBdriver == 'mysql') { |
|
| 941 | - $query = 'DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
|
| 942 | - } else { |
|
| 943 | - $query = "DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
|
| 944 | - } |
|
| 945 | - try { |
|
| 946 | - $sth = $this->db->prepare($query); |
|
| 947 | - $sth->execute(); |
|
| 948 | - } catch(PDOException $e) { |
|
| 949 | - return "error"; |
|
| 950 | - } |
|
| 951 | - return ''; |
|
| 952 | - } |
|
| 953 | - |
|
| 954 | - /** |
|
| 955 | - * Gets all the spotter information based on the callsign |
|
| 956 | - * |
|
| 957 | - * @param string $ident |
|
| 958 | - * @param string $limit |
|
| 959 | - * @param string $sort |
|
| 960 | - * @return array the spotter information |
|
| 961 | - */ |
|
| 962 | - public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '') |
|
| 963 | - { |
|
| 964 | - $global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output"; |
|
| 930 | + } |
|
| 931 | + $spotter_array = $Tracker->getDataFromDB($query, $query_values,$limit_query); |
|
| 932 | + |
|
| 933 | + return $spotter_array; |
|
| 934 | + } |
|
| 935 | + |
|
| 936 | + public function deleteTrackerArchiveData() |
|
| 937 | + { |
|
| 938 | + global $globalArchiveKeepMonths, $globalDBdriver; |
|
| 939 | + date_default_timezone_set('UTC'); |
|
| 940 | + if ($globalDBdriver == 'mysql') { |
|
| 941 | + $query = 'DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
|
| 942 | + } else { |
|
| 943 | + $query = "DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
|
| 944 | + } |
|
| 945 | + try { |
|
| 946 | + $sth = $this->db->prepare($query); |
|
| 947 | + $sth->execute(); |
|
| 948 | + } catch(PDOException $e) { |
|
| 949 | + return "error"; |
|
| 950 | + } |
|
| 951 | + return ''; |
|
| 952 | + } |
|
| 953 | + |
|
| 954 | + /** |
|
| 955 | + * Gets all the spotter information based on the callsign |
|
| 956 | + * |
|
| 957 | + * @param string $ident |
|
| 958 | + * @param string $limit |
|
| 959 | + * @param string $sort |
|
| 960 | + * @return array the spotter information |
|
| 961 | + */ |
|
| 962 | + public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '') |
|
| 963 | + { |
|
| 964 | + $global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output"; |
|
| 965 | 965 | |
| 966 | - date_default_timezone_set('UTC'); |
|
| 967 | - $Tracker = new Tracker($this->db); |
|
| 966 | + date_default_timezone_set('UTC'); |
|
| 967 | + $Tracker = new Tracker($this->db); |
|
| 968 | 968 | |
| 969 | - $query_values = array(); |
|
| 970 | - $limit_query = ''; |
|
| 971 | - $additional_query = ''; |
|
| 969 | + $query_values = array(); |
|
| 970 | + $limit_query = ''; |
|
| 971 | + $additional_query = ''; |
|
| 972 | 972 | |
| 973 | - if ($ident != "") |
|
| 974 | - { |
|
| 975 | - if (!is_string($ident)) |
|
| 976 | - { |
|
| 977 | - return array(); |
|
| 978 | - } else { |
|
| 979 | - $additional_query = " AND (tracker_archive_output.ident = :ident)"; |
|
| 980 | - $query_values = array(':ident' => $ident); |
|
| 981 | - } |
|
| 982 | - } |
|
| 973 | + if ($ident != "") |
|
| 974 | + { |
|
| 975 | + if (!is_string($ident)) |
|
| 976 | + { |
|
| 977 | + return array(); |
|
| 978 | + } else { |
|
| 979 | + $additional_query = " AND (tracker_archive_output.ident = :ident)"; |
|
| 980 | + $query_values = array(':ident' => $ident); |
|
| 981 | + } |
|
| 982 | + } |
|
| 983 | 983 | |
| 984 | - if ($limit != "") |
|
| 985 | - { |
|
| 986 | - $limit_array = explode(",", $limit); |
|
| 984 | + if ($limit != "") |
|
| 985 | + { |
|
| 986 | + $limit_array = explode(",", $limit); |
|
| 987 | 987 | |
| 988 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 989 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 988 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 989 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 990 | 990 | |
| 991 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 992 | - { |
|
| 993 | - //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
| 994 | - $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
| 995 | - } |
|
| 996 | - } |
|
| 997 | - |
|
| 998 | - if ($sort != "") |
|
| 999 | - { |
|
| 1000 | - $search_orderby_array = $Tracker->getOrderBy(); |
|
| 1001 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1002 | - } else { |
|
| 1003 | - $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
| 1004 | - } |
|
| 1005 | - |
|
| 1006 | - $query = $global_query." WHERE tracker_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
|
| 1007 | - |
|
| 1008 | - $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
|
| 1009 | - |
|
| 1010 | - return $spotter_array; |
|
| 1011 | - } |
|
| 1012 | - |
|
| 1013 | - |
|
| 1014 | - /** |
|
| 1015 | - * Gets all the spotter information based on the owner |
|
| 1016 | - * |
|
| 1017 | - * @param string $owner |
|
| 1018 | - * @param string $limit |
|
| 1019 | - * @param string $sort |
|
| 1020 | - * @param array $filter |
|
| 1021 | - * @return array the spotter information |
|
| 1022 | - */ |
|
| 1023 | - public function getTrackerDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
| 1024 | - { |
|
| 1025 | - $global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output"; |
|
| 991 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 992 | + { |
|
| 993 | + //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
| 994 | + $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
| 995 | + } |
|
| 996 | + } |
|
| 997 | + |
|
| 998 | + if ($sort != "") |
|
| 999 | + { |
|
| 1000 | + $search_orderby_array = $Tracker->getOrderBy(); |
|
| 1001 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1002 | + } else { |
|
| 1003 | + $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
| 1004 | + } |
|
| 1005 | + |
|
| 1006 | + $query = $global_query." WHERE tracker_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
|
| 1007 | + |
|
| 1008 | + $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
|
| 1009 | + |
|
| 1010 | + return $spotter_array; |
|
| 1011 | + } |
|
| 1012 | + |
|
| 1013 | + |
|
| 1014 | + /** |
|
| 1015 | + * Gets all the spotter information based on the owner |
|
| 1016 | + * |
|
| 1017 | + * @param string $owner |
|
| 1018 | + * @param string $limit |
|
| 1019 | + * @param string $sort |
|
| 1020 | + * @param array $filter |
|
| 1021 | + * @return array the spotter information |
|
| 1022 | + */ |
|
| 1023 | + public function getTrackerDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
| 1024 | + { |
|
| 1025 | + $global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output"; |
|
| 1026 | 1026 | |
| 1027 | - date_default_timezone_set('UTC'); |
|
| 1028 | - $Tracker = new Tracker($this->db); |
|
| 1027 | + date_default_timezone_set('UTC'); |
|
| 1028 | + $Tracker = new Tracker($this->db); |
|
| 1029 | 1029 | |
| 1030 | - $query_values = array(); |
|
| 1031 | - $limit_query = ''; |
|
| 1032 | - $additional_query = ''; |
|
| 1033 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1030 | + $query_values = array(); |
|
| 1031 | + $limit_query = ''; |
|
| 1032 | + $additional_query = ''; |
|
| 1033 | + $filter_query = $this->getFilter($filter,true,true); |
|
| 1034 | 1034 | |
| 1035 | - if ($owner != "") |
|
| 1036 | - { |
|
| 1037 | - if (!is_string($owner)) |
|
| 1038 | - { |
|
| 1039 | - return array(); |
|
| 1040 | - } else { |
|
| 1041 | - $additional_query = " AND (tracker_archive_output.owner_name = :owner)"; |
|
| 1042 | - $query_values = array(':owner' => $owner); |
|
| 1043 | - } |
|
| 1044 | - } |
|
| 1035 | + if ($owner != "") |
|
| 1036 | + { |
|
| 1037 | + if (!is_string($owner)) |
|
| 1038 | + { |
|
| 1039 | + return array(); |
|
| 1040 | + } else { |
|
| 1041 | + $additional_query = " AND (tracker_archive_output.owner_name = :owner)"; |
|
| 1042 | + $query_values = array(':owner' => $owner); |
|
| 1043 | + } |
|
| 1044 | + } |
|
| 1045 | 1045 | |
| 1046 | - if ($limit != "") |
|
| 1047 | - { |
|
| 1048 | - $limit_array = explode(",", $limit); |
|
| 1046 | + if ($limit != "") |
|
| 1047 | + { |
|
| 1048 | + $limit_array = explode(",", $limit); |
|
| 1049 | 1049 | |
| 1050 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1051 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1050 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1051 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1052 | 1052 | |
| 1053 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1054 | - { |
|
| 1055 | - //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
| 1056 | - $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
| 1057 | - } |
|
| 1058 | - } |
|
| 1059 | - |
|
| 1060 | - if ($sort != "") |
|
| 1061 | - { |
|
| 1062 | - $search_orderby_array = $Tracker->getOrderBy(); |
|
| 1063 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1064 | - } else { |
|
| 1065 | - $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
| 1066 | - } |
|
| 1067 | - |
|
| 1068 | - $query = $global_query.$filter_query." tracker_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query; |
|
| 1069 | - |
|
| 1070 | - $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
|
| 1071 | - |
|
| 1072 | - return $spotter_array; |
|
| 1073 | - } |
|
| 1074 | - |
|
| 1075 | - /** |
|
| 1076 | - * Gets all the spotter information based on the pilot |
|
| 1077 | - * |
|
| 1078 | - * @param string $pilot |
|
| 1079 | - * @param string $limit |
|
| 1080 | - * @param string $sort |
|
| 1081 | - * @param array $filter |
|
| 1082 | - * @return array the spotter information |
|
| 1083 | - */ |
|
| 1084 | - public function getTrackerDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
| 1085 | - { |
|
| 1086 | - $global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output"; |
|
| 1053 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1054 | + { |
|
| 1055 | + //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
| 1056 | + $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
| 1057 | + } |
|
| 1058 | + } |
|
| 1059 | + |
|
| 1060 | + if ($sort != "") |
|
| 1061 | + { |
|
| 1062 | + $search_orderby_array = $Tracker->getOrderBy(); |
|
| 1063 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1064 | + } else { |
|
| 1065 | + $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
| 1066 | + } |
|
| 1067 | + |
|
| 1068 | + $query = $global_query.$filter_query." tracker_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query; |
|
| 1069 | + |
|
| 1070 | + $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
|
| 1071 | + |
|
| 1072 | + return $spotter_array; |
|
| 1073 | + } |
|
| 1074 | + |
|
| 1075 | + /** |
|
| 1076 | + * Gets all the spotter information based on the pilot |
|
| 1077 | + * |
|
| 1078 | + * @param string $pilot |
|
| 1079 | + * @param string $limit |
|
| 1080 | + * @param string $sort |
|
| 1081 | + * @param array $filter |
|
| 1082 | + * @return array the spotter information |
|
| 1083 | + */ |
|
| 1084 | + public function getTrackerDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
| 1085 | + { |
|
| 1086 | + $global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output"; |
|
| 1087 | 1087 | |
| 1088 | - date_default_timezone_set('UTC'); |
|
| 1089 | - $Tracker = new Tracker($this->db); |
|
| 1088 | + date_default_timezone_set('UTC'); |
|
| 1089 | + $Tracker = new Tracker($this->db); |
|
| 1090 | 1090 | |
| 1091 | - $query_values = array(); |
|
| 1092 | - $limit_query = ''; |
|
| 1093 | - $additional_query = ''; |
|
| 1094 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1091 | + $query_values = array(); |
|
| 1092 | + $limit_query = ''; |
|
| 1093 | + $additional_query = ''; |
|
| 1094 | + $filter_query = $this->getFilter($filter,true,true); |
|
| 1095 | 1095 | |
| 1096 | - if ($pilot != "") |
|
| 1097 | - { |
|
| 1098 | - $additional_query = " AND (tracker_archive_output.pilot_id = :pilot OR tracker_archive_output.pilot_name = :pilot)"; |
|
| 1099 | - $query_values = array(':pilot' => $pilot); |
|
| 1100 | - } |
|
| 1096 | + if ($pilot != "") |
|
| 1097 | + { |
|
| 1098 | + $additional_query = " AND (tracker_archive_output.pilot_id = :pilot OR tracker_archive_output.pilot_name = :pilot)"; |
|
| 1099 | + $query_values = array(':pilot' => $pilot); |
|
| 1100 | + } |
|
| 1101 | 1101 | |
| 1102 | - if ($limit != "") |
|
| 1103 | - { |
|
| 1104 | - $limit_array = explode(",", $limit); |
|
| 1102 | + if ($limit != "") |
|
| 1103 | + { |
|
| 1104 | + $limit_array = explode(",", $limit); |
|
| 1105 | 1105 | |
| 1106 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1107 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1106 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1107 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1108 | 1108 | |
| 1109 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1110 | - { |
|
| 1111 | - //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
| 1112 | - $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
| 1113 | - } |
|
| 1114 | - } |
|
| 1115 | - |
|
| 1116 | - if ($sort != "") |
|
| 1117 | - { |
|
| 1118 | - $search_orderby_array = $Tracker->getOrderBy(); |
|
| 1119 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1120 | - } else { |
|
| 1121 | - $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
| 1122 | - } |
|
| 1123 | - |
|
| 1124 | - $query = $global_query.$filter_query." tracker_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query; |
|
| 1125 | - |
|
| 1126 | - $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
|
| 1127 | - |
|
| 1128 | - return $spotter_array; |
|
| 1129 | - } |
|
| 1130 | - |
|
| 1131 | - /** |
|
| 1132 | - * Gets all number of flight over countries |
|
| 1133 | - * |
|
| 1134 | - * @param bool $limit |
|
| 1135 | - * @param int $olderthanmonths |
|
| 1136 | - * @param string $sincedate |
|
| 1137 | - * @return array the airline country list |
|
| 1138 | - */ |
|
| 1139 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1140 | - { |
|
| 1141 | - global $globalDBdriver; |
|
| 1142 | - /* |
|
| 1109 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1110 | + { |
|
| 1111 | + //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
| 1112 | + $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
| 1113 | + } |
|
| 1114 | + } |
|
| 1115 | + |
|
| 1116 | + if ($sort != "") |
|
| 1117 | + { |
|
| 1118 | + $search_orderby_array = $Tracker->getOrderBy(); |
|
| 1119 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1120 | + } else { |
|
| 1121 | + $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
| 1122 | + } |
|
| 1123 | + |
|
| 1124 | + $query = $global_query.$filter_query." tracker_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query; |
|
| 1125 | + |
|
| 1126 | + $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
|
| 1127 | + |
|
| 1128 | + return $spotter_array; |
|
| 1129 | + } |
|
| 1130 | + |
|
| 1131 | + /** |
|
| 1132 | + * Gets all number of flight over countries |
|
| 1133 | + * |
|
| 1134 | + * @param bool $limit |
|
| 1135 | + * @param int $olderthanmonths |
|
| 1136 | + * @param string $sincedate |
|
| 1137 | + * @return array the airline country list |
|
| 1138 | + */ |
|
| 1139 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1140 | + { |
|
| 1141 | + global $globalDBdriver; |
|
| 1142 | + /* |
|
| 1143 | 1143 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
| 1144 | 1144 | FROM countries c, tracker_archive s |
| 1145 | 1145 | WHERE Within(GeomFromText(CONCAT('POINT(',s.longitude,' ',s.latitude,')')), ogc_geom) "; |
| 1146 | 1146 | */ |
| 1147 | - $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
|
| 1147 | + $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
|
| 1148 | 1148 | FROM countries c, tracker_archive s |
| 1149 | 1149 | WHERE c.iso2 = s.over_country "; |
| 1150 | - if ($olderthanmonths > 0) { |
|
| 1151 | - if ($globalDBdriver == 'mysql') { |
|
| 1152 | - $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
|
| 1153 | - } else { |
|
| 1154 | - $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 1155 | - } |
|
| 1156 | - } |
|
| 1157 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1158 | - $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
|
| 1159 | - if ($limit) $query .= " LIMIT 0,10"; |
|
| 1150 | + if ($olderthanmonths > 0) { |
|
| 1151 | + if ($globalDBdriver == 'mysql') { |
|
| 1152 | + $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
|
| 1153 | + } else { |
|
| 1154 | + $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 1155 | + } |
|
| 1156 | + } |
|
| 1157 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1158 | + $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
|
| 1159 | + if ($limit) $query .= " LIMIT 0,10"; |
|
| 1160 | 1160 | |
| 1161 | 1161 | |
| 1162 | - $sth = $this->db->prepare($query); |
|
| 1163 | - $sth->execute(); |
|
| 1162 | + $sth = $this->db->prepare($query); |
|
| 1163 | + $sth->execute(); |
|
| 1164 | 1164 | |
| 1165 | - $flight_array = array(); |
|
| 1166 | - $temp_array = array(); |
|
| 1165 | + $flight_array = array(); |
|
| 1166 | + $temp_array = array(); |
|
| 1167 | 1167 | |
| 1168 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1169 | - { |
|
| 1170 | - $temp_array['flight_count'] = $row['nb']; |
|
| 1171 | - $temp_array['flight_country'] = $row['name']; |
|
| 1172 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1173 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1174 | - $flight_array[] = $temp_array; |
|
| 1175 | - } |
|
| 1176 | - return $flight_array; |
|
| 1177 | - } |
|
| 1178 | - |
|
| 1179 | - /** |
|
| 1180 | - * Gets all number of flight over countries |
|
| 1181 | - * |
|
| 1182 | - * @param bool $limit |
|
| 1183 | - * @param int $olderthanmonths |
|
| 1184 | - * @param string $sincedate |
|
| 1185 | - * @return array the airline country list |
|
| 1186 | - */ |
|
| 1187 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1188 | - { |
|
| 1189 | - global $globalDBdriver; |
|
| 1190 | - /* |
|
| 1168 | + while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1169 | + { |
|
| 1170 | + $temp_array['flight_count'] = $row['nb']; |
|
| 1171 | + $temp_array['flight_country'] = $row['name']; |
|
| 1172 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1173 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1174 | + $flight_array[] = $temp_array; |
|
| 1175 | + } |
|
| 1176 | + return $flight_array; |
|
| 1177 | + } |
|
| 1178 | + |
|
| 1179 | + /** |
|
| 1180 | + * Gets all number of flight over countries |
|
| 1181 | + * |
|
| 1182 | + * @param bool $limit |
|
| 1183 | + * @param int $olderthanmonths |
|
| 1184 | + * @param string $sincedate |
|
| 1185 | + * @return array the airline country list |
|
| 1186 | + */ |
|
| 1187 | + public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1188 | + { |
|
| 1189 | + global $globalDBdriver; |
|
| 1190 | + /* |
|
| 1191 | 1191 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
| 1192 | 1192 | FROM countries c, tracker_archive s |
| 1193 | 1193 | WHERE Within(GeomFromText(CONCAT('POINT(',s.longitude,' ',s.latitude,')')), ogc_geom) "; |
| 1194 | 1194 | */ |
| 1195 | - $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb |
|
| 1195 | + $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb |
|
| 1196 | 1196 | FROM countries c, tracker_archive s, spotter_output o |
| 1197 | 1197 | WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.famtrackid = s.famtrackid "; |
| 1198 | - if ($olderthanmonths > 0) { |
|
| 1199 | - if ($globalDBdriver == 'mysql') { |
|
| 1200 | - $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
|
| 1201 | - } else { |
|
| 1202 | - $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 1203 | - } |
|
| 1204 | - } |
|
| 1205 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1206 | - $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
|
| 1207 | - if ($limit) $query .= " LIMIT 0,10"; |
|
| 1198 | + if ($olderthanmonths > 0) { |
|
| 1199 | + if ($globalDBdriver == 'mysql') { |
|
| 1200 | + $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
|
| 1201 | + } else { |
|
| 1202 | + $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 1203 | + } |
|
| 1204 | + } |
|
| 1205 | + if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1206 | + $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
|
| 1207 | + if ($limit) $query .= " LIMIT 0,10"; |
|
| 1208 | 1208 | |
| 1209 | 1209 | |
| 1210 | - $sth = $this->db->prepare($query); |
|
| 1211 | - $sth->execute(); |
|
| 1210 | + $sth = $this->db->prepare($query); |
|
| 1211 | + $sth->execute(); |
|
| 1212 | 1212 | |
| 1213 | - $flight_array = array(); |
|
| 1214 | - $temp_array = array(); |
|
| 1213 | + $flight_array = array(); |
|
| 1214 | + $temp_array = array(); |
|
| 1215 | 1215 | |
| 1216 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1217 | - { |
|
| 1218 | - $temp_array['airline_icao'] = $row['airline_icao']; |
|
| 1219 | - $temp_array['flight_count'] = $row['nb']; |
|
| 1220 | - $temp_array['flight_country'] = $row['name']; |
|
| 1221 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1222 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1223 | - $flight_array[] = $temp_array; |
|
| 1224 | - } |
|
| 1225 | - return $flight_array; |
|
| 1226 | - } |
|
| 1227 | - |
|
| 1228 | - /** |
|
| 1229 | - * Gets last spotter information based on a particular callsign |
|
| 1230 | - * |
|
| 1231 | - * @param $id |
|
| 1232 | - * @param $date |
|
| 1233 | - * @return array the spotter information |
|
| 1234 | - */ |
|
| 1235 | - public function getDateArchiveTrackerDataById($id,$date) |
|
| 1236 | - { |
|
| 1237 | - $Tracker = new Tracker($this->db); |
|
| 1238 | - date_default_timezone_set('UTC'); |
|
| 1239 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 1240 | - $query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC'; |
|
| 1241 | - $date = date('c',$date); |
|
| 1242 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
| 1243 | - return $spotter_array; |
|
| 1244 | - } |
|
| 1245 | - |
|
| 1246 | - /** |
|
| 1247 | - * Gets all the spotter information based on a particular callsign |
|
| 1248 | - * |
|
| 1249 | - * @param $ident |
|
| 1250 | - * @param $date |
|
| 1251 | - * @return array the spotter information |
|
| 1252 | - */ |
|
| 1253 | - public function getDateArchiveTrackerDataByIdent($ident,$date) |
|
| 1254 | - { |
|
| 1255 | - $Tracker = new Tracker($this->db); |
|
| 1256 | - date_default_timezone_set('UTC'); |
|
| 1257 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 1258 | - $query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC'; |
|
| 1259 | - $date = date('c',$date); |
|
| 1260 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 1261 | - return $spotter_array; |
|
| 1262 | - } |
|
| 1263 | - |
|
| 1264 | - /** |
|
| 1265 | - * Gets all the spotter information based on the airport |
|
| 1266 | - * |
|
| 1267 | - * @param string $airport |
|
| 1268 | - * @param string $limit |
|
| 1269 | - * @param string $sort |
|
| 1270 | - * @param array $filters |
|
| 1271 | - * @return array the spotter information |
|
| 1272 | - */ |
|
| 1273 | - public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1274 | - { |
|
| 1275 | - global $global_query; |
|
| 1276 | - $Tracker = new Tracker($this->db); |
|
| 1277 | - date_default_timezone_set('UTC'); |
|
| 1278 | - $query_values = array(); |
|
| 1279 | - $limit_query = ''; |
|
| 1280 | - $additional_query = ''; |
|
| 1281 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1216 | + while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1217 | + { |
|
| 1218 | + $temp_array['airline_icao'] = $row['airline_icao']; |
|
| 1219 | + $temp_array['flight_count'] = $row['nb']; |
|
| 1220 | + $temp_array['flight_country'] = $row['name']; |
|
| 1221 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1222 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1223 | + $flight_array[] = $temp_array; |
|
| 1224 | + } |
|
| 1225 | + return $flight_array; |
|
| 1226 | + } |
|
| 1227 | + |
|
| 1228 | + /** |
|
| 1229 | + * Gets last spotter information based on a particular callsign |
|
| 1230 | + * |
|
| 1231 | + * @param $id |
|
| 1232 | + * @param $date |
|
| 1233 | + * @return array the spotter information |
|
| 1234 | + */ |
|
| 1235 | + public function getDateArchiveTrackerDataById($id,$date) |
|
| 1236 | + { |
|
| 1237 | + $Tracker = new Tracker($this->db); |
|
| 1238 | + date_default_timezone_set('UTC'); |
|
| 1239 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 1240 | + $query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC'; |
|
| 1241 | + $date = date('c',$date); |
|
| 1242 | + $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
| 1243 | + return $spotter_array; |
|
| 1244 | + } |
|
| 1245 | + |
|
| 1246 | + /** |
|
| 1247 | + * Gets all the spotter information based on a particular callsign |
|
| 1248 | + * |
|
| 1249 | + * @param $ident |
|
| 1250 | + * @param $date |
|
| 1251 | + * @return array the spotter information |
|
| 1252 | + */ |
|
| 1253 | + public function getDateArchiveTrackerDataByIdent($ident,$date) |
|
| 1254 | + { |
|
| 1255 | + $Tracker = new Tracker($this->db); |
|
| 1256 | + date_default_timezone_set('UTC'); |
|
| 1257 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 1258 | + $query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC'; |
|
| 1259 | + $date = date('c',$date); |
|
| 1260 | + $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 1261 | + return $spotter_array; |
|
| 1262 | + } |
|
| 1263 | + |
|
| 1264 | + /** |
|
| 1265 | + * Gets all the spotter information based on the airport |
|
| 1266 | + * |
|
| 1267 | + * @param string $airport |
|
| 1268 | + * @param string $limit |
|
| 1269 | + * @param string $sort |
|
| 1270 | + * @param array $filters |
|
| 1271 | + * @return array the spotter information |
|
| 1272 | + */ |
|
| 1273 | + public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1274 | + { |
|
| 1275 | + global $global_query; |
|
| 1276 | + $Tracker = new Tracker($this->db); |
|
| 1277 | + date_default_timezone_set('UTC'); |
|
| 1278 | + $query_values = array(); |
|
| 1279 | + $limit_query = ''; |
|
| 1280 | + $additional_query = ''; |
|
| 1281 | + $filter_query = $this->getFilter($filters,true,true); |
|
| 1282 | 1282 | |
| 1283 | - if ($airport != "") |
|
| 1284 | - { |
|
| 1285 | - if (!is_string($airport)) |
|
| 1286 | - { |
|
| 1287 | - return array(); |
|
| 1288 | - } else { |
|
| 1289 | - $additional_query .= " AND ((tracker_archive_output.departure_airport_icao = :airport) OR (tracker_archive_output.arrival_airport_icao = :airport))"; |
|
| 1290 | - $query_values = array(':airport' => $airport); |
|
| 1291 | - } |
|
| 1292 | - } |
|
| 1283 | + if ($airport != "") |
|
| 1284 | + { |
|
| 1285 | + if (!is_string($airport)) |
|
| 1286 | + { |
|
| 1287 | + return array(); |
|
| 1288 | + } else { |
|
| 1289 | + $additional_query .= " AND ((tracker_archive_output.departure_airport_icao = :airport) OR (tracker_archive_output.arrival_airport_icao = :airport))"; |
|
| 1290 | + $query_values = array(':airport' => $airport); |
|
| 1291 | + } |
|
| 1292 | + } |
|
| 1293 | 1293 | |
| 1294 | - if ($limit != "") |
|
| 1295 | - { |
|
| 1296 | - $limit_array = explode(",", $limit); |
|
| 1294 | + if ($limit != "") |
|
| 1295 | + { |
|
| 1296 | + $limit_array = explode(",", $limit); |
|
| 1297 | 1297 | |
| 1298 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1299 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1298 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1299 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1300 | 1300 | |
| 1301 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1302 | - { |
|
| 1303 | - //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
| 1304 | - $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
| 1305 | - } |
|
| 1306 | - } |
|
| 1301 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1302 | + { |
|
| 1303 | + //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
|
| 1304 | + $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
| 1305 | + } |
|
| 1306 | + } |
|
| 1307 | 1307 | |
| 1308 | - if ($sort != "") |
|
| 1309 | - { |
|
| 1310 | - $search_orderby_array = $Tracker->getOrderBy(); |
|
| 1311 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1312 | - } else { |
|
| 1313 | - $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
| 1314 | - } |
|
| 1308 | + if ($sort != "") |
|
| 1309 | + { |
|
| 1310 | + $search_orderby_array = $Tracker->getOrderBy(); |
|
| 1311 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1312 | + } else { |
|
| 1313 | + $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
| 1314 | + } |
|
| 1315 | 1315 | |
| 1316 | - $query = $global_query.$filter_query." tracker_archive_output.ident <> '' ".$additional_query." AND ((tracker_archive_output.departure_airport_icao <> 'NA') AND (tracker_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
|
| 1316 | + $query = $global_query.$filter_query." tracker_archive_output.ident <> '' ".$additional_query." AND ((tracker_archive_output.departure_airport_icao <> 'NA') AND (tracker_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
|
| 1317 | 1317 | |
| 1318 | - $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
|
| 1318 | + $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
|
| 1319 | 1319 | |
| 1320 | - return $spotter_array; |
|
| 1321 | - } |
|
| 1320 | + return $spotter_array; |
|
| 1321 | + } |
|
| 1322 | 1322 | } |
| 1323 | 1323 | ?> |
| 1324 | 1324 | \ No newline at end of file |
@@ -23,33 +23,33 @@ discard block |
||
| 23 | 23 | * @param bool $and |
| 24 | 24 | * @return string the SQL part |
| 25 | 25 | */ |
| 26 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 26 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 27 | 27 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 28 | 28 | $filters = array(); |
| 29 | 29 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 30 | 30 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 31 | 31 | $filters = $globalStatsFilters[$globalFilterName]; |
| 32 | 32 | } else { |
| 33 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 33 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | if (isset($filter[0]['source'])) { |
| 37 | - $filters = array_merge($filters,$filter); |
|
| 37 | + $filters = array_merge($filters, $filter); |
|
| 38 | 38 | } |
| 39 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 39 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 40 | 40 | $filter_query_join = ''; |
| 41 | 41 | $filter_query_where = ''; |
| 42 | - foreach($filters as $flt) { |
|
| 42 | + foreach ($filters as $flt) { |
|
| 43 | 43 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 44 | 44 | if (isset($flt['source'])) { |
| 45 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid"; |
|
| 45 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND tracker_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid"; |
|
| 46 | 46 | } else { |
| 47 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid"; |
|
| 47 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid"; |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 52 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 52 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 53 | 53 | } |
| 54 | 54 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 55 | 55 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -77,15 +77,15 @@ discard block |
||
| 77 | 77 | $filter_query_date .= " AND EXTRACT(DAY FROM tracker_archive_output.date) = '".$filter['day']."'"; |
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.famtrackid = tracker_archive.famtrackid"; |
|
| 80 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.famtrackid = tracker_archive.famtrackid"; |
|
| 81 | 81 | } |
| 82 | 82 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 83 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 83 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 84 | 84 | } |
| 85 | 85 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 86 | 86 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 87 | 87 | if ($filter_query_where != '') { |
| 88 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 88 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 89 | 89 | } |
| 90 | 90 | $filter_query = $filter_query_join.$filter_query_where; |
| 91 | 91 | return $filter_query; |
@@ -115,19 +115,19 @@ discard block |
||
| 115 | 115 | require_once(dirname(__FILE__).'/class.Tracker.php'); |
| 116 | 116 | if ($over_country == '') { |
| 117 | 117 | $Tracker = new Tracker($this->db); |
| 118 | - $data_country = $Tracker->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
| 118 | + $data_country = $Tracker->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
| 119 | 119 | if (!empty($data_country)) $country = $data_country['iso2']; |
| 120 | 120 | else $country = ''; |
| 121 | 121 | } else $country = $over_country; |
| 122 | 122 | // Route is not added in tracker_archive |
| 123 | - $query = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
|
| 123 | + $query = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
|
| 124 | 124 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)'; |
| 125 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $country,':comment' => $comment,':type' => $type); |
|
| 125 | + $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $country, ':comment' => $comment, ':type' => $type); |
|
| 126 | 126 | try { |
| 127 | 127 | $sth = $this->db->prepare($query); |
| 128 | 128 | $sth->execute($query_values); |
| 129 | 129 | $sth->closeCursor(); |
| 130 | - } catch(PDOException $e) { |
|
| 130 | + } catch (PDOException $e) { |
|
| 131 | 131 | return "error : ".$e->getMessage(); |
| 132 | 132 | } |
| 133 | 133 | return "success"; |
@@ -145,8 +145,8 @@ discard block |
||
| 145 | 145 | $Tracker = new Tracker($this->db); |
| 146 | 146 | date_default_timezone_set('UTC'); |
| 147 | 147 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 148 | - $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 149 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident)); |
|
| 148 | + $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 149 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident)); |
|
| 150 | 150 | return $spotter_array; |
| 151 | 151 | } |
| 152 | 152 | |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 165 | 165 | //$query = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id"; |
| 166 | 166 | //$query = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
| 167 | - $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1"; |
|
| 167 | + $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1"; |
|
| 168 | 168 | |
| 169 | 169 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
| 170 | 170 | /* |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | } |
| 178 | 178 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 179 | 179 | */ |
| 180 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id)); |
|
| 180 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id)); |
|
| 181 | 181 | |
| 182 | 182 | return $spotter_array; |
| 183 | 183 | } |
@@ -189,19 +189,19 @@ discard block |
||
| 189 | 189 | * @param string $date |
| 190 | 190 | * @return array the spotter information |
| 191 | 191 | */ |
| 192 | - public function getAllArchiveTrackerDataById($id,$date = '') |
|
| 192 | + public function getAllArchiveTrackerDataById($id, $date = '') |
|
| 193 | 193 | { |
| 194 | 194 | date_default_timezone_set('UTC'); |
| 195 | 195 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 196 | - if ($date == '') $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 197 | - else $query = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date"; |
|
| 196 | + if ($date == '') $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 197 | + else $query = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c', $date)."' ORDER BY date"; |
|
| 198 | 198 | |
| 199 | 199 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
| 200 | 200 | |
| 201 | 201 | try { |
| 202 | 202 | $sth = $this->db->prepare($query); |
| 203 | 203 | $sth->execute(array(':id' => $id)); |
| 204 | - } catch(PDOException $e) { |
|
| 204 | + } catch (PDOException $e) { |
|
| 205 | 205 | echo $e->getMessage(); |
| 206 | 206 | die; |
| 207 | 207 | } |
@@ -220,14 +220,14 @@ discard block |
||
| 220 | 220 | { |
| 221 | 221 | date_default_timezone_set('UTC'); |
| 222 | 222 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 223 | - $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id"; |
|
| 223 | + $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id"; |
|
| 224 | 224 | |
| 225 | 225 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
| 226 | 226 | |
| 227 | 227 | try { |
| 228 | 228 | $sth = $this->db->prepare($query); |
| 229 | 229 | $sth->execute(array(':id' => $id)); |
| 230 | - } catch(PDOException $e) { |
|
| 230 | + } catch (PDOException $e) { |
|
| 231 | 231 | echo $e->getMessage(); |
| 232 | 232 | die; |
| 233 | 233 | } |
@@ -249,12 +249,12 @@ discard block |
||
| 249 | 249 | date_default_timezone_set('UTC'); |
| 250 | 250 | |
| 251 | 251 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 252 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
| 252 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
| 253 | 253 | |
| 254 | 254 | try { |
| 255 | 255 | $sth = $this->db->prepare($query); |
| 256 | 256 | $sth->execute(array(':ident' => $ident)); |
| 257 | - } catch(PDOException $e) { |
|
| 257 | + } catch (PDOException $e) { |
|
| 258 | 258 | echo $e->getMessage(); |
| 259 | 259 | die; |
| 260 | 260 | } |
@@ -275,12 +275,12 @@ discard block |
||
| 275 | 275 | date_default_timezone_set('UTC'); |
| 276 | 276 | |
| 277 | 277 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 278 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
| 278 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
| 279 | 279 | |
| 280 | 280 | try { |
| 281 | 281 | $sth = $this->db->prepare($query); |
| 282 | 282 | $sth->execute(array(':id' => $id)); |
| 283 | - } catch(PDOException $e) { |
|
| 283 | + } catch (PDOException $e) { |
|
| 284 | 284 | echo $e->getMessage(); |
| 285 | 285 | die; |
| 286 | 286 | } |
@@ -301,12 +301,12 @@ discard block |
||
| 301 | 301 | date_default_timezone_set('UTC'); |
| 302 | 302 | |
| 303 | 303 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 304 | - $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 304 | + $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 305 | 305 | |
| 306 | 306 | try { |
| 307 | 307 | $sth = $this->db->prepare($query); |
| 308 | 308 | $sth->execute(array(':id' => $id)); |
| 309 | - } catch(PDOException $e) { |
|
| 309 | + } catch (PDOException $e) { |
|
| 310 | 310 | echo $e->getMessage(); |
| 311 | 311 | die; |
| 312 | 312 | } |
@@ -328,13 +328,13 @@ discard block |
||
| 328 | 328 | date_default_timezone_set('UTC'); |
| 329 | 329 | |
| 330 | 330 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 331 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
| 331 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
| 332 | 332 | // $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident"; |
| 333 | 333 | |
| 334 | 334 | try { |
| 335 | 335 | $sth = $this->db->prepare($query); |
| 336 | 336 | $sth->execute(array(':ident' => $ident)); |
| 337 | - } catch(PDOException $e) { |
|
| 337 | + } catch (PDOException $e) { |
|
| 338 | 338 | echo $e->getMessage(); |
| 339 | 339 | die; |
| 340 | 340 | } |
@@ -352,13 +352,13 @@ discard block |
||
| 352 | 352 | * @param $date |
| 353 | 353 | * @return array the spotter information |
| 354 | 354 | */ |
| 355 | - public function getTrackerArchiveData($ident,$famtrackid,$date) |
|
| 355 | + public function getTrackerArchiveData($ident, $famtrackid, $date) |
|
| 356 | 356 | { |
| 357 | 357 | $Tracker = new Tracker($this->db); |
| 358 | 358 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 359 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate"; |
|
| 359 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate"; |
|
| 360 | 360 | |
| 361 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%')); |
|
| 361 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':famtrackid' => $famtrackid, ':date' => $date.'%')); |
|
| 362 | 362 | |
| 363 | 363 | return $spotter_array; |
| 364 | 364 | } |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | try { |
| 375 | 375 | $sth = $this->db->prepare($query); |
| 376 | 376 | $sth->execute(); |
| 377 | - } catch(PDOException $e) { |
|
| 377 | + } catch (PDOException $e) { |
|
| 378 | 378 | echo $e->getMessage(); |
| 379 | 379 | die; |
| 380 | 380 | } |
@@ -388,24 +388,24 @@ discard block |
||
| 388 | 388 | * @param array $filter |
| 389 | 389 | * @return array the spotter information |
| 390 | 390 | */ |
| 391 | - public function getMinLiveTrackerData($begindate,$enddate,$filter = array()) |
|
| 391 | + public function getMinLiveTrackerData($begindate, $enddate, $filter = array()) |
|
| 392 | 392 | { |
| 393 | 393 | global $globalDBdriver; |
| 394 | 394 | date_default_timezone_set('UTC'); |
| 395 | 395 | |
| 396 | 396 | $filter_query = ''; |
| 397 | 397 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 398 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 398 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 399 | 399 | } |
| 400 | 400 | // Use spotter_output also ? |
| 401 | 401 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 402 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 402 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 403 | 403 | } |
| 404 | 404 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 405 | 405 | $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
| 406 | 406 | } |
| 407 | 407 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 408 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 408 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -424,14 +424,14 @@ discard block |
||
| 424 | 424 | GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid |
| 425 | 425 | AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao'; |
| 426 | 426 | */ |
| 427 | - $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 427 | + $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 428 | 428 | FROM tracker_archive |
| 429 | 429 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
| 430 | 430 | WHERE tracker_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
| 431 | 431 | '.$filter_query.' ORDER BY famtrackid'; |
| 432 | 432 | } else { |
| 433 | 433 | //$query = 'SELECT tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao'; |
| 434 | - $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 434 | + $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 435 | 435 | FROM tracker_archive |
| 436 | 436 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
| 437 | 437 | WHERE tracker_archive.date >= '."'".$begindate."'".' AND tracker_archive.date <= '."'".$enddate."'".' |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | try { |
| 442 | 442 | $sth = $this->db->prepare($query); |
| 443 | 443 | $sth->execute(); |
| 444 | - } catch(PDOException $e) { |
|
| 444 | + } catch (PDOException $e) { |
|
| 445 | 445 | echo $e->getMessage(); |
| 446 | 446 | die; |
| 447 | 447 | } |
@@ -458,24 +458,24 @@ discard block |
||
| 458 | 458 | * @param array $filter |
| 459 | 459 | * @return array the spotter information |
| 460 | 460 | */ |
| 461 | - public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array()) |
|
| 461 | + public function getMinLiveTrackerDataPlayback($begindate, $enddate, $filter = array()) |
|
| 462 | 462 | { |
| 463 | 463 | global $globalDBdriver; |
| 464 | 464 | date_default_timezone_set('UTC'); |
| 465 | 465 | |
| 466 | 466 | $filter_query = ''; |
| 467 | 467 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 468 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 468 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 469 | 469 | } |
| 470 | 470 | // Should use spotter_output also ? |
| 471 | 471 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 472 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 472 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 473 | 473 | } |
| 474 | 474 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 475 | 475 | $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
| 476 | 476 | } |
| 477 | 477 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 478 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 478 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -485,7 +485,7 @@ discard block |
||
| 485 | 485 | FROM tracker_archive |
| 486 | 486 | INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao'; |
| 487 | 487 | */ |
| 488 | - $query = 'SELECT a.aircraft_shadow, tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk |
|
| 488 | + $query = 'SELECT a.aircraft_shadow, tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk |
|
| 489 | 489 | FROM tracker_archive_output |
| 490 | 490 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive_output.aircraft_icao = a.icao |
| 491 | 491 | WHERE (tracker_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
| 501 | 501 | '.$filter_query.' GROUP BY tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao, tracker_archive_output.arrival_airport_icao, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow'; |
| 502 | 502 | */ |
| 503 | - $query = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow |
|
| 503 | + $query = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow |
|
| 504 | 504 | FROM tracker_archive_output |
| 505 | 505 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao |
| 506 | 506 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | try { |
| 513 | 513 | $sth = $this->db->prepare($query); |
| 514 | 514 | $sth->execute(); |
| 515 | - } catch(PDOException $e) { |
|
| 515 | + } catch (PDOException $e) { |
|
| 516 | 516 | echo $e->getMessage(); |
| 517 | 517 | die; |
| 518 | 518 | } |
@@ -529,23 +529,23 @@ discard block |
||
| 529 | 529 | * @param array $filter |
| 530 | 530 | * @return array the spotter information |
| 531 | 531 | */ |
| 532 | - public function getLiveTrackerCount($begindate,$enddate,$filter = array()) |
|
| 532 | + public function getLiveTrackerCount($begindate, $enddate, $filter = array()) |
|
| 533 | 533 | { |
| 534 | 534 | global $globalDBdriver, $globalLiveInterval; |
| 535 | 535 | date_default_timezone_set('UTC'); |
| 536 | 536 | |
| 537 | 537 | $filter_query = ''; |
| 538 | 538 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 539 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 539 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 540 | 540 | } |
| 541 | 541 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 542 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 542 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 543 | 543 | } |
| 544 | 544 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 545 | 545 | $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
| 546 | 546 | } |
| 547 | 547 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 548 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 548 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 549 | 549 | } |
| 550 | 550 | |
| 551 | 551 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -560,7 +560,7 @@ discard block |
||
| 560 | 560 | try { |
| 561 | 561 | $sth = $this->db->prepare($query); |
| 562 | 562 | $sth->execute(); |
| 563 | - } catch(PDOException $e) { |
|
| 563 | + } catch (PDOException $e) { |
|
| 564 | 564 | echo $e->getMessage(); |
| 565 | 565 | die; |
| 566 | 566 | } |
@@ -604,7 +604,7 @@ discard block |
||
| 604 | 604 | * @param array $filters |
| 605 | 605 | * @return array the spotter information |
| 606 | 606 | */ |
| 607 | - public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 607 | + public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
| 608 | 608 | { |
| 609 | 609 | global $globalTimezone, $globalDBdriver; |
| 610 | 610 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -626,7 +626,7 @@ discard block |
||
| 626 | 626 | |
| 627 | 627 | $q_array = explode(" ", $q); |
| 628 | 628 | |
| 629 | - foreach ($q_array as $q_item){ |
|
| 629 | + foreach ($q_array as $q_item) { |
|
| 630 | 630 | $additional_query .= " AND ("; |
| 631 | 631 | $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR "; |
| 632 | 632 | $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -658,7 +658,7 @@ discard block |
||
| 658 | 658 | |
| 659 | 659 | if ($registration != "") |
| 660 | 660 | { |
| 661 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 661 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 662 | 662 | if (!is_string($registration)) |
| 663 | 663 | { |
| 664 | 664 | return array(); |
@@ -669,7 +669,7 @@ discard block |
||
| 669 | 669 | |
| 670 | 670 | if ($aircraft_icao != "") |
| 671 | 671 | { |
| 672 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 672 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 673 | 673 | if (!is_string($aircraft_icao)) |
| 674 | 674 | { |
| 675 | 675 | return array(); |
@@ -680,7 +680,7 @@ discard block |
||
| 680 | 680 | |
| 681 | 681 | if ($aircraft_manufacturer != "") |
| 682 | 682 | { |
| 683 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 683 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
| 684 | 684 | if (!is_string($aircraft_manufacturer)) |
| 685 | 685 | { |
| 686 | 686 | return array(); |
@@ -701,7 +701,7 @@ discard block |
||
| 701 | 701 | |
| 702 | 702 | if ($airline_icao != "") |
| 703 | 703 | { |
| 704 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 704 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 705 | 705 | if (!is_string($airline_icao)) |
| 706 | 706 | { |
| 707 | 707 | return array(); |
@@ -712,7 +712,7 @@ discard block |
||
| 712 | 712 | |
| 713 | 713 | if ($airline_country != "") |
| 714 | 714 | { |
| 715 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 715 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
| 716 | 716 | if (!is_string($airline_country)) |
| 717 | 717 | { |
| 718 | 718 | return array(); |
@@ -723,7 +723,7 @@ discard block |
||
| 723 | 723 | |
| 724 | 724 | if ($airline_type != "") |
| 725 | 725 | { |
| 726 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 726 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
| 727 | 727 | if (!is_string($airline_type)) |
| 728 | 728 | { |
| 729 | 729 | return array(); |
@@ -745,7 +745,7 @@ discard block |
||
| 745 | 745 | |
| 746 | 746 | if ($airport != "") |
| 747 | 747 | { |
| 748 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 748 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
| 749 | 749 | if (!is_string($airport)) |
| 750 | 750 | { |
| 751 | 751 | return array(); |
@@ -756,7 +756,7 @@ discard block |
||
| 756 | 756 | |
| 757 | 757 | if ($airport_country != "") |
| 758 | 758 | { |
| 759 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 759 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
| 760 | 760 | if (!is_string($airport_country)) |
| 761 | 761 | { |
| 762 | 762 | return array(); |
@@ -767,7 +767,7 @@ discard block |
||
| 767 | 767 | |
| 768 | 768 | if ($callsign != "") |
| 769 | 769 | { |
| 770 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 770 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 771 | 771 | if (!is_string($callsign)) |
| 772 | 772 | { |
| 773 | 773 | return array(); |
@@ -775,7 +775,7 @@ discard block |
||
| 775 | 775 | $translate = $Translation->ident2icao($callsign); |
| 776 | 776 | if ($translate != $callsign) { |
| 777 | 777 | $additional_query .= " AND (tracker_archive_output.ident = :callsign OR tracker_archive_output.ident = :translate)"; |
| 778 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
| 778 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
| 779 | 779 | } else { |
| 780 | 780 | $additional_query .= " AND (tracker_archive_output.ident = '".$callsign."')"; |
| 781 | 781 | } |
@@ -784,7 +784,7 @@ discard block |
||
| 784 | 784 | |
| 785 | 785 | if ($owner != "") |
| 786 | 786 | { |
| 787 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 787 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 788 | 788 | if (!is_string($owner)) |
| 789 | 789 | { |
| 790 | 790 | return array(); |
@@ -795,7 +795,7 @@ discard block |
||
| 795 | 795 | |
| 796 | 796 | if ($pilot_name != "") |
| 797 | 797 | { |
| 798 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 798 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
| 799 | 799 | if (!is_string($pilot_name)) |
| 800 | 800 | { |
| 801 | 801 | return array(); |
@@ -806,7 +806,7 @@ discard block |
||
| 806 | 806 | |
| 807 | 807 | if ($pilot_id != "") |
| 808 | 808 | { |
| 809 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 809 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
| 810 | 810 | if (!is_string($pilot_id)) |
| 811 | 811 | { |
| 812 | 812 | return array(); |
@@ -817,7 +817,7 @@ discard block |
||
| 817 | 817 | |
| 818 | 818 | if ($departure_airport_route != "") |
| 819 | 819 | { |
| 820 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 820 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
| 821 | 821 | if (!is_string($departure_airport_route)) |
| 822 | 822 | { |
| 823 | 823 | return array(); |
@@ -828,7 +828,7 @@ discard block |
||
| 828 | 828 | |
| 829 | 829 | if ($arrival_airport_route != "") |
| 830 | 830 | { |
| 831 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 831 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
| 832 | 832 | if (!is_string($arrival_airport_route)) |
| 833 | 833 | { |
| 834 | 834 | return array(); |
@@ -841,8 +841,8 @@ discard block |
||
| 841 | 841 | { |
| 842 | 842 | $altitude_array = explode(",", $altitude); |
| 843 | 843 | |
| 844 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 845 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 844 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 845 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 846 | 846 | |
| 847 | 847 | |
| 848 | 848 | if ($altitude_array[1] != "") |
@@ -860,8 +860,8 @@ discard block |
||
| 860 | 860 | { |
| 861 | 861 | $date_array = explode(",", $date_posted); |
| 862 | 862 | |
| 863 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 864 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 863 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
| 864 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
| 865 | 865 | |
| 866 | 866 | if ($globalTimezone != '') { |
| 867 | 867 | date_default_timezone_set($globalTimezone); |
@@ -893,8 +893,8 @@ discard block |
||
| 893 | 893 | { |
| 894 | 894 | $limit_array = explode(",", $limit); |
| 895 | 895 | |
| 896 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 897 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 896 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 897 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 898 | 898 | |
| 899 | 899 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 900 | 900 | { |
@@ -905,8 +905,8 @@ discard block |
||
| 905 | 905 | |
| 906 | 906 | |
| 907 | 907 | if ($origLat != "" && $origLon != "" && $dist != "") { |
| 908 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
| 909 | - $query="SELECT tracker_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 908 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
| 909 | + $query = "SELECT tracker_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 910 | 910 | FROM tracker_archive_output, tracker_archive WHERE spotter_output_archive.famtrackid = tracker_archive.famtrackid AND spotter_output.ident <> '' ".$additional_query."AND CAST(tracker_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(tracker_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 911 | 911 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
| 912 | 912 | } else { |
@@ -923,12 +923,12 @@ discard block |
||
| 923 | 923 | $additional_query .= " AND (tracker_archive_output.waypoints <> '')"; |
| 924 | 924 | } |
| 925 | 925 | |
| 926 | - $query = "SELECT tracker_archive_output.* FROM tracker_archive_output |
|
| 926 | + $query = "SELECT tracker_archive_output.* FROM tracker_archive_output |
|
| 927 | 927 | WHERE tracker_archive_output.ident <> '' |
| 928 | 928 | ".$additional_query." |
| 929 | 929 | ".$filter_query.$orderby_query; |
| 930 | 930 | } |
| 931 | - $spotter_array = $Tracker->getDataFromDB($query, $query_values,$limit_query); |
|
| 931 | + $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
|
| 932 | 932 | |
| 933 | 933 | return $spotter_array; |
| 934 | 934 | } |
@@ -945,7 +945,7 @@ discard block |
||
| 945 | 945 | try { |
| 946 | 946 | $sth = $this->db->prepare($query); |
| 947 | 947 | $sth->execute(); |
| 948 | - } catch(PDOException $e) { |
|
| 948 | + } catch (PDOException $e) { |
|
| 949 | 949 | return "error"; |
| 950 | 950 | } |
| 951 | 951 | return ''; |
@@ -985,8 +985,8 @@ discard block |
||
| 985 | 985 | { |
| 986 | 986 | $limit_array = explode(",", $limit); |
| 987 | 987 | |
| 988 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 989 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 988 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 989 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 990 | 990 | |
| 991 | 991 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 992 | 992 | { |
@@ -1030,7 +1030,7 @@ discard block |
||
| 1030 | 1030 | $query_values = array(); |
| 1031 | 1031 | $limit_query = ''; |
| 1032 | 1032 | $additional_query = ''; |
| 1033 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1033 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1034 | 1034 | |
| 1035 | 1035 | if ($owner != "") |
| 1036 | 1036 | { |
@@ -1047,8 +1047,8 @@ discard block |
||
| 1047 | 1047 | { |
| 1048 | 1048 | $limit_array = explode(",", $limit); |
| 1049 | 1049 | |
| 1050 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1051 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1050 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1051 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1052 | 1052 | |
| 1053 | 1053 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1054 | 1054 | { |
@@ -1091,7 +1091,7 @@ discard block |
||
| 1091 | 1091 | $query_values = array(); |
| 1092 | 1092 | $limit_query = ''; |
| 1093 | 1093 | $additional_query = ''; |
| 1094 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1094 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1095 | 1095 | |
| 1096 | 1096 | if ($pilot != "") |
| 1097 | 1097 | { |
@@ -1103,8 +1103,8 @@ discard block |
||
| 1103 | 1103 | { |
| 1104 | 1104 | $limit_array = explode(",", $limit); |
| 1105 | 1105 | |
| 1106 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1107 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1106 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1107 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1108 | 1108 | |
| 1109 | 1109 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1110 | 1110 | { |
@@ -1136,7 +1136,7 @@ discard block |
||
| 1136 | 1136 | * @param string $sincedate |
| 1137 | 1137 | * @return array the airline country list |
| 1138 | 1138 | */ |
| 1139 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1139 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1140 | 1140 | { |
| 1141 | 1141 | global $globalDBdriver; |
| 1142 | 1142 | /* |
@@ -1165,7 +1165,7 @@ discard block |
||
| 1165 | 1165 | $flight_array = array(); |
| 1166 | 1166 | $temp_array = array(); |
| 1167 | 1167 | |
| 1168 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1168 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1169 | 1169 | { |
| 1170 | 1170 | $temp_array['flight_count'] = $row['nb']; |
| 1171 | 1171 | $temp_array['flight_country'] = $row['name']; |
@@ -1184,7 +1184,7 @@ discard block |
||
| 1184 | 1184 | * @param string $sincedate |
| 1185 | 1185 | * @return array the airline country list |
| 1186 | 1186 | */ |
| 1187 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1187 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1188 | 1188 | { |
| 1189 | 1189 | global $globalDBdriver; |
| 1190 | 1190 | /* |
@@ -1213,7 +1213,7 @@ discard block |
||
| 1213 | 1213 | $flight_array = array(); |
| 1214 | 1214 | $temp_array = array(); |
| 1215 | 1215 | |
| 1216 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1216 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1217 | 1217 | { |
| 1218 | 1218 | $temp_array['airline_icao'] = $row['airline_icao']; |
| 1219 | 1219 | $temp_array['flight_count'] = $row['nb']; |
@@ -1232,14 +1232,14 @@ discard block |
||
| 1232 | 1232 | * @param $date |
| 1233 | 1233 | * @return array the spotter information |
| 1234 | 1234 | */ |
| 1235 | - public function getDateArchiveTrackerDataById($id,$date) |
|
| 1235 | + public function getDateArchiveTrackerDataById($id, $date) |
|
| 1236 | 1236 | { |
| 1237 | 1237 | $Tracker = new Tracker($this->db); |
| 1238 | 1238 | date_default_timezone_set('UTC'); |
| 1239 | 1239 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 1240 | - $query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC'; |
|
| 1241 | - $date = date('c',$date); |
|
| 1242 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
| 1240 | + $query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC'; |
|
| 1241 | + $date = date('c', $date); |
|
| 1242 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
| 1243 | 1243 | return $spotter_array; |
| 1244 | 1244 | } |
| 1245 | 1245 | |
@@ -1250,14 +1250,14 @@ discard block |
||
| 1250 | 1250 | * @param $date |
| 1251 | 1251 | * @return array the spotter information |
| 1252 | 1252 | */ |
| 1253 | - public function getDateArchiveTrackerDataByIdent($ident,$date) |
|
| 1253 | + public function getDateArchiveTrackerDataByIdent($ident, $date) |
|
| 1254 | 1254 | { |
| 1255 | 1255 | $Tracker = new Tracker($this->db); |
| 1256 | 1256 | date_default_timezone_set('UTC'); |
| 1257 | 1257 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 1258 | - $query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC'; |
|
| 1259 | - $date = date('c',$date); |
|
| 1260 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 1258 | + $query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC'; |
|
| 1259 | + $date = date('c', $date); |
|
| 1260 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 1261 | 1261 | return $spotter_array; |
| 1262 | 1262 | } |
| 1263 | 1263 | |
@@ -1270,7 +1270,7 @@ discard block |
||
| 1270 | 1270 | * @param array $filters |
| 1271 | 1271 | * @return array the spotter information |
| 1272 | 1272 | */ |
| 1273 | - public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1273 | + public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
| 1274 | 1274 | { |
| 1275 | 1275 | global $global_query; |
| 1276 | 1276 | $Tracker = new Tracker($this->db); |
@@ -1278,7 +1278,7 @@ discard block |
||
| 1278 | 1278 | $query_values = array(); |
| 1279 | 1279 | $limit_query = ''; |
| 1280 | 1280 | $additional_query = ''; |
| 1281 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1281 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1282 | 1282 | |
| 1283 | 1283 | if ($airport != "") |
| 1284 | 1284 | { |
@@ -1295,8 +1295,8 @@ discard block |
||
| 1295 | 1295 | { |
| 1296 | 1296 | $limit_array = explode(",", $limit); |
| 1297 | 1297 | |
| 1298 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1299 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1298 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1299 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1300 | 1300 | |
| 1301 | 1301 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1302 | 1302 | { |
@@ -13,7 +13,9 @@ discard block |
||
| 13 | 13 | public function __construct($dbc = null) { |
| 14 | 14 | $Connection = new Connection($dbc); |
| 15 | 15 | $this->db = $Connection->db; |
| 16 | - if ($this->db === null) die('Error: No DB connection. (TrackerArchive)'); |
|
| 16 | + if ($this->db === null) { |
|
| 17 | + die('Error: No DB connection. (TrackerArchive)'); |
|
| 18 | + } |
|
| 17 | 19 | } |
| 18 | 20 | |
| 19 | 21 | /** |
@@ -36,7 +38,9 @@ discard block |
||
| 36 | 38 | if (isset($filter[0]['source'])) { |
| 37 | 39 | $filters = array_merge($filters,$filter); |
| 38 | 40 | } |
| 39 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 41 | + if (is_array($globalFilter)) { |
|
| 42 | + $filter = array_merge($filter,$globalFilter); |
|
| 43 | + } |
|
| 40 | 44 | $filter_query_join = ''; |
| 41 | 45 | $filter_query_where = ''; |
| 42 | 46 | foreach($filters as $flt) { |
@@ -82,8 +86,11 @@ discard block |
||
| 82 | 86 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 83 | 87 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 84 | 88 | } |
| 85 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 86 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 89 | + if ($filter_query_where == '' && $where) { |
|
| 90 | + $filter_query_where = ' WHERE'; |
|
| 91 | + } elseif ($filter_query_where != '' && $and) { |
|
| 92 | + $filter_query_where .= ' AND'; |
|
| 93 | + } |
|
| 87 | 94 | if ($filter_query_where != '') { |
| 88 | 95 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 89 | 96 | } |
@@ -116,9 +123,14 @@ discard block |
||
| 116 | 123 | if ($over_country == '') { |
| 117 | 124 | $Tracker = new Tracker($this->db); |
| 118 | 125 | $data_country = $Tracker->getCountryFromLatitudeLongitude($latitude,$longitude); |
| 119 | - if (!empty($data_country)) $country = $data_country['iso2']; |
|
| 120 | - else $country = ''; |
|
| 121 | - } else $country = $over_country; |
|
| 126 | + if (!empty($data_country)) { |
|
| 127 | + $country = $data_country['iso2']; |
|
| 128 | + } else { |
|
| 129 | + $country = ''; |
|
| 130 | + } |
|
| 131 | + } else { |
|
| 132 | + $country = $over_country; |
|
| 133 | + } |
|
| 122 | 134 | // Route is not added in tracker_archive |
| 123 | 135 | $query = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
| 124 | 136 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)'; |
@@ -193,8 +205,11 @@ discard block |
||
| 193 | 205 | { |
| 194 | 206 | date_default_timezone_set('UTC'); |
| 195 | 207 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 196 | - if ($date == '') $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 197 | - else $query = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date"; |
|
| 208 | + if ($date == '') { |
|
| 209 | + $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 210 | + } else { |
|
| 211 | + $query = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date"; |
|
| 212 | + } |
|
| 198 | 213 | |
| 199 | 214 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
| 200 | 215 | |
@@ -649,7 +664,9 @@ discard block |
||
| 649 | 664 | $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR "; |
| 650 | 665 | $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR "; |
| 651 | 666 | $translate = $Translation->ident2icao($q_item); |
| 652 | - if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR "; |
|
| 667 | + if ($translate != $q_item) { |
|
| 668 | + $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR "; |
|
| 669 | + } |
|
| 653 | 670 | $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')"; |
| 654 | 671 | $additional_query .= ")"; |
| 655 | 672 | } |
@@ -867,7 +884,9 @@ discard block |
||
| 867 | 884 | date_default_timezone_set($globalTimezone); |
| 868 | 885 | $datetime = new DateTime(); |
| 869 | 886 | $offset = $datetime->format('P'); |
| 870 | - } else $offset = '+00:00'; |
|
| 887 | + } else { |
|
| 888 | + $offset = '+00:00'; |
|
| 889 | + } |
|
| 871 | 890 | |
| 872 | 891 | |
| 873 | 892 | if ($date_array[1] != "") |
@@ -1154,9 +1173,13 @@ discard block |
||
| 1154 | 1173 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1155 | 1174 | } |
| 1156 | 1175 | } |
| 1157 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1176 | + if ($sincedate != '') { |
|
| 1177 | + $query .= "AND date > '".$sincedate."' "; |
|
| 1178 | + } |
|
| 1158 | 1179 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1159 | - if ($limit) $query .= " LIMIT 0,10"; |
|
| 1180 | + if ($limit) { |
|
| 1181 | + $query .= " LIMIT 0,10"; |
|
| 1182 | + } |
|
| 1160 | 1183 | |
| 1161 | 1184 | |
| 1162 | 1185 | $sth = $this->db->prepare($query); |
@@ -1202,9 +1225,13 @@ discard block |
||
| 1202 | 1225 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1203 | 1226 | } |
| 1204 | 1227 | } |
| 1205 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1228 | + if ($sincedate != '') { |
|
| 1229 | + $query .= "AND s.date > '".$sincedate."' "; |
|
| 1230 | + } |
|
| 1206 | 1231 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1207 | - if ($limit) $query .= " LIMIT 0,10"; |
|
| 1232 | + if ($limit) { |
|
| 1233 | + $query .= " LIMIT 0,10"; |
|
| 1234 | + } |
|
| 1208 | 1235 | |
| 1209 | 1236 | |
| 1210 | 1237 | $sth = $this->db->prepare($query); |
@@ -27,16 +27,16 @@ discard block |
||
| 27 | 27 | if ($this->db === null) die('Error: No DB connection.'); |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * Add schedule data to database |
|
| 32 | - * @param String $ident aircraft ident |
|
| 33 | - * @param String $departure_airport_icao departure airport icao |
|
| 34 | - * @param String $departure_airport_time departure airport time |
|
| 35 | - * @param String $arrival_airport_icao arrival airport icao |
|
| 36 | - * @param String $arrival_airport_time arrival airport time |
|
| 37 | - * @param String $source source of data |
|
| 38 | - * @return string |
|
| 39 | - */ |
|
| 30 | + /** |
|
| 31 | + * Add schedule data to database |
|
| 32 | + * @param String $ident aircraft ident |
|
| 33 | + * @param String $departure_airport_icao departure airport icao |
|
| 34 | + * @param String $departure_airport_time departure airport time |
|
| 35 | + * @param String $arrival_airport_icao arrival airport icao |
|
| 36 | + * @param String $arrival_airport_time arrival airport time |
|
| 37 | + * @param String $source source of data |
|
| 38 | + * @return string |
|
| 39 | + */ |
|
| 40 | 40 | public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') { |
| 41 | 41 | date_default_timezone_set('UTC'); |
| 42 | 42 | $date = date("Y-m-d H:i:s",time()); |
@@ -52,18 +52,18 @@ discard block |
||
| 52 | 52 | } |
| 53 | 53 | if ($sth->fetchColumn() > 0) { |
| 54 | 54 | if ($departure_airport_time == '' && $arrival_airport_time == '') { |
| 55 | - $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao"; |
|
| 56 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao); |
|
| 55 | + $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao"; |
|
| 56 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao); |
|
| 57 | 57 | } elseif ($arrival_airport_time == '') { |
| 58 | - $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao"; |
|
| 59 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao); |
|
| 58 | + $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao"; |
|
| 59 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao); |
|
| 60 | 60 | } elseif ($departure_airport_time == '') { |
| 61 | - $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
|
| 62 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
| 61 | + $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
|
| 62 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
| 63 | 63 | } else { |
| 64 | - //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time"; |
|
| 65 | - $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
|
| 66 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
| 64 | + //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time"; |
|
| 65 | + $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
|
| 66 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
| 67 | 67 | } |
| 68 | 68 | try { |
| 69 | 69 | $sth = $this->db->prepare($query); |
@@ -151,15 +151,15 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | public function checkSchedule($ident) { |
| 153 | 153 | global $globalDBdriver; |
| 154 | - //$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1"; |
|
| 155 | - if ($globalDBdriver == 'mysql') { |
|
| 154 | + //$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1"; |
|
| 155 | + if ($globalDBdriver == 'mysql') { |
|
| 156 | 156 | $query = "SELECT COUNT(*) as nb FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident AND ((date_added BETWEEN DATE(DATE_SUB(CURDATE(), INTERVAL 1 MONTH)) AND DATE(NOW()) and date_modified IS NULL) OR (date_modified BETWEEN DATE(DATE_SUB(CURDATE(), INTERVAL 15 DAY)) AND DATE(NOW()))) LIMIT 1"; |
| 157 | 157 | } else { |
| 158 | 158 | $query = "SELECT COUNT(*) as nb FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident |
| 159 | 159 | AND ((date_added::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) and date_modified::timestamp IS NULL) |
| 160 | 160 | OR (date_modified::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) LIMIT 1"; |
| 161 | 161 | } |
| 162 | - $query_values = array(':ident' => $ident); |
|
| 162 | + $query_values = array(':ident' => $ident); |
|
| 163 | 163 | try { |
| 164 | 164 | $sth = $this->db->prepare($query); |
| 165 | 165 | $sth->execute($query_values); |
@@ -171,13 +171,13 @@ discard block |
||
| 171 | 171 | return $row['nb']; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - /** |
|
| 175 | - * Get flight info from Air France |
|
| 176 | - * @param String $callsign The callsign |
|
| 177 | - * @param String $date date we want flight number info |
|
| 178 | - * @param String $carrier IATA code |
|
| 179 | - * @return array departure and arrival airports and time |
|
| 180 | - */ |
|
| 174 | + /** |
|
| 175 | + * Get flight info from Air France |
|
| 176 | + * @param String $callsign The callsign |
|
| 177 | + * @param String $date date we want flight number info |
|
| 178 | + * @param String $carrier IATA code |
|
| 179 | + * @return array departure and arrival airports and time |
|
| 180 | + */ |
|
| 181 | 181 | public function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') { |
| 182 | 182 | $Common = new Common(); |
| 183 | 183 | $check_date = new Datetime($date); |
@@ -212,12 +212,12 @@ discard block |
||
| 212 | 212 | } else return array(); |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - /** |
|
| 216 | - * Get flight info from EasyJet |
|
| 217 | - * @param String $callsign The callsign |
|
| 218 | - * @param String $date date we want flight number info |
|
| 219 | - * @return array departure and arrival airports and time |
|
| 220 | - */ |
|
| 215 | + /** |
|
| 216 | + * Get flight info from EasyJet |
|
| 217 | + * @param String $callsign The callsign |
|
| 218 | + * @param String $date date we want flight number info |
|
| 219 | + * @return array departure and arrival airports and time |
|
| 220 | + */ |
|
| 221 | 221 | private function getEasyJet($callsign, $date = 'NOW') { |
| 222 | 222 | global $globalTimezone; |
| 223 | 223 | $Common = new Common(); |
@@ -240,11 +240,11 @@ discard block |
||
| 240 | 240 | } else return array(); |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | - /** |
|
| 244 | - * Get flight info from Ryanair |
|
| 245 | - * @param String $callsign The callsign |
|
| 246 | - * @return array Flight departure and arrival airports and time |
|
| 247 | - */ |
|
| 243 | + /** |
|
| 244 | + * Get flight info from Ryanair |
|
| 245 | + * @param String $callsign The callsign |
|
| 246 | + * @return array Flight departure and arrival airports and time |
|
| 247 | + */ |
|
| 248 | 248 | private function getRyanair($callsign) { |
| 249 | 249 | $Common = new Common(); |
| 250 | 250 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -267,10 +267,10 @@ discard block |
||
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | /** |
| 270 | - * Get flight info from Swiss |
|
| 271 | - * @param string $callsign The callsign |
|
| 272 | - * @return array Flight departure and arrival airports and time |
|
| 273 | - */ |
|
| 270 | + * Get flight info from Swiss |
|
| 271 | + * @param string $callsign The callsign |
|
| 272 | + * @return array Flight departure and arrival airports and time |
|
| 273 | + */ |
|
| 274 | 274 | private function getSwiss($callsign) { |
| 275 | 275 | $Common = new Common(); |
| 276 | 276 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -299,11 +299,11 @@ discard block |
||
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | /** |
| 302 | - * Get flight info from British Airways API |
|
| 303 | - * @param String $callsign The callsign |
|
| 304 | - * @param String $date date we want flight number info |
|
| 305 | - * @return array Flight departure and arrival airports and time |
|
| 306 | - */ |
|
| 302 | + * Get flight info from British Airways API |
|
| 303 | + * @param String $callsign The callsign |
|
| 304 | + * @param String $date date we want flight number info |
|
| 305 | + * @return array Flight departure and arrival airports and time |
|
| 306 | + */ |
|
| 307 | 307 | public function getBritishAirways($callsign, $date = 'NOW') { |
| 308 | 308 | global $globalBritishAirwaysKey; |
| 309 | 309 | $Common = new Common(); |
@@ -327,11 +327,11 @@ discard block |
||
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | /** |
| 330 | - * Get flight info from Lutfhansa API |
|
| 331 | - * @param String $callsign The callsign |
|
| 332 | - * @param String $date date we want flight number info |
|
| 333 | - * @return array Flight departure and arrival airports and time |
|
| 334 | - */ |
|
| 330 | + * Get flight info from Lutfhansa API |
|
| 331 | + * @param String $callsign The callsign |
|
| 332 | + * @param String $date date we want flight number info |
|
| 333 | + * @return array Flight departure and arrival airports and time |
|
| 334 | + */ |
|
| 335 | 335 | public function getLufthansa($callsign, $date = 'NOW') { |
| 336 | 336 | global $globalLufthansaKey; |
| 337 | 337 | $Common = new Common(); |
@@ -361,11 +361,11 @@ discard block |
||
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | /** |
| 364 | - * Get flight info from Transavia API |
|
| 365 | - * @param string $callsign The callsign |
|
| 366 | - * @param string $date date we want flight number info |
|
| 367 | - * @return array Flight departure and arrival airports and time |
|
| 368 | - */ |
|
| 364 | + * Get flight info from Transavia API |
|
| 365 | + * @param string $callsign The callsign |
|
| 366 | + * @param string $date date we want flight number info |
|
| 367 | + * @return array Flight departure and arrival airports and time |
|
| 368 | + */ |
|
| 369 | 369 | public function getTransavia($callsign, $date = 'NOW') { |
| 370 | 370 | global $globalTransaviaKey; |
| 371 | 371 | $Common = new Common(); |
@@ -391,10 +391,10 @@ discard block |
||
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | /** |
| 394 | - * Get flight info from Tunisair |
|
| 395 | - * @param string $callsign The callsign |
|
| 396 | - * @return array Flight departure and arrival airports and time |
|
| 397 | - */ |
|
| 394 | + * Get flight info from Tunisair |
|
| 395 | + * @param string $callsign The callsign |
|
| 396 | + * @return array Flight departure and arrival airports and time |
|
| 397 | + */ |
|
| 398 | 398 | public function getTunisair($callsign) { |
| 399 | 399 | $Common = new Common(); |
| 400 | 400 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -410,12 +410,12 @@ discard block |
||
| 410 | 410 | return array(); |
| 411 | 411 | } |
| 412 | 412 | |
| 413 | - /** |
|
| 414 | - * Get flight info from Vueling |
|
| 415 | - * @param String $callsign The callsign |
|
| 416 | - * @param string $date |
|
| 417 | - * @return array Flight departure and arrival airports and time |
|
| 418 | - */ |
|
| 413 | + /** |
|
| 414 | + * Get flight info from Vueling |
|
| 415 | + * @param String $callsign The callsign |
|
| 416 | + * @param string $date |
|
| 417 | + * @return array Flight departure and arrival airports and time |
|
| 418 | + */ |
|
| 419 | 419 | public function getVueling($callsign,$date = 'NOW') { |
| 420 | 420 | $Common = new Common(); |
| 421 | 421 | $check_date = new Datetime($date); |
@@ -437,11 +437,11 @@ discard block |
||
| 437 | 437 | } |
| 438 | 438 | |
| 439 | 439 | /** |
| 440 | - * Get flight info from Iberia |
|
| 441 | - * @param String $callsign The callsign |
|
| 442 | - * @param String $date date we want flight number info |
|
| 443 | - * @return array Flight departure and arrival airports and time |
|
| 444 | - */ |
|
| 440 | + * Get flight info from Iberia |
|
| 441 | + * @param String $callsign The callsign |
|
| 442 | + * @param String $date date we want flight number info |
|
| 443 | + * @return array Flight departure and arrival airports and time |
|
| 444 | + */ |
|
| 445 | 445 | public function getIberia($callsign, $date = 'NOW') { |
| 446 | 446 | $Common = new Common(); |
| 447 | 447 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -470,13 +470,13 @@ discard block |
||
| 470 | 470 | return array(); |
| 471 | 471 | } |
| 472 | 472 | |
| 473 | - /** |
|
| 474 | - * Get flight info from Star Alliance |
|
| 475 | - * @param String $callsign The callsign |
|
| 476 | - * @param String $date date we want flight number info |
|
| 477 | - * @param string $carrier |
|
| 478 | - * @return array Flight departure and arrival airports and time |
|
| 479 | - */ |
|
| 473 | + /** |
|
| 474 | + * Get flight info from Star Alliance |
|
| 475 | + * @param String $callsign The callsign |
|
| 476 | + * @param String $date date we want flight number info |
|
| 477 | + * @param string $carrier |
|
| 478 | + * @return array Flight departure and arrival airports and time |
|
| 479 | + */ |
|
| 480 | 480 | |
| 481 | 481 | private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') { |
| 482 | 482 | $Common = new Common(); |
@@ -508,11 +508,11 @@ discard block |
||
| 508 | 508 | |
| 509 | 509 | |
| 510 | 510 | /** |
| 511 | - * Get flight info from Alitalia |
|
| 512 | - * @param String $callsign The callsign |
|
| 513 | - * @param String $date date we want flight number info |
|
| 514 | - * @return array Flight departure and arrival airports and time |
|
| 515 | - */ |
|
| 511 | + * Get flight info from Alitalia |
|
| 512 | + * @param String $callsign The callsign |
|
| 513 | + * @param String $date date we want flight number info |
|
| 514 | + * @return array Flight departure and arrival airports and time |
|
| 515 | + */ |
|
| 516 | 516 | private function getAlitalia($callsign, $date = 'NOW') { |
| 517 | 517 | $Common = new Common(); |
| 518 | 518 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -532,11 +532,11 @@ discard block |
||
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | /** |
| 535 | - * Get flight info from Brussels airlines |
|
| 536 | - * @param String $callsign The callsign |
|
| 537 | - * @param String $date date we want flight number info |
|
| 538 | - * @return array Flight departure and arrival airports and time |
|
| 539 | - */ |
|
| 535 | + * Get flight info from Brussels airlines |
|
| 536 | + * @param String $callsign The callsign |
|
| 537 | + * @param String $date date we want flight number info |
|
| 538 | + * @return array Flight departure and arrival airports and time |
|
| 539 | + */ |
|
| 540 | 540 | private function getBrussels($callsign, $date = 'NOW') { |
| 541 | 541 | $Common = new Common(); |
| 542 | 542 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -546,25 +546,25 @@ discard block |
||
| 546 | 546 | if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
| 547 | 547 | $data = $Common->getData($url); |
| 548 | 548 | if ($data != '') { |
| 549 | - //echo $data; |
|
| 550 | - $parsed_json = json_decode($data,true); |
|
| 551 | - if (isset($parsed_json[0]['FromAirportCode'])) { |
|
| 549 | + //echo $data; |
|
| 550 | + $parsed_json = json_decode($data,true); |
|
| 551 | + if (isset($parsed_json[0]['FromAirportCode'])) { |
|
| 552 | 552 | $DepartureAirportIata = $parsed_json[0]['FromAirportCode']; |
| 553 | 553 | $ArrivalAirportIata = $parsed_json[0]['ToAirportCode']; |
| 554 | 554 | $departureTime = date('H:i',strtotime($parsed_json[0]['ScheduledDepatureDate'])); |
| 555 | 555 | $arrivalTime = date('H:i',strtotime($parsed_json[0]['ScheduledArrivalDate'])); |
| 556 | 556 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels'); |
| 557 | - } |
|
| 557 | + } |
|
| 558 | 558 | } |
| 559 | 559 | return array(); |
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | /** |
| 563 | - * Get flight info from FlightRadar24 |
|
| 564 | - * @param String $callsign The callsign |
|
| 565 | - * @param String $date date we want flight number info |
|
| 566 | - * @return array Flight departure and arrival airports and time |
|
| 567 | - */ |
|
| 563 | + * Get flight info from FlightRadar24 |
|
| 564 | + * @param String $callsign The callsign |
|
| 565 | + * @param String $date date we want flight number info |
|
| 566 | + * @return array Flight departure and arrival airports and time |
|
| 567 | + */ |
|
| 568 | 568 | /* |
| 569 | 569 | public function getFlightRadar24($callsign, $date = 'NOW') { |
| 570 | 570 | $Common = new Common(); |
@@ -593,11 +593,11 @@ discard block |
||
| 593 | 593 | } |
| 594 | 594 | */ |
| 595 | 595 | /** |
| 596 | - * Get flight info from Lufthansa |
|
| 597 | - * @param String $callsign The callsign |
|
| 598 | - * @param String $date date we want flight number info |
|
| 599 | - * @return array Flight departure and arrival airports and time |
|
| 600 | - */ |
|
| 596 | + * Get flight info from Lufthansa |
|
| 597 | + * @param String $callsign The callsign |
|
| 598 | + * @param String $date date we want flight number info |
|
| 599 | + * @return array Flight departure and arrival airports and time |
|
| 600 | + */ |
|
| 601 | 601 | |
| 602 | 602 | /* private function getLufthansa($callsign, $date = 'NOW') { |
| 603 | 603 | $Common = new Common(); |
@@ -625,10 +625,10 @@ discard block |
||
| 625 | 625 | } |
| 626 | 626 | */ |
| 627 | 627 | /** |
| 628 | - * Get flight info from flytap |
|
| 629 | - * @param String $callsign The callsign |
|
| 630 | - * @return array Flight departure and arrival airports and time |
|
| 631 | - */ |
|
| 628 | + * Get flight info from flytap |
|
| 629 | + * @param String $callsign The callsign |
|
| 630 | + * @return array Flight departure and arrival airports and time |
|
| 631 | + */ |
|
| 632 | 632 | private function getFlyTap($callsign) { |
| 633 | 633 | $Common = new Common(); |
| 634 | 634 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -651,10 +651,10 @@ discard block |
||
| 651 | 651 | } |
| 652 | 652 | |
| 653 | 653 | /** |
| 654 | - * Get flight info from flightmapper |
|
| 655 | - * @param String $callsign The callsign |
|
| 656 | - * @return array Flight departure and arrival airports and time |
|
| 657 | - */ |
|
| 654 | + * Get flight info from flightmapper |
|
| 655 | + * @param String $callsign The callsign |
|
| 656 | + * @return array Flight departure and arrival airports and time |
|
| 657 | + */ |
|
| 658 | 658 | public function getFlightMapper($callsign) { |
| 659 | 659 | $Common = new Common(); |
| 660 | 660 | $airline_icao = ''; |
@@ -682,11 +682,11 @@ discard block |
||
| 682 | 682 | $aarr = ''; |
| 683 | 683 | $n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr); |
| 684 | 684 | if ($n == 7) { |
| 685 | - $departureTime = $dhour; |
|
| 686 | - $arrivalTime = $ahour; |
|
| 687 | - $DepartureAirportIata = str_replace(array('(',')'),'',$darr); |
|
| 688 | - $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr); |
|
| 689 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper'); |
|
| 685 | + $departureTime = $dhour; |
|
| 686 | + $arrivalTime = $ahour; |
|
| 687 | + $DepartureAirportIata = str_replace(array('(',')'),'',$darr); |
|
| 688 | + $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr); |
|
| 689 | + return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper'); |
|
| 690 | 690 | } |
| 691 | 691 | } |
| 692 | 692 | } |
@@ -694,10 +694,10 @@ discard block |
||
| 694 | 694 | } |
| 695 | 695 | |
| 696 | 696 | /** |
| 697 | - * Get flight info from flightaware |
|
| 698 | - * @param String $callsign The callsign |
|
| 699 | - * @return array Flight departure and arrival airports and time |
|
| 700 | - */ |
|
| 697 | + * Get flight info from flightaware |
|
| 698 | + * @param String $callsign The callsign |
|
| 699 | + * @return array Flight departure and arrival airports and time |
|
| 700 | + */ |
|
| 701 | 701 | public function getFlightAware($callsign) { |
| 702 | 702 | global $globalFlightAwareUsername, $globalFlightAwarePassword; |
| 703 | 703 | date_default_timezone_set('UTC'); |
@@ -722,11 +722,11 @@ discard block |
||
| 722 | 722 | $flight = $result['FlightInfoStatusResult']['flights'][0]; |
| 723 | 723 | if (isset($flight['origin'])) { |
| 724 | 724 | return array( |
| 725 | - 'DepartureAirportIATA' => $flight['origin']['alternate_ident'], |
|
| 726 | - 'DepartureTime' => $flight['filed_departure_time']['time'], |
|
| 727 | - 'ArrivalAirportIATA' => $flight['destination']['alternate_ident'], |
|
| 728 | - 'ArrivalTime' => $flight['filed_arrival_time']['time'], |
|
| 729 | - 'Source' => 'website_flightaware'); |
|
| 725 | + 'DepartureAirportIATA' => $flight['origin']['alternate_ident'], |
|
| 726 | + 'DepartureTime' => $flight['filed_departure_time']['time'], |
|
| 727 | + 'ArrivalAirportIATA' => $flight['destination']['alternate_ident'], |
|
| 728 | + 'ArrivalTime' => $flight['filed_arrival_time']['time'], |
|
| 729 | + 'Source' => 'website_flightaware'); |
|
| 730 | 730 | } |
| 731 | 731 | } |
| 732 | 732 | } |
@@ -739,21 +739,21 @@ discard block |
||
| 739 | 739 | $flight = reset($flights['flights']); |
| 740 | 740 | if (isset($flight['activityLog']['flights'][0]['origin'])) { |
| 741 | 741 | return array( |
| 742 | - 'DepartureAirportIATA' => $flight['activityLog']['flights'][0]['origin']['iata'], |
|
| 743 | - 'DepartureTime' => date('H:i',$flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']), |
|
| 744 | - 'ArrivalAirportIATA' => $flight['activityLog']['flights'][0]['destination']['iata'], |
|
| 745 | - 'ArrivalTime' => date('H:i',$flight['activityLog']['flights'][0]['landingTimes']['scheduled']), |
|
| 746 | - 'Source' => 'website_flightaware'); |
|
| 742 | + 'DepartureAirportIATA' => $flight['activityLog']['flights'][0]['origin']['iata'], |
|
| 743 | + 'DepartureTime' => date('H:i',$flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']), |
|
| 744 | + 'ArrivalAirportIATA' => $flight['activityLog']['flights'][0]['destination']['iata'], |
|
| 745 | + 'ArrivalTime' => date('H:i',$flight['activityLog']['flights'][0]['landingTimes']['scheduled']), |
|
| 746 | + 'Source' => 'website_flightaware'); |
|
| 747 | 747 | } |
| 748 | 748 | } |
| 749 | 749 | return array(); |
| 750 | 750 | } |
| 751 | 751 | |
| 752 | 752 | /** |
| 753 | - * Get flight info from CostToTravel |
|
| 754 | - * @param String $callsign The callsign |
|
| 755 | - * @return array Flight departure and arrival airports and time |
|
| 756 | - */ |
|
| 753 | + * Get flight info from CostToTravel |
|
| 754 | + * @param String $callsign The callsign |
|
| 755 | + * @return array Flight departure and arrival airports and time |
|
| 756 | + */ |
|
| 757 | 757 | public function getCostToTravel($callsign) { |
| 758 | 758 | $Common = new Common(); |
| 759 | 759 | $url= "http://www.costtotravel.com/flight-number/".$callsign; |
@@ -776,11 +776,11 @@ discard block |
||
| 776 | 776 | } |
| 777 | 777 | |
| 778 | 778 | /** |
| 779 | - * Get flight info from Air Canada |
|
| 780 | - * @param string $callsign The callsign |
|
| 781 | - * @param string $date date we want flight number info |
|
| 782 | - * @return array Flight departure and arrival airports and time |
|
| 783 | - */ |
|
| 779 | + * Get flight info from Air Canada |
|
| 780 | + * @param string $callsign The callsign |
|
| 781 | + * @param string $date date we want flight number info |
|
| 782 | + * @return array Flight departure and arrival airports and time |
|
| 783 | + */ |
|
| 784 | 784 | private function getAirCanada($callsign,$date = 'NOW') { |
| 785 | 785 | $Common = new Common(); |
| 786 | 786 | if (class_exists("DomDocument") === FALSE) return array(); |
@@ -805,11 +805,11 @@ discard block |
||
| 805 | 805 | } |
| 806 | 806 | |
| 807 | 807 | /** |
| 808 | - * Get flight info from Vietnam Airlines |
|
| 809 | - * @param String $callsign The callsign |
|
| 810 | - * @param String $date date we want flight number info |
|
| 811 | - * @return array Flight departure and arrival airports and time |
|
| 812 | - */ |
|
| 808 | + * Get flight info from Vietnam Airlines |
|
| 809 | + * @param String $callsign The callsign |
|
| 810 | + * @param String $date date we want flight number info |
|
| 811 | + * @return array Flight departure and arrival airports and time |
|
| 812 | + */ |
|
| 813 | 813 | private function getVietnamAirlines($callsign, $date = 'NOW') { |
| 814 | 814 | $Common = new Common(); |
| 815 | 815 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -832,12 +832,12 @@ discard block |
||
| 832 | 832 | } |
| 833 | 833 | |
| 834 | 834 | /** |
| 835 | - * Get flight info from Air Berlin |
|
| 836 | - * @param String $callsign The callsign |
|
| 837 | - * @param String $date date we want flight number info |
|
| 838 | - * @param String $carrier airline code |
|
| 839 | - * @return array Flight departure and arrival airports and time |
|
| 840 | - */ |
|
| 835 | + * Get flight info from Air Berlin |
|
| 836 | + * @param String $callsign The callsign |
|
| 837 | + * @param String $date date we want flight number info |
|
| 838 | + * @param String $carrier airline code |
|
| 839 | + * @return array Flight departure and arrival airports and time |
|
| 840 | + */ |
|
| 841 | 841 | private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') { |
| 842 | 842 | $Common = new Common(); |
| 843 | 843 | date_default_timezone_set('UTC'); |
@@ -866,11 +866,11 @@ discard block |
||
| 866 | 866 | $table = $Common->table2array($data); |
| 867 | 867 | $flight = $table; |
| 868 | 868 | if (isset($flight[5][4])) { |
| 869 | - $arrivalTime = $flight[5][4]; |
|
| 870 | - $arrivalAirport = $flight[5][3]; |
|
| 869 | + $arrivalTime = $flight[5][4]; |
|
| 870 | + $arrivalAirport = $flight[5][3]; |
|
| 871 | 871 | } else { |
| 872 | - $arrivalTime = ''; |
|
| 873 | - $arrivalAirport = ''; |
|
| 872 | + $arrivalTime = ''; |
|
| 873 | + $arrivalAirport = ''; |
|
| 874 | 874 | } |
| 875 | 875 | } else return array(); |
| 876 | 876 | $url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner'; |
@@ -37,9 +37,9 @@ discard block |
||
| 37 | 37 | * @param String $source source of data |
| 38 | 38 | * @return string |
| 39 | 39 | */ |
| 40 | - public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') { |
|
| 40 | + public function addSchedule($ident, $departure_airport_icao, $departure_airport_time, $arrival_airport_icao, $arrival_airport_time, $source = 'website') { |
|
| 41 | 41 | date_default_timezone_set('UTC'); |
| 42 | - $date = date("Y-m-d H:i:s",time()); |
|
| 42 | + $date = date("Y-m-d H:i:s", time()); |
|
| 43 | 43 | //if ($departure_airport_time == '' && $arrival_airport_time == '') exit; |
| 44 | 44 | //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident"; |
| 45 | 45 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident"; |
@@ -47,69 +47,69 @@ discard block |
||
| 47 | 47 | try { |
| 48 | 48 | $sth = $this->db->prepare($query); |
| 49 | 49 | $sth->execute($query_values); |
| 50 | - } catch(PDOException $e) { |
|
| 50 | + } catch (PDOException $e) { |
|
| 51 | 51 | return "error : ".$e->getMessage(); |
| 52 | 52 | } |
| 53 | 53 | if ($sth->fetchColumn() > 0) { |
| 54 | 54 | if ($departure_airport_time == '' && $arrival_airport_time == '') { |
| 55 | 55 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao"; |
| 56 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao); |
|
| 56 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao); |
|
| 57 | 57 | } elseif ($arrival_airport_time == '') { |
| 58 | 58 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao"; |
| 59 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao); |
|
| 59 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao); |
|
| 60 | 60 | } elseif ($departure_airport_time == '') { |
| 61 | 61 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
| 62 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
| 62 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time); |
|
| 63 | 63 | } else { |
| 64 | 64 | //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time"; |
| 65 | 65 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
| 66 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
| 66 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time); |
|
| 67 | 67 | } |
| 68 | 68 | try { |
| 69 | 69 | $sth = $this->db->prepare($query); |
| 70 | 70 | $sth->execute($query_values); |
| 71 | - } catch(PDOException $e) { |
|
| 71 | + } catch (PDOException $e) { |
|
| 72 | 72 | return "error : ".$e->getMessage(); |
| 73 | 73 | } |
| 74 | 74 | if ($sth->fetchColumn() == 0) { |
| 75 | 75 | //$query = 'UPDATE schedule SET departure_airport_icao = :departure_airport_icao, departure_airport_time = :departure_airport_time, arrival_airport_icao = :arrival_airport_icao, arrival_airport_time = :arrival_airport_time, date_modified = :date, source = :source WHERE ident = :ident'; |
| 76 | 76 | if ($departure_airport_time == '' && $arrival_airport_time == '') { |
| 77 | 77 | $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
| 78 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
| 78 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
| 79 | 79 | } elseif ($arrival_airport_time == '') { |
| 80 | 80 | $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
| 81 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
| 81 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
| 82 | 82 | } elseif ($departure_airport_time == '') { |
| 83 | 83 | $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
| 84 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
| 84 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
| 85 | 85 | } else { |
| 86 | 86 | $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
| 87 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
| 87 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
| 88 | 88 | } |
| 89 | 89 | try { |
| 90 | 90 | $sth = $this->db->prepare($query); |
| 91 | 91 | $sth->execute($query_values); |
| 92 | - } catch(PDOException $e) { |
|
| 92 | + } catch (PDOException $e) { |
|
| 93 | 93 | return "error : ".$e->getMessage(); |
| 94 | 94 | } |
| 95 | 95 | } else { |
| 96 | 96 | //$query = 'UPDATE schedule SET date_lastseen = :date WHERE ident = :ident'; |
| 97 | 97 | $query = 'UPDATE routes SET date_lastseen = :date WHERE CallSign = :ident'; |
| 98 | - $query_values = array(':ident' => $ident,':date' => $date); |
|
| 98 | + $query_values = array(':ident' => $ident, ':date' => $date); |
|
| 99 | 99 | try { |
| 100 | 100 | $sth = $this->db->prepare($query); |
| 101 | 101 | $sth->execute($query_values); |
| 102 | - } catch(PDOException $e) { |
|
| 102 | + } catch (PDOException $e) { |
|
| 103 | 103 | return "error : ".$e->getMessage(); |
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | } else { |
| 107 | 107 | $query = 'INSERT INTO routes (CallSign,FromAirport_ICAO, FromAirport_Time, ToAirport_ICAO, ToAirport_Time,date_added,source) VALUES (:ident,:departure_airport_icao,:departure_airport_time,:arrival_airport_icao,:arrival_airport_time,:date,:source)'; |
| 108 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
| 108 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
| 109 | 109 | try { |
| 110 | 110 | $sth = $this->db->prepare($query); |
| 111 | 111 | $sth->execute($query_values); |
| 112 | - } catch(PDOException $e) { |
|
| 112 | + } catch (PDOException $e) { |
|
| 113 | 113 | return "error : ".$e->getMessage(); |
| 114 | 114 | } |
| 115 | 115 | } |
@@ -123,10 +123,10 @@ discard block |
||
| 123 | 123 | */ |
| 124 | 124 | public function getSchedule($ident) { |
| 125 | 125 | $Translation = new Translation($this->db); |
| 126 | - $operator = $Translation->checkTranslation($ident,false); |
|
| 126 | + $operator = $Translation->checkTranslation($ident, false); |
|
| 127 | 127 | if ($ident != $operator) { |
| 128 | 128 | $query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :operator OR CallSign = :ident LIMIT 1"; |
| 129 | - $query_values = array(':ident' => $ident,'operator' => $operator); |
|
| 129 | + $query_values = array(':ident' => $ident, 'operator' => $operator); |
|
| 130 | 130 | } else { |
| 131 | 131 | $query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident LIMIT 1"; |
| 132 | 132 | $query_values = array(':ident' => $ident); |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | try { |
| 135 | 135 | $sth = $this->db->prepare($query); |
| 136 | 136 | $sth->execute($query_values); |
| 137 | - } catch(PDOException $e) { |
|
| 137 | + } catch (PDOException $e) { |
|
| 138 | 138 | return "error : ".$e->getMessage(); |
| 139 | 139 | } |
| 140 | 140 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | try { |
| 164 | 164 | $sth = $this->db->prepare($query); |
| 165 | 165 | $sth->execute($query_values); |
| 166 | - } catch(PDOException $e) { |
|
| 166 | + } catch (PDOException $e) { |
|
| 167 | 167 | return "error : ".$e->getMessage(); |
| 168 | 168 | } |
| 169 | 169 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -178,16 +178,16 @@ discard block |
||
| 178 | 178 | * @param String $carrier IATA code |
| 179 | 179 | * @return array departure and arrival airports and time |
| 180 | 180 | */ |
| 181 | - public function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') { |
|
| 181 | + public function getAirFrance($callsign, $date = 'NOW', $carrier = 'AF') { |
|
| 182 | 182 | $Common = new Common(); |
| 183 | 183 | $check_date = new Datetime($date); |
| 184 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 185 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 184 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 185 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 186 | 186 | $url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym'); |
| 187 | 187 | $json = $Common->getData($url); |
| 188 | 188 | var_dump($json); |
| 189 | 189 | $parsed_json = json_decode($json); |
| 190 | - if (property_exists($parsed_json,'errors') === false) { |
|
| 190 | + if (property_exists($parsed_json, 'errors') === false) { |
|
| 191 | 191 | //$originLong = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originLong'}; |
| 192 | 192 | $originShort = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originShort'}; |
| 193 | 193 | //$departureDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'departureDateMedium'}; |
@@ -197,9 +197,9 @@ discard block |
||
| 197 | 197 | //$arrivalDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalDateMedium'}; |
| 198 | 198 | $arrivalTime = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalTime'}; |
| 199 | 199 | |
| 200 | - preg_match('/\((.*?)\)/',$originShort,$originiata); |
|
| 200 | + preg_match('/\((.*?)\)/', $originShort, $originiata); |
|
| 201 | 201 | $DepartureAirportIata = $originiata[1]; |
| 202 | - preg_match('/\((.*?)\)/',$destinationShort,$destinationiata); |
|
| 202 | + preg_match('/\((.*?)\)/', $destinationShort, $destinationiata); |
|
| 203 | 203 | $ArrivalAirportIata = $destinationiata[1]; |
| 204 | 204 | |
| 205 | 205 | /* |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | $arrivalTime = gmdate('H:i',strtotime($arrivalTime)); |
| 209 | 209 | */ |
| 210 | 210 | |
| 211 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance'); |
|
| 211 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airfrance'); |
|
| 212 | 212 | } else return array(); |
| 213 | 213 | } |
| 214 | 214 | |
@@ -223,8 +223,8 @@ discard block |
||
| 223 | 223 | $Common = new Common(); |
| 224 | 224 | date_default_timezone_set($globalTimezone); |
| 225 | 225 | $check_date = new Datetime($date); |
| 226 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 227 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 226 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 227 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 228 | 228 | $url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign; |
| 229 | 229 | $json = $Common->getData($url); |
| 230 | 230 | $parsed_json = json_decode($json); |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | $departureTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fstd'}; |
| 237 | 237 | $arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'}; |
| 238 | 238 | |
| 239 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet'); |
|
| 239 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_easyjet'); |
|
| 240 | 240 | } else return array(); |
| 241 | 241 | } |
| 242 | 242 | |
@@ -247,12 +247,12 @@ discard block |
||
| 247 | 247 | */ |
| 248 | 248 | private function getRyanair($callsign) { |
| 249 | 249 | $Common = new Common(); |
| 250 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 251 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 250 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 251 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 252 | 252 | $url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/"; |
| 253 | 253 | $post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}'; |
| 254 | - $headers = array('Content-Type: application/json','Content-Length: ' . strlen($post)); |
|
| 255 | - $json = $Common->getData($url,'post',$post,$headers); |
|
| 254 | + $headers = array('Content-Type: application/json', 'Content-Length: '.strlen($post)); |
|
| 255 | + $json = $Common->getData($url, 'post', $post, $headers); |
|
| 256 | 256 | $parsed_json = json_decode($json); |
| 257 | 257 | if (isset($parsed_json->{'flightInfo'})) { |
| 258 | 258 | $flights = $parsed_json->{'flightInfo'}; |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | $ArrivalAirportIata = $parsed_json->{'flightInfo'}[0]->{'arrivalAirport'}->{'iata'}; //name |
| 262 | 262 | $departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'}; |
| 263 | 263 | $arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'}; |
| 264 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair'); |
|
| 264 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair'); |
|
| 265 | 265 | } else return array(); |
| 266 | 266 | } else return array(); |
| 267 | 267 | } |
@@ -273,8 +273,8 @@ discard block |
||
| 273 | 273 | */ |
| 274 | 274 | private function getSwiss($callsign) { |
| 275 | 275 | $Common = new Common(); |
| 276 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 277 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 276 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 277 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 278 | 278 | $url = "http://www.world-of-swiss.com/fr/routenetwork.json"; |
| 279 | 279 | $json = $Common->getData($url); |
| 280 | 280 | $parsed_json = json_decode($json); |
@@ -288,12 +288,12 @@ discard block |
||
| 288 | 288 | if ($flight->{'no'} == "Vol LX ".$numvol) { |
| 289 | 289 | $DepartureAirportIata = $flight->{'from'}->{'code'}; //city |
| 290 | 290 | $ArrivalAirportIata = $flight->{'to'}->{'code'}; //city |
| 291 | - $departureTime = substr($flight->{'from'}->{'hour'},0,5); |
|
| 292 | - $arrivalTime = substr($flight->{'to'}->{'hour'},0,5); |
|
| 291 | + $departureTime = substr($flight->{'from'}->{'hour'},0, 5); |
|
| 292 | + $arrivalTime = substr($flight->{'to'}->{'hour'},0, 5); |
|
| 293 | 293 | } |
| 294 | 294 | } |
| 295 | 295 | if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) { |
| 296 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss'); |
|
| 296 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_swiss'); |
|
| 297 | 297 | } else return array(); |
| 298 | 298 | } else return array(); |
| 299 | 299 | } |
@@ -308,21 +308,21 @@ discard block |
||
| 308 | 308 | global $globalBritishAirwaysKey; |
| 309 | 309 | $Common = new Common(); |
| 310 | 310 | $check_date = new Datetime($date); |
| 311 | - $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
|
| 312 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
| 311 | + $numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign)); |
|
| 312 | + if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array(); |
|
| 313 | 313 | if ($globalBritishAirwaysKey == '') return array(); |
| 314 | 314 | $url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json"; |
| 315 | 315 | $headers = array('Client-Key: '.$globalBritishAirwaysKey); |
| 316 | - $json = $Common->getData($url,'get','',$headers); |
|
| 316 | + $json = $Common->getData($url, 'get', '', $headers); |
|
| 317 | 317 | if ($json == '') return array(); |
| 318 | 318 | $parsed_json = json_decode($json); |
| 319 | 319 | $flights = $parsed_json->{'FlightsResponse'}; |
| 320 | 320 | if (count($flights) > 0) { |
| 321 | 321 | $DepartureAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'DepartureAirport'}; |
| 322 | 322 | $ArrivalAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ArrivalAirport'}; |
| 323 | - $departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'})); |
|
| 324 | - $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'})); |
|
| 325 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways'); |
|
| 323 | + $departureTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'})); |
|
| 324 | + $arrivalTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'})); |
|
| 325 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_britishairways'); |
|
| 326 | 326 | } else return array(); |
| 327 | 327 | } |
| 328 | 328 | |
@@ -336,27 +336,27 @@ discard block |
||
| 336 | 336 | global $globalLufthansaKey; |
| 337 | 337 | $Common = new Common(); |
| 338 | 338 | $check_date = new Datetime($date); |
| 339 | - $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
|
| 340 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
| 339 | + $numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign)); |
|
| 340 | + if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array(); |
|
| 341 | 341 | if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array(); |
| 342 | 342 | $url = "https://api.lufthansa.com/v1/oauth/token"; |
| 343 | - $post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials'); |
|
| 344 | - $data = $Common->getData($url,'post',$post); |
|
| 343 | + $post = array('client_id' => $globalLufthansaKey['key'], 'client_secret' => $globalLufthansaKey['secret'], 'grant_type' => 'client_credentials'); |
|
| 344 | + $data = $Common->getData($url, 'post', $post); |
|
| 345 | 345 | $parsed_data = json_decode($data); |
| 346 | 346 | if (!isset($parsed_data->{'access_token'})) return array(); |
| 347 | 347 | $token = $parsed_data->{'access_token'}; |
| 348 | 348 | |
| 349 | 349 | $url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d'); |
| 350 | - $headers = array('Authorization: Bearer '.$token,'Accept: application/json'); |
|
| 351 | - $json = $Common->getData($url,'get','',$headers); |
|
| 350 | + $headers = array('Authorization: Bearer '.$token, 'Accept: application/json'); |
|
| 351 | + $json = $Common->getData($url, 'get', '', $headers); |
|
| 352 | 352 | if ($json == '') return array(); |
| 353 | 353 | $parsed_json = json_decode($json); |
| 354 | 354 | if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) { |
| 355 | 355 | $DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'}; |
| 356 | - $departureTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
|
| 356 | + $departureTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
|
| 357 | 357 | $ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'}; |
| 358 | - $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
|
| 359 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa'); |
|
| 358 | + $arrivalTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
|
| 359 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_lufthansa'); |
|
| 360 | 360 | } else return array(); |
| 361 | 361 | } |
| 362 | 362 | |
@@ -370,23 +370,23 @@ discard block |
||
| 370 | 370 | global $globalTransaviaKey; |
| 371 | 371 | $Common = new Common(); |
| 372 | 372 | $check_date = new Datetime($date); |
| 373 | - $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
|
| 374 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
| 373 | + $numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign)); |
|
| 374 | + if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array(); |
|
| 375 | 375 | if ($globalTransaviaKey == '') return array(); |
| 376 | 376 | $url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
| 377 | 377 | //$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
| 378 | 378 | $headers = array('apikey: '.$globalTransaviaKey); |
| 379 | - $json = $Common->getData($url,'get','',$headers); |
|
| 379 | + $json = $Common->getData($url, 'get', '', $headers); |
|
| 380 | 380 | //echo 'result : '.$json; |
| 381 | 381 | if ($json == '') return array(); |
| 382 | 382 | $parsed_json = json_decode($json); |
| 383 | 383 | |
| 384 | 384 | if (isset($parsed_json->{'data'}[0])) { |
| 385 | 385 | $DepartureAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'departureAirport'}->{'locationCode'}; |
| 386 | - $departureTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'})); |
|
| 386 | + $departureTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'})); |
|
| 387 | 387 | $ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'}; |
| 388 | - $arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'})); |
|
| 389 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia'); |
|
| 388 | + $arrivalTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'})); |
|
| 389 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_transavia'); |
|
| 390 | 390 | } else return array(); |
| 391 | 391 | } |
| 392 | 392 | |
@@ -397,14 +397,14 @@ discard block |
||
| 397 | 397 | */ |
| 398 | 398 | public function getTunisair($callsign) { |
| 399 | 399 | $Common = new Common(); |
| 400 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 401 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 400 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 401 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 402 | 402 | $url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp"; |
| 403 | 403 | $data = $Common->getData($url); |
| 404 | 404 | $table = $Common->table2array($data); |
| 405 | 405 | foreach ($table as $flight) { |
| 406 | - if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d',$numvol)) { |
|
| 407 | - return array('DepartureAirportIATA' => $flight[2],'DepartureTime' => str_replace('.',':',$flight[5]),'ArrivalAirportIATA' => $flight[3],'ArrivalTime' => str_replace('.',':',$flight[6]),'Source' => 'website_tunisair'); |
|
| 406 | + if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d', $numvol)) { |
|
| 407 | + return array('DepartureAirportIATA' => $flight[2], 'DepartureTime' => str_replace('.', ':', $flight[5]), 'ArrivalAirportIATA' => $flight[3], 'ArrivalTime' => str_replace('.', ':', $flight[6]), 'Source' => 'website_tunisair'); |
|
| 408 | 408 | } |
| 409 | 409 | } |
| 410 | 410 | return array(); |
@@ -416,21 +416,21 @@ discard block |
||
| 416 | 416 | * @param string $date |
| 417 | 417 | * @return array Flight departure and arrival airports and time |
| 418 | 418 | */ |
| 419 | - public function getVueling($callsign,$date = 'NOW') { |
|
| 419 | + public function getVueling($callsign, $date = 'NOW') { |
|
| 420 | 420 | $Common = new Common(); |
| 421 | 421 | $check_date = new Datetime($date); |
| 422 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 423 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 424 | - $final_date = str_replace('/','%2F',$check_date->format('d/m/Y')); |
|
| 422 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 423 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 424 | + $final_date = str_replace('/', '%2F', $check_date->format('d/m/Y')); |
|
| 425 | 425 | $url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB"; |
| 426 | 426 | $data = $Common->getData($url); |
| 427 | - $data=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$data)); |
|
| 427 | + $data = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $data)); |
|
| 428 | 428 | if ($data != '') { |
| 429 | - preg_match('/flightOri=[A-Z]{3}/',$data,$result); |
|
| 430 | - $DepartureAirportIata = str_replace('flightOri=','',$result[0]); |
|
| 431 | - preg_match('/flightDest=[A-Z]{3}/',$data,$result); |
|
| 432 | - $ArrivalAirportIata = str_replace('flightDest=','',$result[0]); |
|
| 433 | - if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling'); |
|
| 429 | + preg_match('/flightOri=[A-Z]{3}/', $data, $result); |
|
| 430 | + $DepartureAirportIata = str_replace('flightOri=', '', $result[0]); |
|
| 431 | + preg_match('/flightDest=[A-Z]{3}/', $data, $result); |
|
| 432 | + $ArrivalAirportIata = str_replace('flightDest=', '', $result[0]); |
|
| 433 | + if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'Source' => 'website_vueling'); |
|
| 434 | 434 | else return array(); |
| 435 | 435 | } |
| 436 | 436 | return array(); |
@@ -444,27 +444,27 @@ discard block |
||
| 444 | 444 | */ |
| 445 | 445 | public function getIberia($callsign, $date = 'NOW') { |
| 446 | 446 | $Common = new Common(); |
| 447 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 447 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 448 | 448 | $check_date = new Datetime($date); |
| 449 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 449 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 450 | 450 | $url = "https://www.iberia.com/web/flightDetail.do"; |
| 451 | - $post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB'); |
|
| 452 | - $data = $Common->getData($url,'post',$post); |
|
| 451 | + $post = array('numvuelo' => $numvol, 'fecha' => $check_date->format('Ymd'), 'airlineID' => 'IB'); |
|
| 452 | + $data = $Common->getData($url, 'post', $post); |
|
| 453 | 453 | if ($data != '') { |
| 454 | 454 | $table = $Common->table2array($data); |
| 455 | 455 | //print_r($table); |
| 456 | 456 | if (count($table) > 0) { |
| 457 | 457 | $flight = $table; |
| 458 | - preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch); |
|
| 459 | - preg_match('/([A-Z]{3})/',$flight[5][0],$ArrivalAirportIataMatch); |
|
| 458 | + preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch); |
|
| 459 | + preg_match('/([A-Z]{3})/', $flight[5][0], $ArrivalAirportIataMatch); |
|
| 460 | 460 | $DepartureAirportIata = $DepartureAirportIataMatch[0]; |
| 461 | 461 | $ArrivalAirportIata = $ArrivalAirportIataMatch[0]; |
| 462 | - $departureTime = substr(trim(str_replace(' lunes','',str_replace(' ','',$flight[3][2]))),0,5); |
|
| 463 | - $arrivalTime = trim(str_replace(' lunes','',str_replace(' ','',$flight[5][1]))); |
|
| 462 | + $departureTime = substr(trim(str_replace(' lunes', '', str_replace(' ', '', $flight[3][2]))), 0, 5); |
|
| 463 | + $arrivalTime = trim(str_replace(' lunes', '', str_replace(' ', '', $flight[5][1]))); |
|
| 464 | 464 | if ($arrivalTime == 'Hora estimada de llegada') { |
| 465 | - $arrivalTime = substr(trim(str_replace(' lunes','',str_replace(' ','',$flight[5][2]))),0,5); |
|
| 466 | - } else $arrivalTime = substr($arrivalTime,0,5); |
|
| 467 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia'); |
|
| 465 | + $arrivalTime = substr(trim(str_replace(' lunes', '', str_replace(' ', '', $flight[5][2]))), 0, 5); |
|
| 466 | + } else $arrivalTime = substr($arrivalTime, 0, 5); |
|
| 467 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_iberia'); |
|
| 468 | 468 | } |
| 469 | 469 | } |
| 470 | 470 | return array(); |
@@ -478,11 +478,11 @@ discard block |
||
| 478 | 478 | * @return array Flight departure and arrival airports and time |
| 479 | 479 | */ |
| 480 | 480 | |
| 481 | - private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') { |
|
| 481 | + private function getStarAlliance($callsign, $date = 'NOW', $carrier = '') { |
|
| 482 | 482 | $Common = new Common(); |
| 483 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 483 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 484 | 484 | $check_date = new Datetime($date); |
| 485 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 485 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 486 | 486 | $url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y'); |
| 487 | 487 | $data = $Common->getData($url); |
| 488 | 488 | if ($data != '') { |
@@ -491,13 +491,13 @@ discard block |
||
| 491 | 491 | $flight = $table; |
| 492 | 492 | //print_r($table); |
| 493 | 493 | if (isset($flight[25]) && isset($flight[29])) { |
| 494 | - preg_match('/([A-Z]{3})/',$flight[25][1],$DepartureAirportIataMatch); |
|
| 495 | - preg_match('/([A-Z]{3})/',$flight[25][3],$ArrivalAirportIataMatch); |
|
| 494 | + preg_match('/([A-Z]{3})/', $flight[25][1], $DepartureAirportIataMatch); |
|
| 495 | + preg_match('/([A-Z]{3})/', $flight[25][3], $ArrivalAirportIataMatch); |
|
| 496 | 496 | $DepartureAirportIata = $DepartureAirportIataMatch[0]; |
| 497 | 497 | $ArrivalAirportIata = $ArrivalAirportIataMatch[0]; |
| 498 | - $departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5); |
|
| 499 | - $arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5); |
|
| 500 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance'); |
|
| 498 | + $departureTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][0])), 0, 5); |
|
| 499 | + $arrivalTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][1])), 0, 5); |
|
| 500 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_staralliance'); |
|
| 501 | 501 | } else return array(); |
| 502 | 502 | } |
| 503 | 503 | |
@@ -515,10 +515,10 @@ discard block |
||
| 515 | 515 | */ |
| 516 | 516 | private function getAlitalia($callsign, $date = 'NOW') { |
| 517 | 517 | $Common = new Common(); |
| 518 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 518 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 519 | 519 | $check_date = new Datetime($date); |
| 520 | - $url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y'); |
|
| 521 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 520 | + $url = "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y'); |
|
| 521 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 522 | 522 | $data = $Common->getData($url); |
| 523 | 523 | if ($data != '') { |
| 524 | 524 | $table = $Common->text2array($data); |
@@ -526,7 +526,7 @@ discard block |
||
| 526 | 526 | $ArrivalAirportIata = ''; |
| 527 | 527 | $departureTime = $table[4]; |
| 528 | 528 | $arrivalTime = $table[5]; |
| 529 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_alitalia'); |
|
| 529 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_alitalia'); |
|
| 530 | 530 | } |
| 531 | 531 | return array(); |
| 532 | 532 | } |
@@ -539,21 +539,21 @@ discard block |
||
| 539 | 539 | */ |
| 540 | 540 | private function getBrussels($callsign, $date = 'NOW') { |
| 541 | 541 | $Common = new Common(); |
| 542 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 542 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 543 | 543 | $check_date = new Datetime($date); |
| 544 | - $url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302"; |
|
| 544 | + $url = "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302"; |
|
| 545 | 545 | //http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber"; |
| 546 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 546 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 547 | 547 | $data = $Common->getData($url); |
| 548 | 548 | if ($data != '') { |
| 549 | 549 | //echo $data; |
| 550 | - $parsed_json = json_decode($data,true); |
|
| 550 | + $parsed_json = json_decode($data, true); |
|
| 551 | 551 | if (isset($parsed_json[0]['FromAirportCode'])) { |
| 552 | 552 | $DepartureAirportIata = $parsed_json[0]['FromAirportCode']; |
| 553 | 553 | $ArrivalAirportIata = $parsed_json[0]['ToAirportCode']; |
| 554 | - $departureTime = date('H:i',strtotime($parsed_json[0]['ScheduledDepatureDate'])); |
|
| 555 | - $arrivalTime = date('H:i',strtotime($parsed_json[0]['ScheduledArrivalDate'])); |
|
| 556 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels'); |
|
| 554 | + $departureTime = date('H:i', strtotime($parsed_json[0]['ScheduledDepatureDate'])); |
|
| 555 | + $arrivalTime = date('H:i', strtotime($parsed_json[0]['ScheduledArrivalDate'])); |
|
| 556 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_brussels'); |
|
| 557 | 557 | } |
| 558 | 558 | } |
| 559 | 559 | return array(); |
@@ -631,21 +631,21 @@ discard block |
||
| 631 | 631 | */ |
| 632 | 632 | private function getFlyTap($callsign) { |
| 633 | 633 | $Common = new Common(); |
| 634 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 635 | - $url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees"; |
|
| 634 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 635 | + $url = "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees"; |
|
| 636 | 636 | //$check_date = new Datetime($date); |
| 637 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 638 | - $post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1'); |
|
| 639 | - $data = $Common->getData($url,'post',$post); |
|
| 637 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 638 | + $post = array('arrivalsdepartures_content' => 'number', 'arrivalsdepartures_tp' => $numvol, 'arrivalsdepartures_trk' => 'ARR', 'arrivalsdepartures_date_trk' => '1', 'aptCode' => '', 'arrivalsdepartures' => 'DEP', 'arrivalsdepartures_date' => '1', 'aptCodeFrom' => '', 'aptCodeTo' => '', 'arrivalsdepartures2' => 'DEP', 'arrivalsdepartures_date2' => '1'); |
|
| 639 | + $data = $Common->getData($url, 'post', $post); |
|
| 640 | 640 | if ($data != '') { |
| 641 | 641 | $table = $Common->table2array($data); |
| 642 | - $departureTime = trim(substr($table[15][0],0,5)); |
|
| 643 | - $arrivalTime = trim(substr($table[35][0],0,5)); |
|
| 644 | - preg_match('/([A-Z]{3})/',$table[11][0],$DepartureAirportIataMatch); |
|
| 645 | - preg_match('/([A-Z]{3})/',$table[31][0],$ArrivalAirportIataMatch); |
|
| 642 | + $departureTime = trim(substr($table[15][0], 0, 5)); |
|
| 643 | + $arrivalTime = trim(substr($table[35][0], 0, 5)); |
|
| 644 | + preg_match('/([A-Z]{3})/', $table[11][0], $DepartureAirportIataMatch); |
|
| 645 | + preg_match('/([A-Z]{3})/', $table[31][0], $ArrivalAirportIataMatch); |
|
| 646 | 646 | $DepartureAirportIata = $DepartureAirportIataMatch[0]; |
| 647 | 647 | $ArrivalAirportIata = $ArrivalAirportIataMatch[0]; |
| 648 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flytap'); |
|
| 648 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flytap'); |
|
| 649 | 649 | } |
| 650 | 650 | return array(); |
| 651 | 651 | } |
@@ -667,10 +667,10 @@ discard block |
||
| 667 | 667 | } |
| 668 | 668 | } |
| 669 | 669 | if ($airline_icao == '') return array(); |
| 670 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 671 | - $url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol; |
|
| 670 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 671 | + $url = "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol; |
|
| 672 | 672 | //$check_date = new Datetime($date); |
| 673 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 673 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 674 | 674 | $data = $Common->getData($url); |
| 675 | 675 | if ($data != '') { |
| 676 | 676 | $table = $Common->table2array($data); |
@@ -680,13 +680,13 @@ discard block |
||
| 680 | 680 | $darr = ''; |
| 681 | 681 | $ahour = ''; |
| 682 | 682 | $aarr = ''; |
| 683 | - $n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr); |
|
| 683 | + $n = sscanf($sched, '%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])', $dhour, $darr, $ahour, $aarr); |
|
| 684 | 684 | if ($n == 7) { |
| 685 | 685 | $departureTime = $dhour; |
| 686 | 686 | $arrivalTime = $ahour; |
| 687 | - $DepartureAirportIata = str_replace(array('(',')'),'',$darr); |
|
| 688 | - $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr); |
|
| 689 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper'); |
|
| 687 | + $DepartureAirportIata = str_replace(array('(', ')'), '', $darr); |
|
| 688 | + $ArrivalAirportIata = str_replace(array('(', ')'), '', $aarr); |
|
| 689 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flightmapper'); |
|
| 690 | 690 | } |
| 691 | 691 | } |
| 692 | 692 | } |
@@ -718,7 +718,7 @@ discard block |
||
| 718 | 718 | $url = 'http://'.$globalFlightAwareUsername.':'.$globalFlightAwarePassword.'@flightxml.flightaware.com/json/FlightXML3/FlightInfoStatus?ident='.$callsign; |
| 719 | 719 | $data = $Common->getData($url); |
| 720 | 720 | if ($data != '') { |
| 721 | - $result = json_decode($data,true); |
|
| 721 | + $result = json_decode($data, true); |
|
| 722 | 722 | $flight = $result['FlightInfoStatusResult']['flights'][0]; |
| 723 | 723 | if (isset($flight['origin'])) { |
| 724 | 724 | return array( |
@@ -731,18 +731,18 @@ discard block |
||
| 731 | 731 | } |
| 732 | 732 | } |
| 733 | 733 | |
| 734 | - $url= "http://flightaware.com/live/flight/".$callsign; |
|
| 734 | + $url = "http://flightaware.com/live/flight/".$callsign; |
|
| 735 | 735 | $data = $Common->getData($url); |
| 736 | 736 | if ($data != '') { |
| 737 | - preg_match(':<script>var trackpollBootstrap = (.*?);</script>:',$data,$result); |
|
| 738 | - $flights = json_decode($result[1],true); |
|
| 737 | + preg_match(':<script>var trackpollBootstrap = (.*?);</script>:', $data, $result); |
|
| 738 | + $flights = json_decode($result[1], true); |
|
| 739 | 739 | $flight = reset($flights['flights']); |
| 740 | 740 | if (isset($flight['activityLog']['flights'][0]['origin'])) { |
| 741 | 741 | return array( |
| 742 | 742 | 'DepartureAirportIATA' => $flight['activityLog']['flights'][0]['origin']['iata'], |
| 743 | - 'DepartureTime' => date('H:i',$flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']), |
|
| 743 | + 'DepartureTime' => date('H:i', $flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']), |
|
| 744 | 744 | 'ArrivalAirportIATA' => $flight['activityLog']['flights'][0]['destination']['iata'], |
| 745 | - 'ArrivalTime' => date('H:i',$flight['activityLog']['flights'][0]['landingTimes']['scheduled']), |
|
| 745 | + 'ArrivalTime' => date('H:i', $flight['activityLog']['flights'][0]['landingTimes']['scheduled']), |
|
| 746 | 746 | 'Source' => 'website_flightaware'); |
| 747 | 747 | } |
| 748 | 748 | } |
@@ -756,20 +756,20 @@ discard block |
||
| 756 | 756 | */ |
| 757 | 757 | public function getCostToTravel($callsign) { |
| 758 | 758 | $Common = new Common(); |
| 759 | - $url= "http://www.costtotravel.com/flight-number/".$callsign; |
|
| 759 | + $url = "http://www.costtotravel.com/flight-number/".$callsign; |
|
| 760 | 760 | //$check_date = new Datetime($date); |
| 761 | 761 | //if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
| 762 | 762 | $data = $Common->getData($url); |
| 763 | 763 | if ($data != '') { |
| 764 | 764 | $table = $Common->table2array($data); |
| 765 | 765 | if (isset($table[11][1])) { |
| 766 | - if (is_numeric(substr($table[11][1],0,1))) $departureTime = substr($table[11][1],0,5); |
|
| 766 | + if (is_numeric(substr($table[11][1], 0, 1))) $departureTime = substr($table[11][1], 0, 5); |
|
| 767 | 767 | else $departureTime = ''; |
| 768 | - if (is_numeric(substr($table[17][1],0,1))) $arrivalTime = substr($table[17][1],0,5); |
|
| 768 | + if (is_numeric(substr($table[17][1], 0, 1))) $arrivalTime = substr($table[17][1], 0, 5); |
|
| 769 | 769 | else $arrivalTime = ''; |
| 770 | - $DepartureAirportIata = substr($table[13][1],0,3); |
|
| 771 | - $ArrivalAirportIata = substr($table[15][1],0,3); |
|
| 772 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_costtotravel'); |
|
| 770 | + $DepartureAirportIata = substr($table[13][1], 0, 3); |
|
| 771 | + $ArrivalAirportIata = substr($table[15][1], 0, 3); |
|
| 772 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_costtotravel'); |
|
| 773 | 773 | } |
| 774 | 774 | } |
| 775 | 775 | return array(); |
@@ -781,14 +781,14 @@ discard block |
||
| 781 | 781 | * @param string $date date we want flight number info |
| 782 | 782 | * @return array Flight departure and arrival airports and time |
| 783 | 783 | */ |
| 784 | - private function getAirCanada($callsign,$date = 'NOW') { |
|
| 784 | + private function getAirCanada($callsign, $date = 'NOW') { |
|
| 785 | 785 | $Common = new Common(); |
| 786 | 786 | if (class_exists("DomDocument") === FALSE) return array(); |
| 787 | 787 | date_default_timezone_set('UTC'); |
| 788 | 788 | $check_date = new Datetime($date); |
| 789 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 790 | - $url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249"; |
|
| 791 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 789 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 790 | + $url = "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249"; |
|
| 791 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 792 | 792 | $data = $Common->getData($url); |
| 793 | 793 | $dom = new DomDocument(); |
| 794 | 794 | $dom->loadXML($data); |
@@ -796,11 +796,11 @@ discard block |
||
| 796 | 796 | $departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0); |
| 797 | 797 | if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) { |
| 798 | 798 | $DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
| 799 | - $departureTime = date('H:i',strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
|
| 799 | + $departureTime = date('H:i', strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
|
| 800 | 800 | $arrival = $dom->getElementsByTagName('ArrivalStationInfo')->item(0); |
| 801 | 801 | $ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
| 802 | - $arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
|
| 803 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada'); |
|
| 802 | + $arrivalTime = date('H:i', strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
|
| 803 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_aircanada'); |
|
| 804 | 804 | } else return array(); |
| 805 | 805 | } |
| 806 | 806 | |
@@ -812,21 +812,21 @@ discard block |
||
| 812 | 812 | */ |
| 813 | 813 | private function getVietnamAirlines($callsign, $date = 'NOW') { |
| 814 | 814 | $Common = new Common(); |
| 815 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 815 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 816 | 816 | $check_date = new Datetime($date); |
| 817 | - $url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&"; |
|
| 818 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 817 | + $url = "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&"; |
|
| 818 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 819 | 819 | $data = $Common->getData($url); |
| 820 | 820 | if ($data != '') { |
| 821 | 821 | $table = $Common->table2array($data); |
| 822 | 822 | $flight = $table; |
| 823 | - preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch); |
|
| 824 | - preg_match('/([A-Z]{3})/',$flight[21][0],$ArrivalAirportIataMatch); |
|
| 823 | + preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch); |
|
| 824 | + preg_match('/([A-Z]{3})/', $flight[21][0], $ArrivalAirportIataMatch); |
|
| 825 | 825 | $DepartureAirportIata = $DepartureAirportIataMatch[0]; |
| 826 | 826 | $ArrivalAirportIata = $ArrivalAirportIataMatch[0]; |
| 827 | 827 | $departureTime = $flight[5][1]; |
| 828 | 828 | $arrivalTime = $flight[23][1]; |
| 829 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_vietnamairlines'); |
|
| 829 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_vietnamairlines'); |
|
| 830 | 830 | } |
| 831 | 831 | return array(); |
| 832 | 832 | } |
@@ -838,16 +838,16 @@ discard block |
||
| 838 | 838 | * @param String $carrier airline code |
| 839 | 839 | * @return array Flight departure and arrival airports and time |
| 840 | 840 | */ |
| 841 | - private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') { |
|
| 841 | + private function getAirBerlin($callsign, $date = 'NOW', $carrier = 'AB') { |
|
| 842 | 842 | $Common = new Common(); |
| 843 | 843 | date_default_timezone_set('UTC'); |
| 844 | 844 | //AB = airberlin, HG/NLY = NIKI, 4T/BHP = Belair |
| 845 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
| 845 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
| 846 | 846 | $check_date = new Datetime($date); |
| 847 | - $url= "http://www.airberlin.com/en-US/site/aims.php"; |
|
| 848 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 849 | - $post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier); |
|
| 850 | - $data = $Common->getData($url,'post',$post); |
|
| 847 | + $url = "http://www.airberlin.com/en-US/site/aims.php"; |
|
| 848 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
| 849 | + $post = array('type' => 'departure', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => $carrier); |
|
| 850 | + $data = $Common->getData($url, 'post', $post); |
|
| 851 | 851 | //echo $data; |
| 852 | 852 | $DepartureAirportIata = ''; |
| 853 | 853 | $ArrivalAirportIata = ''; |
@@ -860,8 +860,8 @@ discard block |
||
| 860 | 860 | if (isset($flight[5][2])) $departureAirport = $flight[5][2]; |
| 861 | 861 | else $departureAirport = ''; |
| 862 | 862 | } else return array(); |
| 863 | - $post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB'); |
|
| 864 | - $data = $Common->getData($url,'post',$post); |
|
| 863 | + $post = array('type' => 'arrival', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => 'AB'); |
|
| 864 | + $data = $Common->getData($url, 'post', $post); |
|
| 865 | 865 | if ($data != '') { |
| 866 | 866 | $table = $Common->table2array($data); |
| 867 | 867 | $flight = $table; |
@@ -889,7 +889,7 @@ discard block |
||
| 889 | 889 | } |
| 890 | 890 | } |
| 891 | 891 | if (isset($DepartureAirportIata)) { |
| 892 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin'); |
|
| 892 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airberlin'); |
|
| 893 | 893 | } else return array(); |
| 894 | 894 | } |
| 895 | 895 | |
@@ -899,7 +899,7 @@ discard block |
||
| 899 | 899 | * @param String $date Date |
| 900 | 900 | * @return array Schedules info |
| 901 | 901 | */ |
| 902 | - public function fetchSchedule($ident,$date = 'NOW') { |
|
| 902 | + public function fetchSchedule($ident, $date = 'NOW') { |
|
| 903 | 903 | global $globalSchedulesSources, $globalSchedulesFetch, $globalOffline, $globalFlightAwareUsername; |
| 904 | 904 | //$Common = new Common(); |
| 905 | 905 | if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) return array(); |
@@ -969,7 +969,7 @@ discard block |
||
| 969 | 969 | // Brussels Airlines |
| 970 | 970 | case "BEL": |
| 971 | 971 | case "SN": |
| 972 | - return $this->getBrussels($ident,$date); |
|
| 972 | + return $this->getBrussels($ident, $date); |
|
| 973 | 973 | /* |
| 974 | 974 | // Copa Airlines |
| 975 | 975 | case "CMP": |
@@ -1068,7 +1068,7 @@ discard block |
||
| 1068 | 1068 | case "DS": |
| 1069 | 1069 | case "EZY": |
| 1070 | 1070 | case "EZS": |
| 1071 | - return $this->getEasyJet($ident,$date); |
|
| 1071 | + return $this->getEasyJet($ident, $date); |
|
| 1072 | 1072 | // Ryanair |
| 1073 | 1073 | case "FR": |
| 1074 | 1074 | case "RYR": |
@@ -1120,19 +1120,19 @@ discard block |
||
| 1120 | 1120 | return $this->getIberia($ident); |
| 1121 | 1121 | // Vietnam Airlines |
| 1122 | 1122 | case "HVN": |
| 1123 | - return $this->getVietnamAirlines($ident,$date); |
|
| 1123 | + return $this->getVietnamAirlines($ident, $date); |
|
| 1124 | 1124 | // Air Berlin |
| 1125 | 1125 | case "AB": |
| 1126 | 1126 | case "BER": |
| 1127 | - return $this->getAirBerlin($ident,$date,'AB'); |
|
| 1127 | + return $this->getAirBerlin($ident, $date, 'AB'); |
|
| 1128 | 1128 | // NIKI |
| 1129 | 1129 | case "HG": |
| 1130 | 1130 | case "NLY": |
| 1131 | - return $this->getAirBerlin($ident,$date,'HG'); |
|
| 1131 | + return $this->getAirBerlin($ident, $date, 'HG'); |
|
| 1132 | 1132 | // BelAir |
| 1133 | 1133 | case "4T": |
| 1134 | 1134 | case "BHP": |
| 1135 | - return $this->getAirBerlin($ident,$date,'4T'); |
|
| 1135 | + return $this->getAirBerlin($ident, $date, '4T'); |
|
| 1136 | 1136 | default: |
| 1137 | 1137 | if (strlen($airline_icao) == 3) { |
| 1138 | 1138 | $Spotter = new Spotter($this->db); |
@@ -1141,9 +1141,9 @@ discard block |
||
| 1141 | 1141 | } |
| 1142 | 1142 | // Randomly use a generic function to get hours |
| 1143 | 1143 | if (strlen($airline_icao) == 2) { |
| 1144 | - if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightaware'); |
|
| 1144 | + if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightaware'); |
|
| 1145 | 1145 | if (count($globalSchedulesSources) > 0) { |
| 1146 | - $rand = mt_rand(0,count($globalSchedulesSources)-1); |
|
| 1146 | + $rand = mt_rand(0, count($globalSchedulesSources) - 1); |
|
| 1147 | 1147 | $source = $globalSchedulesSources[$rand]; |
| 1148 | 1148 | if ($source == 'flightmapper') return $this->getFlightMapper($ident); |
| 1149 | 1149 | elseif ($source == 'costtotravel') return $this->getCostToTravel($ident); |
@@ -24,7 +24,9 @@ discard block |
||
| 24 | 24 | public function __construct($dbc = null) { |
| 25 | 25 | $Connection = new Connection($dbc); |
| 26 | 26 | $this->db = $Connection->db(); |
| 27 | - if ($this->db === null) die('Error: No DB connection.'); |
|
| 27 | + if ($this->db === null) { |
|
| 28 | + die('Error: No DB connection.'); |
|
| 29 | + } |
|
| 28 | 30 | } |
| 29 | 31 | |
| 30 | 32 | /** |
@@ -141,7 +143,9 @@ discard block |
||
| 141 | 143 | $sth->closeCursor(); |
| 142 | 144 | if (is_array($row) && count($row) > 0) { |
| 143 | 145 | return $row; |
| 144 | - } else return array(); |
|
| 146 | + } else { |
|
| 147 | + return array(); |
|
| 148 | + } |
|
| 145 | 149 | } |
| 146 | 150 | |
| 147 | 151 | /* |
@@ -182,7 +186,9 @@ discard block |
||
| 182 | 186 | $Common = new Common(); |
| 183 | 187 | $check_date = new Datetime($date); |
| 184 | 188 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 185 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 189 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 190 | + return array(); |
|
| 191 | + } |
|
| 186 | 192 | $url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym'); |
| 187 | 193 | $json = $Common->getData($url); |
| 188 | 194 | var_dump($json); |
@@ -209,7 +215,9 @@ discard block |
||
| 209 | 215 | */ |
| 210 | 216 | |
| 211 | 217 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance'); |
| 212 | - } else return array(); |
|
| 218 | + } else { |
|
| 219 | + return array(); |
|
| 220 | + } |
|
| 213 | 221 | } |
| 214 | 222 | |
| 215 | 223 | /** |
@@ -224,7 +232,9 @@ discard block |
||
| 224 | 232 | date_default_timezone_set($globalTimezone); |
| 225 | 233 | $check_date = new Datetime($date); |
| 226 | 234 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 227 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 235 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 236 | + return array(); |
|
| 237 | + } |
|
| 228 | 238 | $url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign; |
| 229 | 239 | $json = $Common->getData($url); |
| 230 | 240 | $parsed_json = json_decode($json); |
@@ -237,7 +247,9 @@ discard block |
||
| 237 | 247 | $arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'}; |
| 238 | 248 | |
| 239 | 249 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet'); |
| 240 | - } else return array(); |
|
| 250 | + } else { |
|
| 251 | + return array(); |
|
| 252 | + } |
|
| 241 | 253 | } |
| 242 | 254 | |
| 243 | 255 | /** |
@@ -248,7 +260,9 @@ discard block |
||
| 248 | 260 | private function getRyanair($callsign) { |
| 249 | 261 | $Common = new Common(); |
| 250 | 262 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 251 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 263 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 264 | + return array(); |
|
| 265 | + } |
|
| 252 | 266 | $url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/"; |
| 253 | 267 | $post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}'; |
| 254 | 268 | $headers = array('Content-Type: application/json','Content-Length: ' . strlen($post)); |
@@ -262,8 +276,12 @@ discard block |
||
| 262 | 276 | $departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'}; |
| 263 | 277 | $arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'}; |
| 264 | 278 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair'); |
| 265 | - } else return array(); |
|
| 266 | - } else return array(); |
|
| 279 | + } else { |
|
| 280 | + return array(); |
|
| 281 | + } |
|
| 282 | + } else { |
|
| 283 | + return array(); |
|
| 284 | + } |
|
| 267 | 285 | } |
| 268 | 286 | |
| 269 | 287 | /** |
@@ -274,7 +292,9 @@ discard block |
||
| 274 | 292 | private function getSwiss($callsign) { |
| 275 | 293 | $Common = new Common(); |
| 276 | 294 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 277 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 295 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 296 | + return array(); |
|
| 297 | + } |
|
| 278 | 298 | $url = "http://www.world-of-swiss.com/fr/routenetwork.json"; |
| 279 | 299 | $json = $Common->getData($url); |
| 280 | 300 | $parsed_json = json_decode($json); |
@@ -294,8 +314,12 @@ discard block |
||
| 294 | 314 | } |
| 295 | 315 | if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) { |
| 296 | 316 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss'); |
| 297 | - } else return array(); |
|
| 298 | - } else return array(); |
|
| 317 | + } else { |
|
| 318 | + return array(); |
|
| 319 | + } |
|
| 320 | + } else { |
|
| 321 | + return array(); |
|
| 322 | + } |
|
| 299 | 323 | } |
| 300 | 324 | |
| 301 | 325 | /** |
@@ -309,12 +333,18 @@ discard block |
||
| 309 | 333 | $Common = new Common(); |
| 310 | 334 | $check_date = new Datetime($date); |
| 311 | 335 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
| 312 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
| 313 | - if ($globalBritishAirwaysKey == '') return array(); |
|
| 336 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
| 337 | + return array(); |
|
| 338 | + } |
|
| 339 | + if ($globalBritishAirwaysKey == '') { |
|
| 340 | + return array(); |
|
| 341 | + } |
|
| 314 | 342 | $url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json"; |
| 315 | 343 | $headers = array('Client-Key: '.$globalBritishAirwaysKey); |
| 316 | 344 | $json = $Common->getData($url,'get','',$headers); |
| 317 | - if ($json == '') return array(); |
|
| 345 | + if ($json == '') { |
|
| 346 | + return array(); |
|
| 347 | + } |
|
| 318 | 348 | $parsed_json = json_decode($json); |
| 319 | 349 | $flights = $parsed_json->{'FlightsResponse'}; |
| 320 | 350 | if (count($flights) > 0) { |
@@ -323,7 +353,9 @@ discard block |
||
| 323 | 353 | $departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'})); |
| 324 | 354 | $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'})); |
| 325 | 355 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways'); |
| 326 | - } else return array(); |
|
| 356 | + } else { |
|
| 357 | + return array(); |
|
| 358 | + } |
|
| 327 | 359 | } |
| 328 | 360 | |
| 329 | 361 | /** |
@@ -337,19 +369,27 @@ discard block |
||
| 337 | 369 | $Common = new Common(); |
| 338 | 370 | $check_date = new Datetime($date); |
| 339 | 371 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
| 340 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
| 341 | - if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array(); |
|
| 372 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
| 373 | + return array(); |
|
| 374 | + } |
|
| 375 | + if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') { |
|
| 376 | + return array(); |
|
| 377 | + } |
|
| 342 | 378 | $url = "https://api.lufthansa.com/v1/oauth/token"; |
| 343 | 379 | $post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials'); |
| 344 | 380 | $data = $Common->getData($url,'post',$post); |
| 345 | 381 | $parsed_data = json_decode($data); |
| 346 | - if (!isset($parsed_data->{'access_token'})) return array(); |
|
| 382 | + if (!isset($parsed_data->{'access_token'})) { |
|
| 383 | + return array(); |
|
| 384 | + } |
|
| 347 | 385 | $token = $parsed_data->{'access_token'}; |
| 348 | 386 | |
| 349 | 387 | $url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d'); |
| 350 | 388 | $headers = array('Authorization: Bearer '.$token,'Accept: application/json'); |
| 351 | 389 | $json = $Common->getData($url,'get','',$headers); |
| 352 | - if ($json == '') return array(); |
|
| 390 | + if ($json == '') { |
|
| 391 | + return array(); |
|
| 392 | + } |
|
| 353 | 393 | $parsed_json = json_decode($json); |
| 354 | 394 | if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) { |
| 355 | 395 | $DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'}; |
@@ -357,7 +397,9 @@ discard block |
||
| 357 | 397 | $ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'}; |
| 358 | 398 | $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
| 359 | 399 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa'); |
| 360 | - } else return array(); |
|
| 400 | + } else { |
|
| 401 | + return array(); |
|
| 402 | + } |
|
| 361 | 403 | } |
| 362 | 404 | |
| 363 | 405 | /** |
@@ -371,14 +413,20 @@ discard block |
||
| 371 | 413 | $Common = new Common(); |
| 372 | 414 | $check_date = new Datetime($date); |
| 373 | 415 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
| 374 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
| 375 | - if ($globalTransaviaKey == '') return array(); |
|
| 416 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
| 417 | + return array(); |
|
| 418 | + } |
|
| 419 | + if ($globalTransaviaKey == '') { |
|
| 420 | + return array(); |
|
| 421 | + } |
|
| 376 | 422 | $url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
| 377 | 423 | //$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
| 378 | 424 | $headers = array('apikey: '.$globalTransaviaKey); |
| 379 | 425 | $json = $Common->getData($url,'get','',$headers); |
| 380 | 426 | //echo 'result : '.$json; |
| 381 | - if ($json == '') return array(); |
|
| 427 | + if ($json == '') { |
|
| 428 | + return array(); |
|
| 429 | + } |
|
| 382 | 430 | $parsed_json = json_decode($json); |
| 383 | 431 | |
| 384 | 432 | if (isset($parsed_json->{'data'}[0])) { |
@@ -387,7 +435,9 @@ discard block |
||
| 387 | 435 | $ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'}; |
| 388 | 436 | $arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'})); |
| 389 | 437 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia'); |
| 390 | - } else return array(); |
|
| 438 | + } else { |
|
| 439 | + return array(); |
|
| 440 | + } |
|
| 391 | 441 | } |
| 392 | 442 | |
| 393 | 443 | /** |
@@ -398,7 +448,9 @@ discard block |
||
| 398 | 448 | public function getTunisair($callsign) { |
| 399 | 449 | $Common = new Common(); |
| 400 | 450 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 401 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 451 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 452 | + return array(); |
|
| 453 | + } |
|
| 402 | 454 | $url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp"; |
| 403 | 455 | $data = $Common->getData($url); |
| 404 | 456 | $table = $Common->table2array($data); |
@@ -420,7 +472,9 @@ discard block |
||
| 420 | 472 | $Common = new Common(); |
| 421 | 473 | $check_date = new Datetime($date); |
| 422 | 474 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 423 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 475 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 476 | + return array(); |
|
| 477 | + } |
|
| 424 | 478 | $final_date = str_replace('/','%2F',$check_date->format('d/m/Y')); |
| 425 | 479 | $url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB"; |
| 426 | 480 | $data = $Common->getData($url); |
@@ -430,8 +484,11 @@ discard block |
||
| 430 | 484 | $DepartureAirportIata = str_replace('flightOri=','',$result[0]); |
| 431 | 485 | preg_match('/flightDest=[A-Z]{3}/',$data,$result); |
| 432 | 486 | $ArrivalAirportIata = str_replace('flightDest=','',$result[0]); |
| 433 | - if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling'); |
|
| 434 | - else return array(); |
|
| 487 | + if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') { |
|
| 488 | + return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling'); |
|
| 489 | + } else { |
|
| 490 | + return array(); |
|
| 491 | + } |
|
| 435 | 492 | } |
| 436 | 493 | return array(); |
| 437 | 494 | } |
@@ -446,7 +503,9 @@ discard block |
||
| 446 | 503 | $Common = new Common(); |
| 447 | 504 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 448 | 505 | $check_date = new Datetime($date); |
| 449 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 506 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 507 | + return array(); |
|
| 508 | + } |
|
| 450 | 509 | $url = "https://www.iberia.com/web/flightDetail.do"; |
| 451 | 510 | $post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB'); |
| 452 | 511 | $data = $Common->getData($url,'post',$post); |
@@ -463,7 +522,9 @@ discard block |
||
| 463 | 522 | $arrivalTime = trim(str_replace(' lunes','',str_replace(' ','',$flight[5][1]))); |
| 464 | 523 | if ($arrivalTime == 'Hora estimada de llegada') { |
| 465 | 524 | $arrivalTime = substr(trim(str_replace(' lunes','',str_replace(' ','',$flight[5][2]))),0,5); |
| 466 | - } else $arrivalTime = substr($arrivalTime,0,5); |
|
| 525 | + } else { |
|
| 526 | + $arrivalTime = substr($arrivalTime,0,5); |
|
| 527 | + } |
|
| 467 | 528 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia'); |
| 468 | 529 | } |
| 469 | 530 | } |
@@ -482,7 +543,9 @@ discard block |
||
| 482 | 543 | $Common = new Common(); |
| 483 | 544 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 484 | 545 | $check_date = new Datetime($date); |
| 485 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 546 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 547 | + return array(); |
|
| 548 | + } |
|
| 486 | 549 | $url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y'); |
| 487 | 550 | $data = $Common->getData($url); |
| 488 | 551 | if ($data != '') { |
@@ -498,7 +561,9 @@ discard block |
||
| 498 | 561 | $departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5); |
| 499 | 562 | $arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5); |
| 500 | 563 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance'); |
| 501 | - } else return array(); |
|
| 564 | + } else { |
|
| 565 | + return array(); |
|
| 566 | + } |
|
| 502 | 567 | } |
| 503 | 568 | |
| 504 | 569 | |
@@ -518,7 +583,9 @@ discard block |
||
| 518 | 583 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 519 | 584 | $check_date = new Datetime($date); |
| 520 | 585 | $url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y'); |
| 521 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 586 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 587 | + return array(); |
|
| 588 | + } |
|
| 522 | 589 | $data = $Common->getData($url); |
| 523 | 590 | if ($data != '') { |
| 524 | 591 | $table = $Common->text2array($data); |
@@ -543,7 +610,9 @@ discard block |
||
| 543 | 610 | $check_date = new Datetime($date); |
| 544 | 611 | $url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302"; |
| 545 | 612 | //http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber"; |
| 546 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 613 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 614 | + return array(); |
|
| 615 | + } |
|
| 547 | 616 | $data = $Common->getData($url); |
| 548 | 617 | if ($data != '') { |
| 549 | 618 | //echo $data; |
@@ -634,7 +703,9 @@ discard block |
||
| 634 | 703 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 635 | 704 | $url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees"; |
| 636 | 705 | //$check_date = new Datetime($date); |
| 637 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 706 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 707 | + return array(); |
|
| 708 | + } |
|
| 638 | 709 | $post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1'); |
| 639 | 710 | $data = $Common->getData($url,'post',$post); |
| 640 | 711 | if ($data != '') { |
@@ -666,11 +737,15 @@ discard block |
||
| 666 | 737 | $airline_icao = substr($callsign, 0, 3); |
| 667 | 738 | } |
| 668 | 739 | } |
| 669 | - if ($airline_icao == '') return array(); |
|
| 740 | + if ($airline_icao == '') { |
|
| 741 | + return array(); |
|
| 742 | + } |
|
| 670 | 743 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 671 | 744 | $url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol; |
| 672 | 745 | //$check_date = new Datetime($date); |
| 673 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 746 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 747 | + return array(); |
|
| 748 | + } |
|
| 674 | 749 | $data = $Common->getData($url); |
| 675 | 750 | if ($data != '') { |
| 676 | 751 | $table = $Common->table2array($data); |
@@ -763,10 +838,16 @@ discard block |
||
| 763 | 838 | if ($data != '') { |
| 764 | 839 | $table = $Common->table2array($data); |
| 765 | 840 | if (isset($table[11][1])) { |
| 766 | - if (is_numeric(substr($table[11][1],0,1))) $departureTime = substr($table[11][1],0,5); |
|
| 767 | - else $departureTime = ''; |
|
| 768 | - if (is_numeric(substr($table[17][1],0,1))) $arrivalTime = substr($table[17][1],0,5); |
|
| 769 | - else $arrivalTime = ''; |
|
| 841 | + if (is_numeric(substr($table[11][1],0,1))) { |
|
| 842 | + $departureTime = substr($table[11][1],0,5); |
|
| 843 | + } else { |
|
| 844 | + $departureTime = ''; |
|
| 845 | + } |
|
| 846 | + if (is_numeric(substr($table[17][1],0,1))) { |
|
| 847 | + $arrivalTime = substr($table[17][1],0,5); |
|
| 848 | + } else { |
|
| 849 | + $arrivalTime = ''; |
|
| 850 | + } |
|
| 770 | 851 | $DepartureAirportIata = substr($table[13][1],0,3); |
| 771 | 852 | $ArrivalAirportIata = substr($table[15][1],0,3); |
| 772 | 853 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_costtotravel'); |
@@ -783,16 +864,22 @@ discard block |
||
| 783 | 864 | */ |
| 784 | 865 | private function getAirCanada($callsign,$date = 'NOW') { |
| 785 | 866 | $Common = new Common(); |
| 786 | - if (class_exists("DomDocument") === FALSE) return array(); |
|
| 867 | + if (class_exists("DomDocument") === FALSE) { |
|
| 868 | + return array(); |
|
| 869 | + } |
|
| 787 | 870 | date_default_timezone_set('UTC'); |
| 788 | 871 | $check_date = new Datetime($date); |
| 789 | 872 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 790 | 873 | $url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249"; |
| 791 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 874 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 875 | + return array(); |
|
| 876 | + } |
|
| 792 | 877 | $data = $Common->getData($url); |
| 793 | 878 | $dom = new DomDocument(); |
| 794 | 879 | $dom->loadXML($data); |
| 795 | - if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) return array(); |
|
| 880 | + if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) { |
|
| 881 | + return array(); |
|
| 882 | + } |
|
| 796 | 883 | $departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0); |
| 797 | 884 | if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) { |
| 798 | 885 | $DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
@@ -801,7 +888,9 @@ discard block |
||
| 801 | 888 | $ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
| 802 | 889 | $arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
| 803 | 890 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada'); |
| 804 | - } else return array(); |
|
| 891 | + } else { |
|
| 892 | + return array(); |
|
| 893 | + } |
|
| 805 | 894 | } |
| 806 | 895 | |
| 807 | 896 | /** |
@@ -815,7 +904,9 @@ discard block |
||
| 815 | 904 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 816 | 905 | $check_date = new Datetime($date); |
| 817 | 906 | $url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&"; |
| 818 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 907 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 908 | + return array(); |
|
| 909 | + } |
|
| 819 | 910 | $data = $Common->getData($url); |
| 820 | 911 | if ($data != '') { |
| 821 | 912 | $table = $Common->table2array($data); |
@@ -845,7 +936,9 @@ discard block |
||
| 845 | 936 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
| 846 | 937 | $check_date = new Datetime($date); |
| 847 | 938 | $url= "http://www.airberlin.com/en-US/site/aims.php"; |
| 848 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
| 939 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
| 940 | + return array(); |
|
| 941 | + } |
|
| 849 | 942 | $post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier); |
| 850 | 943 | $data = $Common->getData($url,'post',$post); |
| 851 | 944 | //echo $data; |
@@ -855,11 +948,19 @@ discard block |
||
| 855 | 948 | if ($data != '') { |
| 856 | 949 | $table = $Common->table2array($data); |
| 857 | 950 | $flight = $table; |
| 858 | - if (isset($flight[5][4])) $departureTime = $flight[5][4]; |
|
| 859 | - else $departureTime = ''; |
|
| 860 | - if (isset($flight[5][2])) $departureAirport = $flight[5][2]; |
|
| 861 | - else $departureAirport = ''; |
|
| 862 | - } else return array(); |
|
| 951 | + if (isset($flight[5][4])) { |
|
| 952 | + $departureTime = $flight[5][4]; |
|
| 953 | + } else { |
|
| 954 | + $departureTime = ''; |
|
| 955 | + } |
|
| 956 | + if (isset($flight[5][2])) { |
|
| 957 | + $departureAirport = $flight[5][2]; |
|
| 958 | + } else { |
|
| 959 | + $departureAirport = ''; |
|
| 960 | + } |
|
| 961 | + } else { |
|
| 962 | + return array(); |
|
| 963 | + } |
|
| 863 | 964 | $post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB'); |
| 864 | 965 | $data = $Common->getData($url,'post',$post); |
| 865 | 966 | if ($data != '') { |
@@ -872,10 +973,14 @@ discard block |
||
| 872 | 973 | $arrivalTime = ''; |
| 873 | 974 | $arrivalAirport = ''; |
| 874 | 975 | } |
| 875 | - } else return array(); |
|
| 976 | + } else { |
|
| 977 | + return array(); |
|
| 978 | + } |
|
| 876 | 979 | $url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner'; |
| 877 | 980 | $json = $Common->getData($url); |
| 878 | - if ($json == '') return array(); |
|
| 981 | + if ($json == '') { |
|
| 982 | + return array(); |
|
| 983 | + } |
|
| 879 | 984 | $parsed_json = json_decode($json); |
| 880 | 985 | $airports = $parsed_json->{'suggestList'}; |
| 881 | 986 | if (count($airports) > 0) { |
@@ -890,7 +995,9 @@ discard block |
||
| 890 | 995 | } |
| 891 | 996 | if (isset($DepartureAirportIata)) { |
| 892 | 997 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin'); |
| 893 | - } else return array(); |
|
| 998 | + } else { |
|
| 999 | + return array(); |
|
| 1000 | + } |
|
| 894 | 1001 | } |
| 895 | 1002 | |
| 896 | 1003 | /* |
@@ -902,7 +1009,9 @@ discard block |
||
| 902 | 1009 | public function fetchSchedule($ident,$date = 'NOW') { |
| 903 | 1010 | global $globalSchedulesSources, $globalSchedulesFetch, $globalOffline, $globalFlightAwareUsername; |
| 904 | 1011 | //$Common = new Common(); |
| 905 | - if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) return array(); |
|
| 1012 | + if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) { |
|
| 1013 | + return array(); |
|
| 1014 | + } |
|
| 906 | 1015 | $airline_icao = ''; |
| 907 | 1016 | if (!is_numeric(substr($ident, 0, 3))) |
| 908 | 1017 | { |
@@ -1137,18 +1246,27 @@ discard block |
||
| 1137 | 1246 | if (strlen($airline_icao) == 3) { |
| 1138 | 1247 | $Spotter = new Spotter($this->db); |
| 1139 | 1248 | $airline_info = $Spotter->getAllAirlineInfo($airline_icao); |
| 1140 | - if (isset($airline_info[0]['iata'])) $airline_icao = $airline_info[0]['iata']; |
|
| 1249 | + if (isset($airline_info[0]['iata'])) { |
|
| 1250 | + $airline_icao = $airline_info[0]['iata']; |
|
| 1251 | + } |
|
| 1141 | 1252 | } |
| 1142 | 1253 | // Randomly use a generic function to get hours |
| 1143 | 1254 | if (strlen($airline_icao) == 2) { |
| 1144 | - if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightaware'); |
|
| 1255 | + if (!isset($globalSchedulesSources)) { |
|
| 1256 | + $globalSchedulesSources = array('flightmapper','costtotravel','flightaware'); |
|
| 1257 | + } |
|
| 1145 | 1258 | if (count($globalSchedulesSources) > 0) { |
| 1146 | 1259 | $rand = mt_rand(0,count($globalSchedulesSources)-1); |
| 1147 | 1260 | $source = $globalSchedulesSources[$rand]; |
| 1148 | - if ($source == 'flightmapper') return $this->getFlightMapper($ident); |
|
| 1149 | - elseif ($source == 'costtotravel') return $this->getCostToTravel($ident); |
|
| 1261 | + if ($source == 'flightmapper') { |
|
| 1262 | + return $this->getFlightMapper($ident); |
|
| 1263 | + } elseif ($source == 'costtotravel') { |
|
| 1264 | + return $this->getCostToTravel($ident); |
|
| 1265 | + } |
|
| 1150 | 1266 | //elseif ($source == 'flightradar24') return $this->getFlightRadar24($ident,$date); |
| 1151 | - elseif ($source == 'flightaware' && $globalFlightAwareUsername != '') return $this->getFlightAware($ident); |
|
| 1267 | + elseif ($source == 'flightaware' && $globalFlightAwareUsername != '') { |
|
| 1268 | + return $this->getFlightAware($ident); |
|
| 1269 | + } |
|
| 1152 | 1270 | } |
| 1153 | 1271 | } |
| 1154 | 1272 | } |
@@ -36,12 +36,12 @@ discard block |
||
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | - * Get Accidents data from DB |
|
| 40 | - * @param String $limit Limit |
|
| 41 | - * @param String $type Set type accident or incident |
|
| 42 | - * @param String $date get data for a date |
|
| 43 | - * @return array Return Accidents data in array |
|
| 44 | - */ |
|
| 39 | + * Get Accidents data from DB |
|
| 40 | + * @param String $limit Limit |
|
| 41 | + * @param String $type Set type accident or incident |
|
| 42 | + * @param String $date get data for a date |
|
| 43 | + * @return array Return Accidents data in array |
|
| 44 | + */ |
|
| 45 | 45 | public function getAccidentData($limit = '',$type = '',$date = '') { |
| 46 | 46 | global $globalDBdriver; |
| 47 | 47 | $Image = new Image($this->db); |
@@ -384,11 +384,11 @@ discard block |
||
| 384 | 384 | return $row['nb']; |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | - /** |
|
| 388 | - * Check if lastest accident update date is older than 1 day |
|
| 389 | - * @return bool|string |
|
| 390 | - */ |
|
| 391 | - public static function check_last_accidents_update() { |
|
| 387 | + /** |
|
| 388 | + * Check if lastest accident update date is older than 1 day |
|
| 389 | + * @return bool|string |
|
| 390 | + */ |
|
| 391 | + public static function check_last_accidents_update() { |
|
| 392 | 392 | global $globalDBdriver; |
| 393 | 393 | if ($globalDBdriver == 'mysql') { |
| 394 | 394 | $query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_accident_db' AND value > DATE_SUB(NOW(), INTERVAL 1 DAY)"; |
@@ -407,11 +407,11 @@ discard block |
||
| 407 | 407 | else return true; |
| 408 | 408 | } |
| 409 | 409 | |
| 410 | - /** |
|
| 411 | - * Insert accident update date |
|
| 412 | - * @return string |
|
| 413 | - */ |
|
| 414 | - public static function insert_last_accidents_update() { |
|
| 410 | + /** |
|
| 411 | + * Insert accident update date |
|
| 412 | + * @return string |
|
| 413 | + */ |
|
| 414 | + public static function insert_last_accidents_update() { |
|
| 415 | 415 | $query = "DELETE FROM config WHERE name = 'last_update_accident_db'; |
| 416 | 416 | INSERT INTO config (name,value) VALUES ('last_update_accident_db',NOW());"; |
| 417 | 417 | try { |
@@ -42,20 +42,20 @@ discard block |
||
| 42 | 42 | * @param String $date get data for a date |
| 43 | 43 | * @return array Return Accidents data in array |
| 44 | 44 | */ |
| 45 | - public function getAccidentData($limit = '',$type = '',$date = '') { |
|
| 45 | + public function getAccidentData($limit = '', $type = '', $date = '') { |
|
| 46 | 46 | global $globalDBdriver; |
| 47 | 47 | $Image = new Image($this->db); |
| 48 | 48 | $Spotter = new Spotter($this->db); |
| 49 | 49 | $Translation = new Translation($this->db); |
| 50 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
| 50 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
| 51 | 51 | date_default_timezone_set('UTC'); |
| 52 | 52 | $result = array(); |
| 53 | 53 | $limit_query = ''; |
| 54 | 54 | if ($limit != "") |
| 55 | 55 | { |
| 56 | 56 | $limit_array = explode(",", $limit); |
| 57 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 58 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 57 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 58 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 59 | 59 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 60 | 60 | { |
| 61 | 61 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -64,29 +64,29 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | if ($type != '') { |
| 66 | 66 | if ($date != '') { |
| 67 | - if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) { |
|
| 67 | + if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) { |
|
| 68 | 68 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 69 | 69 | //$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 70 | - $query_values = array(':type' => $type,':date' => $date); |
|
| 71 | - } elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/",$date)) { |
|
| 70 | + $query_values = array(':type' => $type, ':date' => $date); |
|
| 71 | + } elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/", $date)) { |
|
| 72 | 72 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date BETWEEN :dated AND :datef GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 73 | - $query_values = array(':type' => $type,':dated' => $date.'-01', ':datef' => $date.'-31'); |
|
| 74 | - } elseif (preg_match("/^[0-9]{4}$/",$date)) { |
|
| 73 | + $query_values = array(':type' => $type, ':dated' => $date.'-01', ':datef' => $date.'-31'); |
|
| 74 | + } elseif (preg_match("/^[0-9]{4}$/", $date)) { |
|
| 75 | 75 | if ($globalDBdriver == 'mysql') { |
| 76 | 76 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND YEAR(date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 77 | 77 | } else { |
| 78 | 78 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND EXTRACT(YEAR FROM date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 79 | 79 | } |
| 80 | - $query_values = array(':type' => $type,':date' => $date); |
|
| 80 | + $query_values = array(':type' => $type, ':date' => $date); |
|
| 81 | 81 | } else { |
| 82 | 82 | $date = $date.'%'; |
| 83 | 83 | if ($globalDBdriver == 'mysql') { |
| 84 | 84 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND DATE_FORMAT(date,'%Y-%m-%d') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 85 | - $query_values = array(':type' => $type,':date' => $date); |
|
| 85 | + $query_values = array(':type' => $type, ':date' => $date); |
|
| 86 | 86 | } else { |
| 87 | 87 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 88 | 88 | //$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 89 | - $query_values = array(':type' => $type,':date' => $date); |
|
| 89 | + $query_values = array(':type' => $type, ':date' => $date); |
|
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | } else { |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | } else { |
| 99 | 99 | if ($date != '') { |
| 100 | - if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) { |
|
| 100 | + if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) { |
|
| 101 | 101 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 102 | 102 | //$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 103 | 103 | } else { |
@@ -116,18 +116,18 @@ discard block |
||
| 116 | 116 | try { |
| 117 | 117 | $sth = $this->db->prepare($query); |
| 118 | 118 | $sth->execute($query_values); |
| 119 | - } catch(PDOException $e) { |
|
| 119 | + } catch (PDOException $e) { |
|
| 120 | 120 | echo "error : ".$e->getMessage(); |
| 121 | 121 | return array(); |
| 122 | 122 | } |
| 123 | 123 | $i = 0; |
| 124 | 124 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 125 | - if (preg_match('/^[\w\-]+$/',$row['registration'])) { |
|
| 125 | + if (preg_match('/^[\w\-]+$/', $row['registration'])) { |
|
| 126 | 126 | $data = array(); |
| 127 | 127 | if ($row['registration'] != '') { |
| 128 | 128 | $image_array = $Image->getSpotterImage($row['registration']); |
| 129 | - if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
| 130 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 129 | + if (count($image_array) > 0) $data = array_merge($data, array('image' => $image_array[0]['image'], 'image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website'])); |
|
| 130 | + else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
| 131 | 131 | $aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']); |
| 132 | 132 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type); |
| 133 | 133 | if (!empty($aircraft_info)) { |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | $data['aircraft_name'] = $aircraft_info[0]['type']; |
| 136 | 136 | $data['aircraft_manufacturer'] = $aircraft_info[0]['manufacturer']; |
| 137 | 137 | } else { |
| 138 | - $data = array_merge($data,array('aircraft_type' => 'NA')); |
|
| 138 | + $data = array_merge($data, array('aircraft_type' => 'NA')); |
|
| 139 | 139 | } |
| 140 | 140 | $owner_data = $Spotter->getAircraftOwnerByRegistration($row['registration']); |
| 141 | 141 | if (!empty($owner_data)) { |
@@ -143,18 +143,18 @@ discard block |
||
| 143 | 143 | $data['aircraft_base'] = $owner_data['base']; |
| 144 | 144 | $data['aircraft_date_first_reg'] = $owner_data['date_first_reg']; |
| 145 | 145 | } |
| 146 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 146 | + } else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
| 147 | 147 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
| 148 | 148 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
| 149 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3)); |
|
| 149 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 3)); |
|
| 150 | 150 | if (isset($identicao[0])) { |
| 151 | - if (substr($row['ident'],0,2) == 'AF') { |
|
| 152 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 153 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 154 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 155 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
| 151 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
| 152 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 153 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
| 154 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
| 155 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
| 156 | 156 | } else $icao = $row['ident']; |
| 157 | - $icao = $Translation->checkTranslation($icao,false); |
|
| 157 | + $icao = $Translation->checkTranslation($icao, false); |
|
| 158 | 158 | //$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url'])); |
| 159 | 159 | if ($row['airline_name'] != '' && !isset($data['airline_name'])) { |
| 160 | 160 | //echo 'Check airline info... for '.$row['airline_name'].' '; |
@@ -163,16 +163,16 @@ discard block |
||
| 163 | 163 | if (!empty($airline_info)) { |
| 164 | 164 | //echo 'data found !'."\n"; |
| 165 | 165 | //print_r($airline_info); |
| 166 | - $data = array_merge($data,$airline_info); |
|
| 166 | + $data = array_merge($data, $airline_info); |
|
| 167 | 167 | } |
| 168 | 168 | //else echo 'No data...'."\n"; |
| 169 | 169 | } |
| 170 | - $data = array_merge($row,$data); |
|
| 170 | + $data = array_merge($row, $data); |
|
| 171 | 171 | if ($data['ident'] == null) $data['ident'] = $icao; |
| 172 | 172 | if ($data['title'] == null) { |
| 173 | 173 | $data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country']; |
| 174 | 174 | } else $data['message'] = strtolower($data['title']); |
| 175 | - $ids = $Spotter->getAllIDByRegistration($data['registration'],true); |
|
| 175 | + $ids = $Spotter->getAllIDByRegistration($data['registration'], true); |
|
| 176 | 176 | $date = $data['date']; |
| 177 | 177 | if (isset($ids[$date])) { |
| 178 | 178 | $data['spotted'] = TRUE; |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | try { |
| 205 | 205 | $sth = $this->db->prepare($query); |
| 206 | 206 | $sth->execute(); |
| 207 | - } catch(PDOException $e) { |
|
| 207 | + } catch (PDOException $e) { |
|
| 208 | 208 | echo "Error : ".$e->getMessage(); |
| 209 | 209 | return array(); |
| 210 | 210 | } |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | try { |
| 226 | 226 | $sth = $this->db->prepare($query); |
| 227 | 227 | $sth->execute(); |
| 228 | - } catch(PDOException $e) { |
|
| 228 | + } catch (PDOException $e) { |
|
| 229 | 229 | echo "Error : ".$e->getMessage(); |
| 230 | 230 | return array(); |
| 231 | 231 | } |
@@ -241,15 +241,15 @@ discard block |
||
| 241 | 241 | if ($globalDebug) echo 'Import '.$file."\n"; |
| 242 | 242 | $result = array(); |
| 243 | 243 | if (file_exists($file)) { |
| 244 | - if (($handle = fopen($file,'r')) !== FALSE) { |
|
| 245 | - while (($data = fgetcsv($handle,2000,",")) !== FALSE) { |
|
| 244 | + if (($handle = fopen($file, 'r')) !== FALSE) { |
|
| 245 | + while (($data = fgetcsv($handle, 2000, ",")) !== FALSE) { |
|
| 246 | 246 | if (isset($data[1]) && $data[1] != '0000-00-00 00:00:00') { |
| 247 | - $result[] = array('registration' => $data[0],'date' => strtotime($data[1]),'url' => $data[2],'country' => $data[3],'place' => $data[4],'title' => $data[5],'fatalities' => $data[6],'latitude' => $data[7],'longitude' => $data[8],'type' => $data[9],'ident' => $data[10],'aircraft_manufacturer' => $data[11],'aircraft_name' => $data[12],'operator' => $data[13],'source' => 'website_fam'); |
|
| 247 | + $result[] = array('registration' => $data[0], 'date' => strtotime($data[1]), 'url' => $data[2], 'country' => $data[3], 'place' => $data[4], 'title' => $data[5], 'fatalities' => $data[6], 'latitude' => $data[7], 'longitude' => $data[8], 'type' => $data[9], 'ident' => $data[10], 'aircraft_manufacturer' => $data[11], 'aircraft_name' => $data[12], 'operator' => $data[13], 'source' => 'website_fam'); |
|
| 248 | 248 | } |
| 249 | 249 | } |
| 250 | 250 | fclose($handle); |
| 251 | 251 | } |
| 252 | - if (!empty($result)) $this->add($result,true); |
|
| 252 | + if (!empty($result)) $this->add($result, true); |
|
| 253 | 253 | elseif ($globalDebug) echo 'Nothing to import'; |
| 254 | 254 | } |
| 255 | 255 | } |
@@ -265,8 +265,8 @@ discard block |
||
| 265 | 265 | $all_md5_new = array(); |
| 266 | 266 | if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) { |
| 267 | 267 | if ($this->check_accidents_nb() > 0) { |
| 268 | - if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) { |
|
| 269 | - while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) { |
|
| 268 | + if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) { |
|
| 269 | + while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) { |
|
| 270 | 270 | if (isset($data[1])) { |
| 271 | 271 | $year = $data[0]; |
| 272 | 272 | $all_md5[$year] = $data[1]; |
@@ -276,10 +276,10 @@ discard block |
||
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | 278 | } |
| 279 | - $Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5',dirname(__FILE__).'/../install/tmp/cr-all.md5'); |
|
| 279 | + $Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5', dirname(__FILE__).'/../install/tmp/cr-all.md5'); |
|
| 280 | 280 | if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) { |
| 281 | - if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) { |
|
| 282 | - while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) { |
|
| 281 | + if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) { |
|
| 282 | + while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) { |
|
| 283 | 283 | if (isset($data[1])) { |
| 284 | 284 | $year = $data[0]; |
| 285 | 285 | $all_md5_new[$year] = $data[1]; |
@@ -288,10 +288,10 @@ discard block |
||
| 288 | 288 | fclose($handle); |
| 289 | 289 | } elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
| 290 | 290 | } elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
| 291 | - $result = $Common->arr_diff($all_md5_new,$all_md5); |
|
| 291 | + $result = $Common->arr_diff($all_md5_new, $all_md5); |
|
| 292 | 292 | if (empty($result) && $globalDebug) echo 'Nothing to update'; |
| 293 | 293 | foreach ($result as $file => $md5) { |
| 294 | - $Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file); |
|
| 294 | + $Common->download('http://data.flightairmap.fr/data/cr/'.$file, dirname(__FILE__).'/../install/tmp/'.$file); |
|
| 295 | 295 | if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
| 296 | 296 | elseif ($globalDebug) echo 'Download '.$file.' failed'; |
| 297 | 297 | } |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | * Add data to DB |
| 302 | 302 | * @param Array $crash An array with accidents/incidents data |
| 303 | 303 | */ |
| 304 | - public function add($crash,$new = false) { |
|
| 304 | + public function add($crash, $new = false) { |
|
| 305 | 305 | global $globalTransaction, $globalDebug, $globalAircraftImageFetch; |
| 306 | 306 | require_once('class.Connection.php'); |
| 307 | 307 | require_once('class.Image.php'); |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | $sthd->execute(array(':source' => $crash[0]['source'])); |
| 318 | 318 | } |
| 319 | 319 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 320 | - $initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null); |
|
| 320 | + $initial_array = array('ident' => null, 'type' => 'accident', 'url' => null, 'registration' => null, 'date' => null, 'place' => null, 'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '', 'source' => '', 'aircraft_manufacturer' => null, 'aircraft_name' => null, 'operator' => null); |
|
| 321 | 321 | $query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source'; |
| 322 | 322 | $sth_check = $Connection->db->prepare($query_check); |
| 323 | 323 | $query = 'INSERT INTO accidents (aircraft_manufacturer,aircraft_name,ident,registration,date,url,country,place,title,fatalities,latitude,longitude,type,airline_name,source) VALUES (:aircraft_manufacturer,:aircraft_name,:ident,:registration,:date,:url,:country,:place,:title,:fatalities,:latitude,:longitude,:type,:airline_name,:source)'; |
@@ -330,15 +330,15 @@ discard block |
||
| 330 | 330 | $cr = array_map(function($value) { |
| 331 | 331 | return $value === "" ? NULL : $value; |
| 332 | 332 | }, $cr); |
| 333 | - if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) { |
|
| 334 | - if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
| 335 | - $query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']); |
|
| 333 | + if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/', $cr['registration'])) { |
|
| 334 | + if (strpos($cr['registration'], '-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
| 335 | + $query_check_values = array(':registration' => $cr['registration'], ':date' => date('Y-m-d', $cr['date']), ':type' => $cr['type'], ':source' => $cr['source']); |
|
| 336 | 336 | $sth_check->execute($query_check_values); |
| 337 | 337 | $result_check = $sth_check->fetchAll(PDO::FETCH_ASSOC); |
| 338 | 338 | if ($result_check[0]['nb'] == 0) { |
| 339 | - $query_values = array(':registration' => trim($cr['registration']),':date' => date('Y-m-d',$cr['date']),':url' => $cr['url'],':country' => $cr['country'],':place' => $cr['place'],':title' => $cr['title'],':fatalities' => $cr['fatalities'],':latitude' => $cr['latitude'],':longitude' => $cr['longitude'],':type' => $cr['type'],':source' => $cr['source'],':ident' => $cr['ident'],':aircraft_manufacturer' => $cr['aircraft_manufacturer'],':aircraft_name' => $cr['aircraft_name'],':airline_name' => $cr['operator']); |
|
| 339 | + $query_values = array(':registration' => trim($cr['registration']), ':date' => date('Y-m-d', $cr['date']), ':url' => $cr['url'], ':country' => $cr['country'], ':place' => $cr['place'], ':title' => $cr['title'], ':fatalities' => $cr['fatalities'], ':latitude' => $cr['latitude'], ':longitude' => $cr['longitude'], ':type' => $cr['type'], ':source' => $cr['source'], ':ident' => $cr['ident'], ':aircraft_manufacturer' => $cr['aircraft_manufacturer'], ':aircraft_name' => $cr['aircraft_name'], ':airline_name' => $cr['operator']); |
|
| 340 | 340 | $sth->execute($query_values); |
| 341 | - if ($cr['date'] > time()-(30*86400)) { |
|
| 341 | + if ($cr['date'] > time() - (30*86400)) { |
|
| 342 | 342 | if ($globalAircraftImageFetch) { |
| 343 | 343 | $imgchk = $Image->getSpotterImage($cr['registration']); |
| 344 | 344 | if (empty($imgchk)) { |
@@ -349,17 +349,17 @@ discard block |
||
| 349 | 349 | // elseif ($globalDebug) echo 'Image already in DB'."\n"; |
| 350 | 350 | } |
| 351 | 351 | if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type']; |
| 352 | - $Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date'])); |
|
| 352 | + $Spotter->setHighlightFlightByRegistration($cr['registration'], $cr['title'], date('Y-m-d', $cr['date'])); |
|
| 353 | 353 | } |
| 354 | 354 | } |
| 355 | 355 | } |
| 356 | - if ($globalTransaction && $j % 1000 == 0) { |
|
| 356 | + if ($globalTransaction && $j%1000 == 0) { |
|
| 357 | 357 | $Connection->db->commit(); |
| 358 | 358 | $Connection->db->beginTransaction(); |
| 359 | 359 | } |
| 360 | 360 | } |
| 361 | 361 | if ($globalTransaction) $Connection->db->commit(); |
| 362 | - } catch(PDOException $e) { |
|
| 362 | + } catch (PDOException $e) { |
|
| 363 | 363 | if ($globalTransaction) $Connection->db->rollBack(); |
| 364 | 364 | echo $e->getMessage(); |
| 365 | 365 | } |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | $Connection = new Connection(); |
| 378 | 378 | $sth = $Connection->db->prepare($query); |
| 379 | 379 | $sth->execute(); |
| 380 | - } catch(PDOException $e) { |
|
| 380 | + } catch (PDOException $e) { |
|
| 381 | 381 | return "error : ".$e->getMessage(); |
| 382 | 382 | } |
| 383 | 383 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | $Connection = new Connection(); |
| 400 | 400 | $sth = $Connection->db->prepare($query); |
| 401 | 401 | $sth->execute(); |
| 402 | - } catch(PDOException $e) { |
|
| 402 | + } catch (PDOException $e) { |
|
| 403 | 403 | return "error : ".$e->getMessage(); |
| 404 | 404 | } |
| 405 | 405 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | $Connection = new Connection(); |
| 419 | 419 | $sth = $Connection->db->prepare($query); |
| 420 | 420 | $sth->execute(); |
| 421 | - } catch(PDOException $e) { |
|
| 421 | + } catch (PDOException $e) { |
|
| 422 | 422 | return "error : ".$e->getMessage(); |
| 423 | 423 | } |
| 424 | 424 | return ''; |
@@ -20,7 +20,9 @@ discard block |
||
| 20 | 20 | public function __construct($dbc = null) { |
| 21 | 21 | $Connection = new Connection($dbc); |
| 22 | 22 | $this->db = $Connection->db(); |
| 23 | - if ($this->db === null) die('Error: No DB connection. (Accident)'); |
|
| 23 | + if ($this->db === null) { |
|
| 24 | + die('Error: No DB connection. (Accident)'); |
|
| 25 | + } |
|
| 24 | 26 | } |
| 25 | 27 | |
| 26 | 28 | /* |
@@ -126,8 +128,11 @@ discard block |
||
| 126 | 128 | $data = array(); |
| 127 | 129 | if ($row['registration'] != '') { |
| 128 | 130 | $image_array = $Image->getSpotterImage($row['registration']); |
| 129 | - if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
| 130 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 131 | + if (count($image_array) > 0) { |
|
| 132 | + $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
| 133 | + } else { |
|
| 134 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 135 | + } |
|
| 131 | 136 | $aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']); |
| 132 | 137 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type); |
| 133 | 138 | if (!empty($aircraft_info)) { |
@@ -143,17 +148,30 @@ discard block |
||
| 143 | 148 | $data['aircraft_base'] = $owner_data['base']; |
| 144 | 149 | $data['aircraft_date_first_reg'] = $owner_data['date_first_reg']; |
| 145 | 150 | } |
| 146 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 147 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
| 148 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
| 151 | + } else { |
|
| 152 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 153 | + } |
|
| 154 | + if ($row['registration'] == '') { |
|
| 155 | + $row['registration'] = 'NA'; |
|
| 156 | + } |
|
| 157 | + if ($row['ident'] == '') { |
|
| 158 | + $row['ident'] = 'NA'; |
|
| 159 | + } |
|
| 149 | 160 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3)); |
| 150 | 161 | if (isset($identicao[0])) { |
| 151 | 162 | if (substr($row['ident'],0,2) == 'AF') { |
| 152 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 153 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 154 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 163 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
| 164 | + $icao = $row['ident']; |
|
| 165 | + } else { |
|
| 166 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 167 | + } |
|
| 168 | + } else { |
|
| 169 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 170 | + } |
|
| 155 | 171 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
| 156 | - } else $icao = $row['ident']; |
|
| 172 | + } else { |
|
| 173 | + $icao = $row['ident']; |
|
| 174 | + } |
|
| 157 | 175 | $icao = $Translation->checkTranslation($icao,false); |
| 158 | 176 | //$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url'])); |
| 159 | 177 | if ($row['airline_name'] != '' && !isset($data['airline_name'])) { |
@@ -168,10 +186,14 @@ discard block |
||
| 168 | 186 | //else echo 'No data...'."\n"; |
| 169 | 187 | } |
| 170 | 188 | $data = array_merge($row,$data); |
| 171 | - if ($data['ident'] == null) $data['ident'] = $icao; |
|
| 189 | + if ($data['ident'] == null) { |
|
| 190 | + $data['ident'] = $icao; |
|
| 191 | + } |
|
| 172 | 192 | if ($data['title'] == null) { |
| 173 | 193 | $data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country']; |
| 174 | - } else $data['message'] = strtolower($data['title']); |
|
| 194 | + } else { |
|
| 195 | + $data['message'] = strtolower($data['title']); |
|
| 196 | + } |
|
| 175 | 197 | $ids = $Spotter->getAllIDByRegistration($data['registration'],true); |
| 176 | 198 | $date = $data['date']; |
| 177 | 199 | if (isset($ids[$date])) { |
@@ -190,8 +212,9 @@ discard block |
||
| 190 | 212 | if (isset($result)) { |
| 191 | 213 | $result[0]['query_number_rows'] = $i; |
| 192 | 214 | return $result; |
| 215 | + } else { |
|
| 216 | + return array(); |
|
| 193 | 217 | } |
| 194 | - else return array(); |
|
| 195 | 218 | } |
| 196 | 219 | |
| 197 | 220 | /* |
@@ -238,7 +261,9 @@ discard block |
||
| 238 | 261 | */ |
| 239 | 262 | public function import($file) { |
| 240 | 263 | global $globalDebug; |
| 241 | - if ($globalDebug) echo 'Import '.$file."\n"; |
|
| 264 | + if ($globalDebug) { |
|
| 265 | + echo 'Import '.$file."\n"; |
|
| 266 | + } |
|
| 242 | 267 | $result = array(); |
| 243 | 268 | if (file_exists($file)) { |
| 244 | 269 | if (($handle = fopen($file,'r')) !== FALSE) { |
@@ -249,8 +274,11 @@ discard block |
||
| 249 | 274 | } |
| 250 | 275 | fclose($handle); |
| 251 | 276 | } |
| 252 | - if (!empty($result)) $this->add($result,true); |
|
| 253 | - elseif ($globalDebug) echo 'Nothing to import'; |
|
| 277 | + if (!empty($result)) { |
|
| 278 | + $this->add($result,true); |
|
| 279 | + } elseif ($globalDebug) { |
|
| 280 | + echo 'Nothing to import'; |
|
| 281 | + } |
|
| 254 | 282 | } |
| 255 | 283 | } |
| 256 | 284 | |
@@ -286,14 +314,23 @@ discard block |
||
| 286 | 314 | } |
| 287 | 315 | } |
| 288 | 316 | fclose($handle); |
| 289 | - } elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
|
| 290 | - } elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
|
| 317 | + } elseif ($globalDebug) { |
|
| 318 | + echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
|
| 319 | + } |
|
| 320 | + } elseif ($globalDebug) { |
|
| 321 | + echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
|
| 322 | + } |
|
| 291 | 323 | $result = $Common->arr_diff($all_md5_new,$all_md5); |
| 292 | - if (empty($result) && $globalDebug) echo 'Nothing to update'; |
|
| 324 | + if (empty($result) && $globalDebug) { |
|
| 325 | + echo 'Nothing to update'; |
|
| 326 | + } |
|
| 293 | 327 | foreach ($result as $file => $md5) { |
| 294 | 328 | $Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file); |
| 295 | - if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
|
| 296 | - elseif ($globalDebug) echo 'Download '.$file.' failed'; |
|
| 329 | + if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) { |
|
| 330 | + $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
|
| 331 | + } elseif ($globalDebug) { |
|
| 332 | + echo 'Download '.$file.' failed'; |
|
| 333 | + } |
|
| 297 | 334 | } |
| 298 | 335 | } |
| 299 | 336 | |
@@ -310,13 +347,17 @@ discard block |
||
| 310 | 347 | $Image = new Image($this->db); |
| 311 | 348 | $Spotter = new Spotter($this->db); |
| 312 | 349 | |
| 313 | - if (empty($crash)) return false; |
|
| 350 | + if (empty($crash)) { |
|
| 351 | + return false; |
|
| 352 | + } |
|
| 314 | 353 | if ($new === false) { |
| 315 | 354 | $query_delete = 'DELETE FROM accidents WHERE source = :source'; |
| 316 | 355 | $sthd = $Connection->db->prepare($query_delete); |
| 317 | 356 | $sthd->execute(array(':source' => $crash[0]['source'])); |
| 318 | 357 | } |
| 319 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 358 | + if ($globalTransaction) { |
|
| 359 | + $Connection->db->beginTransaction(); |
|
| 360 | + } |
|
| 320 | 361 | $initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null); |
| 321 | 362 | $query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source'; |
| 322 | 363 | $sth_check = $Connection->db->prepare($query_check); |
@@ -331,7 +372,9 @@ discard block |
||
| 331 | 372 | return $value === "" ? NULL : $value; |
| 332 | 373 | }, $cr); |
| 333 | 374 | if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) { |
| 334 | - if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
| 375 | + if (strpos($cr['registration'],'-') === FALSE) { |
|
| 376 | + $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
| 377 | + } |
|
| 335 | 378 | $query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']); |
| 336 | 379 | $sth_check->execute($query_check_values); |
| 337 | 380 | $result_check = $sth_check->fetchAll(PDO::FETCH_ASSOC); |
@@ -342,13 +385,19 @@ discard block |
||
| 342 | 385 | if ($globalAircraftImageFetch) { |
| 343 | 386 | $imgchk = $Image->getSpotterImage($cr['registration']); |
| 344 | 387 | if (empty($imgchk)) { |
| 345 | - if ($globalDebug) echo "\t".'Get image for '.$cr['registration'].'...'; |
|
| 388 | + if ($globalDebug) { |
|
| 389 | + echo "\t".'Get image for '.$cr['registration'].'...'; |
|
| 390 | + } |
|
| 346 | 391 | $Image->addSpotterImage($cr['registration']); |
| 347 | - if ($globalDebug) echo "\t".'Done'."\n"; |
|
| 392 | + if ($globalDebug) { |
|
| 393 | + echo "\t".'Done'."\n"; |
|
| 394 | + } |
|
| 348 | 395 | } |
| 349 | 396 | // elseif ($globalDebug) echo 'Image already in DB'."\n"; |
| 350 | 397 | } |
| 351 | - if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type']; |
|
| 398 | + if ($cr['title'] == '') { |
|
| 399 | + $cr['title'] = $cr['registration'].' '.$cr['type']; |
|
| 400 | + } |
|
| 352 | 401 | $Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date'])); |
| 353 | 402 | } |
| 354 | 403 | } |
@@ -358,9 +407,13 @@ discard block |
||
| 358 | 407 | $Connection->db->beginTransaction(); |
| 359 | 408 | } |
| 360 | 409 | } |
| 361 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 410 | + if ($globalTransaction) { |
|
| 411 | + $Connection->db->commit(); |
|
| 412 | + } |
|
| 362 | 413 | } catch(PDOException $e) { |
| 363 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 414 | + if ($globalTransaction) { |
|
| 415 | + $Connection->db->rollBack(); |
|
| 416 | + } |
|
| 364 | 417 | echo $e->getMessage(); |
| 365 | 418 | } |
| 366 | 419 | $sth_check->closeCursor(); |
@@ -403,8 +456,11 @@ discard block |
||
| 403 | 456 | return "error : ".$e->getMessage(); |
| 404 | 457 | } |
| 405 | 458 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 406 | - if ($row['nb'] > 0) return false; |
|
| 407 | - else return true; |
|
| 459 | + if ($row['nb'] > 0) { |
|
| 460 | + return false; |
|
| 461 | + } else { |
|
| 462 | + return true; |
|
| 463 | + } |
|
| 408 | 464 | } |
| 409 | 465 | |
| 410 | 466 | /** |