From 191f5591ba031de5fc74b76e3df4300eb391bdd2 Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Wed, 30 Oct 2024 15:13:58 +0000 Subject: [PATCH] Improved handling of Callbook Data --- application/controllers/User.php | 48 ++++++++++++++++++++-------- application/models/Logbook_model.php | 15 ++++----- 2 files changed, 41 insertions(+), 22 deletions(-) diff --git a/application/controllers/User.php b/application/controllers/User.php index 5cb9da11..d3b91646 100644 --- a/application/controllers/User.php +++ b/application/controllers/User.php @@ -755,23 +755,25 @@ class User extends CI_Controller $this->input->set_cookie($cookie); } if ($this->session->userdata('user_id') == $this->input->post('id', true)) { - - // Handle user_callbook_type - if (isset($_POST['user_callbook_type'])) { - $this->user_options_model->set_option('callbook', 'callbook_type', array('value' => $_POST['user_callbook_type'])); - } else { - $this->user_options_model->set_option('callbook', 'callbook_type', array('value' => '')); - } - - // Handle user_callbook_username - if (isset($_POST['user_callbook_username'])) { - $this->user_options_model->set_option('callbook', 'callbook_username', array('value' => $_POST['user_callbook_username'])); - } else { - $this->user_options_model->set_option('callbook', 'callbook_username', array('value' => '')); - } // Handle user_callbook_password + if (isset($_POST['user_callbook_password']) && !empty($_POST['user_callbook_password'])) { + + // Handle user_callbook_type + if (isset($_POST['user_callbook_type'])) { + $this->user_options_model->set_option('callbook', 'callbook_type', array('value' => $_POST['user_callbook_type'])); + } else { + $this->user_options_model->set_option('callbook', 'callbook_type', array('value' => '')); + } + + // Handle user_callbook_username + if (isset($_POST['user_callbook_username'])) { + $this->user_options_model->set_option('callbook', 'callbook_username', array('value' => $_POST['user_callbook_username'])); + } else { + $this->user_options_model->set_option('callbook', 'callbook_username', array('value' => '')); + } + // Load the encryption library $this->load->library('encryption'); @@ -780,6 +782,24 @@ class User extends CI_Controller // Save the encrypted password $this->user_options_model->set_option('callbook', 'callbook_password', array('value' => $encrypted_password)); + + // if callbook type is QRZ + if ($_POST['user_callbook_type'] == 'QRZ') { + // Lookup using QRZ + $this->load->library('qrz'); + + $qrz_session_key = $this->qrz->session($_POST['user_callbook_username'], $_POST['user_callbook_password']); + $this->session->set_userdata('qrz_session_key', $qrz_session_key); + } elseif ($_POST['user_callbook_type'] == "HamQTH") { + $this->load->library('hamqth'); + $hamqth_session_key = $this->hamqth->session($_POST['user_callbook_username'], $_POST['user_callbook_password']); + $this->session->set_userdata('hamqth_session_key', $hamqth_session_key); + } + + // Update Session data + $this->session->set_userdata('callbook_type', $_POST['user_callbook_type']); + $this->session->set_userdata('callbook_username', $_POST['user_callbook_username']); + $this->session->set_userdata('callbook_password', $encrypted_password); } if (isset($_POST['user_dashboard_enable_dxpedition_card'])) { diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 1eb99b36..951fb8d8 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -4340,14 +4340,13 @@ class Logbook_model extends CI_Model public function get_entity($dxcc) { - $sql = "select name, cqz, lat, 'long' from dxcc_entities where adif = " . $dxcc; - $query = $this->db->query($sql); - - if ($query->result() > 0) { - $row = $query->row_array(); - return $row; - } - return ''; + $sql = "SELECT name, cqz, lat, `long` FROM dxcc_entities WHERE adif = ?"; + $query = $this->db->query($sql, array($dxcc)); + + if ($query->num_rows() > 0) { + return $query->row_array(); + } + return ''; } /*