From 4d73a50ef60cc5389a89867e32888d0d9d99161b Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Tue, 10 Nov 2020 20:25:26 -0500 Subject: [PATCH 01/17] Shows full name, but only when logged in (if available) --- application/libraries/Qrz.php | 2 +- application/views/view_log/qso.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/application/libraries/Qrz.php b/application/libraries/Qrz.php index dd0c995d..356073dc 100755 --- a/application/libraries/Qrz.php +++ b/application/libraries/Qrz.php @@ -73,7 +73,7 @@ class Qrz { // Return Required Fields $data['callsign'] = (string) $xml->Callsign->call; - $data['name'] = (string) $xml->Callsign->fname; + $data['name'] = (string) $xml->Callsign->fname . ' '. (string) $xml->Callsign->name; $data['gridsquare'] = (string) $xml->Callsign->grid; $data['city'] = (string) $xml->Callsign->addr2; $data['lat'] = (string) $xml->Callsign->lat; diff --git a/application/views/view_log/qso.php b/application/views/view_log/qso.php index 7a98d489..ff661084 100644 --- a/application/views/view_log/qso.php +++ b/application/views/view_log/qso.php @@ -141,13 +141,15 @@ + config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE) { ?> - COL_NAME != null) { ?> + COL_NAME != null) { ?> Name: COL_NAME; ?> + config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE) { ?> COL_COMMENT != null) { ?> From 8660d3d3ce6d0a22e5ecfbaf59743ca044dd6def Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Tue, 10 Nov 2020 22:13:25 -0500 Subject: [PATCH 02/17] Does a lookup on qrz/hamqth on api or when entering by hand. Names and grid squares are returned and populated if not already set. Full names are set since they are not shown unless logged in. --- application/controllers/Logbook.php | 33 +------------------ application/models/Logbook_model.php | 48 ++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 32 deletions(-) diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index d7a78199..ddadc4b9 100755 --- a/application/controllers/Logbook.php +++ b/application/controllers/Logbook.php @@ -138,39 +138,8 @@ class Logbook extends CI_Controller { return; } + $callbook = $this->logbook_model->loadCallBook($callsign); - 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')); - } - - 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); - } - - $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)) { diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index b5bd539b..907379d8 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -1791,6 +1791,16 @@ class Logbook_model extends CI_Model { } } + // if we are doing lookups and grid square and name aren't set, do the lookup now + + $callbook = $this->loadCallBook(strtoupper($record['call'])); + if (isset($callbook)) { + $record['name']= $callbook['name']; + if (empty($record['gridsquare'])) { + $record['gridsquare'] = $callbook['gridsquare']; + } + } + if (!$skip) { // Create array with QSO Data use ?: @@ -2158,6 +2168,42 @@ class Logbook_model extends CI_Model { } } + public function loadCallBook($callsign) + { + 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')); + } + + 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); + } + + $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')); + } + } + return $callbook; + } public function update_all_station_ids() { @@ -2271,4 +2317,6 @@ function validateADIFDate($date, $format = 'Ymd') $d = DateTime::createFromFormat($format, $date); return $d && $d->format($format) == $date; } + + ?> From 593db48556a2860caf62b0f6eeaea789906f50f9 Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Wed, 11 Nov 2020 09:17:08 -0500 Subject: [PATCH 03/17] Added exception handling when qrz or hamqth is not available/accessible. --- application/libraries/Hamqth.php | 67 +++++++++++++++------------- application/libraries/Qrz.php | 67 +++++++++++++++------------- application/models/Logbook_model.php | 52 ++++++++++----------- 3 files changed, 97 insertions(+), 89 deletions(-) diff --git a/application/libraries/Hamqth.php b/application/libraries/Hamqth.php index 69b49aad..c0ad8c86 100644 --- a/application/libraries/Hamqth.php +++ b/application/libraries/Hamqth.php @@ -56,41 +56,44 @@ class Hamqth { public function search($callsign, $key) { + $data = null; + try { + // URL to the XML Source + $xml_feed_url = 'https://www.hamqth.com/xml.php?id=' . $key . '&callsign=' . $callsign . '&prg=cloudlog'; - // URL to the XML Source - $xml_feed_url = 'https://www.hamqth.com/xml.php?id='.$key.'&callsign='.$callsign.'&prg=cloudlog'; + // 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); + $xml = curl_exec($ch); + curl_close($ch); - // 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); - $xml = curl_exec($ch); - curl_close($ch); + // Create XML object + $xml = simplexml_load_string($xml); + if (empty($xml)) return; - // Create XML object - $xml = simplexml_load_string($xml); + // Return Required Fields + $data['callsign'] = (string)$xml->search->callsign; + $data['name'] = (string)$xml->search->nick; + $data['gridsquare'] = (string)$xml->search->grid; + $data['city'] = (string)$xml->search->adr_city; + $data['lat'] = (string)$xml->search->latitude; + $data['long'] = (string)$xml->search->longitude; + $data['iota'] = (string)$xml->search->iota; + $data['us_state'] = (string)$xml->search->us_state; + $data['us_county'] = (string)$xml->search->us_county; + $data['error'] = (string)$xml->session->error; - // Return Required Fields - $data['callsign'] = (string) $xml->search->callsign; - $data['name'] = (string) $xml->search->nick; - $data['gridsquare'] = (string) $xml->search->grid; - $data['city'] = (string) $xml->search->adr_city; - $data['lat'] = (string) $xml->search->latitude; - $data['long'] = (string) $xml->search->longitude; - $data['iota'] = (string) $xml->search->iota; - $data['us_state'] = (string) $xml->search->us_state; - $data['us_county'] = (string) $xml->search->us_county; - $data['error'] = (string) $xml->session->error; - - if($xml->search->country == "United States") { - $data['state'] = (string) $xml->search->us_state; - $data['us_county'] = (string) $xml->search->us_county; - } else { - $data['state'] = null; - $data['us_county'] = null; - } - - return $data; + if ($xml->search->country == "United States") { + $data['state'] = (string)$xml->search->us_state; + $data['us_county'] = (string)$xml->search->us_county; + } else { + $data['state'] = null; + $data['us_county'] = null; + } + } finally { + return $data; + } } } diff --git a/application/libraries/Qrz.php b/application/libraries/Qrz.php index 356073dc..532a893e 100755 --- a/application/libraries/Qrz.php +++ b/application/libraries/Qrz.php @@ -56,40 +56,43 @@ class Qrz { public function search($callsign, $key) { + $data = null; + try { + // URL to the XML Source + $xml_feed_url = 'http://xmldata.qrz.com/xml/current/?s=' . $key . ';callsign=' . $callsign . ''; - // URL to the XML Source - $xml_feed_url = 'http://xmldata.qrz.com/xml/current/?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); - $xml = curl_exec($ch); - curl_close($ch); - - // Create XML object - $xml = simplexml_load_string($xml); - - // Return Required Fields - $data['callsign'] = (string) $xml->Callsign->call; - $data['name'] = (string) $xml->Callsign->fname . ' '. (string) $xml->Callsign->name; - $data['gridsquare'] = (string) $xml->Callsign->grid; - $data['city'] = (string) $xml->Callsign->addr2; - $data['lat'] = (string) $xml->Callsign->lat; - $data['long'] = (string) $xml->Callsign->lon; - $data['iota'] = (string) $xml->Callsign->iota; - $data['qslmgr'] = (string) $xml->Callsign->qslmgr; + // 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); + $xml = curl_exec($ch); + curl_close($ch); - if($xml->Callsign->country == "United States") { - $data['state'] = (string) $xml->Callsign->state; - $data['us_county'] = (string) $xml->Callsign->county; - } else { - $data['state'] = null; - $data['us_county'] = null; - } + // Create XML object + $xml = simplexml_load_string($xml); + if (empty($xml)) return; - - return $data; + // Return Required Fields + $data['callsign'] = (string)$xml->Callsign->call; + $data['name'] = (string)$xml->Callsign->fname . ' ' . (string)$xml->Callsign->name; + $data['gridsquare'] = (string)$xml->Callsign->grid; + $data['city'] = (string)$xml->Callsign->addr2; + $data['lat'] = (string)$xml->Callsign->lat; + $data['long'] = (string)$xml->Callsign->lon; + $data['iota'] = (string)$xml->Callsign->iota; + $data['qslmgr'] = (string)$xml->Callsign->qslmgr; + + if ($xml->Callsign->country == "United States") { + $data['state'] = (string)$xml->Callsign->state; + $data['us_county'] = (string)$xml->Callsign->county; + } else { + $data['state'] = null; + $data['us_county'] = null; + } + } finally { + + return $data; + } } } diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 907379d8..002cda23 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -2170,39 +2170,41 @@ class Logbook_model extends CI_Model { public function loadCallBook($callsign) { - 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'); + $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); + 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')); } - $callbook = $this->qrz->search($callsign, $this->session->userdata('qrz_session_key')); - } + 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->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->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->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 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; } - return $callbook; } public function update_all_station_ids() { From 406441894234979e06b2ed75c41087d47c740784 Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Wed, 11 Nov 2020 12:18:37 -0500 Subject: [PATCH 04/17] Trying to get full names working correctly --- application/controllers/Logbook.php | 15 ++++++++------- application/libraries/Qrz.php | 12 ++++++++++-- application/models/Logbook_model.php | 8 ++++++-- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index ddadc4b9..80db8bcf 100755 --- a/application/controllers/Logbook.php +++ b/application/controllers/Logbook.php @@ -122,7 +122,7 @@ class Logbook extends CI_Controller { $measurement_base = $this->session->userdata('user_measurement_base'); } - $return['callsign_name'] = $this->logbook_model->call_name($callsign); + $return['callsign_name'] = $this->logbook_model->call_name($callsign); $return['callsign_qra'] = $this->logbook_model->call_qra($callsign); $return['callsign_qth'] = $this->logbook_model->call_qth($callsign); $return['callsign_iota'] = $this->logbook_model->call_iota($callsign); @@ -138,7 +138,8 @@ class Logbook extends CI_Controller { return; } - $callbook = $this->logbook_model->loadCallBook($callsign); + + $callbook = $this->logbook_model->loadCallBook($callsign, $this->config->item('personal')); if (isset($callbook)) @@ -490,8 +491,8 @@ class Logbook extends CI_Controller { $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')); + echo("Part 1: ". (int)$this->config->item('personal')); + $data['callsign'] = $this->qrz->search($id, $this->session->userdata('qrz_session_key'), $this->config->item('personal')); } // There's no hamli integration? Disabled for now. @@ -544,11 +545,11 @@ class Logbook extends CI_Controller { $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')); + $qrz_session_key = $this->qrz->session($this->config->item('qrz_username')); $this->session->set_userdata('qrz_session_key', $qrz_session_key); } - - $data['callsign'] = $this->qrz->search($id, $this->session->userdata('qrz_session_key')); + echo ("Part 2: ". $this->config->item('personal'). "
"); + $data['callsign'] = $this->qrz->search($id, $this->session->userdata('qrz_session_key'), $this->config->item('qrz_password'), $this->config->item('personal')); } else { // Lookup using hamli $this->load->library('hamli'); diff --git a/application/libraries/Qrz.php b/application/libraries/Qrz.php index 532a893e..afbc3884 100755 --- a/application/libraries/Qrz.php +++ b/application/libraries/Qrz.php @@ -54,8 +54,11 @@ class Qrz { } - public function search($callsign, $key) + public function search($callsign, $key, $private="dog") { + echo("Callsign: ".$callsign."
"); + echo("key: ".$key."
"); + echo("FOOOOOO: ". $private."
"); $data = null; try { // URL to the XML Source @@ -75,7 +78,12 @@ class Qrz { // Return Required Fields $data['callsign'] = (string)$xml->Callsign->call; - $data['name'] = (string)$xml->Callsign->fname . ' ' . (string)$xml->Callsign->name; + + if ($private === true) { + $data['name'] = (string)$xml->Callsign->fname . ' AAAA ' . (string)$xml->Callsign->name; + } else { + $data['name'] = (string)$xml->Callsign->fname; + } $data['gridsquare'] = (string)$xml->Callsign->grid; $data['city'] = (string)$xml->Callsign->addr2; $data['lat'] = (string)$xml->Callsign->lat; diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 002cda23..9cbca2e1 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -2168,7 +2168,7 @@ class Logbook_model extends CI_Model { } } - public function loadCallBook($callsign) + public function loadCallBook($callsign, $personal=false) { $callbook = null; try { @@ -2181,7 +2181,11 @@ class Logbook_model extends CI_Model { $this->session->set_userdata('qrz_session_key', $qrz_session_key); } - $callbook = $this->qrz->search($callsign, $this->session->userdata('qrz_session_key')); + + $personal = "foo"; + echo ("part 3: ". $personal. "
"); + $callbook = $this->qrz->search($callsign, $this->session->userdata('qrz_session_key'), $this->config->item('qrz_password'), "foobar"); + echo ("part 4: ". $personal. "
"); } if ($this->config->item('callbook') == "hamqth" && $this->config->item('hamqth_username') != null && $this->config->item('hamqth_password') != null) { From 30600ae220a5f9f69f1dca73aba040b6d6be524b Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Wed, 11 Nov 2020 14:38:00 -0500 Subject: [PATCH 05/17] Added support for a config flag to determine if we should get full names from qrz. Added error checking for this with the api for import as well. --- application/controllers/Logbook.php | 10 +++++----- application/libraries/Qrz.php | 9 +++------ application/models/Logbook_model.php | 8 +++----- install/config/config.php | 11 +++++++++++ 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index 80db8bcf..654d92ee 100755 --- a/application/controllers/Logbook.php +++ b/application/controllers/Logbook.php @@ -139,7 +139,7 @@ class Logbook extends CI_Controller { } - $callbook = $this->logbook_model->loadCallBook($callsign, $this->config->item('personal')); + $callbook = $this->logbook_model->loadCallBook($callsign, $this->config->item('use_fullname')); if (isset($callbook)) @@ -491,8 +491,8 @@ class Logbook extends CI_Controller { $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); } - echo("Part 1: ". (int)$this->config->item('personal')); - $data['callsign'] = $this->qrz->search($id, $this->session->userdata('qrz_session_key'), $this->config->item('personal')); + + $data['callsign'] = $this->qrz->search($id, $this->session->userdata('qrz_session_key'), $this->config->item('use_fullname')); } // There's no hamli integration? Disabled for now. @@ -548,8 +548,8 @@ class Logbook extends CI_Controller { $qrz_session_key = $this->qrz->session($this->config->item('qrz_username')); $this->session->set_userdata('qrz_session_key', $qrz_session_key); } - echo ("Part 2: ". $this->config->item('personal'). "
"); - $data['callsign'] = $this->qrz->search($id, $this->session->userdata('qrz_session_key'), $this->config->item('qrz_password'), $this->config->item('personal')); + + $data['callsign'] = $this->qrz->search($id, $this->session->userdata('qrz_session_key'), $this->config->item('qrz_password'), $this->config->item('use_fullname')); } else { // Lookup using hamli $this->load->library('hamli'); diff --git a/application/libraries/Qrz.php b/application/libraries/Qrz.php index afbc3884..0ab43b1c 100755 --- a/application/libraries/Qrz.php +++ b/application/libraries/Qrz.php @@ -54,11 +54,8 @@ class Qrz { } - public function search($callsign, $key, $private="dog") + public function search($callsign, $key, $use_fullname) { - echo("Callsign: ".$callsign."
"); - echo("key: ".$key."
"); - echo("FOOOOOO: ". $private."
"); $data = null; try { // URL to the XML Source @@ -79,8 +76,8 @@ class Qrz { // Return Required Fields $data['callsign'] = (string)$xml->Callsign->call; - if ($private === true) { - $data['name'] = (string)$xml->Callsign->fname . ' AAAA ' . (string)$xml->Callsign->name; + if ($use_fullname === true) { + $data['name'] = (string)$xml->Callsign->fname . ' ' . (string)$xml->Callsign->name; } else { $data['name'] = (string)$xml->Callsign->fname; } diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 9cbca2e1..b2c9678e 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -2168,7 +2168,7 @@ class Logbook_model extends CI_Model { } } - public function loadCallBook($callsign, $personal=false) + public function loadCallBook($callsign, $use_fullname=false) { $callbook = null; try { @@ -2182,10 +2182,8 @@ class Logbook_model extends CI_Model { } - $personal = "foo"; - echo ("part 3: ". $personal. "
"); - $callbook = $this->qrz->search($callsign, $this->session->userdata('qrz_session_key'), $this->config->item('qrz_password'), "foobar"); - echo ("part 4: ". $personal. "
"); + + $callbook = $this->qrz->search($callsign, $this->session->userdata('qrz_session_key'), $use_fullname); } if ($this->config->item('callbook') == "hamqth" && $this->config->item('hamqth_username') != null && $this->config->item('hamqth_password') != null) { diff --git a/install/config/config.php b/install/config/config.php index 9be40323..008e9004 100644 --- a/install/config/config.php +++ b/install/config/config.php @@ -40,10 +40,21 @@ $config['display_freq'] = false; | | 'qrz_username' QRZ.com user login | 'qrz_password' QRZ.com user password +| 'use_fullname' Get full names from QRZ, may not be GDPR compliant */ $config['qrz_username'] = ""; $config['qrz_password'] = ""; +$config['use_fullname'] = false; + + +/* +|-------------------------------------------------------------------------- +| Are we running this on a personal server? If we are, GDPR laws +| prevent us from storing personal information. +| +*/ +$config['personal'] = false; /* |-------------------------------------------------------------------------- From 7c2c6cf4f0593129ebe6607cea8eab3cce362456 Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Wed, 11 Nov 2020 18:42:32 -0500 Subject: [PATCH 06/17] Checks to see if eithere the name and gridsquare is set on import, and if neithere is not set, it will do the lookup. If both are set in the adi for import, no lookup will be done. --- application/models/Logbook_model.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index b2c9678e..6092fddb 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -1793,11 +1793,16 @@ class Logbook_model extends CI_Model { // if we are doing lookups and grid square and name aren't set, do the lookup now - $callbook = $this->loadCallBook(strtoupper($record['call'])); - if (isset($callbook)) { - $record['name']= $callbook['name']; - if (empty($record['gridsquare'])) { - $record['gridsquare'] = $callbook['gridsquare']; + if ((empty($record['name'])) || empty($record['gridsquare'])) { + $callbook = $this->loadCallBook(strtoupper($record['call']), $this->config->item('use_fullname')); + if (isset($callbook)) { + if (empty($record['name'])) { + $record['name'] = $callbook['name']; + } + + if (empty($record['gridsquare'])) { + $record['gridsquare'] = $callbook['gridsquare']; + } } } From f70b24971018a0eb20db391fa55457ba42fc6c38 Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Wed, 11 Nov 2020 18:46:10 -0500 Subject: [PATCH 07/17] Fixed code that I accidently deleted --- application/controllers/Logbook.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index 654d92ee..5182a852 100755 --- a/application/controllers/Logbook.php +++ b/application/controllers/Logbook.php @@ -545,7 +545,7 @@ class Logbook extends CI_Controller { $this->load->library('qrz'); if(!$this->session->userdata('qrz_session_key')) { - $qrz_session_key = $this->qrz->session($this->config->item('qrz_username')); + $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); } From 9718ae672ebea0354e1ac33e3671221ce5ad9da1 Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Wed, 11 Nov 2020 18:48:30 -0500 Subject: [PATCH 08/17] Fixed code that I accidently deleted --- application/controllers/Logbook.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index 5182a852..f663c7c3 100755 --- a/application/controllers/Logbook.php +++ b/application/controllers/Logbook.php @@ -549,7 +549,7 @@ class Logbook extends CI_Controller { $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('qrz_password'), $this->config->item('use_fullname')); + $data['callsign'] = $this->qrz->search($id, $this->session->userdata('qrz_session_key'), $this->config->item('use_fullname')); } else { // Lookup using hamli $this->load->library('hamli'); From 80f4bc210c43bdd73e602cc717749b2f9972535f Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Fri, 13 Nov 2020 08:01:30 -0500 Subject: [PATCH 09/17] Escape names so that names with quotes in them work (aka, nicknames) --- application/libraries/Qrz.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/libraries/Qrz.php b/application/libraries/Qrz.php index 0ab43b1c..6019ac3d 100755 --- a/application/libraries/Qrz.php +++ b/application/libraries/Qrz.php @@ -77,9 +77,9 @@ class Qrz { $data['callsign'] = (string)$xml->Callsign->call; if ($use_fullname === true) { - $data['name'] = (string)$xml->Callsign->fname . ' ' . (string)$xml->Callsign->name; + $data['name'] = addslashes((string)$xml->Callsign->fname) . ' ' . addslashes((string)$xml->Callsign->name); } else { - $data['name'] = (string)$xml->Callsign->fname; + $data['name'] = addslashes((string)$xml->Callsign->fname); } $data['gridsquare'] = (string)$xml->Callsign->grid; $data['city'] = (string)$xml->Callsign->addr2; From 064075980bccc6ce965a0e009421771781269cf5 Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Fri, 13 Nov 2020 08:02:17 -0500 Subject: [PATCH 10/17] Check to see if dxcc is set on import to avoid errors --- application/models/Logbook_model.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 6092fddb..c89e2807 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -1538,7 +1538,9 @@ class Logbook_model extends CI_Model { if(isset($record['country'])) { $country = $record['country']; } else { - $country = ucwords(strtolower($dxcc[1])); + if (isset($dxcc[1])) { + $country = ucwords(strtolower($dxcc[1])); + } } // RST recevied From a5561236b18e1df3b90bf2af2ebc5d98812a1a0f Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Fri, 13 Nov 2020 10:57:48 -0500 Subject: [PATCH 11/17] Add a check when doing QRZ lookups to see if the session is valid, if not, create a new session and try again. --- application/models/Logbook_model.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index c89e2807..aba5184c 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -2191,6 +2191,14 @@ class Logbook_model extends CI_Model { $callbook = $this->qrz->search($callsign, $this->session->userdata('qrz_session_key'), $use_fullname); + + // if we got nothing, it's probably because our session key is invalid, try again + if (!isset($callbook['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); + $callbook = $this->qrz->search($callsign, $this->session->userdata('qrz_session_key'), $use_fullname); + } } if ($this->config->item('callbook') == "hamqth" && $this->config->item('hamqth_username') != null && $this->config->item('hamqth_password') != null) { From ace8de82bfcc84f13ad0230d42b496843c15039f Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Fri, 13 Nov 2020 13:30:37 -0500 Subject: [PATCH 12/17] Fixes issues #1. Apparently the code I added broke it, and there was a different issue that was causing names not to save. --- application/libraries/Qrz.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/libraries/Qrz.php b/application/libraries/Qrz.php index 6019ac3d..f855706a 100755 --- a/application/libraries/Qrz.php +++ b/application/libraries/Qrz.php @@ -77,9 +77,9 @@ class Qrz { $data['callsign'] = (string)$xml->Callsign->call; if ($use_fullname === true) { - $data['name'] = addslashes((string)$xml->Callsign->fname) . ' ' . addslashes((string)$xml->Callsign->name); + $data['name'] = (string)$xml->Callsign->fname. ' ' . (string)$xml->Callsign->name; } else { - $data['name'] = addslashes((string)$xml->Callsign->fname); + $data['name'] = (string)$xml->Callsign->fname; } $data['gridsquare'] = (string)$xml->Callsign->grid; $data['city'] = (string)$xml->Callsign->addr2; From c896e5d909d0edd9a4d029a131919b2b61de4aad Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Fri, 13 Nov 2020 13:43:33 -0500 Subject: [PATCH 13/17] When using fullname, the space was always inserted between first and last names even when no name was set. This now fixes issues #3 by triming the resultant string. --- application/libraries/Qrz.php | 1 + 1 file changed, 1 insertion(+) diff --git a/application/libraries/Qrz.php b/application/libraries/Qrz.php index f855706a..42a280be 100755 --- a/application/libraries/Qrz.php +++ b/application/libraries/Qrz.php @@ -81,6 +81,7 @@ class Qrz { } else { $data['name'] = (string)$xml->Callsign->fname; } + $data['name'] = trim($data['name']); $data['gridsquare'] = (string)$xml->Callsign->grid; $data['city'] = (string)$xml->Callsign->addr2; $data['lat'] = (string)$xml->Callsign->lat; From bf24cff4aa28e862b40c3915d4c8bb7c6e6cb499 Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Sat, 14 Nov 2020 15:40:22 -0500 Subject: [PATCH 14/17] Fix for #2, if dxcc info is not in the adif, and the user wants to get it from the adif, we will still look it up if it's not included. --- application/models/Logbook_model.php | 2 +- application/views/adif/import.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index aba5184c..4ac8ab79 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -1525,7 +1525,7 @@ class Logbook_model extends CI_Model { $entity = $this->get_entity($record['dxcc']); $dxcc = array($record['dxcc'], $entity['name']); } else { - $dxcc = NULL; + $dxcc = $this->check_dxcc_table($record['call'], $time_off); } } else { $dxcc = $this->check_dxcc_table($record['call'], $time_off); diff --git a/application/views/adif/import.php b/application/views/adif/import.php index 7f56d40e..56f26899 100644 --- a/application/views/adif/import.php +++ b/application/views/adif/import.php @@ -53,7 +53,8 @@ -
If not selected, Cloudlog will attempt to determine DXCC information automatically.
+
If not selected, Cloudlog will attempt to determine DXCC information automatically.
+ If selected, we will import from ADIF, but determine if not included in entries.
From 4ed092b955299c439d43ac70b84557f2309f9d45 Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Mon, 16 Nov 2020 10:00:47 -0500 Subject: [PATCH 15/17] Fixed an issue that I had fixed for imports when the QRZ session key had expired lookups would fail. Now it does the same thing for manually entering QSOs --- application/controllers/Logbook.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index f663c7c3..caaf8730 100755 --- a/application/controllers/Logbook.php +++ b/application/controllers/Logbook.php @@ -491,8 +491,14 @@ class Logbook extends CI_Controller { $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= $this->qrz->search($id, $this->session->userdata('qrz_session_key'), $this->config->item('use_fullname')); - $data['callsign'] = $this->qrz->search($id, $this->session->userdata('qrz_session_key'), $this->config->item('use_fullname')); + if (empty($data['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); + $data = $this->qrz->search($id, $this->session->userdata('qrz_session_key'), $this->config->item('use_fullname')); + } } // There's no hamli integration? Disabled for now. From 9365f551a7487180986283a9eaba15b75e2c99e2 Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Tue, 5 Oct 2021 19:24:50 +0200 Subject: [PATCH 16/17] Removed lines that should not be there. Problably comes from a merge. --- application/views/view_log/qso.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/application/views/view_log/qso.php b/application/views/view_log/qso.php index f826b83a..4b4b3569 100644 --- a/application/views/view_log/qso.php +++ b/application/views/view_log/qso.php @@ -144,24 +144,19 @@ -<<<<<<< HEAD - config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE) { ?> -======= COL_CNTY != null && $row->COL_CNTY != ",") { ?> USA County: COL_CNTY; ?> ->>>>>>> 9e058dac9a7454cebd80396e5de94ae445eed096 - COL_NAME != null) { ?> + COL_NAME != null) { ?> lang->line('general_word_name'); ?> COL_NAME; ?> - config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE) { ?> COL_COMMENT != null) { ?> From a7694080e39d60a1d172bb7a0ffcc6f04e6f7187 Mon Sep 17 00:00:00 2001 From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com> Date: Tue, 5 Oct 2021 20:55:17 +0200 Subject: [PATCH 17/17] Update config.php --- install/config/config.php | 9 --------- 1 file changed, 9 deletions(-) diff --git a/install/config/config.php b/install/config/config.php index 008e9004..84d03517 100644 --- a/install/config/config.php +++ b/install/config/config.php @@ -47,15 +47,6 @@ $config['qrz_username'] = ""; $config['qrz_password'] = ""; $config['use_fullname'] = false; - -/* -|-------------------------------------------------------------------------- -| Are we running this on a personal server? If we are, GDPR laws -| prevent us from storing personal information. -| -*/ -$config['personal'] = false; - /* |-------------------------------------------------------------------------- | HamQTH Login Options