From aac251d251c10ce18bada262b9ca9d44a227b6b0 Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Mon, 26 Feb 2024 16:00:07 +0000 Subject: [PATCH] [ADIF Import] Catch when RX_PWR is not a number and error out If RX_POWER is not a number or K or KW then set the value to null and show error. Fixes #2983 --- application/models/Logbook_model.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 5645d4e3..a9c77bb0 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -2984,8 +2984,9 @@ class Logbook_model extends CI_Model } /* Used to check if the qso is already in the database */ - function import_check($datetime, $callsign, $band, $mode, $station_callsign, $station_id = null) { - $mode=$this->get_main_mode_from_mode($mode); + function import_check($datetime, $callsign, $band, $mode, $station_callsign, $station_id = null) + { + $mode = $this->get_main_mode_from_mode($mode); $this->db->select('COL_PRIMARY_KEY, COL_TIME_ON, COL_CALL, COL_BAND'); $this->db->where('COL_TIME_ON >= DATE_ADD(DATE_FORMAT("' . $datetime . '", \'%Y-%m-%d %H:%i\' ), INTERVAL -15 MINUTE )'); @@ -2995,8 +2996,8 @@ class Logbook_model extends CI_Model $this->db->where('COL_BAND', $band); $this->db->where('COL_MODE', $mode); - if(isset($station_id) && $station_id > 0) { - $this->db->where('station_id', $station_id); + if (isset($station_id) && $station_id > 0) { + $this->db->where('station_id', $station_id); } $query = $this->db->get($this->config->item('table_name')); @@ -3412,8 +3413,15 @@ class Logbook_model extends CI_Model // Check if RX_PWR is "K" which N1MM+ uses to indicate 1000W if ($record['rx_pwr'] == "K") { $rx_pwr = 1000; + } elseif ($record['rx_pwr'] == "KW") { + $rx_pwr = 1000; } else { - $rx_pwr = filter_var($record['rx_pwr'], FILTER_VALIDATE_FLOAT); + if (isset($record['rx_pwr']) && is_numeric($record['rx_pwr'])) { + $rx_pwr = $record['rx_pwr']; + } else { + $rx_pwr = null; + $my_error .= "Error QSO: Date: " . $time_on . " Callsign: " . $record['call'] . " RX_PWR (".$record['rx_pwr'].") is not a number
"; + } } } else { $rx_pwr = NULL;