LoTW CRL check function

This commit is contained in:
phl0
2025-11-19 14:07:58 +01:00
parent 15475a62a3
commit 6b35bd48bd
2 changed files with 23 additions and 1 deletions

View File

@@ -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

View File

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