比较提交
2 提交
master
...
copilot/fi
| 作者 | SHA1 | 提交日期 | |
|---|---|---|---|
|
|
9f6def38da | ||
|
|
5b00d420c3 |
共有 4 个文件被更改,包括 117 次插入 和 148 次删除
|
|
@ -83,7 +83,7 @@ $db['default'] = array(
|
||||||
// The following values can probably stay the same.
|
// The following values can probably stay the same.
|
||||||
'dbdriver' => 'mysqli',
|
'dbdriver' => 'mysqli',
|
||||||
'dbprefix' => '',
|
'dbprefix' => '',
|
||||||
'pconnect' => TRUE,
|
'pconnect' => FALSE,
|
||||||
'db_debug' => (ENVIRONMENT !== 'production'),
|
'db_debug' => (ENVIRONMENT !== 'production'),
|
||||||
'cache_on' => FALSE,
|
'cache_on' => FALSE,
|
||||||
'cachedir' => '',
|
'cachedir' => '',
|
||||||
|
|
|
||||||
|
|
@ -826,72 +826,18 @@ class Logbook extends CI_Controller
|
||||||
$html .= "</div>";
|
$html .= "</div>";
|
||||||
return $html;
|
return $html;
|
||||||
} else {
|
} else {
|
||||||
// if session data callbook_type is qrz
|
// Use the loadCallBook method from the model which handles fallback logic
|
||||||
if ($this->session->userdata('callbook_type') == "QRZ") {
|
$this->load->model('logbook_model');
|
||||||
// Lookup using QRZ
|
$callsign['callsign'] = $this->logbook_model->loadCallBook($id, $this->config->item('use_fullname'));
|
||||||
$this->load->library('qrz');
|
|
||||||
|
if (!empty($callsign['callsign'])) {
|
||||||
// Load the encryption library
|
|
||||||
$this->load->library('encryption');
|
|
||||||
|
|
||||||
// Decrypt the password
|
|
||||||
$decrypted_password = $this->encryption->decrypt($this->session->userdata('callbook_password'));
|
|
||||||
|
|
||||||
if (!$this->session->userdata('qrz_session_key')) {
|
|
||||||
$qrz_session_key = $this->qrz->session($this->session->userdata('callbook_username'), $decrypted_password);
|
|
||||||
$this->session->set_userdata('qrz_session_key', $qrz_session_key);
|
|
||||||
}
|
|
||||||
$callsign['callsign'] = $this->qrz->search($id, $this->session->userdata('qrz_session_key'), $this->config->item('use_fullname'));
|
|
||||||
|
|
||||||
if (empty($callsign['callsign']['callsign'])) {
|
|
||||||
$qrz_session_key = $this->qrz->session($this->session->userdata('callbook_username'), $decrypted_password);
|
|
||||||
$this->session->set_userdata('qrz_session_key', $qrz_session_key);
|
|
||||||
$callsign['callsign'] = $this->qrz->search($id, $this->session->userdata('qrz_session_key'), $this->config->item('use_fullname'));
|
|
||||||
}
|
|
||||||
if (isset($callsign['callsign']['dxcc'])) {
|
if (isset($callsign['callsign']['dxcc'])) {
|
||||||
$this->load->model('logbook_model');
|
|
||||||
$entity = $this->logbook_model->get_entity($callsign['callsign']['dxcc']);
|
$entity = $this->logbook_model->get_entity($callsign['callsign']['dxcc']);
|
||||||
$callsign['callsign']['dxcc_name'] = $entity['name'];
|
$callsign['callsign']['dxcc_name'] = $entity['name'];
|
||||||
}
|
}
|
||||||
} elseif ($this->session->userdata('callbook_type') == "HamQTH") {
|
|
||||||
// Load the HamQTH library
|
|
||||||
$this->load->library('hamqth');
|
|
||||||
|
|
||||||
// Load the encryption library
|
|
||||||
$this->load->library('encryption');
|
|
||||||
|
|
||||||
// Decrypt the password
|
|
||||||
$decrypted_password = $this->encryption->decrypt($this->session->userdata('callbook_password'));
|
|
||||||
|
|
||||||
|
|
||||||
if (!$this->session->userdata('hamqth_session_key')) {
|
|
||||||
$hamqth_session_key = $this->hamqth->session($this->session->userdata('callbook_username'), $decrypted_password);
|
|
||||||
$this->session->set_userdata('hamqth_session_key', $hamqth_session_key);
|
|
||||||
}
|
|
||||||
|
|
||||||
$callsign['callsign'] = $this->hamqth->search($id, $this->session->userdata('hamqth_session_key'));
|
|
||||||
|
|
||||||
// If HamQTH session has expired, start a new session and retry the search.
|
|
||||||
if ($callsign['callsign']['error'] == "Session does not exist or expired") {
|
|
||||||
$hamqth_session_key = $this->hamqth->session($this->session->userdata('callbook_username'), $decrypted_password);
|
|
||||||
$this->session->set_userdata('hamqth_session_key', $hamqth_session_key);
|
|
||||||
$callsign['callsign'] = $this->hamqth->search($callsign, $this->session->userdata('hamqth_session_key'));
|
|
||||||
}
|
|
||||||
if (isset($data['callsign']['gridsquare'])) {
|
|
||||||
$this->load->model('logbook_model');
|
|
||||||
$callsign['grid_worked'] = $this->logbook_model->check_if_grid_worked_in_logbook(strtoupper(substr($data['callsign']['gridsquare'], 0, 4)), 0, $this->session->userdata('user_default_band'));
|
|
||||||
}
|
|
||||||
if (isset($callsign['callsign']['dxcc'])) {
|
|
||||||
$this->load->model('logbook_model');
|
|
||||||
$entity = $this->logbook_model->get_entity($callsign['callsign']['dxcc']);
|
|
||||||
$callsign['callsign']['dxcc_name'] = $entity['name'];
|
|
||||||
}
|
|
||||||
if (isset($callsign['callsign']['error'])) {
|
|
||||||
$callsign['error'] = $callsign['callsign']['error'];
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// No callbook type set, return error message
|
// No callbook type set, return error message with better guidance
|
||||||
$callsign['error'] = 'Online callbook not configured. Go to <a href="' . site_url('user/edit/' . $this->session->userdata('user_id')) . '" class="alert-link">Account Settings</a> and select either QRZ or HamQTH in the "Callbook" section.';
|
$callsign['error'] = 'Online callbook not configured. You can configure QRZ or HamQTH credentials either in <a href="' . site_url('user/edit/' . $this->session->userdata('user_id')) . '" class="alert-link">Account Settings</a> or in the config.php file.';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($callsign['callsign']['gridsquare'])) {
|
if (isset($callsign['callsign']['gridsquare'])) {
|
||||||
|
|
@ -943,70 +889,18 @@ class Logbook extends CI_Controller
|
||||||
|
|
||||||
$this->load->view('view_log/partial/log_ajax.php', $data);
|
$this->load->view('view_log/partial/log_ajax.php', $data);
|
||||||
} else {
|
} else {
|
||||||
// if session data callbook_type is qrz
|
// Use the loadCallBook method from the model which handles fallback logic
|
||||||
if ($this->session->userdata('callbook_type') == "QRZ") {
|
$this->load->model('logbook_model');
|
||||||
// Lookup using QRZ
|
$data['callsign'] = $this->logbook_model->loadCallBook($fixedid, $this->config->item('use_fullname'));
|
||||||
$this->load->library('qrz');
|
|
||||||
|
if (!empty($data['callsign'])) {
|
||||||
// Load the encryption library
|
|
||||||
$this->load->library('encryption');
|
|
||||||
|
|
||||||
// Decrypt the password
|
|
||||||
$decrypted_password = $this->encryption->decrypt($this->session->userdata('callbook_password'));
|
|
||||||
|
|
||||||
if (!$this->session->userdata('qrz_session_key')) {
|
|
||||||
$qrz_session_key = $this->qrz->session($this->session->userdata('callbook_username'), $decrypted_password);
|
|
||||||
$this->session->set_userdata('qrz_session_key', $qrz_session_key);
|
|
||||||
}
|
|
||||||
$data['callsign'] = $this->qrz->search($fixedid, $this->session->userdata('qrz_session_key'), $this->config->item('use_fullname'));
|
|
||||||
|
|
||||||
if (empty($data['callsign']['callsign'])) {
|
|
||||||
$qrz_session_key = $this->qrz->session($this->session->userdata('callbook_username'), $decrypted_password);
|
|
||||||
$this->session->set_userdata('qrz_session_key', $qrz_session_key);
|
|
||||||
$data['callsign'] = $this->qrz->search($fixedid, $this->session->userdata('qrz_session_key'), $this->config->item('use_fullname'));
|
|
||||||
}
|
|
||||||
if (isset($data['callsign']['dxcc'])) {
|
if (isset($data['callsign']['dxcc'])) {
|
||||||
$this->load->model('logbook_model');
|
|
||||||
$entity = $this->logbook_model->get_entity($data['callsign']['dxcc']);
|
$entity = $this->logbook_model->get_entity($data['callsign']['dxcc']);
|
||||||
$data['callsign']['dxcc_name'] = $entity['name'];
|
$data['callsign']['dxcc_name'] = $entity['name'];
|
||||||
}
|
}
|
||||||
if (isset($data['callsign']['gridsquare'])) {
|
if (isset($data['callsign']['gridsquare'])) {
|
||||||
$this->load->model('logbook_model');
|
|
||||||
$data['grid_worked'] = $this->logbook_model->check_if_grid_worked_in_logbook(strtoupper(substr($data['callsign']['gridsquare'], 0, 4)), 0, $this->session->userdata('user_default_band'));
|
$data['grid_worked'] = $this->logbook_model->check_if_grid_worked_in_logbook(strtoupper(substr($data['callsign']['gridsquare'], 0, 4)), 0, $this->session->userdata('user_default_band'));
|
||||||
}
|
}
|
||||||
} elseif ($this->session->userdata('callbook_type') == "HamQTH") {
|
|
||||||
// Load the HamQTH library
|
|
||||||
$this->load->library('hamqth');
|
|
||||||
|
|
||||||
// Load the encryption library
|
|
||||||
$this->load->library('encryption');
|
|
||||||
|
|
||||||
// Decrypt the password
|
|
||||||
$decrypted_password = $this->encryption->decrypt($this->session->userdata('callbook_password'));
|
|
||||||
|
|
||||||
|
|
||||||
if (!$this->session->userdata('hamqth_session_key')) {
|
|
||||||
$hamqth_session_key = $this->hamqth->session($this->session->userdata('callbook_username'), $decrypted_password);
|
|
||||||
$this->session->set_userdata('hamqth_session_key', $hamqth_session_key);
|
|
||||||
}
|
|
||||||
|
|
||||||
$data['callsign'] = $this->hamqth->search($fixedid, $this->session->userdata('hamqth_session_key'));
|
|
||||||
|
|
||||||
// If HamQTH session has expired, start a new session and retry the search.
|
|
||||||
if ($data['callsign']['error'] == "Session does not exist or expired") {
|
|
||||||
$hamqth_session_key = $this->hamqth->session($this->session->userdata('callbook_username'), $decrypted_password);
|
|
||||||
$this->session->set_userdata('hamqth_session_key', $hamqth_session_key);
|
|
||||||
$data['callsign'] = $this->hamqth->search($fixedid, $this->session->userdata('hamqth_session_key'));
|
|
||||||
}
|
|
||||||
if (isset($data['callsign']['gridsquare'])) {
|
|
||||||
$this->load->model('logbook_model');
|
|
||||||
$data['grid_worked'] = $this->logbook_model->check_if_grid_worked_in_logbook(strtoupper(substr($data['callsign']['gridsquare'], 0, 4)), 0, $this->session->userdata('user_default_band'));
|
|
||||||
}
|
|
||||||
if (isset($data['callsign']['dxcc'])) {
|
|
||||||
$this->load->model('logbook_model');
|
|
||||||
$entity = $this->logbook_model->get_entity($data['callsign']['dxcc']);
|
|
||||||
$data['callsign']['dxcc_name'] = $entity['name'];
|
|
||||||
}
|
|
||||||
if (isset($data['callsign']['error'])) {
|
if (isset($data['callsign']['error'])) {
|
||||||
$data['error'] = $data['callsign']['error'];
|
$data['error'] = $data['callsign']['error'];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4576,61 +4576,136 @@ class Logbook_model extends CI_Model
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get effective callbook configuration, falling back from session to config file
|
||||||
|
* Returns array with 'type', 'username', 'password', 'use_config'
|
||||||
|
*/
|
||||||
|
private function getCallbookConfig()
|
||||||
|
{
|
||||||
|
$callbook_type = $this->session->userdata('callbook_type');
|
||||||
|
$callbook_username = $this->session->userdata('callbook_username');
|
||||||
|
$callbook_password = $this->session->userdata('callbook_password');
|
||||||
|
|
||||||
|
// If session has valid callbook configuration, use it
|
||||||
|
if (!empty($callbook_type) && $callbook_type != "None" && !empty($callbook_username) && !empty($callbook_password)) {
|
||||||
|
// Load the encryption library and decrypt password
|
||||||
|
$this->load->library('encryption');
|
||||||
|
$decrypted_password = $this->encryption->decrypt($callbook_password);
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'type' => $callbook_type,
|
||||||
|
'username' => $callbook_username,
|
||||||
|
'password' => $decrypted_password,
|
||||||
|
'use_config' => false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fall back to config file settings
|
||||||
|
$config_qrz_username = $this->config->item('qrz_username');
|
||||||
|
$config_qrz_password = $this->config->item('qrz_password');
|
||||||
|
$config_hamqth_username = $this->config->item('hamqth_username');
|
||||||
|
$config_hamqth_password = $this->config->item('hamqth_password');
|
||||||
|
$config_callbook = $this->config->item('callbook');
|
||||||
|
|
||||||
|
// Check QRZ config first
|
||||||
|
if (!empty($config_qrz_username) && !empty($config_qrz_password)) {
|
||||||
|
return array(
|
||||||
|
'type' => 'QRZ',
|
||||||
|
'username' => $config_qrz_username,
|
||||||
|
'password' => $config_qrz_password,
|
||||||
|
'use_config' => true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check HamQTH config
|
||||||
|
if (!empty($config_hamqth_username) && !empty($config_hamqth_password)) {
|
||||||
|
return array(
|
||||||
|
'type' => 'HamQTH',
|
||||||
|
'username' => $config_hamqth_username,
|
||||||
|
'password' => $config_hamqth_password,
|
||||||
|
'use_config' => true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check legacy callbook config setting
|
||||||
|
if ($config_callbook == 'qrz' && !empty($config_qrz_username) && !empty($config_qrz_password)) {
|
||||||
|
return array(
|
||||||
|
'type' => 'QRZ',
|
||||||
|
'username' => $config_qrz_username,
|
||||||
|
'password' => $config_qrz_password,
|
||||||
|
'use_config' => true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($config_callbook == 'hamqth' && !empty($config_hamqth_username) && !empty($config_hamqth_password)) {
|
||||||
|
return array(
|
||||||
|
'type' => 'HamQTH',
|
||||||
|
'username' => $config_hamqth_username,
|
||||||
|
'password' => $config_hamqth_password,
|
||||||
|
'use_config' => true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// No valid configuration found
|
||||||
|
return array(
|
||||||
|
'type' => null,
|
||||||
|
'username' => null,
|
||||||
|
'password' => null,
|
||||||
|
'use_config' => false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function loadCallBook($callsign, $use_fullname = false)
|
public function loadCallBook($callsign, $use_fullname = false)
|
||||||
{
|
{
|
||||||
$callbook = null;
|
$callbook = null;
|
||||||
try {
|
try {
|
||||||
if ($this->session->userdata('callbook_type') == "QRZ") {
|
$config = $this->getCallbookConfig();
|
||||||
|
|
||||||
|
if ($config['type'] == "QRZ" && !empty($config['username']) && !empty($config['password'])) {
|
||||||
// Lookup using QRZ
|
// Lookup using QRZ
|
||||||
$this->load->library('qrz');
|
$this->load->library('qrz');
|
||||||
|
|
||||||
// Load the encryption library
|
// Use a different session key name for config-based credentials to avoid conflicts
|
||||||
$this->load->library('encryption');
|
$session_key_name = $config['use_config'] ? 'qrz_config_session_key' : 'qrz_session_key';
|
||||||
|
|
||||||
// Decrypt the password
|
if(!$this->session->userdata($session_key_name)) {
|
||||||
$decrypted_password = $this->encryption->decrypt($this->session->userdata('callbook_password'));
|
$qrz_session_key = $this->qrz->session($config['username'], $config['password']);
|
||||||
|
$this->session->set_userdata($session_key_name, $qrz_session_key);
|
||||||
if(!$this->session->userdata('qrz_session_key')) {
|
|
||||||
$qrz_session_key = $this->qrz->session($this->session->userdata('callbook_username'), $decrypted_password);
|
|
||||||
$this->session->set_userdata('qrz_session_key', $qrz_session_key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$callbook = $this->qrz->search($callsign, $this->session->userdata('qrz_session_key'), $use_fullname);
|
$callbook = $this->qrz->search($callsign, $this->session->userdata($session_key_name), $use_fullname);
|
||||||
|
|
||||||
// if we got nothing, it's probably because our session key is invalid, try again
|
// if we got nothing, it's probably because our session key is invalid, try again
|
||||||
if (($callbook['callsign'] ?? '') == '') {
|
if (($callbook['callsign'] ?? '') == '') {
|
||||||
$qrz_session_key = $this->qrz->session($this->session->userdata('callbook_username'), $decrypted_password);
|
$qrz_session_key = $this->qrz->session($config['username'], $config['password']);
|
||||||
$this->session->set_userdata('qrz_session_key', $qrz_session_key);
|
$this->session->set_userdata($session_key_name, $qrz_session_key);
|
||||||
$callbook = $this->qrz->search($callsign, $this->session->userdata('qrz_session_key'), $use_fullname);
|
$callbook = $this->qrz->search($callsign, $this->session->userdata($session_key_name), $use_fullname);
|
||||||
// if we still got nothing, and it's a compound callsign, then try a search for the base call
|
// if we still got nothing, and it's a compound callsign, then try a search for the base call
|
||||||
if (($callbook['callsign'] ?? '') == '' && strpos($callsign, "/") !== false) {
|
if (($callbook['callsign'] ?? '') == '' && strpos($callsign, "/") !== false) {
|
||||||
$callbook = $this->qrz->search($this->get_plaincall($callsign), $this->session->userdata('qrz_session_key'), $use_fullname);
|
$callbook = $this->qrz->search($this->get_plaincall($callsign), $this->session->userdata($session_key_name), $use_fullname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->session->userdata('callbook_type') == "HamQTH") {
|
if ($config['type'] == "HamQTH" && !empty($config['username']) && !empty($config['password'])) {
|
||||||
// Load the HamQTH library
|
// Load the HamQTH library
|
||||||
$this->load->library('hamqth');
|
$this->load->library('hamqth');
|
||||||
|
|
||||||
// Load the encryption library
|
// Use a different session key name for config-based credentials to avoid conflicts
|
||||||
$this->load->library('encryption');
|
$session_key_name = $config['use_config'] ? 'hamqth_config_session_key' : 'hamqth_session_key';
|
||||||
|
|
||||||
// Decrypt the password
|
|
||||||
$decrypted_password = $this->encryption->decrypt($this->session->userdata('callbook_password'));
|
|
||||||
|
|
||||||
if(!$this->session->userdata('hamqth_session_key')) {
|
if(!$this->session->userdata($session_key_name)) {
|
||||||
$hamqth_session_key = $this->hamqth->session($this->session->userdata('callbook_username'), $decrypted_password);
|
$hamqth_session_key = $this->hamqth->session($config['username'], $config['password']);
|
||||||
$this->session->set_userdata('hamqth_session_key', $hamqth_session_key);
|
$this->session->set_userdata($session_key_name, $hamqth_session_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
$callbook = $this->hamqth->search($callsign, $this->session->userdata('hamqth_session_key'));
|
$callbook = $this->hamqth->search($callsign, $this->session->userdata($session_key_name));
|
||||||
|
|
||||||
// If HamQTH session has expired, start a new session and retry the search.
|
// If HamQTH session has expired, start a new session and retry the search.
|
||||||
if ($callbook['error'] == "Session does not exist or expired") {
|
if ($callbook['error'] == "Session does not exist or expired") {
|
||||||
$hamqth_session_key = $this->hamqth->session($this->session->userdata('callbook_username'), $decrypted_password);
|
$hamqth_session_key = $this->hamqth->session($config['username'], $config['password']);
|
||||||
$this->session->set_userdata('hamqth_session_key', $hamqth_session_key);
|
$this->session->set_userdata($session_key_name, $hamqth_session_key);
|
||||||
$callbook = $this->hamqth->search($callsign, $this->session->userdata('hamqth_session_key'));
|
$callbook = $this->hamqth->search($callsign, $this->session->userdata($session_key_name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ $db['default'] = array(
|
||||||
// The following values can probably stay the same.
|
// The following values can probably stay the same.
|
||||||
'dbdriver' => 'mysqli',
|
'dbdriver' => 'mysqli',
|
||||||
'dbprefix' => '',
|
'dbprefix' => '',
|
||||||
'pconnect' => TRUE,
|
'pconnect' => FALSE,
|
||||||
'db_debug' => (ENVIRONMENT !== 'production'),
|
'db_debug' => (ENVIRONMENT !== 'production'),
|
||||||
'cache_on' => FALSE,
|
'cache_on' => FALSE,
|
||||||
'cachedir' => '',
|
'cachedir' => '',
|
||||||
|
|
|
||||||
正在加载…
在新工单中引用