From e40492b19517d4b2dfaee467378399a6da5229e5 Mon Sep 17 00:00:00 2001 From: DB4SCW Date: Mon, 24 Nov 2025 14:45:44 +0000 Subject: [PATCH 1/9] add trx number handling --- application/controllers/Cabrillo.php | 5 ++++- application/libraries/Cbr_parser.php | 15 ++++++++++----- application/views/adif/import.php | 4 ++++ application/views/adif/import_success.php | 2 +- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/application/controllers/Cabrillo.php b/application/controllers/Cabrillo.php index 972fd0f5e..c8e6483a8 100644 --- a/application/controllers/Cabrillo.php +++ b/application/controllers/Cabrillo.php @@ -188,8 +188,11 @@ class Cabrillo extends CI_Controller { //get flag about the presence of the serial number $serial_number_present = ($this->input->post('serial_number_present', true) == 1); + //get flag about the presence of the trx number + $trx_number_present = ($this->input->post('trx_number_present', true) == 1); + //parse the uploaded file - $parsed_cbr = $this->cbr_parser->parse_from_file('./uploads/'.$data['upload_data']['file_name'], $serial_number_present); + $parsed_cbr = $this->cbr_parser->parse_from_file('./uploads/'.$data['upload_data']['file_name'], $serial_number_present, $trx_number_present); //return with error, reset upload filesize if(count($parsed_cbr["QSOS"]) < 1) diff --git a/application/libraries/Cbr_parser.php b/application/libraries/Cbr_parser.php index 73c35a0db..8dc256cf7 100644 --- a/application/libraries/Cbr_parser.php +++ b/application/libraries/Cbr_parser.php @@ -1,13 +1,13 @@ parse(mb_convert_encoding(file_get_contents($filename), "UTF-8"), $serial_number_present); + return $this->parse(mb_convert_encoding(file_get_contents($filename), "UTF-8"), $serial_number_present, $trx_number_present); } - public function parse(string $input, $serial_number_present = false) : array + public function parse(string $input, $serial_number_present = false, $trx_number_present = false) : array { //split the input into lines $lines = explode("\n", trim($input)); @@ -35,6 +35,11 @@ class CBR_Parser $qso_mode = false; } + //if we encounter a QTC, skip that line + if(strpos($line, 'QTC:') === 0){ + continue; + } + //if we encounter "END-OF-LOG", stop processing lines if (strpos($line, 'END-OF-LOG') === 0) { break; @@ -171,7 +176,7 @@ class CBR_Parser //get all remaining received exchanges $exchange_nr = 1; $startindex = ($rcvd_59_pos + ($serial_number_present ? 2 : 1)); - $endindex = (count($line)); + $endindex = $trx_number_present ? (count($line)) -1 : (count($line)); for ($i = $startindex; $i < $endindex; $i++) { $qso_line["RCVD_EXCH_" . $exchange_nr] = $line[$i]; $exchange_nr++; @@ -292,7 +297,7 @@ class CBR_Parser $result["SENT_59_POS"] = $sent_59_pos; $result["RCVD_59_POS"] = $rcvd_59_pos; $result["SENT_EXCHANGE_COUNT"] = $rcvd_59_pos - $sent_59_pos - ($serial_number_present ? 3 : 2); - $result["RCVD_EXCHANGE_COUNT"] = $max_qso_fields - 1 - $rcvd_59_pos - ($serial_number_present ? 1 : 0); + $result["RCVD_EXCHANGE_COUNT"] = $max_qso_fields - 1 - $rcvd_59_pos - ($serial_number_present ? 1 : 0) - ($trx_number_present ? 1 : 0); //return result return $result; diff --git a/application/views/adif/import.php b/application/views/adif/import.php index 93b778f1e..d6fdb9f31 100644 --- a/application/views/adif/import.php +++ b/application/views/adif/import.php @@ -410,6 +410,10 @@ echo ''; } ?> +
+ + +
diff --git a/application/views/adif/import_success.php b/application/views/adif/import_success.php index 38759ed09..8530d7f45 100644 --- a/application/views/adif/import_success.php +++ b/application/views/adif/import_success.php @@ -37,7 +37,7 @@ 0) {?>