@@ -13,10 +13,10 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | - * Get SQL query part for filter used |
|
| 17 | - * @param Array $filter the filter |
|
| 18 | - * @return Array the SQL part |
|
| 19 | - */ |
|
| 16 | + * Get SQL query part for filter used |
|
| 17 | + * @param Array $filter the filter |
|
| 18 | + * @return Array the SQL part |
|
| 19 | + */ |
|
| 20 | 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 22 | 22 | $filters = array(); |
@@ -139,11 +139,11 @@ discard block |
||
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | /** |
| 142 | - * Gets all the spotter information based on the latest data entry |
|
| 143 | - * |
|
| 144 | - * @return Array the spotter information |
|
| 145 | - * |
|
| 146 | - */ |
|
| 142 | + * Gets all the spotter information based on the latest data entry |
|
| 143 | + * |
|
| 144 | + * @return Array the spotter information |
|
| 145 | + * |
|
| 146 | + */ |
|
| 147 | 147 | public function getLiveSpotterData($limit = '', $sort = '', $filter = array()) |
| 148 | 148 | { |
| 149 | 149 | global $globalDBdriver, $globalLiveInterval; |
@@ -186,11 +186,11 @@ discard block |
||
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /** |
| 189 | - * Gets Minimal Live Spotter data |
|
| 190 | - * |
|
| 191 | - * @return Array the spotter information |
|
| 192 | - * |
|
| 193 | - */ |
|
| 189 | + * Gets Minimal Live Spotter data |
|
| 190 | + * |
|
| 191 | + * @return Array the spotter information |
|
| 192 | + * |
|
| 193 | + */ |
|
| 194 | 194 | public function getMinLiveSpotterData($filter = array()) |
| 195 | 195 | { |
| 196 | 196 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap2DAircraftsLimit; |
@@ -238,11 +238,11 @@ discard block |
||
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | /** |
| 241 | - * Gets Minimal Live Spotter data since xx seconds |
|
| 242 | - * |
|
| 243 | - * @return Array the spotter information |
|
| 244 | - * |
|
| 245 | - */ |
|
| 241 | + * Gets Minimal Live Spotter data since xx seconds |
|
| 242 | + * |
|
| 243 | + * @return Array the spotter information |
|
| 244 | + * |
|
| 245 | + */ |
|
| 246 | 246 | public function getMinLastLiveSpotterData($coord = array(),$filter = array(), $limit = false, $id = '') |
| 247 | 247 | { |
| 248 | 248 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit; |
@@ -339,11 +339,11 @@ discard block |
||
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | /** |
| 342 | - * Gets Minimal Live Spotter data since xx seconds |
|
| 343 | - * |
|
| 344 | - * @return Array the spotter information |
|
| 345 | - * |
|
| 346 | - */ |
|
| 342 | + * Gets Minimal Live Spotter data since xx seconds |
|
| 343 | + * |
|
| 344 | + * @return Array the spotter information |
|
| 345 | + * |
|
| 346 | + */ |
|
| 347 | 347 | public function getMinLastLiveSpotterDataByID($id = '',$filter = array(), $limit = false) |
| 348 | 348 | { |
| 349 | 349 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit; |
@@ -408,11 +408,11 @@ discard block |
||
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | /** |
| 411 | - * Gets number of latest data entry |
|
| 412 | - * |
|
| 413 | - * @return String number of entry |
|
| 414 | - * |
|
| 415 | - */ |
|
| 411 | + * Gets number of latest data entry |
|
| 412 | + * |
|
| 413 | + * @return String number of entry |
|
| 414 | + * |
|
| 415 | + */ |
|
| 416 | 416 | public function getLiveSpotterCount($filter = array()) |
| 417 | 417 | { |
| 418 | 418 | global $globalDBdriver, $globalLiveInterval; |
@@ -439,11 +439,11 @@ discard block |
||
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | /** |
| 442 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 443 | - * |
|
| 444 | - * @return Array the spotter information |
|
| 445 | - * |
|
| 446 | - */ |
|
| 442 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 443 | + * |
|
| 444 | + * @return Array the spotter information |
|
| 445 | + * |
|
| 446 | + */ |
|
| 447 | 447 | public function getLiveSpotterDatabyCoord($coord, $filter = array()) |
| 448 | 448 | { |
| 449 | 449 | global $globalDBdriver, $globalLiveInterval; |
@@ -468,11 +468,11 @@ discard block |
||
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | /** |
| 471 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 472 | - * |
|
| 473 | - * @return Array the spotter information |
|
| 474 | - * |
|
| 475 | - */ |
|
| 471 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 472 | + * |
|
| 473 | + * @return Array the spotter information |
|
| 474 | + * |
|
| 475 | + */ |
|
| 476 | 476 | public function getMinLiveSpotterDatabyCoord($coord, $filter = array()) |
| 477 | 477 | { |
| 478 | 478 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -537,11 +537,11 @@ discard block |
||
| 537 | 537 | } |
| 538 | 538 | |
| 539 | 539 | /** |
| 540 | - * Gets all the spotter information based on a user's latitude and longitude |
|
| 541 | - * |
|
| 542 | - * @return Array the spotter information |
|
| 543 | - * |
|
| 544 | - */ |
|
| 540 | + * Gets all the spotter information based on a user's latitude and longitude |
|
| 541 | + * |
|
| 542 | + * @return Array the spotter information |
|
| 543 | + * |
|
| 544 | + */ |
|
| 545 | 545 | public function getLatestSpotterForLayar($lat, $lng, $radius, $interval) |
| 546 | 546 | { |
| 547 | 547 | $Spotter = new Spotter($this->db); |
@@ -551,98 +551,98 @@ discard block |
||
| 551 | 551 | return false; |
| 552 | 552 | } |
| 553 | 553 | } |
| 554 | - if ($lng != '') |
|
| 555 | - { |
|
| 556 | - if (!is_numeric($lng)) |
|
| 557 | - { |
|
| 558 | - return false; |
|
| 559 | - } |
|
| 560 | - } |
|
| 561 | - |
|
| 562 | - if ($radius != '') |
|
| 563 | - { |
|
| 564 | - if (!is_numeric($radius)) |
|
| 565 | - { |
|
| 566 | - return false; |
|
| 567 | - } |
|
| 568 | - } |
|
| 554 | + if ($lng != '') |
|
| 555 | + { |
|
| 556 | + if (!is_numeric($lng)) |
|
| 557 | + { |
|
| 558 | + return false; |
|
| 559 | + } |
|
| 560 | + } |
|
| 561 | + |
|
| 562 | + if ($radius != '') |
|
| 563 | + { |
|
| 564 | + if (!is_numeric($radius)) |
|
| 565 | + { |
|
| 566 | + return false; |
|
| 567 | + } |
|
| 568 | + } |
|
| 569 | 569 | $additional_query = ''; |
| 570 | - if ($interval != '') |
|
| 571 | - { |
|
| 572 | - if (!is_string($interval)) |
|
| 573 | - { |
|
| 574 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 575 | - return false; |
|
| 576 | - } else { |
|
| 577 | - if ($interval == '1m') |
|
| 578 | - { |
|
| 579 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 580 | - } else if ($interval == '15m'){ |
|
| 581 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
| 582 | - } |
|
| 583 | - } |
|
| 584 | - } else { |
|
| 585 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 586 | - } |
|
| 587 | - |
|
| 588 | - $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
| 570 | + if ($interval != '') |
|
| 571 | + { |
|
| 572 | + if (!is_string($interval)) |
|
| 573 | + { |
|
| 574 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 575 | + return false; |
|
| 576 | + } else { |
|
| 577 | + if ($interval == '1m') |
|
| 578 | + { |
|
| 579 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 580 | + } else if ($interval == '15m'){ |
|
| 581 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
| 582 | + } |
|
| 583 | + } |
|
| 584 | + } else { |
|
| 585 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 586 | + } |
|
| 587 | + |
|
| 588 | + $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
| 589 | 589 | WHERE spotter_live.latitude <> '' |
| 590 | 590 | AND spotter_live.longitude <> '' |
| 591 | 591 | ".$additional_query." |
| 592 | 592 | HAVING distance < :radius |
| 593 | 593 | ORDER BY distance"; |
| 594 | 594 | |
| 595 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 595 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 596 | 596 | |
| 597 | - return $spotter_array; |
|
| 598 | - } |
|
| 597 | + return $spotter_array; |
|
| 598 | + } |
|
| 599 | 599 | |
| 600 | 600 | |
| 601 | - /** |
|
| 602 | - * Gets all the spotter information based on a particular callsign |
|
| 603 | - * |
|
| 604 | - * @return Array the spotter information |
|
| 605 | - * |
|
| 606 | - */ |
|
| 601 | + /** |
|
| 602 | + * Gets all the spotter information based on a particular callsign |
|
| 603 | + * |
|
| 604 | + * @return Array the spotter information |
|
| 605 | + * |
|
| 606 | + */ |
|
| 607 | 607 | public function getLastLiveSpotterDataByIdent($ident) |
| 608 | 608 | { |
| 609 | 609 | $Spotter = new Spotter($this->db); |
| 610 | 610 | date_default_timezone_set('UTC'); |
| 611 | 611 | |
| 612 | 612 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 613 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 613 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 614 | 614 | |
| 615 | 615 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
| 616 | 616 | |
| 617 | 617 | return $spotter_array; |
| 618 | 618 | } |
| 619 | 619 | |
| 620 | - /** |
|
| 621 | - * Gets all the spotter information based on a particular callsign |
|
| 622 | - * |
|
| 623 | - * @return Array the spotter information |
|
| 624 | - * |
|
| 625 | - */ |
|
| 620 | + /** |
|
| 621 | + * Gets all the spotter information based on a particular callsign |
|
| 622 | + * |
|
| 623 | + * @return Array the spotter information |
|
| 624 | + * |
|
| 625 | + */ |
|
| 626 | 626 | public function getDateLiveSpotterDataByIdent($ident,$date) |
| 627 | 627 | { |
| 628 | 628 | $Spotter = new Spotter($this->db); |
| 629 | 629 | date_default_timezone_set('UTC'); |
| 630 | 630 | |
| 631 | 631 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 632 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 632 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 633 | 633 | |
| 634 | - $date = date('c',$date); |
|
| 634 | + $date = date('c',$date); |
|
| 635 | 635 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
| 636 | 636 | |
| 637 | 637 | return $spotter_array; |
| 638 | 638 | } |
| 639 | 639 | |
| 640 | - /** |
|
| 641 | - * Gets last spotter information based on a particular callsign |
|
| 642 | - * |
|
| 643 | - * @return Array the spotter information |
|
| 644 | - * |
|
| 645 | - */ |
|
| 640 | + /** |
|
| 641 | + * Gets last spotter information based on a particular callsign |
|
| 642 | + * |
|
| 643 | + * @return Array the spotter information |
|
| 644 | + * |
|
| 645 | + */ |
|
| 646 | 646 | public function getLastLiveSpotterDataById($id) |
| 647 | 647 | { |
| 648 | 648 | $Spotter = new Spotter($this->db); |
@@ -653,12 +653,12 @@ discard block |
||
| 653 | 653 | return $spotter_array; |
| 654 | 654 | } |
| 655 | 655 | |
| 656 | - /** |
|
| 657 | - * Gets last spotter information based on a particular callsign |
|
| 658 | - * |
|
| 659 | - * @return Array the spotter information |
|
| 660 | - * |
|
| 661 | - */ |
|
| 656 | + /** |
|
| 657 | + * Gets last spotter information based on a particular callsign |
|
| 658 | + * |
|
| 659 | + * @return Array the spotter information |
|
| 660 | + * |
|
| 661 | + */ |
|
| 662 | 662 | public function getDateLiveSpotterDataById($id,$date) |
| 663 | 663 | { |
| 664 | 664 | $Spotter = new Spotter($this->db); |
@@ -671,21 +671,21 @@ discard block |
||
| 671 | 671 | return $spotter_array; |
| 672 | 672 | } |
| 673 | 673 | |
| 674 | - /** |
|
| 675 | - * Gets altitude information based on a particular callsign |
|
| 676 | - * |
|
| 677 | - * @return Array the spotter information |
|
| 678 | - * |
|
| 679 | - */ |
|
| 674 | + /** |
|
| 675 | + * Gets altitude information based on a particular callsign |
|
| 676 | + * |
|
| 677 | + * @return Array the spotter information |
|
| 678 | + * |
|
| 679 | + */ |
|
| 680 | 680 | public function getAltitudeLiveSpotterDataByIdent($ident) |
| 681 | 681 | { |
| 682 | 682 | |
| 683 | 683 | date_default_timezone_set('UTC'); |
| 684 | 684 | |
| 685 | 685 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 686 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 686 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 687 | 687 | |
| 688 | - try { |
|
| 688 | + try { |
|
| 689 | 689 | |
| 690 | 690 | $sth = $this->db->prepare($query); |
| 691 | 691 | $sth->execute(array(':ident' => $ident)); |
@@ -698,12 +698,12 @@ discard block |
||
| 698 | 698 | return $spotter_array; |
| 699 | 699 | } |
| 700 | 700 | |
| 701 | - /** |
|
| 702 | - * Gets all the spotter information based on a particular id |
|
| 703 | - * |
|
| 704 | - * @return Array the spotter information |
|
| 705 | - * |
|
| 706 | - */ |
|
| 701 | + /** |
|
| 702 | + * Gets all the spotter information based on a particular id |
|
| 703 | + * |
|
| 704 | + * @return Array the spotter information |
|
| 705 | + * |
|
| 706 | + */ |
|
| 707 | 707 | public function getAllLiveSpotterDataById($id,$liveinterval = false) |
| 708 | 708 | { |
| 709 | 709 | global $globalDBdriver, $globalLiveInterval; |
@@ -731,18 +731,18 @@ discard block |
||
| 731 | 731 | return $spotter_array; |
| 732 | 732 | } |
| 733 | 733 | |
| 734 | - /** |
|
| 735 | - * Gets all the spotter information based on a particular ident |
|
| 736 | - * |
|
| 737 | - * @return Array the spotter information |
|
| 738 | - * |
|
| 739 | - */ |
|
| 734 | + /** |
|
| 735 | + * Gets all the spotter information based on a particular ident |
|
| 736 | + * |
|
| 737 | + * @return Array the spotter information |
|
| 738 | + * |
|
| 739 | + */ |
|
| 740 | 740 | public function getAllLiveSpotterDataByIdent($ident) |
| 741 | 741 | { |
| 742 | 742 | date_default_timezone_set('UTC'); |
| 743 | 743 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 744 | 744 | $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
| 745 | - try { |
|
| 745 | + try { |
|
| 746 | 746 | |
| 747 | 747 | $sth = $this->db->prepare($query); |
| 748 | 748 | $sth->execute(array(':ident' => $ident)); |
@@ -756,23 +756,23 @@ discard block |
||
| 756 | 756 | |
| 757 | 757 | |
| 758 | 758 | /** |
| 759 | - * Deletes all info in the table |
|
| 760 | - * |
|
| 761 | - * @return String success or false |
|
| 762 | - * |
|
| 763 | - */ |
|
| 759 | + * Deletes all info in the table |
|
| 760 | + * |
|
| 761 | + * @return String success or false |
|
| 762 | + * |
|
| 763 | + */ |
|
| 764 | 764 | public function deleteLiveSpotterData() |
| 765 | 765 | { |
| 766 | 766 | global $globalDBdriver; |
| 767 | 767 | if ($globalDBdriver == 'mysql') { |
| 768 | 768 | //$query = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date"; |
| 769 | 769 | $query = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date'; |
| 770 | - //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
| 770 | + //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
| 771 | 771 | } else { |
| 772 | 772 | $query = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date"; |
| 773 | 773 | } |
| 774 | 774 | |
| 775 | - try { |
|
| 775 | + try { |
|
| 776 | 776 | |
| 777 | 777 | $sth = $this->db->prepare($query); |
| 778 | 778 | $sth->execute(); |
@@ -784,18 +784,18 @@ discard block |
||
| 784 | 784 | } |
| 785 | 785 | |
| 786 | 786 | /** |
| 787 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 788 | - * |
|
| 789 | - * @return String success or false |
|
| 790 | - * |
|
| 791 | - */ |
|
| 787 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 788 | + * |
|
| 789 | + * @return String success or false |
|
| 790 | + * |
|
| 791 | + */ |
|
| 792 | 792 | public function deleteLiveSpotterDataNotUpdated() |
| 793 | 793 | { |
| 794 | 794 | global $globalDBdriver, $globalDebug; |
| 795 | 795 | if ($globalDBdriver == 'mysql') { |
| 796 | 796 | //$query = 'SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < spotter_live.date) LIMIT 800 OFFSET 0'; |
| 797 | - $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0"; |
|
| 798 | - try { |
|
| 797 | + $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0"; |
|
| 798 | + try { |
|
| 799 | 799 | |
| 800 | 800 | $sth = $this->db->prepare($query); |
| 801 | 801 | $sth->execute(); |
@@ -803,8 +803,8 @@ discard block |
||
| 803 | 803 | return "error"; |
| 804 | 804 | } |
| 805 | 805 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
| 806 | - $i = 0; |
|
| 807 | - $j =0; |
|
| 806 | + $i = 0; |
|
| 807 | + $j =0; |
|
| 808 | 808 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 809 | 809 | foreach($all as $row) |
| 810 | 810 | { |
@@ -812,20 +812,20 @@ discard block |
||
| 812 | 812 | $j++; |
| 813 | 813 | if ($j == 30) { |
| 814 | 814 | if ($globalDebug) echo "."; |
| 815 | - try { |
|
| 815 | + try { |
|
| 816 | 816 | |
| 817 | 817 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 818 | 818 | $sth->execute(); |
| 819 | 819 | } catch(PDOException $e) { |
| 820 | 820 | return "error"; |
| 821 | 821 | } |
| 822 | - $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
| 823 | - $j = 0; |
|
| 822 | + $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
| 823 | + $j = 0; |
|
| 824 | 824 | } |
| 825 | 825 | $query_delete .= "'".$row['flightaware_id']."',"; |
| 826 | 826 | } |
| 827 | 827 | if ($i > 0) { |
| 828 | - try { |
|
| 828 | + try { |
|
| 829 | 829 | |
| 830 | 830 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 831 | 831 | $sth->execute(); |
@@ -836,9 +836,9 @@ discard block |
||
| 836 | 836 | return "success"; |
| 837 | 837 | } elseif ($globalDBdriver == 'pgsql') { |
| 838 | 838 | //$query = "SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < spotter_live.date) LIMIT 800 OFFSET 0"; |
| 839 | - //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
| 840 | - $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)"; |
|
| 841 | - try { |
|
| 839 | + //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
| 840 | + $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)"; |
|
| 841 | + try { |
|
| 842 | 842 | |
| 843 | 843 | $sth = $this->db->prepare($query); |
| 844 | 844 | $sth->execute(); |
@@ -882,17 +882,17 @@ discard block |
||
| 882 | 882 | } |
| 883 | 883 | |
| 884 | 884 | /** |
| 885 | - * Deletes all info in the table for an ident |
|
| 886 | - * |
|
| 887 | - * @return String success or false |
|
| 888 | - * |
|
| 889 | - */ |
|
| 885 | + * Deletes all info in the table for an ident |
|
| 886 | + * |
|
| 887 | + * @return String success or false |
|
| 888 | + * |
|
| 889 | + */ |
|
| 890 | 890 | public function deleteLiveSpotterDataByIdent($ident) |
| 891 | 891 | { |
| 892 | 892 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 893 | 893 | $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
| 894 | 894 | |
| 895 | - try { |
|
| 895 | + try { |
|
| 896 | 896 | |
| 897 | 897 | $sth = $this->db->prepare($query); |
| 898 | 898 | $sth->execute(array(':ident' => $ident)); |
@@ -904,17 +904,17 @@ discard block |
||
| 904 | 904 | } |
| 905 | 905 | |
| 906 | 906 | /** |
| 907 | - * Deletes all info in the table for an id |
|
| 908 | - * |
|
| 909 | - * @return String success or false |
|
| 910 | - * |
|
| 911 | - */ |
|
| 907 | + * Deletes all info in the table for an id |
|
| 908 | + * |
|
| 909 | + * @return String success or false |
|
| 910 | + * |
|
| 911 | + */ |
|
| 912 | 912 | public function deleteLiveSpotterDataById($id) |
| 913 | 913 | { |
| 914 | 914 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 915 | 915 | $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
| 916 | 916 | |
| 917 | - try { |
|
| 917 | + try { |
|
| 918 | 918 | |
| 919 | 919 | $sth = $this->db->prepare($query); |
| 920 | 920 | $sth->execute(array(':id' => $id)); |
@@ -927,11 +927,11 @@ discard block |
||
| 927 | 927 | |
| 928 | 928 | |
| 929 | 929 | /** |
| 930 | - * Gets the aircraft ident within the last hour |
|
| 931 | - * |
|
| 932 | - * @return String the ident |
|
| 933 | - * |
|
| 934 | - */ |
|
| 930 | + * Gets the aircraft ident within the last hour |
|
| 931 | + * |
|
| 932 | + * @return String the ident |
|
| 933 | + * |
|
| 934 | + */ |
|
| 935 | 935 | public function getIdentFromLastHour($ident) |
| 936 | 936 | { |
| 937 | 937 | global $globalDBdriver, $globalTimezone; |
@@ -957,14 +957,14 @@ discard block |
||
| 957 | 957 | $ident_result = $row['ident']; |
| 958 | 958 | } |
| 959 | 959 | return $ident_result; |
| 960 | - } |
|
| 960 | + } |
|
| 961 | 961 | |
| 962 | 962 | /** |
| 963 | - * Check recent aircraft |
|
| 964 | - * |
|
| 965 | - * @return String the ident |
|
| 966 | - * |
|
| 967 | - */ |
|
| 963 | + * Check recent aircraft |
|
| 964 | + * |
|
| 965 | + * @return String the ident |
|
| 966 | + * |
|
| 967 | + */ |
|
| 968 | 968 | public function checkIdentRecent($ident) |
| 969 | 969 | { |
| 970 | 970 | global $globalDBdriver, $globalTimezone; |
@@ -990,14 +990,14 @@ discard block |
||
| 990 | 990 | $ident_result = $row['flightaware_id']; |
| 991 | 991 | } |
| 992 | 992 | return $ident_result; |
| 993 | - } |
|
| 993 | + } |
|
| 994 | 994 | |
| 995 | 995 | /** |
| 996 | - * Check recent aircraft by id |
|
| 997 | - * |
|
| 998 | - * @return String the ident |
|
| 999 | - * |
|
| 1000 | - */ |
|
| 996 | + * Check recent aircraft by id |
|
| 997 | + * |
|
| 998 | + * @return String the ident |
|
| 999 | + * |
|
| 1000 | + */ |
|
| 1001 | 1001 | public function checkIdRecent($id) |
| 1002 | 1002 | { |
| 1003 | 1003 | global $globalDBdriver, $globalTimezone; |
@@ -1023,14 +1023,14 @@ discard block |
||
| 1023 | 1023 | $ident_result = $row['flightaware_id']; |
| 1024 | 1024 | } |
| 1025 | 1025 | return $ident_result; |
| 1026 | - } |
|
| 1026 | + } |
|
| 1027 | 1027 | |
| 1028 | 1028 | /** |
| 1029 | - * Check recent aircraft by ModeS |
|
| 1030 | - * |
|
| 1031 | - * @return String the ModeS |
|
| 1032 | - * |
|
| 1033 | - */ |
|
| 1029 | + * Check recent aircraft by ModeS |
|
| 1030 | + * |
|
| 1031 | + * @return String the ModeS |
|
| 1032 | + * |
|
| 1033 | + */ |
|
| 1034 | 1034 | public function checkModeSRecent($modes) |
| 1035 | 1035 | { |
| 1036 | 1036 | global $globalDBdriver, $globalTimezone; |
@@ -1060,11 +1060,11 @@ discard block |
||
| 1060 | 1060 | } |
| 1061 | 1061 | |
| 1062 | 1062 | /** |
| 1063 | - * Gets the aircraft data from the last 20 seconds |
|
| 1064 | - * |
|
| 1065 | - * @return Array the spotter data |
|
| 1066 | - * |
|
| 1067 | - */ |
|
| 1063 | + * Gets the aircraft data from the last 20 seconds |
|
| 1064 | + * |
|
| 1065 | + * @return Array the spotter data |
|
| 1066 | + * |
|
| 1067 | + */ |
|
| 1068 | 1068 | public function getRealTimeData($q = '') |
| 1069 | 1069 | { |
| 1070 | 1070 | global $globalDBdriver; |
@@ -1106,16 +1106,16 @@ discard block |
||
| 1106 | 1106 | } |
| 1107 | 1107 | |
| 1108 | 1108 | /** |
| 1109 | - * Adds a new spotter data |
|
| 1110 | - * |
|
| 1111 | - * @param String $flightaware_id the ID from flightaware |
|
| 1112 | - * @param String $ident the flight ident |
|
| 1113 | - * @param String $aircraft_icao the aircraft type |
|
| 1114 | - * @param String $departure_airport_icao the departure airport |
|
| 1115 | - * @param String $arrival_airport_icao the arrival airport |
|
| 1116 | - * @return String success or false |
|
| 1117 | - * |
|
| 1118 | - */ |
|
| 1109 | + * Adds a new spotter data |
|
| 1110 | + * |
|
| 1111 | + * @param String $flightaware_id the ID from flightaware |
|
| 1112 | + * @param String $ident the flight ident |
|
| 1113 | + * @param String $aircraft_icao the aircraft type |
|
| 1114 | + * @param String $departure_airport_icao the departure airport |
|
| 1115 | + * @param String $arrival_airport_icao the arrival airport |
|
| 1116 | + * @return String success or false |
|
| 1117 | + * |
|
| 1118 | + */ |
|
| 1119 | 1119 | public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
| 1120 | 1120 | { |
| 1121 | 1121 | global $globalURL, $globalArchive, $globalDebug; |
@@ -1258,10 +1258,10 @@ discard block |
||
| 1258 | 1258 | $arrival_airport_country = ''; |
| 1259 | 1259 | |
| 1260 | 1260 | |
| 1261 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1262 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1263 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1264 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1261 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1262 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1263 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1264 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1265 | 1265 | |
| 1266 | 1266 | $query = ''; |
| 1267 | 1267 | if ($globalArchive) { |
@@ -1282,10 +1282,10 @@ discard block |
||
| 1282 | 1282 | return "error : ".$e->getMessage(); |
| 1283 | 1283 | } |
| 1284 | 1284 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1285 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
| 1286 | - $SpotterArchive = new SpotterArchive($this->db); |
|
| 1287 | - $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
| 1288 | - if ($globalDebug) echo $result.')'; |
|
| 1285 | + if ($globalDebug) echo '(Add to SBS archive : '; |
|
| 1286 | + $SpotterArchive = new SpotterArchive($this->db); |
|
| 1287 | + $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
| 1288 | + if ($globalDebug) echo $result.')'; |
|
| 1289 | 1289 | } elseif ($globalDebug && $putinarchive !== true) { |
| 1290 | 1290 | echo '(Not adding to archive)'; |
| 1291 | 1291 | } elseif ($globalDebug && $noarchive === true) { |