From e5f0eb03e81023e7417f51e50c40013b88d3a658 Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Fri, 24 Nov 2023 13:08:40 +0100 Subject: [PATCH 1/5] Fixed variable typo in LoTW --- application/controllers/Lotw.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php index 7a49a055..13998bc4 100644 --- a/application/controllers/Lotw.php +++ b/application/controllers/Lotw.php @@ -435,7 +435,7 @@ class Lotw extends CI_Controller { // Read Cert Data $certdata= openssl_x509_parse($results['cert'],0); - + // Store Variables $data['issued_callsign'] = $certdata['subject']['undefined']; $data['issued_name'] = $certdata['subject']['commonName']; @@ -637,7 +637,7 @@ class Lotw extends CI_Controller { $config['upload_path'] = './uploads/'; $file = $config['upload_path'] . 'lotwreport_download.adi'; if (file_exists($file) && ! is_writable($file)) { - $result.= "Temporary download file ".$file." is not writable. Aborting!"; + $results .= "Temporary download file ".$file." is not writable. Aborting!"; } // Get credentials for LoTW From 452c0dfdaa2ea603150088f6ad6e9c3b6783a150 Mon Sep 17 00:00:00 2001 From: phl0 Date: Fri, 24 Nov 2023 13:49:30 +0100 Subject: [PATCH 2/5] Refactor LoTW imports --- application/controllers/Lotw.php | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php index 13998bc4..a6f3bf7d 100644 --- a/application/controllers/Lotw.php +++ b/application/controllers/Lotw.php @@ -630,14 +630,22 @@ class Lotw extends CI_Controller { $query = $this->user_model->get_all_lotw_users(); if ($query->num_rows() >= 1) { - $results=''; + $result = ''; foreach ($query->result() as $user) { if ( ($sync_user_id != null) && ($sync_user_id != $user->user_id) ) { continue; } + // Validate that LoTW credentials are not empty + // TODO: We don't actually see the error message + if ($user->user_lotw_password == '') { + $result = "You have not defined your ARRL LoTW credentials!"; + continue; + } + $config['upload_path'] = './uploads/'; $file = $config['upload_path'] . 'lotwreport_download.adi'; if (file_exists($file) && ! is_writable($file)) { - $results .= "Temporary download file ".$file." is not writable. Aborting!"; + $result = "Temporary download file ".$file." is not writable. Aborting!"; + continue; } // Get credentials for LoTW @@ -649,14 +657,7 @@ class Lotw extends CI_Controller { $q = $query->row(); $lotw_url = $q->lotw_download_url; - // Validate that LoTW credentials are not empty - // TODO: We don't actually see the error message - if ($data['user_lotw_name'] == '' || $data['user_lotw_password'] == '') - { - echo "You have not defined your ARRL LoTW credentials!"; - } - - $lotw_last_qsl_date = date('Y-m-d', strtotime($this->logbook_model->lotw_last_qsl_date($user->user_id))); + $lotw_last_qsl_date = date('Y-m-d', strtotime($this->logbook_model->lotw_last_qsl_date($user->user_id))); // Build URL for LoTW report file $lotw_url .= "?"; @@ -668,19 +669,22 @@ class Lotw extends CI_Controller { $lotw_url .= "$lotw_last_qsl_date"; if (! is_writable(dirname($file))) { - $results.= "Temporary download directory ".dirname($file)." is not writable. Aborting!"; + $result = "Temporary download directory ".dirname($file)." is not writable. Aborting!"; continue; } file_put_contents($file, file_get_contents($lotw_url)); if (file_get_contents($file, false, null, 0, 39) != "ARRL Logbook of the World Status Report") { - $results.= "LoTW downloading failed for User ".$data['user_lotw_name']." either due to it being down or incorrect logins."; + $result = "LoTW downloading failed for User ".$data['user_lotw_name']." either due to it being down or incorrect logins."; continue; } ini_set('memory_limit', '-1'); - $results.= $this->loadFromFile($file, false); + $result = $this->loadFromFile($file, false); } - return $results; + if ($result == '') { + $result = "You have not defined your ARRL LoTW credentials!"; + } + return $result; } else { return "No LoTW User details found to carry out matches."; } From 114cd087656787c68ffadce1bc1f19017aca4512 Mon Sep 17 00:00:00 2001 From: phl0 Date: Fri, 24 Nov 2023 15:12:53 +0100 Subject: [PATCH 3/5] Align form input fields --- application/views/lotw/import.php | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/application/views/lotw/import.php b/application/views/lotw/import.php index d76e9239..b27e32cb 100644 --- a/application/views/lotw/import.php +++ b/application/views/lotw/import.php @@ -1,9 +1,9 @@

-

- +
-
+
load->view('layout/messages'); ?> @@ -16,21 +16,16 @@

- +
-
+

- -

- -
- - -
+ +

:

@@ -42,11 +37,12 @@

-

+

+
- + - +
From ea27403ea6eeaf6757466c68c6e814f7cd12edad Mon Sep 17 00:00:00 2001 From: phl0 Date: Fri, 24 Nov 2023 16:15:01 +0100 Subject: [PATCH 4/5] Allow to select the callsign to download LoTW cnfms for --- application/controllers/Lotw.php | 10 ++++++---- application/language/english/lotw_lang.php | 1 + application/models/Stations.php | 11 ++++++++++- application/views/lotw/import.php | 15 +++++++++++++++ 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php index a6f3bf7d..b64c8e0d 100644 --- a/application/controllers/Lotw.php +++ b/application/controllers/Lotw.php @@ -746,9 +746,9 @@ class Lotw extends CI_Controller { $lotw_url .= "&qso_qslsince="; $lotw_url .= "$lotw_last_qsl_date"; - // Only pull back entries that belong to this callsign - $lotw_call = $this->session->userdata('user_callsign'); - $lotw_url .= "&qso_owncall=$lotw_call"; + if ($this->input->post('callsign') != '0') { + $lotw_url .= "&qso_owncall=".$this->input->post('callsign'); + } file_put_contents($file, file_get_contents($lotw_url)); @@ -761,9 +761,11 @@ class Lotw extends CI_Controller { { $data['error'] = $this->upload->display_errors(); + $this->load->model('Stations'); + $data['callsigns'] = $this->Stations->callsigns_of_user($this->session->userdata('user_id')); $this->load->view('interface_assets/header', $data); - $this->load->view('lotw/import'); + $this->load->view('lotw/import', $data); $this->load->view('interface_assets/footer'); } else diff --git a/application/language/english/lotw_lang.php b/application/language/english/lotw_lang.php index 3ed3245d..788274b1 100644 --- a/application/language/english/lotw_lang.php +++ b/application/language/english/lotw_lang.php @@ -34,6 +34,7 @@ $lang['lotw_upload_exported_adif_file_from_lotw'] = 'Upload the Exported ADIF fi $lang['lotw_upload_type_must_be_adi'] = 'Log files must have the file type .adi'; $lang['lotw_pull_lotw_data_for_me'] = 'Pull LoTW data for me'; +$lang['lotw_select_callsign'] = 'Select callsign to pull LoTW confirmations for'; $lang['lotw_report_download_overview_helptext'] = 'Cloudlog will use the LoTW username and password stored in your user profile to download a report from LoTW for you. The report Cloudlog downloads will have all confirmations since chosen date, or since your last LoTW confirmation (fetched from your log), up until now.'; diff --git a/application/models/Stations.php b/application/models/Stations.php index 054921cf..03b89aa7 100644 --- a/application/models/Stations.php +++ b/application/models/Stations.php @@ -24,7 +24,7 @@ class Stations extends CI_Model { } function all_of_user($userid = null) { - if ($userid == null) { + if ($userid == null) { $userid=$this->session->userdata('user_id'); // Fallback to session-uid, if userid is omitted } $this->db->select('station_profile.*, dxcc_entities.name as station_country, dxcc_entities.end as dxcc_end'); @@ -33,6 +33,15 @@ class Stations extends CI_Model { return $this->db->get('station_profile'); } + function callsigns_of_user($userid = null) { + if ($userid == null) { + $userid=$this->session->userdata('user_id'); // Fallback to session-uid, if userid is omitted + } + $this->db->select('distinct(station_profile.station_callsign) as callsign'); + $this->db->where('user_id', $userid); + return $this->db->get('station_profile'); + } + function profile($id) { // Clean ID $clean_id = $this->security->xss_clean($id); diff --git a/application/views/lotw/import.php b/application/views/lotw/import.php index b27e32cb..8b370340 100644 --- a/application/views/lotw/import.php +++ b/application/views/lotw/import.php @@ -36,6 +36,21 @@
+
+
+ + result() as $call) { + $options[$call->callsign] = $call->callsign; + } + ksort($options); + array_unshift($options, 'All'); + echo form_dropdown('callsign', $options, 'All'); + ?> +
+
+

From 0c8c2b2f1ec1293838634376d83e829d95c71f31 Mon Sep 17 00:00:00 2001 From: phl0 Date: Fri, 24 Nov 2023 16:17:11 +0100 Subject: [PATCH 5/5] Translations added --- application/language/bulgarian/lotw_lang.php | 1 + application/language/chinese_simplified/lotw_lang.php | 1 + application/language/czech/lotw_lang.php | 1 + application/language/dutch/lotw_lang.php | 1 + application/language/finnish/lotw_lang.php | 1 + application/language/french/lotw_lang.php | 1 + application/language/german/lotw_lang.php | 1 + application/language/greek/lotw_lang.php | 1 + application/language/italian/lotw_lang.php | 1 + application/language/polish/lotw_lang.php | 1 + application/language/russian/lotw_lang.php | 1 + application/language/spanish/lotw_lang.php | 1 + application/language/swedish/lotw_lang.php | 1 + application/language/turkish/lotw_lang.php | 1 + 14 files changed, 14 insertions(+) diff --git a/application/language/bulgarian/lotw_lang.php b/application/language/bulgarian/lotw_lang.php index eda6a36d..feb31524 100644 --- a/application/language/bulgarian/lotw_lang.php +++ b/application/language/bulgarian/lotw_lang.php @@ -34,6 +34,7 @@ $lang['lotw_upload_exported_adif_file_from_lotw'] = 'Upload the Exported ADIF fi $lang['lotw_upload_type_must_be_adi'] = 'Log files must have the file type .adi'; $lang['lotw_pull_lotw_data_for_me'] = 'Pull LoTW data for me'; +$lang['lotw_select_callsign'] = 'Select callsign to pull LoTW confirmations for'; $lang['lotw_report_download_overview_helptext'] = 'Cloudlog will use the LoTW username and password stored in your user profile to download a report from LoTW for you. The report Cloudlog downloads will have all confirmations since chosen date, or since your last LoTW confirmation (fetched from your log), up until now.'; diff --git a/application/language/chinese_simplified/lotw_lang.php b/application/language/chinese_simplified/lotw_lang.php index 7d788259..4ffcc62e 100644 --- a/application/language/chinese_simplified/lotw_lang.php +++ b/application/language/chinese_simplified/lotw_lang.php @@ -34,6 +34,7 @@ $lang['lotw_upload_exported_adif_file_from_lotw'] = '下载从 LoTW