From 6e54a915d4cc82f418ab2c004b1442c267ea082e Mon Sep 17 00:00:00 2001 From: phl0 Date: Tue, 11 Apr 2023 22:40:53 +0200 Subject: [PATCH 1/3] Make LotW downloads more verbose regarding file writing --- application/controllers/Lotw.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php index e4a6debb..5384f1e0 100644 --- a/application/controllers/Lotw.php +++ b/application/controllers/Lotw.php @@ -615,6 +615,9 @@ class Lotw extends CI_Controller { $config['upload_path'] = './uploads/'; $file = $config['upload_path'] . 'lotwreport_download.adi'; + if (file_exists($file) && ! is_writable($file)) { + return "Temporary download file ".$file." is not writable. Aborting!"; + } // Get credentials for LoTW $data['user_lotw_name'] = urlencode($user->user_lotw_name); @@ -643,6 +646,9 @@ class Lotw extends CI_Controller { $lotw_url .= "&qso_qslsince="; $lotw_url .= "$lotw_last_qsl_date"; + if (! is_writable(dirname($file))) { + return "Temporary download directory ".dirname($file)." is not writable. Aborting!"; + } file_put_contents($file, file_get_contents($lotw_url)); ini_set('memory_limit', '-1'); From 9d76681c05511e91006995f8f69ed42bd1c40318 Mon Sep 17 00:00:00 2001 From: phl0 Date: Tue, 11 Apr 2023 22:58:50 +0200 Subject: [PATCH 2/3] Correct error message. Empty file is not necessarily a failed login to 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 5384f1e0..97403b15 100644 --- a/application/controllers/Lotw.php +++ b/application/controllers/Lotw.php @@ -359,7 +359,6 @@ class Lotw extends CI_Controller { | Download QSO Matches from LoTW */ echo "

"; - echo "LoTW Matches
"; echo $this->lotw_download(); } @@ -580,6 +579,7 @@ class Lotw extends CI_Controller { unlink($filepath); if(isset($data['lotw_table_headers'])) { + echo "LoTW Matches
"; if($display_view == TRUE) { $data['page_title'] = "LoTW ADIF Information"; $this->load->view('interface_assets/header', $data); @@ -589,7 +589,7 @@ class Lotw extends CI_Controller { return $tableheaders.$table; } } else { - echo "LoTW Downloading failed either due to it being down or incorrect logins."; + echo "Downloaded LotW report contains no matches."; } } From bf4ffe47cda08816a814079d41993b9fdd6d1bf4 Mon Sep 17 00:00:00 2001 From: phl0 Date: Tue, 11 Apr 2023 23:19:32 +0200 Subject: [PATCH 3/3] Check for valid downloaded LotW status report and report errors appropriately --- application/controllers/Lotw.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php index 97403b15..e5be23f0 100644 --- a/application/controllers/Lotw.php +++ b/application/controllers/Lotw.php @@ -650,6 +650,9 @@ class Lotw extends CI_Controller { return "Temporary download directory ".dirname($file)." is not writable. Aborting!"; } 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") { + return "LotW downloading failed either due to it being down or incorrect logins."; + } ini_set('memory_limit', '-1'); $results = $this->loadFromFile($file, false);