您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. class Conn {
  3. private $con;
  4. public function __construct() {
  5. $this->con = new SQLite3("/home/pi/raspberry-noaa/panel.db");
  6. }
  7. public function getPasses() {
  8. $today = strtotime(date('Y-m-d', time()));
  9. $query = $this->con->query("SELECT sat_name, is_active,
  10. pass_start, pass_end,
  11. max_elev FROM predict_passes
  12. WHERE (pass_start > $today) ORDER BY
  13. pass_start ASC;");
  14. $passes = [];
  15. $i = 0;
  16. while($row = $query->fetchArray()){
  17. $passes[$i] = $row;
  18. $i++;
  19. }
  20. return $passes;
  21. }
  22. public function totalPages($img_per_page) {
  23. $total_pages = $this->con->querySingle("SELECT count() from decoded_passes;");
  24. return ceil($total_pages/$img_per_page);
  25. }
  26. public function getImages($page, $img_per_page) {
  27. $query = $this->con->prepare("SELECT decoded_passes.id, predict_passes.pass_start,
  28. file_path, is_noaa, predict_passes.sat_name, predict_passes.max_elev
  29. FROM decoded_passes INNER JOIN predict_passes
  30. ON predict_passes.pass_start = decoded_passes.pass_start
  31. ORDER BY decoded_passes.pass_start DESC LIMIT ? OFFSET ?;");
  32. $query->bindValue(1, $img_per_page);
  33. $query->bindValue(2, $img_per_page * ($page-1));
  34. $result = $query->execute();
  35. $images = [];
  36. $i = 0;
  37. while($row = $result->fetchArray()){
  38. $images[$i] = $row;
  39. $i++;
  40. }
  41. return $images;
  42. }
  43. public function getEnhacements($id) {
  44. $query = $this->con->prepare('SELECT daylight_pass, is_noaa
  45. FROM decoded_passes WHERE id = ?;');
  46. $query->bindValue(1, $id);
  47. $result = $query->execute();
  48. $pass = $result->fetchArray();
  49. if ($pass['is_noaa'] == 0) {
  50. $enhacements = ['-122-rectified.jpg'];
  51. } else {
  52. if ($pass['daylight_pass'] == 1) {
  53. $enhacements = ['-ZA.jpg','-MCIR.jpg','-MCIR-precip.jpg','-MSA.jpg','-MSA-precip.jpg','-HVC.jpg','-HVC-precip.jpg','-HVCT.jpg','-HVCT-precip.jpg'];
  54. } else {
  55. $enhacements = ['-ZA.jpg','-MCIR.jpg','-MCIR-precip.jpg'];
  56. }
  57. }
  58. return $enhacements;
  59. }
  60. public function getPath($id) {
  61. $query = $this->con->prepare('SELECT file_path FROM decoded_passes
  62. WHERE id = ?;');
  63. $query->bindValue(1, $id);
  64. $result = $query->execute();
  65. $image = $result->fetchArray();
  66. return $image['file_path'];
  67. }
  68. }
  69. ?>