From 5032ca815736ad3f093deaef3d13c27cac09c987 Mon Sep 17 00:00:00 2001 From: int2001 Date: Sat, 12 Oct 2024 06:05:36 +0000 Subject: [PATCH] Bindings for the activated-gm-controller --- .../models/Activated_gridmap_model.php | 211 ++++++++++-------- 1 file changed, 121 insertions(+), 90 deletions(-) diff --git a/application/models/Activated_gridmap_model.php b/application/models/Activated_gridmap_model.php index c669c5488..73b3c3178 100644 --- a/application/models/Activated_gridmap_model.php +++ b/application/models/Activated_gridmap_model.php @@ -3,7 +3,7 @@ class Activated_gridmap_model extends CI_Model { function get_band_confirmed($band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat, $orbit, $propagation) { - + $bindings=[]; $this->load->model('logbooks_model'); $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); @@ -20,35 +20,42 @@ class Activated_gridmap_model extends CI_Model { . 'AND station_profile.station_id in ('.$location_list.')'; if ($band != 'All') { - if ($band == 'SAT') { - $sql .= " and col_prop_mode ='" . $band . "'"; - if ($sat != 'All' && $sat != '') { - $sql .= " and col_sat_name ='" . $sat . "'"; - } - } else { - if ($propagation != '') { - $sql .= " and col_prop_mode ='" . $propagation . "'"; - } - $sql .= " and col_band ='" . $band . "'"; - } - } else { - if ($propagation != '') { - $sql .= " and col_prop_mode ='" . $propagation . "'"; - } - } + if ($band == 'SAT') { + $sql .= " and col_prop_mode = ?"; + $bindings[]=$band; + if ($sat != 'All' && $sat != '') { + $sql .= " and col_sat_name = ?"; + $bindings[]=$sat; + } + } else { + if ($propagation != '') { + $sql .= " and col_prop_mode = ?"; + $bindings[]=$propagation; + } + $sql .= " and col_band = ?"; + $bindings[]=$band; + } + } else { + if ($propagation != '') { + $sql .= " and col_prop_mode = ?"; + $bindings[]=$propagation; + } + } - if ($mode != 'All') { - $sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')"; - } + if ($mode != 'All') { + $sql .= " and (col_mode = ? or col_submode = ?)"; + $bindings[]=$mode; + $bindings[]=$mode; + } - $sql .= $this->addOrbitToQuery($orbit); + $sql .= $this->addOrbitToQuery($orbit,$bindings); $sql .= $this->addQslToQuery($qsl, $lotw, $eqsl, $qrz); - return $this->db->query($sql); + return $this->db->query($sql, $bindings); } function get_band($band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat, $orbit, $propagation) { - + $bindings=[]; $this->load->model('logbooks_model'); $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); @@ -65,34 +72,41 @@ class Activated_gridmap_model extends CI_Model { . 'AND station_profile.station_id in ('.$location_list.')'; if ($band != 'All') { - if ($band == 'SAT') { - $sql .= " and col_prop_mode ='" . $band . "'"; - if ($sat != 'All' && $sat != '') { - $sql .= " and col_sat_name ='" . $sat . "'"; - } - } else { - if ($propagation != '') { - $sql .= " and col_prop_mode ='" . $propagation . "'"; - } - $sql .= " and col_band ='" . $band . "'"; - } - } else { - if ($propagation != '') { - $sql .= " and col_prop_mode ='" . $propagation . "'"; - } - } + if ($band == 'SAT') { + $sql .= " and col_prop_mode = ?"; + $bindings[]=$band; + if ($sat != 'All' && $sat != '') { + $sql .= " and col_sat_name = ?"; + $bindings[]=$sat; + } + } else { + if ($propagation != '') { + $sql .= " and col_prop_mode = ?"; + $bindings[]=$propagation; + } + $sql .= " and col_band = ?"; + $bindings[]=$band; + } + } else { + if ($propagation != '') { + $sql .= " and col_prop_mode = ?"; + $bindings[]=$propagation; + } + } - if ($mode != 'All') { - $sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')"; - } + if ($mode != 'All') { + $sql .= " and (col_mode = ? or col_submode = ?)"; + $bindings[]=$mode; + $bindings[]=$mode; + } - $sql .= $this->addOrbitToQuery($orbit); + $sql .= $this->addOrbitToQuery($orbit,$bindings); - return $this->db->query($sql); + return $this->db->query($sql,$bindings); } function get_band_worked_vucc_squares($band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat, $orbit, $propagation) { - + $bindings=[]; $this->load->model('logbooks_model'); $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); @@ -109,35 +123,43 @@ class Activated_gridmap_model extends CI_Model { .$location_list.') AND COL_VUCC_GRIDS != ""'; if ($band != 'All') { - if ($band == 'SAT') { - $sql .= " and col_prop_mode ='" . $band . "'"; - if ($sat != 'All' && $sat != '') { - $sql .= " and col_sat_name ='" . $sat . "'"; - } - } else { - if ($propagation != '') { - $sql .= " and col_prop_mode ='" . $propagation . "'"; - } - $sql .= " and col_band ='" . $band . "'"; - } - } else { - if ($propagation != '') { - $sql .= " and col_prop_mode ='" . $propagation . "'"; - } - } + if ($band == 'SAT') { + $sql .= " and col_prop_mode = ?"; + $bindings[]=$band; + if ($sat != 'All' && $sat != '') { + $sql .= " and col_sat_name = ?"; + $bindings[]=$sat; + } + } else { + if ($propagation != '') { + $sql .= " and col_prop_mode = ?"; + $bindings[]=$propagation; + } + $sql .= " and col_band = ?"; + $bindings[]=$band; + } + } else { + if ($propagation != '') { + $sql .= " and col_prop_mode = ?"; + $bindings[]=$propagation; + } + } - if ($mode != 'All') { - $sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')"; - } + if ($mode != 'All') { + $sql .= " and (col_mode = ? or col_submode = ?)"; + $bindings[]=$mode; + $bindings[]=$mode; + } - $sql .= $this->addOrbitToQuery($orbit); + + $sql .= $this->addOrbitToQuery($orbit,$bindings); return null; - return $this->db->query($sql); + return $this->db->query($sql,$bindings); } function get_band_confirmed_vucc_squares($band, $mode, $qsl, $lotw, $eqsl, $qrz, $sat, $orbit, $propagation) { - + $bindings=[]; $this->load->model('logbooks_model'); $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); @@ -153,34 +175,42 @@ class Activated_gridmap_model extends CI_Model { .' WHERE station_id in (' .$location_list.') AND COL_VUCC_GRIDS != ""'; + if ($band != 'All') { - if ($band == 'SAT') { - $sql .= " and col_prop_mode ='" . $band . "'"; - if ($sat != 'All' && $sat != '') { - $sql .= " and col_sat_name ='" . $sat . "'"; - } - } else { - if ($propagation != '') { - $sql .= " and col_prop_mode ='" . $propagation . "'"; - } - $sql .= " and col_band ='" . $band . "'"; - } - } else { - if ($propagation != '') { - $sql .= " and col_prop_mode ='" . $propagation . "'"; - } - } + if ($band == 'SAT') { + $sql .= " and col_prop_mode = ?"; + $bindings[]=$band; + if ($sat != 'All' && $sat != '') { + $sql .= " and col_sat_name = ?"; + $bindings[]=$sat; + } + } else { + if ($propagation != '') { + $sql .= " and col_prop_mode = ?"; + $bindings[]=$propagation; + } + $sql .= " and col_band = ?"; + $bindings[]=$band; + } + } else { + if ($propagation != '') { + $sql .= " and col_prop_mode = ?"; + $bindings[]=$propagation; + } + } - if ($mode != 'All') { - $sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')"; - } + if ($mode != 'All') { + $sql .= " and (col_mode = ? or col_submode = ?)"; + $bindings[]=$mode; + $bindings[]=$mode; + } - $sql .= $this->addOrbitToQuery($orbit); + $sql .= $this->addOrbitToQuery($orbit,$bindings); $sql .= $this->addQslToQuery($qsl, $lotw, $eqsl, $qrz); return null; - return $this->db->query($sql); + return $this->db->query($sql,$bindings); } // Adds confirmation to query @@ -208,10 +238,11 @@ class Activated_gridmap_model extends CI_Model { } // Adds orbit type to query - function addOrbitToQuery($orbit) { + function addOrbitToQuery($orbit,&$bindings) { $sql = ''; if ($orbit != 'All') { - $sql .= ' AND satellite.orbit = \''.$orbit.'\''; + $sql .= ' AND satellite.orbit = ?'; + $bindings[]=$orbit; } return $sql;