| @@ 3242-3268 (lines=27) @@ | ||
| 3239 | * @return String the ident |
|
| 3240 | * |
|
| 3241 | */ |
|
| 3242 | public function getIdentFromLastHour($ident) |
|
| 3243 | { |
|
| 3244 | global $globalDBdriver, $globalTimezone; |
|
| 3245 | if ($globalDBdriver == 'mysql') { |
|
| 3246 | $query = "SELECT spotter_output.ident FROM spotter_output |
|
| 3247 | WHERE spotter_output.ident = :ident |
|
| 3248 | AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
|
| 3249 | AND spotter_output.date < UTC_TIMESTAMP()"; |
|
| 3250 | $query_data = array(':ident' => $ident); |
|
| 3251 | } elseif ($globalDBdriver == 'pgsql') { |
|
| 3252 | $query = "SELECT spotter_output.ident FROM spotter_output |
|
| 3253 | WHERE spotter_output.ident = :ident |
|
| 3254 | AND spotter_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
|
| 3255 | AND spotter_output.date < now() AT TIME ZONE 'UTC'"; |
|
| 3256 | $query_data = array(':ident' => $ident); |
|
| 3257 | } |
|
| 3258 | ||
| 3259 | $sth = $this->db->prepare($query); |
|
| 3260 | $sth->execute($query_data); |
|
| 3261 | $ident_result=''; |
|
| 3262 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 3263 | { |
|
| 3264 | $ident_result = $row['ident']; |
|
| 3265 | } |
|
| 3266 | ||
| 3267 | return $ident_result; |
|
| 3268 | } |
|
| 3269 | ||
| 3270 | ||
| 3271 | /** |
|
| @@ 660-685 (lines=26) @@ | ||
| 657 | * @return String the ident |
|
| 658 | * |
|
| 659 | */ |
|
| 660 | public function getIdentFromLastHour($ident) |
|
| 661 | { |
|
| 662 | global $globalDBdriver, $globalTimezone; |
|
| 663 | if ($globalDBdriver == 'mysql') { |
|
| 664 | $query = 'SELECT spotter_live.ident FROM spotter_live |
|
| 665 | WHERE spotter_live.ident = :ident |
|
| 666 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
|
| 667 | AND spotter_live.date < UTC_TIMESTAMP()'; |
|
| 668 | $query_data = array(':ident' => $ident); |
|
| 669 | } elseif ($globalDBdriver == 'pgsql') { |
|
| 670 | $query = "SELECT spotter_live.ident FROM spotter_live |
|
| 671 | WHERE spotter_live.ident = :ident |
|
| 672 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
|
| 673 | AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
|
| 674 | $query_data = array(':ident' => $ident); |
|
| 675 | } |
|
| 676 | ||
| 677 | $sth = $this->db->prepare($query); |
|
| 678 | $sth->execute($query_data); |
|
| 679 | $ident_result=''; |
|
| 680 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 681 | { |
|
| 682 | $ident_result = $row['ident']; |
|
| 683 | } |
|
| 684 | return $ident_result; |
|
| 685 | } |
|
| 686 | ||
| 687 | /** |
|
| 688 | * Check recent aircraft |
|
| @@ 693-718 (lines=26) @@ | ||
| 690 | * @return String the ident |
|
| 691 | * |
|
| 692 | */ |
|
| 693 | public function checkIdentRecent($ident) |
|
| 694 | { |
|
| 695 | global $globalDBdriver, $globalTimezone; |
|
| 696 | if ($globalDBdriver == 'mysql') { |
|
| 697 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 698 | WHERE spotter_live.ident = :ident |
|
| 699 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
|
| 700 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
|
| 701 | $query_data = array(':ident' => $ident); |
|
| 702 | } elseif ($globalDBdriver == 'pgsql') { |
|
| 703 | $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 704 | WHERE spotter_live.ident = :ident |
|
| 705 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
|
| 706 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
|
| 707 | $query_data = array(':ident' => $ident); |
|
| 708 | } |
|
| 709 | ||
| 710 | $sth = $this->db->prepare($query); |
|
| 711 | $sth->execute($query_data); |
|
| 712 | $ident_result=''; |
|
| 713 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 714 | { |
|
| 715 | $ident_result = $row['flightaware_id']; |
|
| 716 | } |
|
| 717 | return $ident_result; |
|
| 718 | } |
|
| 719 | ||
| 720 | /** |
|
| 721 | * Check recent aircraft by ModeS |
|
| @@ 726-752 (lines=27) @@ | ||
| 723 | * @return String the ModeS |
|
| 724 | * |
|
| 725 | */ |
|
| 726 | public function checkModeSRecent($modes) |
|
| 727 | { |
|
| 728 | global $globalDBdriver, $globalTimezone; |
|
| 729 | if ($globalDBdriver == 'mysql') { |
|
| 730 | $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 731 | WHERE spotter_live.ModeS = :modes |
|
| 732 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
|
| 733 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
|
| 734 | $query_data = array(':modes' => $modes); |
|
| 735 | } elseif ($globalDBdriver == 'pgsql') { |
|
| 736 | $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 737 | WHERE spotter_live.ModeS = :modes |
|
| 738 | AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '30 MINUTE'"; |
|
| 739 | // // AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
|
| 740 | $query_data = array(':modes' => $modes); |
|
| 741 | } |
|
| 742 | ||
| 743 | $sth = $this->db->prepare($query); |
|
| 744 | $sth->execute($query_data); |
|
| 745 | $ident_result=''; |
|
| 746 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 747 | { |
|
| 748 | //$ident_result = $row['spotter_live_id']; |
|
| 749 | $ident_result = $row['flightaware_id']; |
|
| 750 | } |
|
| 751 | return $ident_result; |
|
| 752 | } |
|
| 753 | ||
| 754 | /** |
|
| 755 | * Adds a new spotter data |
|