diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index 9f77851bd3..32665b82ec 100644 --- a/application/controllers/Logbook.php +++ b/application/controllers/Logbook.php @@ -97,7 +97,8 @@ function json($tempcallsign, $tempband, $tempmode, $tempstation_id = null, $date // Check Database for all other data $this->load->model('logbook_model'); - $lotw_days=$this->logbook_model->check_last_lotw($callsign); + $lotw_days = $this->logbook_model->check_last_lotw($callsign); + if ($lotw_days != null) { $lotw_member="active"; } else { @@ -127,12 +128,12 @@ function json($tempcallsign, $tempband, $tempmode, $tempstation_id = null, $date $return['dxcc'] = $this->dxcheck($callsign,$date); - $lookupcall=$this->logbook_model->get_plaincall($callsign); - - $return['partial'] = $this->partial($lookupcall, $band); + $lookupcall = $this->logbook_model->get_plaincall($callsign); $callbook = $this->logbook_model->loadCallBook($callsign, $this->config->item('use_fullname')); + $return['partial'] = $this->partial($lookupcall, $callbook, $callsign, $return['dxcc'], $lotw_days, $band); + if ($this->session->userdata('user_measurement_base') == NULL) { $measurement_base = $this->config->item('measurement_base'); } else { @@ -614,7 +615,7 @@ function view($id) { $this->load->view('interface_assets/footer'); } - function partial($id, $band = null) { + function partial($lookupcall, $callbook, $callsign, $dxcc, $lotw_days, $band = null) { $this->load->model('user_model'); if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; } @@ -631,10 +632,10 @@ function partial($id, $band = null) { $this->db->where_in('station_profile.station_id', $logbooks_locations_array); $this->db->group_start(); - $this->db->where($this->config->item('table_name').'.COL_CALL', $id); - $this->db->or_like($this->config->item('table_name').'.COL_CALL', '/'.$id,'before'); - $this->db->or_like($this->config->item('table_name').'.COL_CALL', $id.'/','after'); - $this->db->or_like($this->config->item('table_name').'.COL_CALL', '/'.$id.'/'); + $this->db->where($this->config->item('table_name').'.COL_CALL', $lookupcall); + $this->db->or_like($this->config->item('table_name').'.COL_CALL', '/'.$lookupcall,'before'); + $this->db->or_like($this->config->item('table_name').'.COL_CALL', $lookupcall.'/','after'); + $this->db->or_like($this->config->item('table_name').'.COL_CALL', '/'.$lookupcall.'/'); $this->db->group_end(); $this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "desc"); @@ -825,82 +826,28 @@ function partial($id, $band = null) { $html .= ""; return $html; } else { - if ($this->config->item('callbook') == "qrz" && $this->config->item('qrz_username') != null && $this->config->item('qrz_password') != null) { - // Lookup using QRZ - $this->load->library('qrz'); - - if(!$this->session->userdata('qrz_session_key')) { - $qrz_session_key = $this->qrz->session($this->config->item('qrz_username'), $this->config->item('qrz_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->config->item('qrz_username'), $this->config->item('qrz_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'])) { - $this->load->model('logbook_model'); - $entity = $this->logbook_model->get_entity($callsign['callsign']['dxcc']); - $callsign['callsign']['dxcc_name'] = $entity['name']; - $callsign['dxcc_worked'] = $this->logbook_model->check_if_dxcc_worked_in_logbook($callsign['callsign']['dxcc'], null, $this->session->userdata('user_default_band')); - $callsign['dxcc_confirmed'] = $this->logbook_model->check_if_dxcc_cnfmd_in_logbook($callsign['callsign']['dxcc'], null, $this->session->userdata('user_default_band')); - } - } else if ($this->config->item('callbook') == "hamqth" && $this->config->item('hamqth_username') != null && $this->config->item('hamqth_password') != null) { - // Load the HamQTH library - $this->load->library('hamqth'); - - if(!$this->session->userdata('hamqth_session_key')) { - $hamqth_session_key = $this->hamqth->session($this->config->item('hamqth_username'), $this->config->item('hamqth_password')); - $this->session->set_userdata('hamqth_session_key', $hamqth_session_key); - } - - $callsign['callsign'] = $this->hamqth->search($id, $this->session->userdata('hamqth_session_key')); + $callsigninfo['callsign'] = $callbook; - // 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->config->item('hamqth_username'), $this->config->item('hamqth_password')); - $this->session->set_userdata('hamqth_session_key', $hamqth_session_key); - $callsign['callsign'] = $this->hamqth->search($id, $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)), null, $this->session->userdata('user_default_band'))->num_rows(); - } - 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']; - $callsign['dxcc_worked'] = $this->logbook_model->check_if_dxcc_worked_in_logbook($callsign['callsign']['dxcc'], null, $this->session->userdata('user_default_band')); - $callsign['dxcc_confirmed'] = $this->logbook_model->check_if_dxcc_cnfmd_in_logbook($callsign['callsign']['dxcc'], null, $this->session->userdata('user_default_band')); - } - if (isset($callsign['callsign']['error'])) { - $callsign['error'] = $callsign['callsign']['error']; - } - } else { - $callsign['error'] = 'Lookup not configured. Please review configuration.'; - } - - // There's no hamli integration? Disabled for now. - /*else { - // Lookup using hamli - $this->load->library('hamli'); + if ($dxcc['adif'] !== 0) { + $this->load->model('logbook_model'); + $callsigninfo['callsign']['dxcc_name'] = $dxcc['entity']; + $callsigninfo['dxcc_worked'] = $this->logbook_model->check_if_dxcc_worked_in_logbook($dxcc['adif'], null, $this->session->userdata('user_default_band')); + $callsigninfo['dxcc_confirmed'] = $this->logbook_model->check_if_dxcc_cnfmd_in_logbook($dxcc['adif'], null, $this->session->userdata('user_default_band')); + } - $callsign['callsign'] = $this->hamli->callsign($id); - }*/ + if (isset($callsigninfo['callsign']['gridsquare'])) { + $this->load->model('logbook_model'); + $callsigninfo['grid_worked'] = $this->logbook_model->check_if_grid_worked_in_logbook(strtoupper(substr($callsigninfo['callsign']['gridsquare'],0,4)), null, $band)->num_rows(); + } - if (isset($callsign['callsign']['gridsquare'])) { - $this->load->model('logbook_model'); - $callsign['grid_worked'] = $this->logbook_model->check_if_grid_worked_in_logbook(strtoupper(substr($callsign['callsign']['gridsquare'],0,4)), null, $band)->num_rows(); - } - if (isset($callsign['callsign']['error'])) { - $callsign['error'] = $callsign['callsign']['error']; - } + if (isset($callsigninfo['callsign']['error'])) { + $callsigninfo['error'] = $callsigninfo['callsign']['error']; + } - $callsign['id'] = strtoupper($id); - $callsign['lotw_lastupload'] = $this->logbook_model->check_last_lotw($id); - return $this->load->view('search/result', $callsign, true); + $callsigninfo['lookupcall'] = strtoupper($lookupcall); + $callsigninfo['realcall'] = strtoupper($callsign); + $callsigninfo['lotw_lastupload'] = $lotw_days; + return $this->load->view('search/result', $callsigninfo, true); } } @@ -937,67 +884,27 @@ function search_result($id="", $id2="") { $data['results'] = $iota_search; $this->load->view('view_log/partial/log_ajax.php', $data); } else { - if ($this->config->item('callbook') == "qrz" && $this->config->item('qrz_username') != null && $this->config->item('qrz_password') != null) { - // Lookup using QRZ - $this->load->library('qrz'); - - if(!$this->session->userdata('qrz_session_key')) { - $qrz_session_key = $this->qrz->session($this->config->item('qrz_username'), $this->config->item('qrz_password')); - $this->session->set_userdata('qrz_session_key', $qrz_session_key); - } - - $data['callsign'] = $this->qrz->search($id, $this->session->userdata('qrz_session_key'), $this->config->item('use_fullname')); - if (isset($data['callsign']['gridsquare'])) { - $data['grid_worked'] = $this->logbook_model->check_if_grid_worked_in_logbook(strtoupper(substr($data['callsign']['gridsquare'],0,4)), null, $this->session->userdata('user_default_band'))->num_rows(); - } - if (isset($data['callsign']['dxcc'])) { - $entity = $this->logbook_model->get_entity($data['callsign']['dxcc']); - $data['callsign']['dxcc_name'] = $entity['name']; - $data['dxcc_worked'] = $this->logbook_model->check_if_dxcc_worked_in_logbook($data['callsign']['dxcc'], null, $this->session->userdata('user_default_band')); - $data['dxcc_confirmed'] = $this->logbook_model->check_if_dxcc_cnfmd_in_logbook($data['callsign']['dxcc'], null, $this->session->userdata('user_default_band')); - } - if (isset($data['callsign']['error'])) { - $data['error'] = $data['callsign']['error']; - } - } else if ($this->config->item('callbook') == "hamqth" && $this->config->item('hamqth_username') != null && $this->config->item('hamqth_password') != null) { - // Load the HamQTH library - $this->load->library('hamqth'); - - if(!$this->session->userdata('hamqth_session_key')) { - $hamqth_session_key = $this->hamqth->session($this->config->item('hamqth_username'), $this->config->item('hamqth_password')); - $this->session->set_userdata('hamqth_session_key', $hamqth_session_key); - } + if (!$this->load->is_loaded('callbook')) { + $this->load->library('callbook'); + } - $data['callsign'] = $this->hamqth->search($id, $this->session->userdata('hamqth_session_key')); + $data['callsign'] = $this->callbook->getCallbookData($id); - // 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->config->item('hamqth_username'), $this->config->item('hamqth_password')); - $this->session->set_userdata('hamqth_session_key', $hamqth_session_key); - $data['callsign'] = $this->hamqth->search($id, $this->session->userdata('hamqth_session_key')); - } - if (isset($data['callsign']['gridsquare'])) { - $data['grid_worked'] = $this->logbook_model->check_if_grid_worked_in_logbook(strtoupper(substr($data['callsign']['gridsquare'],0,4)), null, $this->session->userdata('user_default_band'))->num_rows(); - } - if (isset($data['callsign']['dxcc'])) { - $entity = $this->logbook_model->get_entity($data['callsign']['dxcc']); - $data['callsign']['dxcc_name'] = $entity['name']; - $data['dxcc_worked'] = $this->logbook_model->check_if_dxcc_worked_in_logbook($data['callsign']['dxcc'], null, $this->session->userdata('user_default_band')); - $data['dxcc_confirmed'] = $this->logbook_model->check_if_dxcc_cnfmd_in_logbook($data['callsign']['dxcc'], null, $this->session->userdata('user_default_band')); - } - if (isset($data['callsign']['error'])) { - $data['error'] = $data['callsign']['error']; - } - } else { - $data['error'] = 'Lookup not configured. Please review configuration.'; - } /*else { - // Lookup using hamli - $this->load->library('hamli'); - - $data['callsign'] = $this->hamli->callsign($id); - }*/ + if (isset($data['callsign']['gridsquare'])) { + $data['grid_worked'] = $this->logbook_model->check_if_grid_worked_in_logbook(strtoupper(substr($data['callsign']['gridsquare'],0,4)), null, $this->session->userdata('user_default_band'))->num_rows(); + } + if (isset($data['callsign']['dxcc'])) { + $entity = $this->logbook_model->get_entity($data['callsign']['dxcc']); + $data['callsign']['dxcc_name'] = $entity['name']; + $data['dxcc_worked'] = $this->logbook_model->check_if_dxcc_worked_in_logbook($data['callsign']['dxcc'], null, $this->session->userdata('user_default_band')); + $data['dxcc_confirmed'] = $this->logbook_model->check_if_dxcc_cnfmd_in_logbook($data['callsign']['dxcc'], null, $this->session->userdata('user_default_band')); + } + if (isset($data['callsign']['error'])) { + $data['error'] = $data['callsign']['error']; + } - $data['id'] = strtoupper($id); + $data['lookupcall'] = strtoupper($id); + $data['realcall'] = strtoupper($id); $data['lotw_lastupload'] = $this->logbook_model->check_last_lotw($id); $this->load->view('search/result', $data); diff --git a/application/libraries/Callbook.php b/application/libraries/Callbook.php new file mode 100644 index 0000000000..06cd40f91e --- /dev/null +++ b/application/libraries/Callbook.php @@ -0,0 +1,154 @@ +ci = & get_instance(); + } + + // TODO: + // Implement the following: + // - Implement callsign reduced logic + public function getCallbookData($callsign) { + switch ($this->ci->config->item('callbook')) { + case 'qrz': + if ($this->ci->config->item('qrz_username') == null || $this->ci->config->item('qrz_password') == null) { + $callbook['error'] = 'Lookup not configured. Please review configuration.'; + return $callbook; + } + return $this->qrz($this->ci->config->item('qrz_username'), $this->ci->config->item('qrz_password'), $callsign, $this->ci->config->item('use_fullname')); + break; + case 'qrzcq': + if ($this->ci->config->item('qrzcq_username') == null || $this->ci->config->item('qrzcq_password') == null) { + $callbook['error'] = 'Lookup not configured. Please review configuration.'; + return $callbook; + } + return $this->qrzcq($this->ci->config->item('qrzcq_username'), $this->ci->config->item('qrzcq_password'), $callsign); + break; + case 'hamqth': + if ($this->ci->config->item('hamqth_username') == null || $this->ci->config->item('hamqth_password') == null) { + $callbook['error'] = 'Lookup not configured. Please review configuration.'; + return $callbook; + } + return $this->hamqth($this->ci->config->item('hamqth_username'), $this->ci->config->item('hamqth_password'), $callsign); + break; + default: + $callbook['error'] = 'No callbook defined. Please review configuration.'; + return $callbook; + } + } + + function qrz($username, $password, $callsign, $fullname) { + if (!$this->ci->load->is_loaded('qrz')) { + $this->ci->load->library('qrz'); + } + + if (!$this->ci->session->userdata('qrz_session_key')) { + $qrz_session_key = $this->ci->qrz->session($username, $password); + $this->ci->session->set_userdata('qrz_session_key', $qrz_session_key); + } + + $callbook = $this->ci->qrz->search($callsign, $this->ci->session->userdata('qrz_session_key'), $fullname); + + if ($callbook['error'] ?? '' == 'Invalid session key') { + $qrz_session_key = $this->ci->qrz->session($username, $password); + $this->ci->session->set_userdata('qrz_session_key', $qrz_session_key); + $callbook = $this->ci->qrz->search($callsign, $this->ci->session->userdata('qrz_session_key'), $fullname); + } + + if (strpos($callbook['error'] ?? '', 'Not found') !== false && strpos($callsign, "/") !== false) { + $plaincall = $this->get_plaincall($callsign); + // Now try again but give back reduced data, as we can't validate location and stuff (true at the end) + $callbook = $this->ci->qrz->search($plaincall, $this->ci->session->userdata('qrz_session_key'), $fullname, true); + } + + return $callbook; + } + + function qrzcq($username, $password, $callsign) { + if (!$this->ci->load->is_loaded('qrzcq')) { + $this->ci->load->library('qrzcq'); + } + + if (!$this->ci->session->userdata('qrzcq_session_key')) { + $result = $this->ci->qrzcq->session($username, $password); + if ($result[0] == 0) { + $this->ci->session->set_userdata('qrzcq_session_key', $result[1]); + } else { + $data['error'] = __("QRZCQ Error").": ".$result[1]; + return $data; + } + } + + $callbook = $this->ci->qrzcq->search($callsign, $this->ci->session->userdata('qrzcq_session_key')); + + if ($callbook['error'] ?? '' == 'Invalid session key') { + $qrzcq_session_key = $this->ci->qrzcq->session($username, $password); + $this->ci->session->set_userdata('qrzcq_session_key', $qrzcq_session_key); + $callbook = $this->ci->qrzcq->search($callsign, $this->ci->session->userdata('qrzcq_session_key')); + } + + if (strpos($callbook['error'] ?? '', 'Not found') !== false && strpos($callsign, "/") !== false) { + $plaincall = $this->get_plaincall($callsign); + // Now try again but give back reduced data, as we can't validate location and stuff (true at the end) + $callbook = $this->ci->qrzcq->search($plaincall, $this->ci->session->userdata('qrzcq_session_key'), true); + } + + return $callbook; + } + + function hamqth($username, $password, $callsign) { + // Load the HamQTH library + if (!$this->ci->load->is_loaded('hamqth')) { + $this->ci->load->library('hamqth'); + } + + if (!$this->ci->session->userdata('hamqth_session_key')) { + $hamqth_session_key = $this->ci->hamqth->session($username, $password); + $this->ci->session->set_userdata('hamqth_session_key', $hamqth_session_key); + } + + $callbook = $this->ci->hamqth->search($callsign, $this->ci->session->userdata('hamqth_session_key')); + + // If HamQTH session has expired, start a new session and retry the search. + if ($callbook['error'] == "Session does not exist or expired") { + $hamqth_session_key = $this->ci->hamqth->session($username, $password); + $this->ci->session->set_userdata('hamqth_session_key', $hamqth_session_key); + $callbook = $this->ci->hamqth->search($callsign, $this->ci->session->userdata('hamqth_session_key')); + } + + if (strpos($callbook['error'] ?? '', 'Not found') !== false && strpos($callsign, "/") !== false) { + $plaincall = $this->get_plaincall($callsign); + // Now try again but give back reduced data, as we can't validate location and stuff (true at the end) + $callbook = $this->ci->hamqth->search($plaincall, $this->ci->session->userdata('hamqth_session_key'), true); + } + + return $callbook; + } + + function get_plaincall($callsign) { + $split_callsign = explode('/', $callsign); + if (count($split_callsign) == 1) { // case F0ABC --> return cel 0 // + $lookupcall = $split_callsign[0]; + } else if (count($split_callsign) == 3) { // case EA/F0ABC/P --> return cel 1 // + $lookupcall = $split_callsign[1]; + } else { // case F0ABC/P --> return cel 0 OR case EA/FOABC --> retunr 1 (normaly not exist) // + if (in_array(strtoupper($split_callsign[1]), array('P', 'M', 'MM', 'QRP', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'))) { + $lookupcall = $split_callsign[0]; + } else if (strlen($split_callsign[1]) > 3) { // Last Element longer than 3 chars? Take that as call + $lookupcall = $split_callsign[1]; + } else { // Last Element up to 3 Chars? Take first element as Call + $lookupcall = $split_callsign[0]; + } + } + return $lookupcall; + } +} diff --git a/application/libraries/Qrzcq.php b/application/libraries/Qrzcq.php new file mode 100644 index 0000000000..de1968b73a --- /dev/null +++ b/application/libraries/Qrzcq.php @@ -0,0 +1,151 @@ +optionslib->get_option('version')); + $xml = curl_exec($ch); + curl_close($ch); + + // Create XML object + $xml = simplexml_load_string($xml); + + if (isset($xml->Session->Key)) { + $result = array( 0, (string) $xml->Session->Key); + } else if (isset($xml->Session->Error)) { + $result = array( 1, (string) $xml->Session->Error); + } else { + $result = array( 2, 'Unknown error'); + } + + return $result; + } + + // Set Session Key session. + public function set_session($username, $password) { + + $ci = & get_instance(); + + // URL to the XML Source + $xml_feed_url = 'https://ssl.qrzcq.com/xml/?username='.$username.';password='.urlencode($password).';agent=wavelog'; + + // CURL Functions + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $xml_feed_url); + curl_setopt($ch, CURLOPT_HEADER, false); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); + curl_setopt($ch, CURLOPT_TIMEOUT, 10); + curl_setopt($ch, CURLOPT_USERAGENT, 'Wavelog/'.$ci->optionslib->get_option('version')); + $xml = curl_exec($ch); + curl_close($ch); + + // Create XML object + $xml = simplexml_load_string($xml); + + $key = (string) $xml->Session->Key; + + $ci->session->set_userdata('qrzcq_session_key', $key); + + return true; + } + + + public function search($callsign, $key, $reduced = false) { + $data = null; + $ci = & get_instance(); + try { + // URL to the XML Source + $xml_feed_url = 'https://ssl.qrzcq.com/xml/?s=' . $key . ';callsign=' . $callsign . ''; + + // CURL Functions + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $xml_feed_url); + curl_setopt($ch, CURLOPT_HEADER, false); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); + curl_setopt($ch, CURLOPT_TIMEOUT, 10); + curl_setopt($ch, CURLOPT_USERAGENT, 'Wavelog/'.$ci->optionslib->get_option('version')); + $xml = curl_exec($ch); + $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + curl_close($ch); + if ($httpcode != 200) return $data['error'] = 'Problems with qrzcq.com communication'; // Exit function if no 200. If request fails, 0 is returned + + // Create XML object + $xml = simplexml_load_string($xml); + if (!empty($xml->Session->Error)) { + return $data['error'] = $xml->Session->Error; + } + + // Return Required Fields + $data['callsign'] = (string)$xml->Callsign->call; + + $data['name'] = (string)$xml->Callsign->name; + + // we always give back the name, no matter if reduced data or not + $data['name'] = trim($data['name']); + + // Sanitize gridsquare to allow only up to 8 characters + $unclean_gridsquare = (string)$xml->Callsign->locator; // Get the gridsquare from QRZ convert to string + $clean_gridsquare = strlen($unclean_gridsquare) > 8 ? substr($unclean_gridsquare,0,8) : $unclean_gridsquare; // Trim gridsquare to 8 characters max + + if ($reduced == false) { + + $data['gridsquare'] = $clean_gridsquare; + $data['city'] = (string)$xml->Callsign->city; + $data['lat'] = (string)$xml->Callsign->latitude; + $data['long'] = (string)$xml->Callsign->longitude; + $data['dxcc'] = (string)$xml->Callsign->dxcc; + $data['state'] = (string)$xml->Callsign->state; + $data['iota'] = (string)$xml->Callsign->iota; + $data['image'] = (string)$xml->Callsign->qslpic; + $data['ituz'] = (string)$xml->Callsign->itu; + $data['cqz'] = (string)$xml->Callsign->cq; + $data['continent'] = (string)$xml->Callsign->continent; + + if ($xml->Callsign->country == "United States") { + $data['us_county'] = (string)$xml->Callsign->county; + } else { + $data['us_county'] = null; + $data['county'] = (string)$xml->Callsign->county; + } + + } else { + + $data['gridsquare'] = ''; + $data['city'] = ''; + $data['lat'] = ''; + $data['long'] = ''; + $data['dxcc'] = ''; + $data['state'] = ''; + $data['iota'] = ''; + $data['image'] = (string)$xml->Callsign->qslpic; + $data['county'] = ''; + $data['us_county'] = ''; + $data['ituz'] = ''; + $data['cqz'] = ''; + + } + } finally { + + return $data; + } + } +} diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index c7d8762a48..96865f6020 100644 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -278,8 +278,8 @@ function create_qso() { $distance=null; if ( (($this->input->post('distance') ?? '') != '') && (is_numeric($this->input->post('distance'))) ) { $distance=$this->input->post('distance'); - } - + } + // Create array with QSO Data $data = array( 'COL_TIME_ON' => $datetime, @@ -2389,7 +2389,7 @@ function check_if_dxcc_cnfmd_in_logbook_api($user_default_confirmation,$dxcc, $s $binding=[]; if ($station_ids == null) { return []; - } + } $extrawhere = $this->qsl_default_where($user_default_confirmation); @@ -4270,7 +4270,7 @@ function import($record, $station_id = "0", $skipDuplicate = false, $markClublog 'COL_CREDIT_GRANTED' => (!empty($record['credit_granted'])) ? $record['credit_granted'] : '', 'COL_CREDIT_SUBMITTED' => (!empty($record['credit_submitted'])) ? $record['credit_submitted'] : '', 'COL_DARC_DOK' => (!empty($record['darc_dok'])) ? strtoupper($record['darc_dok']) : '', - 'COL_DISTANCE' => $distance, + 'COL_DISTANCE' => $distance, 'COL_DXCC' => $dxcc[0], 'COL_EMAIL' => (!empty($record['email'])) ? $record['email'] : '', 'COL_EQ_CALL' => (!empty($record['eq_call'])) ? $record['eq_call'] : '', @@ -4448,7 +4448,7 @@ function import($record, $station_id = "0", $skipDuplicate = false, $markClublog } else { $this->add_qso($data, $skipexport); } - + } else { $my_error .= "Date/Time: " . ($time_on ?? 'N/A') . " Callsign: " . ($record['call'] ?? 'N/A') . " Band: " . ($band ?? 'N/A') . " ".__("Duplicate for")." ". ($station_profile_call ?? 'N/A') . "
"; } @@ -4983,40 +4983,12 @@ public function check_missing_grid_id($all) { if ($r->num_rows() > 0) { foreach ($r->result_array() as $row) { $callsign = $row['COL_CALL']; - if ($this->config->item('callbook') == "qrz" && $this->config->item('qrz_username') != null && $this->config->item('qrz_password') != null) { - // Lookup using QRZ - if (!$this->load->is_loaded('qrz')) { - $this->load->library('qrz'); - } - - if (!$this->session->userdata('qrz_session_key')) { - $qrz_session_key = $this->qrz->session($this->config->item('qrz_username'), $this->config->item('qrz_password')); - $this->session->set_userdata('qrz_session_key', $qrz_session_key); - } - - $callbook = $this->qrz->search($callsign, $this->session->userdata('qrz_session_key')); + if (!$this->load->is_loaded('callbook')) { + $this->load->library('callbook'); } - if ($this->config->item('callbook') == "hamqth" && $this->config->item('hamqth_username') != null && $this->config->item('hamqth_password') != null) { - // Load the HamQTH library - if (!$this->load->is_loaded('hamqth')) { - $this->load->library('hamqth'); - } - - if (!$this->session->userdata('hamqth_session_key')) { - $hamqth_session_key = $this->hamqth->session($this->config->item('hamqth_username'), $this->config->item('hamqth_password')); - $this->session->set_userdata('hamqth_session_key', $hamqth_session_key); - } + $callbook = $this->callbook->getCallbookData($callsign); - $callbook = $this->hamqth->search($callsign, $this->session->userdata('hamqth_session_key')); - - // If HamQTH session has expired, start a new session and retry the search. - if ($callbook['error'] == "Session does not exist or expired") { - $hamqth_session_key = $this->hamqth->session($this->config->item('hamqth_username'), $this->config->item('hamqth_password')); - $this->session->set_userdata('hamqth_session_key', $hamqth_session_key); - $callbook = $this->hamqth->search($callsign, $this->session->userdata('hamqth_session_key')); - } - } if (isset($callbook)) { if (isset($callbook['error'])) { printf("Error: " . $callbook['error'] . "
"); @@ -5112,55 +5084,12 @@ function get_plaincall($callsign) { public function loadCallBook($callsign, $use_fullname = false) { $callbook = null; try { - if ($this->config->item('callbook') == "qrz" && $this->config->item('qrz_username') != null && $this->config->item('qrz_password') != null) { - // Lookup using QRZ - $this->load->library('qrz'); - - if (!$this->session->userdata('qrz_session_key')) { - $qrz_session_key = $this->qrz->session($this->config->item('qrz_username'), $this->config->item('qrz_password')); - $this->session->set_userdata('qrz_session_key', $qrz_session_key); - } - - $callbook = $this->qrz->search($callsign, $this->session->userdata('qrz_session_key'), $use_fullname); - - // We need to handle, if the sessionkey is invalid - if ($callbook['error'] ?? '' == 'Invalid session key') { - $this->qrz->set_session($this->config->item('qrz_username'), $this->config->item('qrz_password')); - $callbook = $this->qrz->search($callsign, $this->session->userdata('qrz_session_key'), $use_fullname); - } - - // If the callsign contains a slash we have a pre- or suffix. If then the result is "Not found" we can try again with the plain call - if (strpos($callbook['error'] ?? '', 'Not found') !== false && strpos($callsign, "/") !== false) { - $plaincall = $this->get_plaincall($callsign); - // Now try again but give back reduced data, as we can't validate location and stuff (true at the end) - $callbook = $this->qrz->search($plaincall, $this->session->userdata('qrz_session_key'), $use_fullname, true); - } + if (!$this->load->is_loaded('callbook')) { + $this->load->library('callbook'); } - if ($this->config->item('callbook') == "hamqth" && $this->config->item('hamqth_username') != null && $this->config->item('hamqth_password') != null) { - // Load the HamQTH library - $this->load->library('hamqth'); + $callbook = $this->callbook->getCallbookData($callsign); - if (!$this->session->userdata('hamqth_session_key')) { - $hamqth_session_key = $this->hamqth->session($this->config->item('hamqth_username'), $this->config->item('hamqth_password')); - $this->session->set_userdata('hamqth_session_key', $hamqth_session_key); - } - - // if the callsign contains a pre- or suffix we only give back reduced data to avoid wrong data (location and other things are not valid then) - if (strpos($callsign, "/") !== false) { - $reduced = true; - } else { - $reduced = false; - } - $callbook = $this->hamqth->search($callsign, $this->session->userdata('hamqth_session_key'), $reduced); - - // If HamQTH session has expired, start a new session and retry the search. - if ($callbook['error'] == "Session does not exist or expired") { - $hamqth_session_key = $this->hamqth->session($this->config->item('hamqth_username'), $this->config->item('hamqth_password')); - $this->session->set_userdata('hamqth_session_key', $hamqth_session_key); - $callbook = $this->hamqth->search($callsign, $this->session->userdata('hamqth_session_key')); - } - } } finally { return $callbook; } diff --git a/application/views/search/result.php b/application/views/search/result.php index 8fbe57a289..602f0684a0 100644 --- a/application/views/search/result.php +++ b/application/views/search/result.php @@ -1,9 +1,9 @@
-

+

-

+

-

+

@@ -26,7 +26,7 @@
- pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy