diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php
index 966ee3e54..7a8c63749 100644
--- a/application/controllers/Lotw.php
+++ b/application/controllers/Lotw.php
@@ -211,14 +211,26 @@ class Lotw extends CI_Controller {
// Get Certificate Data
$this->load->model('Lotw_model');
$data['station_profile'] = $station_profile;
- $data['lotw_cert_info'] = $this->Lotw_model->lotw_cert_details($station_profile->station_callsign, $station_profile->station_dxcc, $station_profile->user_id);
+
+ $cert_query = $this->Lotw_model->lotw_cert_details($station_profile->station_callsign, $station_profile->user_id);
+ if ($cert_query->num_rows() > 1) {
+ echo $station_profile->station_callsign.": Multiple matching LoTW certificates found. Skipping.
";
+ continue;
+ }
// If Station Profile has no LoTW Cert continue on.
- if(!isset($data['lotw_cert_info']->cert_dxcc_id)) {
+ if ($cert_query->num_rows() == 0) {
echo $station_profile->station_callsign.": No LoTW certificate for station callsign found.
";
continue;
}
+ $data['lotw_cert_info'] = $cert_query->row();
+ // Check if station profile DXCC matches cert DXCC
+ if ($data['lotw_cert_info']->cert_dxcc_id != $station_profile->station_dxcc) {
+ echo $station_profile->station_callsign.": DXCC of station profile does not match DXCC of LoTW certificate.
";
+ continue;
+ }
+
// Check if LoTW certificate itself is valid
// Validty of QSO dates will be checked later
$current_date = date('Y-m-d H:i:s');
diff --git a/application/models/Lotw_model.php b/application/models/Lotw_model.php
index 952466d37..388fa31aa 100644
--- a/application/models/Lotw_model.php
+++ b/application/models/Lotw_model.php
@@ -22,13 +22,12 @@ class Lotw_model extends CI_Model {
}
- function lotw_cert_details($callsign, $dxcc, $user_id) {
- $this->db->where('cert_dxcc_id', $dxcc);
+ function lotw_cert_details($callsign, $user_id) {
$this->db->where('user_id', $user_id);
$this->db->where('callsign', $callsign);
$query = $this->db->get('lotw_certs');
- return $query->row();
+ return $query;
}
function find_cert($callsign, $dxcc, $user_id) {