From b487e4506e2b9df6253abb177d7853d5427bdded Mon Sep 17 00:00:00 2001 From: int2001 Date: Tue, 1 Oct 2024 18:25:03 +0000 Subject: [PATCH 1/5] Added exceptionhandling for QSOs with no Call --- application/models/Logbook_model.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index bd654349b..a4838588d 100644 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -3294,7 +3294,7 @@ class Logbook_model extends CI_Model { $binding[] = $datetime; $binding[] = $datetime; - $binding[] = $callsign; + $binding[] = $callsign ?? ''; $binding[] = $station_callsign; $binding[] = $band; $binding[] = $mode; @@ -3559,6 +3559,12 @@ class Logbook_model extends CI_Model { // Join date+time $time_on = date('Y-m-d', strtotime($record['qso_date'] ?? '1970-01-01')) . " " . date('H:i:s', strtotime($record['time_on'] ?? '00:00:00')); + if (($record['call'] ?? '') == '') { + log_message("Error","Trying to import QSO without Call for station_id ".$station_id); + $returner['error']=__("QSO on")." ".$time_on.": ".__("You tried to import a QSO without any given CALL. This QSO wasn't imported. It's invalid"); + return($returner); + } + if (isset($record['time_off'])) { if (isset($record['date_off'])) { // date_off and time_off set From 4b24ddab1da9dc558cd9046115d7188c7af05e60 Mon Sep 17 00:00:00 2001 From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com> Date: Tue, 1 Oct 2024 20:32:48 +0200 Subject: [PATCH 2/5] Removed call check, since it's fetched in logbook_model --- application/libraries/Adif_parser.php | 44 ++++++++++++--------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/application/libraries/Adif_parser.php b/application/libraries/Adif_parser.php index 0a833d381..01cdb686e 100644 --- a/application/libraries/Adif_parser.php +++ b/application/libraries/Adif_parser.php @@ -23,7 +23,7 @@ class ADIF_Parser var $currentarray = 0; // current place in the array var $i = 0; //the iterator var $headers = array(); - + public function initialize() //this function locates the { @@ -40,7 +40,7 @@ class ADIF_Parser $pos = 0; goto noheaders; }; - + while($this->i < $pos) { //skip comments @@ -52,7 +52,7 @@ class ADIF_Parser { break; } - + $this->i++; } }else{ @@ -66,19 +66,19 @@ class ADIF_Parser $tag = $tag.mb_substr($this->data, $this->i, 1, "UTF-8"); $this->i++; } - + $this->i++; //iterate past the : - + //find out how long the value is - + while($this->i < $pos && mb_substr($this->data, $this->i, 1, "UTF-8") != '>') { $value_length = $value_length.mb_substr($this->data, $this->i, 1, "UTF-8"); $this->i++; } - + $this->i++; //iterate past the > - + $len = (int)$value_length; //copy the value into the buffer @@ -93,15 +93,15 @@ class ADIF_Parser $tag = ""; $value_length = ""; $value = ""; - + } } $this->i++; - + }; - + $this->i = $pos+5; //iterate past the // Skip to here in case we did not find headers @@ -116,10 +116,10 @@ class ADIF_Parser $this->currentarray = 0; return 1; } - + public function feed($input_data) //allows the parser to be fed a string { - + if (strpos($input_data, "") !== false) { $arr=explode("",$input_data); $newstring = $arr[1]; @@ -130,12 +130,12 @@ class ADIF_Parser $this->datasplit = preg_split("//i", mb_substr($this->data, $this->i, NULL, "UTF-8")); } - + public function load_from_file($fname) //allows the user to accept a filename as input { $this->data = $string = mb_convert_encoding(file_get_contents($fname), "UTF-8"); } - + //the following function does the processing of the array into its key and value pairs public function record_to_array($record) { @@ -193,7 +193,7 @@ class ADIF_Parser }; return $return; } - + //finds the next record in the file public function get_record() { @@ -201,16 +201,10 @@ class ADIF_Parser if($this->currentarray >= count($this->datasplit)) { return array(); //return nothing } else { - // Is this a valid QSO? - if (mb_stristr($this->datasplit[$this->currentarray], "record_to_array($this->datasplit[$this->currentarray++]); //process and return output - } - else { - return array(); - } + return $this->record_to_array($this->datasplit[$this->currentarray++]); //process and return output } } - + public function get_header($key) { if(array_key_exists(mb_strtolower($key, "UTF-8"), $this->headers)) @@ -220,6 +214,6 @@ class ADIF_Parser return NULL; } } - + } ?> From 835681332098ecf212f2ee37aaf91f04b76526e4 Mon Sep 17 00:00:00 2001 From: int2001 Date: Tue, 1 Oct 2024 18:47:37 +0000 Subject: [PATCH 3/5] Add empty-call check as well for 3rd party services --- application/controllers/Lotw.php | 4 +++- application/controllers/Qrz.php | 9 ++++++--- application/libraries/EqslImporter.php | 3 +++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php index 7722681f4..8e2d39a0b 100644 --- a/application/controllers/Lotw.php +++ b/application/controllers/Lotw.php @@ -506,7 +506,9 @@ class Lotw extends CI_Controller { if (!isset($record['app_lotw_rxqsl'])) { continue; } - + if (($record['call'] ?? '') == '') { // Failsafe if no call is given + continue; + } $time_on = date('Y-m-d', strtotime($record['qso_date'])) ." ".date('H:i', strtotime($record['time_on'])); $qsl_date = date('Y-m-d H:i', strtotime($record['app_lotw_rxqsl'])); diff --git a/application/controllers/Qrz.php b/application/controllers/Qrz.php index 2e0dec9bb..8d78fd0e5 100644 --- a/application/controllers/Qrz.php +++ b/application/controllers/Qrz.php @@ -413,6 +413,9 @@ class Qrz extends CI_Controller { if ((!(isset($record['app_qrzlog_qsldate']))) || (!(isset($record['qso_date'])))) { continue; } + if (($record['call'] ?? '') == '') { // Failsafe if no Call is giveb + continue; + } $time_on = date('Y-m-d', strtotime($record['qso_date'])) ." ".date('H:i', strtotime($record['time_on'])); $qsl_date = date('Y-m-d', strtotime($record['app_qrzlog_qsldate'])); @@ -424,7 +427,7 @@ class Qrz extends CI_Controller { } // If we have a positive match from LoTW, record it in the DB according to the user's preferences - if ($record['app_qrzlog_status'] == "C") { + if (($record['app_qrzlog_status'] ?? '')== "C") { $record['qsl_rcvd'] = $config['qrz_rcvd_mark']; } @@ -440,7 +443,7 @@ class Qrz extends CI_Controller { $table .= "".$record['station_callsign'].""; $table .= "".$time_on.""; $table .= "".$record['call'].""; - $table .= "".$record['mode'].""; + $table .= "".($record['mode'] ?? '').""; $table .= "".$record['qsl_rcvd'].""; $table .= "".$qsl_date.""; $table .= "QSO Record: ".$status[0].""; @@ -450,7 +453,7 @@ class Qrz extends CI_Controller { $table .= "".$record['station_callsign'].""; $table .= "".$time_on.""; $table .= "".$record['call'].""; - $table .= "".$record['mode'].""; + $table .= "".($record['mode'] ?? '').""; $table .= "".$record['qsl_rcvd'].""; $table .= "QSO Record: ".$status[0].""; $table .= ""; diff --git a/application/libraries/EqslImporter.php b/application/libraries/EqslImporter.php index f0d213975..2110d1f49 100644 --- a/application/libraries/EqslImporter.php +++ b/application/libraries/EqslImporter.php @@ -149,6 +149,9 @@ class EqslImporter $qsos = array(); $records = $updated = $not_found = $dupes = 0; while ($record = $this->CI->adif_parser->get_record()) { + if (($record['call'] ?? '') == '') { // Failsafe if no call was given + continue; + } $records += 1; $time_on = date('Y-m-d', strtotime($record['qso_date'])) . " " . date('H:i', strtotime($record['time_on'])); From 987c8cb60fb797b58114e669d21726b7ccccfda7 Mon Sep 17 00:00:00 2001 From: int2001 Date: Wed, 2 Oct 2024 09:40:12 +0000 Subject: [PATCH 4/5] unset record (safety reasons) --- application/controllers/Qrz.php | 1 + 1 file changed, 1 insertion(+) diff --git a/application/controllers/Qrz.php b/application/controllers/Qrz.php index 8d78fd0e5..55198742c 100644 --- a/application/controllers/Qrz.php +++ b/application/controllers/Qrz.php @@ -459,6 +459,7 @@ class Qrz extends CI_Controller { $table .= ""; } } + unset($record); } if ($table != "") { From 1db967b6d51cfc67a07976ef4be6f7516362bb7c Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Thu, 3 Oct 2024 13:14:18 +0000 Subject: [PATCH 5/5] some more details in error message --- application/models/Logbook_model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index a4838588d..6086504e7 100644 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -3560,7 +3560,7 @@ class Logbook_model extends CI_Model { $time_on = date('Y-m-d', strtotime($record['qso_date'] ?? '1970-01-01')) . " " . date('H:i:s', strtotime($record['time_on'] ?? '00:00:00')); if (($record['call'] ?? '') == '') { - log_message("Error","Trying to import QSO without Call for station_id ".$station_id); + log_message("Error", "Trying to import QSO without Call for station_id " . $station_id . ". QSO Date/Time: " . $time_on . " Mode: " . ($record['mode'] ?? '') . " Band: " . ($record['band'] ?? '')); $returner['error']=__("QSO on")." ".$time_on.": ".__("You tried to import a QSO without any given CALL. This QSO wasn't imported. It's invalid"); return($returner); }