Skip to content

Commit

Permalink
Improved handling of Callbook Data
Browse files Browse the repository at this point in the history
  • Loading branch information
magicbug committed Oct 30, 2024
1 parent 7fdf83c commit 191f559
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 22 deletions.
48 changes: 34 additions & 14 deletions application/controllers/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -755,23 +755,25 @@ function edit()
$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');

Expand All @@ -780,6 +782,24 @@ function edit()

// 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'])) {
Expand Down
15 changes: 7 additions & 8 deletions application/models/Logbook_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -4340,14 +4340,13 @@ function wpx($testcall, $i)

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 '';
}

/*
Expand Down

0 comments on commit 191f559

Please sign in to comment.