From eccf8ac57617281f0b179ace82f726bd2e976a27 Mon Sep 17 00:00:00 2001 From: DB4SCW Date: Mon, 18 Nov 2024 14:43:08 +0000 Subject: [PATCH] bug fixes --- application/controllers/Cabrillo.php | 16 ++++++++-------- application/libraries/Cbr_parser.php | 8 ++++---- application/models/Logbook_model.php | 12 +++++++----- application/views/adif/import.php | 2 +- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/application/controllers/Cabrillo.php b/application/controllers/Cabrillo.php index faeb2a869..ff6f43c13 100644 --- a/application/controllers/Cabrillo.php +++ b/application/controllers/Cabrillo.php @@ -9,8 +9,8 @@ if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Cabrillo extends CI_Controller { - function __construct() { - parent::__construct(); + public function __construct() { + parent::__construct(); $this->load->model('user_model'); if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('error', __("You're not allowed to do that!")); redirect('dashboard'); } @@ -152,7 +152,7 @@ class Cabrillo extends CI_Controller { //configure upload $config['upload_path'] = './uploads/'; - $config['allowed_types'] = 'cbr|CBR'; + $config['allowed_types'] = 'cbr|CBR|log|LOG'; //load upload library $this->load->library('upload', $config); @@ -184,8 +184,11 @@ class Cabrillo extends CI_Controller { $this->load->library('cbr_parser'); } + //get flag about the presence of the serial number + $serial_number_present = ($this->input->post('serial_number_present', true) == 1); + //parse the uploaded file - $parsed_cbr = $this->cbr_parser->parse_from_file('./uploads/'.$data['upload_data']['file_name']); + $parsed_cbr = $this->cbr_parser->parse_from_file('./uploads/'.$data['upload_data']['file_name'], $serial_number_present); //return with error, reset upload filesize if(count($parsed_cbr["QSOS"]) < 1) @@ -200,13 +203,10 @@ class Cabrillo extends CI_Controller { return; } - //get flag about the presence of the serial number - $serial_number_present = ($this->input('serial_number_present', true) == 1); - //get all station ids for the active user $this->load->model('stations'); $station_ids = []; - foreach ($this->stations->all_of_user() as $station) { + foreach ($this->stations->all_of_user()->result() as $station) { array_push($station_ids, $station->station_id); } diff --git a/application/libraries/Cbr_parser.php b/application/libraries/Cbr_parser.php index ce56b06a8..e4f2e4d73 100755 --- a/application/libraries/Cbr_parser.php +++ b/application/libraries/Cbr_parser.php @@ -1,10 +1,10 @@ parse(mb_convert_encoding(file_get_contents($filename), "UTF-8")); + return $this->parse(mb_convert_encoding(file_get_contents($filename), "UTF-8"), $serial_number_present); } public function parse(string $input, $serial_number_present = false) : array @@ -47,7 +47,7 @@ class CBR_Parser $parts = explode(': ', $line, 2); //collect header information - $header[$parts[0]] = $parts[1]; + $header[$parts[0]] = preg_replace('/\s+/', '', $parts[1]); //skip to next line continue; @@ -104,7 +104,7 @@ class CBR_Parser //abort if basic things (Callsign and Contest ID) are not included in the header $header_fields = array_keys($header); - if(!in_array('CALLSIGN', $header_fields) or !in_array('CONTEST', $header)){ + if(!in_array('CALLSIGN', $header_fields) or !in_array('CONTEST', $header_fields)){ $result = []; $result["HEADER"] = $header; $result["QSOS"] = []; diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 1448660b1..7987b1448 100644 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -5459,11 +5459,13 @@ class Logbook_model extends CI_Model { //prepare datetime from format '2099-12-31 13:47' to be usable in a performant query $datetime_raw = $date . ' ' . substr($time, 0, 2) . ':' . substr($time, 2, 2); $datetime = new DateTime($datetime_raw,new DateTimeZone('UTC')); - $synthetic_endtime = $datetime->add(new DateInterval('PT1M')); - - //load only for specific date and time. Since - $this->db->where('COL_TIME_ON >=', $datetime->format('Y-m-d H:i:s')); - $this->db->where('COL_TIME_ON <', $synthetic_endtime->format('Y-m-d H:i:s')); + $from_datetime = $datetime->format('Y-m-d H:i:s'); + $datetime->add(new DateInterval('PT1M')); + $to_datetime = $datetime->format('Y-m-d H:i:s'); + + //load only QSOs during this minute + $this->db->where('COL_TIME_ON >=', $from_datetime); + $this->db->where('COL_TIME_ON <', $to_datetime); //return whatever is left return $this->db->get(); diff --git a/application/views/adif/import.php b/application/views/adif/import.php index c44df4357..6cf40fc87 100644 --- a/application/views/adif/import.php +++ b/application/views/adif/import.php @@ -312,7 +312,7 @@
- +