From 6b35bd48bd447dce84a54f79e9018731caebde94 Mon Sep 17 00:00:00 2001 From: phl0 Date: Wed, 19 Nov 2025 14:07:58 +0100 Subject: [PATCH] LoTW CRL check function --- application/controllers/Lotw.php | 22 ++++++++++++++++++++++ application/models/Lotw_model.php | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php index 0cc15f85f..c476724a5 100644 --- a/application/controllers/Lotw.php +++ b/application/controllers/Lotw.php @@ -1257,4 +1257,26 @@ class Lotw extends CI_Controller { endswitch; } + function lotw_cert_status ($serial = null) { + if (($serial ?? '') != '' && is_numeric($serial)) { + $url = 'https://lotw.arrl.org/lotw/crl?serial='.$serial; + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); + $result = curl_exec($ch); + $xml = new SimpleXMLElement($result); + switch ((string)$xml->Status) { + case 'Superceded': + return 1; + case 'Unrevoked': + return 0; + default: + log_message('error', 'Unknown LotW CRL status: '.(string)$xml->Status); + return 99; + } + } + return 99; + } + } // end class diff --git a/application/models/Lotw_model.php b/application/models/Lotw_model.php index 5d825df9a..0f2d0eea9 100644 --- a/application/models/Lotw_model.php +++ b/application/models/Lotw_model.php @@ -12,7 +12,7 @@ class Lotw_model extends CI_Model { */ function lotw_certs($user_id) { - $this->db->select('lotw_certs.lotw_cert_id as lotw_cert_id, lotw_certs.callsign as callsign, dxcc_entities.name as cert_dxcc, dxcc_entities.end as cert_dxcc_end, lotw_certs.qso_start_date as qso_start_date, lotw_certs.qso_end_date as qso_end_date, lotw_certs.date_created as date_created, lotw_certs.date_expires as date_expires, lotw_certs.last_upload as last_upload, lotw_certs.last_upload_fail as last_upload_fail, lotw_certs.last_upload_status as last_upload_status'); + $this->db->select('lotw_certs.lotw_cert_id as lotw_cert_id, lotw_certs.serial as serial, lotw_certs.callsign as callsign, dxcc_entities.name as cert_dxcc, dxcc_entities.end as cert_dxcc_end, lotw_certs.qso_start_date as qso_start_date, lotw_certs.qso_end_date as qso_end_date, lotw_certs.date_created as date_created, lotw_certs.date_expires as date_expires, lotw_certs.last_upload as last_upload, lotw_certs.last_upload_fail as last_upload_fail, lotw_certs.last_upload_status as last_upload_status'); $this->db->where('user_id', $user_id); $this->db->join('dxcc_entities','lotw_certs.cert_dxcc_id = dxcc_entities.adif','left'); $this->db->order_by('callsign', 'ASC');