2020-11-08 10:46:08 +01:00
|
|
|
<?php
|
|
|
|
|
class Contesting_model extends CI_Model {
|
2020-12-28 19:55:51 +01:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* This function gets the QSOs to fill the "Contest Logbook" under the contesting form.
|
|
|
|
|
*/
|
|
|
|
|
function getSessionQsos($qso) {
|
|
|
|
|
$CI =& get_instance();
|
|
|
|
|
$CI->load->model('Stations');
|
|
|
|
|
$station_id = $CI->Stations->find_active();
|
|
|
|
|
|
|
|
|
|
$qsoarray = explode(',', $qso);
|
|
|
|
|
|
|
|
|
|
$contestid = $qsoarray[2];
|
|
|
|
|
$date = DateTime::createFromFormat('d-m-Y H:i:s', $qsoarray[0]);
|
2024-03-27 11:29:58 +01:00
|
|
|
if ($date == false) $date = DateTime::createFromFormat('d-m-Y H:i', $qsoarray[0]);
|
Add Cabrillo export modal & format improvements
Add a full Cabrillo export workflow and harden Cabrillo/QSO formatting. Introduces a modal UI to export contest logs (new button + modal form with fields for location, category time, operators, club, soapbox, date range and other Cabrillo categories). Controller updates pass the new fields to the export action. Cabrilloformat library extended to accept and emit LOCATION and CATEGORY-TIME, improve header field ordering and presence checks, map ADIF modes to the five Cabrillo modes (CW/PH/FM/RY/DG), fix a band label (2.4G -> 2.3G), and emit placeholders for missing received exchanges to preserve column alignment. Contesting_model: more robust date parsing with UTC fallback, ensure session QSO marker only persists when timestamp valid, and build start timestamp when LIVE mode omits start_date/start_time. Frontend JS: setSession() now returns the ajax promise so callers can await it; several callers updated to await setSession and re-fetch session data before refreshing the QSO table; restore full table search on callsign blur and when suggestions are cleared. Misc: small form/input fixes (club field type, default overlay option) and additional server-supplied data loaded into the contesting view (active station id, contest session, station profile). These changes add required Cabrillo fields for certain contests and make exports and session handling more reliable.
2026-03-27 00:04:21 +00:00
|
|
|
// If date still can't be parsed fall back to start of today (UTC) to show all today's QSOs
|
|
|
|
|
if ($date == false) $date = new DateTime('today', new DateTimeZone('UTC'));
|
2020-12-28 19:55:51 +01:00
|
|
|
$date = $date->format('Y-m-d H:i:s');
|
|
|
|
|
|
2026-06-24 22:10:20 +01:00
|
|
|
$this->db->select("date_format(col_time_on, '%d-%m-%Y %H:%i:%s') as col_time_on, col_call, col_band, col_mode,
|
|
|
|
|
col_submode, col_rst_sent, col_rst_rcvd, coalesce(col_srx, '') col_srx, coalesce(col_srx_string, '') col_srx_string,
|
|
|
|
|
coalesce(col_stx, '') col_stx, coalesce(col_stx_string, '') col_stx_string, coalesce(col_gridsquare, '') col_gridsquare,
|
|
|
|
|
coalesce(col_vucc_grids, '') col_vucc_grids", false);
|
|
|
|
|
$this->db->from($this->config->item('table_name'));
|
|
|
|
|
$this->db->where('station_id', (int) $station_id);
|
|
|
|
|
$this->db->where('COL_TIME_ON >=', $date);
|
|
|
|
|
$this->db->where('COL_CONTEST_ID', $contestid);
|
|
|
|
|
$this->db->order_by('COL_PRIMARY_KEY', 'ASC');
|
|
|
|
|
|
|
|
|
|
$data = $this->db->get();
|
2023-04-10 18:54:24 +02:00
|
|
|
return $data->result();
|
2024-01-14 18:04:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getSessionFreshQsos($contest_id) {
|
|
|
|
|
$CI =& get_instance();
|
|
|
|
|
$CI->load->model('Stations');
|
|
|
|
|
$station_id = $CI->Stations->find_active();
|
|
|
|
|
|
2026-06-24 22:10:20 +01:00
|
|
|
$contestid = (string) $contest_id;
|
2024-01-14 18:04:35 +00:00
|
|
|
|
|
|
|
|
// save contestid to debug
|
|
|
|
|
// Get current date and time
|
|
|
|
|
$now = new DateTime();
|
|
|
|
|
$now->modify('-1 minute');
|
|
|
|
|
$date = $now->format('Y-m-d H:i:s');
|
|
|
|
|
|
2026-06-24 22:10:20 +01:00
|
|
|
$this->db->select("date_format(col_time_on, '%d-%m-%Y %H:%i:%s') as col_time_on, col_call, col_band, col_mode,
|
|
|
|
|
col_submode, col_rst_sent, col_rst_rcvd, coalesce(col_srx, '') col_srx, coalesce(col_srx_string, '') col_srx_string,
|
|
|
|
|
coalesce(col_stx, '') col_stx, coalesce(col_stx_string, '') col_stx_string, coalesce(col_gridsquare, '') col_gridsquare,
|
|
|
|
|
coalesce(col_vucc_grids, '') col_vucc_grids", false);
|
|
|
|
|
$this->db->from($this->config->item('table_name'));
|
|
|
|
|
$this->db->where('station_id', (int) $station_id);
|
|
|
|
|
$this->db->where('COL_TIME_ON >=', $date);
|
|
|
|
|
$this->db->where('COL_CONTEST_ID', $contestid);
|
|
|
|
|
$this->db->order_by('COL_PRIMARY_KEY', 'ASC');
|
2024-01-14 18:04:35 +00:00
|
|
|
|
2026-06-24 22:10:20 +01:00
|
|
|
$data = $this->db->get();
|
2024-01-14 18:04:35 +00:00
|
|
|
|
|
|
|
|
return $data->result();
|
2023-04-10 18:54:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getSession() {
|
|
|
|
|
$CI =& get_instance();
|
|
|
|
|
$CI->load->model('Stations');
|
|
|
|
|
$station_id = $CI->Stations->find_active();
|
|
|
|
|
|
2026-06-24 22:10:20 +01:00
|
|
|
$this->db->where('station_id', (int) $station_id);
|
|
|
|
|
$data = $this->db->get('contest_session');
|
2024-03-27 11:31:39 +01:00
|
|
|
|
2023-04-10 18:54:24 +02:00
|
|
|
return $data->row();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function deleteSession() {
|
|
|
|
|
$CI =& get_instance();
|
|
|
|
|
$CI->load->model('Stations');
|
|
|
|
|
$station_id = $CI->Stations->find_active();
|
|
|
|
|
|
2026-06-24 22:10:20 +01:00
|
|
|
$this->db->where('station_id', (int) $station_id);
|
|
|
|
|
$this->db->delete('contest_session');
|
2023-04-10 18:54:24 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function setSession() {
|
|
|
|
|
$CI =& get_instance();
|
|
|
|
|
$CI->load->model('Stations');
|
|
|
|
|
$station_id = $CI->Stations->find_active();
|
|
|
|
|
|
|
|
|
|
$qso = "";
|
|
|
|
|
|
|
|
|
|
if ($this->input->post('callsign')) {
|
Add Cabrillo export modal & format improvements
Add a full Cabrillo export workflow and harden Cabrillo/QSO formatting. Introduces a modal UI to export contest logs (new button + modal form with fields for location, category time, operators, club, soapbox, date range and other Cabrillo categories). Controller updates pass the new fields to the export action. Cabrilloformat library extended to accept and emit LOCATION and CATEGORY-TIME, improve header field ordering and presence checks, map ADIF modes to the five Cabrillo modes (CW/PH/FM/RY/DG), fix a band label (2.4G -> 2.3G), and emit placeholders for missing received exchanges to preserve column alignment. Contesting_model: more robust date parsing with UTC fallback, ensure session QSO marker only persists when timestamp valid, and build start timestamp when LIVE mode omits start_date/start_time. Frontend JS: setSession() now returns the ajax promise so callers can await it; several callers updated to await setSession and re-fetch session data before refreshing the QSO table; restore full table search on callsign blur and when suggestions are cleared. Misc: small form/input fixes (club field type, default overlay option) and additional server-supplied data loaded into the contesting view (active station id, contest session, station profile). These changes add required Cabrillo fields for certain contests and make exports and session handling more reliable.
2026-03-27 00:04:21 +00:00
|
|
|
// In LIVE mode start_date/start_time are disabled fields and not submitted, use server UTC time
|
|
|
|
|
$start_date = xss_clean($this->input->post('start_date', true));
|
|
|
|
|
$start_time = xss_clean($this->input->post('start_time', true));
|
|
|
|
|
if (empty($start_date) || empty($start_time)) {
|
|
|
|
|
$timestamp = gmdate('d-m-Y H:i:s');
|
|
|
|
|
} else {
|
|
|
|
|
$timestamp = $start_date . ' ' . $start_time;
|
|
|
|
|
}
|
|
|
|
|
$qso = $timestamp . ',' . xss_clean($this->input->post('callsign', true)) . ',' . xss_clean($this->input->post('contestname', true));
|
2023-04-10 18:54:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$data = array(
|
|
|
|
|
'contestid' => xss_clean($this->input->post('contestname', true)),
|
|
|
|
|
'exchangetype' => xss_clean($this->input->post('exchangetype', true)),
|
|
|
|
|
'exchangesent' => xss_clean($this->input->post('exch_sent', true)),
|
|
|
|
|
'serialsent' => xss_clean($this->input->post('exch_serial_s', true)),
|
2023-04-11 08:14:18 +02:00
|
|
|
'copytodok' => $this->input->post('copyexchangetodok', true) == "" ? 0 : xss_clean($this->input->post('copyexchangetodok', true)),
|
2023-04-10 18:54:24 +02:00
|
|
|
'qso' => $qso,
|
|
|
|
|
'station_id' => $station_id,
|
|
|
|
|
);
|
|
|
|
|
|
2024-03-27 11:31:39 +01:00
|
|
|
if ($this->input->post('copyexchangeto')) {
|
|
|
|
|
$data['copytodok'] = xss_clean($this->input->post('copyexchangeto'));
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-24 22:10:20 +01:00
|
|
|
$this->db->where('station_id', (int) $station_id);
|
|
|
|
|
$querydata = $this->db->get('contest_session');
|
2023-04-10 18:54:24 +02:00
|
|
|
|
|
|
|
|
if ($querydata->num_rows() == 0) {
|
|
|
|
|
$this->db->insert('contest_session', $data);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$result = $querydata->row();
|
|
|
|
|
|
|
|
|
|
if ($result->qso != "") {
|
Add Cabrillo export modal & format improvements
Add a full Cabrillo export workflow and harden Cabrillo/QSO formatting. Introduces a modal UI to export contest logs (new button + modal form with fields for location, category time, operators, club, soapbox, date range and other Cabrillo categories). Controller updates pass the new fields to the export action. Cabrilloformat library extended to accept and emit LOCATION and CATEGORY-TIME, improve header field ordering and presence checks, map ADIF modes to the five Cabrillo modes (CW/PH/FM/RY/DG), fix a band label (2.4G -> 2.3G), and emit placeholders for missing received exchanges to preserve column alignment. Contesting_model: more robust date parsing with UTC fallback, ensure session QSO marker only persists when timestamp valid, and build start timestamp when LIVE mode omits start_date/start_time. Frontend JS: setSession() now returns the ajax promise so callers can await it; several callers updated to await setSession and re-fetch session data before refreshing the QSO table; restore full table search on callsign blur and when suggestions are cleared. Misc: small form/input fixes (club field type, default overlay option) and additional server-supplied data loaded into the contesting view (active station id, contest session, station profile). These changes add required Cabrillo fields for certain contests and make exports and session handling more reliable.
2026-03-27 00:04:21 +00:00
|
|
|
// Only keep the existing qso marker if its timestamp is valid to avoid persisting bad data
|
|
|
|
|
$existing_parts = explode(',', $result->qso);
|
|
|
|
|
$existing_date = DateTime::createFromFormat('d-m-Y H:i:s', $existing_parts[0]);
|
|
|
|
|
if ($existing_date == false) $existing_date = DateTime::createFromFormat('d-m-Y H:i', $existing_parts[0]);
|
|
|
|
|
if ($existing_date !== false) {
|
|
|
|
|
$data['qso'] = $result->qso;
|
|
|
|
|
}
|
2023-04-10 18:54:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->updateSession($data, $station_id);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateSession($data, $station_id) {
|
|
|
|
|
$this->db->where('station_id', $station_id);
|
|
|
|
|
|
|
|
|
|
$this->db->update('contest_session', $data);
|
2020-12-28 19:55:51 +01:00
|
|
|
}
|
2021-02-12 23:27:08 +01:00
|
|
|
|
|
|
|
|
function getActivecontests() {
|
|
|
|
|
|
|
|
|
|
$sql = "SELECT name, adifname FROM contest WHERE active = 1 ORDER BY name ASC";
|
|
|
|
|
|
|
|
|
|
$data = $this->db->query($sql);
|
|
|
|
|
|
|
|
|
|
return($data->result_array());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getAllContests() {
|
|
|
|
|
|
|
|
|
|
$sql = "SELECT id, name, adifname, active FROM contest ORDER BY name ASC";
|
|
|
|
|
|
|
|
|
|
$data = $this->db->query($sql);
|
|
|
|
|
|
|
|
|
|
return($data->result_array());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function delete($id) {
|
Sanitize IDs and migrate SQL to Query Builder
Replace ad-hoc xss_clean calls with explicit casting and stronger type checks for ID/parameter handling, and convert many raw SQL strings to CodeIgniter Query Builder usage. Added normalize_location_ids helpers (Activators_model, Oqrs_model) to safely parse location lists and used where_in/parameter binding/escaping to avoid injection and improve maintainability. Also adjusted session user_id handling, improved LIKE/DATE/TIMEDIFF usage, and tightened several model/controller methods (Labels, Activators, Bands, Contesting, Labels_model, Modes, Oqrs_model, Qsl_model, Setup_model, Sstv_model, User_model) for safer, clearer DB queries and inputs.
2026-06-24 22:15:31 +01:00
|
|
|
$clean_id = (int) $id;
|
2021-02-12 23:27:08 +01:00
|
|
|
|
|
|
|
|
// Delete Contest
|
|
|
|
|
$this->db->delete('contest', array('id' => $clean_id));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function activate($id) {
|
Sanitize IDs and migrate SQL to Query Builder
Replace ad-hoc xss_clean calls with explicit casting and stronger type checks for ID/parameter handling, and convert many raw SQL strings to CodeIgniter Query Builder usage. Added normalize_location_ids helpers (Activators_model, Oqrs_model) to safely parse location lists and used where_in/parameter binding/escaping to avoid injection and improve maintainability. Also adjusted session user_id handling, improved LIKE/DATE/TIMEDIFF usage, and tightened several model/controller methods (Labels, Activators, Bands, Contesting, Labels_model, Modes, Oqrs_model, Qsl_model, Setup_model, Sstv_model, User_model) for safer, clearer DB queries and inputs.
2026-06-24 22:15:31 +01:00
|
|
|
$clean_id = (int) $id;
|
2021-02-12 23:27:08 +01:00
|
|
|
|
|
|
|
|
$data = array(
|
|
|
|
|
'active' => '1',
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$this->db->where('id', $clean_id);
|
|
|
|
|
|
|
|
|
|
$this->db->update('contest', $data);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function deactivate($id) {
|
Sanitize IDs and migrate SQL to Query Builder
Replace ad-hoc xss_clean calls with explicit casting and stronger type checks for ID/parameter handling, and convert many raw SQL strings to CodeIgniter Query Builder usage. Added normalize_location_ids helpers (Activators_model, Oqrs_model) to safely parse location lists and used where_in/parameter binding/escaping to avoid injection and improve maintainability. Also adjusted session user_id handling, improved LIKE/DATE/TIMEDIFF usage, and tightened several model/controller methods (Labels, Activators, Bands, Contesting, Labels_model, Modes, Oqrs_model, Qsl_model, Setup_model, Sstv_model, User_model) for safer, clearer DB queries and inputs.
2026-06-24 22:15:31 +01:00
|
|
|
$clean_id = (int) $id;
|
2021-02-12 23:27:08 +01:00
|
|
|
|
|
|
|
|
$data = array(
|
|
|
|
|
'active' => '0',
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$this->db->where('id', $clean_id);
|
|
|
|
|
|
|
|
|
|
$this->db->update('contest', $data);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function add() {
|
|
|
|
|
$data = array(
|
|
|
|
|
'name' => xss_clean($this->input->post('name', true)),
|
|
|
|
|
'adifname' => xss_clean($this->input->post('adifname', true)),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$this->db->insert('contest', $data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function contest($id) {
|
2026-06-24 22:08:30 +01:00
|
|
|
$clean_id = (int) $id;
|
2021-02-12 23:27:08 +01:00
|
|
|
|
2026-06-24 22:08:30 +01:00
|
|
|
$this->db->select('id, name, adifname, active');
|
|
|
|
|
$this->db->where('id', $clean_id);
|
|
|
|
|
$data = $this->db->get('contest');
|
2021-02-12 23:27:08 +01:00
|
|
|
|
|
|
|
|
return ($data->row());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function edit($id) {
|
|
|
|
|
$data = array(
|
|
|
|
|
'name' => xss_clean($this->input->post('name', true)),
|
|
|
|
|
'adifname' => xss_clean($this->input->post('adifname', true)),
|
|
|
|
|
'active' => xss_clean($this->input->post('active', true)),
|
|
|
|
|
);
|
|
|
|
|
|
Sanitize IDs and migrate SQL to Query Builder
Replace ad-hoc xss_clean calls with explicit casting and stronger type checks for ID/parameter handling, and convert many raw SQL strings to CodeIgniter Query Builder usage. Added normalize_location_ids helpers (Activators_model, Oqrs_model) to safely parse location lists and used where_in/parameter binding/escaping to avoid injection and improve maintainability. Also adjusted session user_id handling, improved LIKE/DATE/TIMEDIFF usage, and tightened several model/controller methods (Labels, Activators, Bands, Contesting, Labels_model, Modes, Oqrs_model, Qsl_model, Setup_model, Sstv_model, User_model) for safer, clearer DB queries and inputs.
2026-06-24 22:15:31 +01:00
|
|
|
$this->db->where('id', (int) $id);
|
2021-02-12 23:27:08 +01:00
|
|
|
$this->db->update('contest', $data);
|
|
|
|
|
}
|
2021-10-23 19:44:41 +02:00
|
|
|
|
|
|
|
|
function activateall() {
|
|
|
|
|
$data = array(
|
|
|
|
|
'active' => '1',
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$this->db->update('contest', $data);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function deactivateall() {
|
|
|
|
|
$data = array(
|
|
|
|
|
'active' => '0',
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$this->db->update('contest', $data);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2021-10-24 16:48:23 +02:00
|
|
|
|
2023-04-10 18:54:24 +02:00
|
|
|
function checkIfWorkedBefore($call, $band, $mode, $contest) {
|
2021-10-24 16:48:23 +02:00
|
|
|
$CI =& get_instance();
|
|
|
|
|
$CI->load->model('Stations');
|
|
|
|
|
$station_id = $CI->Stations->find_active();
|
|
|
|
|
|
2023-04-10 18:54:24 +02:00
|
|
|
$contest_session = $this->getSession();
|
|
|
|
|
|
2023-11-09 15:11:36 +01:00
|
|
|
if ($contest_session && $contest_session->qso != "") {
|
2023-04-10 18:54:24 +02:00
|
|
|
$qsoarray = explode(',', $contest_session->qso);
|
|
|
|
|
|
|
|
|
|
$date = DateTime::createFromFormat('d-m-Y H:i:s', $qsoarray[0]);
|
2024-03-27 11:29:58 +01:00
|
|
|
if ($date == false) $date = DateTime::createFromFormat('d-m-Y H:i', $qsoarray[0]);
|
2023-04-10 18:54:24 +02:00
|
|
|
$date = $date->format('Y-m-d H:i:s');
|
2023-12-30 20:17:24 +00:00
|
|
|
|
2023-12-31 06:55:25 +00:00
|
|
|
$this->db->select('timediff(UTC_TIMESTAMP(),col_time_off) b4, COL_TIME_OFF');
|
2023-04-10 18:54:24 +02:00
|
|
|
$this->db->where('STATION_ID', $station_id);
|
|
|
|
|
$this->db->where('COL_CALL', xss_clean($call));
|
|
|
|
|
$this->db->where("COL_BAND", xss_clean($band));
|
|
|
|
|
$this->db->where("COL_CONTEST_ID", xss_clean($contest));
|
|
|
|
|
$this->db->where("COL_TIME_ON >=", $date);
|
|
|
|
|
$this->db->group_start();
|
|
|
|
|
$this->db->where("COL_MODE", xss_clean($mode));
|
|
|
|
|
$this->db->or_where("COL_SUBMODE", xss_clean($mode));
|
|
|
|
|
$this->db->group_end();
|
2023-12-30 20:17:24 +00:00
|
|
|
$this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "DESC");
|
2023-04-10 18:54:24 +02:00
|
|
|
$query = $this->db->get($this->config->item('table_name'));
|
|
|
|
|
|
|
|
|
|
return $query;
|
|
|
|
|
}
|
|
|
|
|
return;
|
2021-10-24 16:48:23 +02:00
|
|
|
}
|
2023-04-12 11:58:47 +02:00
|
|
|
|
2023-04-12 14:24:03 +02:00
|
|
|
function export_custom($from, $to, $contest_id, $station_id) {
|
Sanitize IDs and migrate SQL to Query Builder
Replace ad-hoc xss_clean calls with explicit casting and stronger type checks for ID/parameter handling, and convert many raw SQL strings to CodeIgniter Query Builder usage. Added normalize_location_ids helpers (Activators_model, Oqrs_model) to safely parse location lists and used where_in/parameter binding/escaping to avoid injection and improve maintainability. Also adjusted session user_id handling, improved LIKE/DATE/TIMEDIFF usage, and tightened several model/controller methods (Labels, Activators, Bands, Contesting, Labels_model, Modes, Oqrs_model, Qsl_model, Setup_model, Sstv_model, User_model) for safer, clearer DB queries and inputs.
2026-06-24 22:15:31 +01:00
|
|
|
$station_id = (int) $station_id;
|
|
|
|
|
$contest_id = (string) $contest_id;
|
2023-04-12 11:58:47 +02:00
|
|
|
$this->db->select(''.$this->config->item('table_name').'.*, station_profile.*');
|
|
|
|
|
$this->db->from($this->config->item('table_name'));
|
|
|
|
|
$this->db->where($this->config->item('table_name').'.station_id', $station_id);
|
|
|
|
|
|
|
|
|
|
// If date is set, we format the date and add it to the where-statement
|
|
|
|
|
if ($from != 0) {
|
|
|
|
|
$from = DateTime::createFromFormat('Y-m-d', $from);
|
|
|
|
|
$from = $from->format('Y-m-d');
|
Sanitize IDs and migrate SQL to Query Builder
Replace ad-hoc xss_clean calls with explicit casting and stronger type checks for ID/parameter handling, and convert many raw SQL strings to CodeIgniter Query Builder usage. Added normalize_location_ids helpers (Activators_model, Oqrs_model) to safely parse location lists and used where_in/parameter binding/escaping to avoid injection and improve maintainability. Also adjusted session user_id handling, improved LIKE/DATE/TIMEDIFF usage, and tightened several model/controller methods (Labels, Activators, Bands, Contesting, Labels_model, Modes, Oqrs_model, Qsl_model, Setup_model, Sstv_model, User_model) for safer, clearer DB queries and inputs.
2026-06-24 22:15:31 +01:00
|
|
|
$this->db->where('DATE('.$this->config->item('table_name').'.COL_TIME_ON) >= '.$this->db->escape($from), NULL, FALSE);
|
2023-04-12 11:58:47 +02:00
|
|
|
}
|
|
|
|
|
if ($to != 0) {
|
|
|
|
|
$to = DateTime::createFromFormat('Y-m-d', $to);
|
|
|
|
|
$to = $to->format('Y-m-d');
|
Sanitize IDs and migrate SQL to Query Builder
Replace ad-hoc xss_clean calls with explicit casting and stronger type checks for ID/parameter handling, and convert many raw SQL strings to CodeIgniter Query Builder usage. Added normalize_location_ids helpers (Activators_model, Oqrs_model) to safely parse location lists and used where_in/parameter binding/escaping to avoid injection and improve maintainability. Also adjusted session user_id handling, improved LIKE/DATE/TIMEDIFF usage, and tightened several model/controller methods (Labels, Activators, Bands, Contesting, Labels_model, Modes, Oqrs_model, Qsl_model, Setup_model, Sstv_model, User_model) for safer, clearer DB queries and inputs.
2026-06-24 22:15:31 +01:00
|
|
|
$this->db->where('DATE('.$this->config->item('table_name').'.COL_TIME_ON) <= '.$this->db->escape($to), NULL, FALSE);
|
2023-04-12 11:58:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->db->where($this->config->item('table_name').'.COL_CONTEST_ID', $contest_id);
|
|
|
|
|
|
|
|
|
|
$this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "ASC");
|
|
|
|
|
|
|
|
|
|
$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
|
|
|
|
|
|
|
|
|
|
return $this->db->get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function get_logged_contests2() {
|
|
|
|
|
$CI =& get_instance();
|
|
|
|
|
$CI->load->model('Stations');
|
Sanitize IDs and migrate SQL to Query Builder
Replace ad-hoc xss_clean calls with explicit casting and stronger type checks for ID/parameter handling, and convert many raw SQL strings to CodeIgniter Query Builder usage. Added normalize_location_ids helpers (Activators_model, Oqrs_model) to safely parse location lists and used where_in/parameter binding/escaping to avoid injection and improve maintainability. Also adjusted session user_id handling, improved LIKE/DATE/TIMEDIFF usage, and tightened several model/controller methods (Labels, Activators, Bands, Contesting, Labels_model, Modes, Oqrs_model, Qsl_model, Setup_model, Sstv_model, User_model) for safer, clearer DB queries and inputs.
2026-06-24 22:15:31 +01:00
|
|
|
$station_id = (int) $CI->Stations->find_active();
|
2023-04-12 11:58:47 +02:00
|
|
|
|
Sanitize IDs and migrate SQL to Query Builder
Replace ad-hoc xss_clean calls with explicit casting and stronger type checks for ID/parameter handling, and convert many raw SQL strings to CodeIgniter Query Builder usage. Added normalize_location_ids helpers (Activators_model, Oqrs_model) to safely parse location lists and used where_in/parameter binding/escaping to avoid injection and improve maintainability. Also adjusted session user_id handling, improved LIKE/DATE/TIMEDIFF usage, and tightened several model/controller methods (Labels, Activators, Bands, Contesting, Labels_model, Modes, Oqrs_model, Qsl_model, Setup_model, Sstv_model, User_model) for safer, clearer DB queries and inputs.
2026-06-24 22:15:31 +01:00
|
|
|
$this->db->select('col_contest_id, min(date(col_time_on)) mindate, max(date(col_time_on)) maxdate, year(col_time_on) year, month(col_time_on) month', false);
|
|
|
|
|
$this->db->from($this->config->item('table_name'));
|
|
|
|
|
$this->db->where("coalesce(COL_CONTEST_ID, '') <> ''", NULL, FALSE);
|
|
|
|
|
$this->db->where('station_id', $station_id);
|
|
|
|
|
$this->db->group_by('COL_CONTEST_ID, year(col_time_on), month(col_time_on)', false);
|
|
|
|
|
$this->db->order_by('year(col_time_on)', 'DESC', false);
|
2023-04-12 11:58:47 +02:00
|
|
|
|
Sanitize IDs and migrate SQL to Query Builder
Replace ad-hoc xss_clean calls with explicit casting and stronger type checks for ID/parameter handling, and convert many raw SQL strings to CodeIgniter Query Builder usage. Added normalize_location_ids helpers (Activators_model, Oqrs_model) to safely parse location lists and used where_in/parameter binding/escaping to avoid injection and improve maintainability. Also adjusted session user_id handling, improved LIKE/DATE/TIMEDIFF usage, and tightened several model/controller methods (Labels, Activators, Bands, Contesting, Labels_model, Modes, Oqrs_model, Qsl_model, Setup_model, Sstv_model, User_model) for safer, clearer DB queries and inputs.
2026-06-24 22:15:31 +01:00
|
|
|
$data = $this->db->get();
|
2023-04-12 11:58:47 +02:00
|
|
|
|
|
|
|
|
return ($data->result());
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-12 14:24:03 +02:00
|
|
|
function get_logged_years($station_id) {
|
Sanitize IDs and migrate SQL to Query Builder
Replace ad-hoc xss_clean calls with explicit casting and stronger type checks for ID/parameter handling, and convert many raw SQL strings to CodeIgniter Query Builder usage. Added normalize_location_ids helpers (Activators_model, Oqrs_model) to safely parse location lists and used where_in/parameter binding/escaping to avoid injection and improve maintainability. Also adjusted session user_id handling, improved LIKE/DATE/TIMEDIFF usage, and tightened several model/controller methods (Labels, Activators, Bands, Contesting, Labels_model, Modes, Oqrs_model, Qsl_model, Setup_model, Sstv_model, User_model) for safer, clearer DB queries and inputs.
2026-06-24 22:15:31 +01:00
|
|
|
$station_id = (int) $station_id;
|
|
|
|
|
$this->db->distinct();
|
|
|
|
|
$this->db->select('year(col_time_on) year', false);
|
|
|
|
|
$this->db->from($this->config->item('table_name'));
|
|
|
|
|
$this->db->where("coalesce(COL_CONTEST_ID, '') <> ''", NULL, FALSE);
|
|
|
|
|
$this->db->where('station_id', $station_id);
|
|
|
|
|
$this->db->order_by('year(col_time_on)', 'DESC', false);
|
|
|
|
|
$data = $this->db->get();
|
2023-04-12 11:58:47 +02:00
|
|
|
|
2023-04-12 14:24:03 +02:00
|
|
|
return $data->result();
|
2023-04-12 11:58:47 +02:00
|
|
|
}
|
|
|
|
|
|
2023-04-12 14:24:03 +02:00
|
|
|
function get_logged_contests($station_id, $year) {
|
Sanitize IDs and migrate SQL to Query Builder
Replace ad-hoc xss_clean calls with explicit casting and stronger type checks for ID/parameter handling, and convert many raw SQL strings to CodeIgniter Query Builder usage. Added normalize_location_ids helpers (Activators_model, Oqrs_model) to safely parse location lists and used where_in/parameter binding/escaping to avoid injection and improve maintainability. Also adjusted session user_id handling, improved LIKE/DATE/TIMEDIFF usage, and tightened several model/controller methods (Labels, Activators, Bands, Contesting, Labels_model, Modes, Oqrs_model, Qsl_model, Setup_model, Sstv_model, User_model) for safer, clearer DB queries and inputs.
2026-06-24 22:15:31 +01:00
|
|
|
$station_id = (int) $station_id;
|
|
|
|
|
$year = (int) $year;
|
|
|
|
|
$this->db->distinct();
|
|
|
|
|
$this->db->select('col_contest_id');
|
|
|
|
|
$this->db->from($this->config->item('table_name'));
|
|
|
|
|
$this->db->where("coalesce(COL_CONTEST_ID, '') <> ''", NULL, FALSE);
|
|
|
|
|
$this->db->where('station_id', $station_id);
|
|
|
|
|
$this->db->where('year(col_time_on)', $year, false);
|
|
|
|
|
$this->db->order_by('COL_CONTEST_ID', 'ASC');
|
|
|
|
|
$data = $this->db->get();
|
2023-04-12 11:58:47 +02:00
|
|
|
|
|
|
|
|
return $data->result();
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-12 14:24:03 +02:00
|
|
|
function get_contest_dates($station_id, $year, $contestid) {
|
Sanitize IDs and migrate SQL to Query Builder
Replace ad-hoc xss_clean calls with explicit casting and stronger type checks for ID/parameter handling, and convert many raw SQL strings to CodeIgniter Query Builder usage. Added normalize_location_ids helpers (Activators_model, Oqrs_model) to safely parse location lists and used where_in/parameter binding/escaping to avoid injection and improve maintainability. Also adjusted session user_id handling, improved LIKE/DATE/TIMEDIFF usage, and tightened several model/controller methods (Labels, Activators, Bands, Contesting, Labels_model, Modes, Oqrs_model, Qsl_model, Setup_model, Sstv_model, User_model) for safer, clearer DB queries and inputs.
2026-06-24 22:15:31 +01:00
|
|
|
$station_id = (int) $station_id;
|
|
|
|
|
$year = (int) $year;
|
|
|
|
|
$this->db->distinct();
|
|
|
|
|
$this->db->select('date(col_time_on) date', false);
|
|
|
|
|
$this->db->from($this->config->item('table_name'));
|
|
|
|
|
$this->db->where("coalesce(COL_CONTEST_ID, '') <> ''", NULL, FALSE);
|
|
|
|
|
$this->db->where('station_id', $station_id);
|
|
|
|
|
$this->db->where('year(col_time_on)', $year, false);
|
|
|
|
|
$this->db->where('col_contest_id', $contestid);
|
|
|
|
|
$data = $this->db->get();
|
2023-04-12 11:58:47 +02:00
|
|
|
|
|
|
|
|
return $data->result();
|
|
|
|
|
}
|
2021-02-12 23:27:08 +01:00
|
|
|
}
|