bug fixes

This commit is contained in:
DB4SCW
2024-11-18 14:43:08 +00:00
parent 0b2ea8c6bc
commit eccf8ac576
4 changed files with 20 additions and 18 deletions

View File

@@ -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);
}

View File

@@ -1,10 +1,10 @@
<?php
class CBR_Parser
{
public function parse_from_file($filename) : array
public function parse_from_file($filename, $serial_number_present = false) : array
{
//load file, call parser
return $this->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"] = [];

View File

@@ -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();

View File

@@ -312,7 +312,7 @@
<div class="mb-3 row">
<div class="col-md-10">
<div class="form-check-inline">
<input class="form-check-input" type="checkbox" name="serial_number_present" value="0" id="serial_number_present" unchecked>
<input class="form-check-input" type="checkbox" name="serial_number_present" value="1" id="serial_number_present" unchecked>
<label class="form-check-label" for="serial_number_present"><?= __("A Serial Number is part of the Exchange of this contest.") ?></label>
</div>
<div class="small form-text text-muted"><?= __("If unchecked, this will erase the default serial number that (for example) N1MM+ produces. If checked, it will correct the serial number if necessary.") ?></div>