From 94464802e66f8db1af645aeb026b01d454781840 Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Tue, 2 Jul 2024 22:03:53 +0200 Subject: [PATCH 1/7] rename Lotw Model for general lotw purpose --- application/controllers/Lotw.php | 8 ++++---- application/models/{LotwCert.php => Lotw.php} | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) rename application/models/{LotwCert.php => Lotw.php} (99%) diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php index f0a330b0d..96a50ec68 100644 --- a/application/controllers/Lotw.php +++ b/application/controllers/Lotw.php @@ -50,7 +50,7 @@ class Lotw extends CI_Controller { } // Load required models for page generation - $this->load->model('LotwCert'); + $this->load->model('Lotw'); // Get Array of the logged in users LoTW certs. $data['lotw_cert_results'] = $this->LotwCert->lotw_certs($this->session->userdata('user_id')); @@ -142,7 +142,7 @@ class Lotw extends CI_Controller { else { // Load database queries - $this->load->model('LotwCert'); + $this->load->model('Lotw'); //Upload of P12 successful $data = array('upload_data' => $this->upload->data()); @@ -226,7 +226,7 @@ class Lotw extends CI_Controller { foreach ($station_profiles->result() as $station_profile) { // Get Certificate Data - $this->load->model('LotwCert'); + $this->load->model('Lotw'); $data['station_profile'] = $station_profile; $data['lotw_cert_info'] = $this->LotwCert->lotw_cert_details($station_profile->station_callsign, $station_profile->station_dxcc); @@ -389,7 +389,7 @@ class Lotw extends CI_Controller { $this->load->model('user_model'); if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } - $this->load->model('LotwCert'); + $this->load->model('Lotw'); $this->LotwCert->delete_certificate($this->session->userdata('user_id'), $cert_id); diff --git a/application/models/LotwCert.php b/application/models/Lotw.php similarity index 99% rename from application/models/LotwCert.php rename to application/models/Lotw.php index 1b46901f1..be66849b6 100644 --- a/application/models/LotwCert.php +++ b/application/models/Lotw.php @@ -1,6 +1,6 @@ Date: Tue, 2 Jul 2024 22:12:48 +0200 Subject: [PATCH 2/7] no direct model use in a view and ordered the loads a bit --- application/controllers/Dashboard.php | 39 ++++++++++++++------------- application/views/dashboard/index.php | 5 ++-- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/application/controllers/Dashboard.php b/application/controllers/Dashboard.php index bab4e3ee3..7991d82c8 100644 --- a/application/controllers/Dashboard.php +++ b/application/controllers/Dashboard.php @@ -5,27 +5,30 @@ class Dashboard extends CI_Controller public function index() { - // Database connections - $this->load->model('logbook_model'); - $this->load->model('user_model'); - - // LoTW infos - $this->load->model('LotwCert'); - // Check if users logged in - + $this->load->model('user_model'); if ($this->user_model->validate_session() == 0) { // user is not logged in redirect('user/login'); } + // Database connections + $this->load->model('logbook_model'); + + // LoTW infos + $this->load->model('Lotw'); + $current_date = date('Y-m-d H:i:s'); + $data['lotw_cert_expired'] = $this->Lotw->lotw_cert_expired($this->session->userdata('user_id'), $current_date); + $data['lotw_cert_expiring'] = $this->Lotw->lotw_cert_expiring($this->session->userdata('user_id'), $current_date); + + $this->load->model('logbooks_model'); $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - + // Calculate Lat/Lng from Locator to use on Maps if ($this->session->userdata('user_locator')) { $this->load->library('qra'); - + $qra_position = $this->qra->qra2latlong($this->session->userdata('user_locator')); if ($qra_position) { $data['qra'] = "set"; @@ -37,26 +40,26 @@ class Dashboard extends CI_Controller } else { $data['qra'] = "none"; } - + $this->load->model('stations'); $this->load->model('setup_model'); - + $data['countryCount'] = $this->setup_model->getCountryCount(); $data['logbookCount'] = $this->setup_model->getLogbookCount(); $data['locationCount'] = $this->setup_model->getLocationCount(); - + $data['current_active'] = $this->stations->find_active(); - + $data['themesWithoutMode'] = $this->setup_model->checkThemesWithoutMode(); $data['dashboard_map'] = $this->optionslib->get_option('dashboard_map'); - + $data['user_map_custom'] = $this->optionslib->get_map_custom(); - + $this->load->model('cat'); $this->load->model('vucc'); - + $data['radio_status'] = $this->cat->recent_status(); - + // Store info $data['todays_qsos'] = $this->logbook_model->todays_qsos($logbooks_locations_array); $data['total_qsos'] = $this->logbook_model->total_qsos($logbooks_locations_array); diff --git a/application/views/dashboard/index.php b/application/views/dashboard/index.php index d83f34aa3..c426f7352 100644 --- a/application/views/dashboard/index.php +++ b/application/views/dashboard/index.php @@ -113,14 +113,13 @@ function echo_table_col($row, $name) { session->userdata('user_id')) { ?> LotwCert->lotw_cert_expired($this->session->userdata('user_id'), $current_date) == true) { ?> + if($lotw_cert_expired == true) { ?> - LotwCert->lotw_cert_expiring($this->session->userdata('user_id'), $current_date) == true) { ?> + From 679c8b949f714841e00ae0ecc4fb4463e389b9b8 Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Tue, 2 Jul 2024 22:16:05 +0200 Subject: [PATCH 3/7] cleared some whitespaces --- application/controllers/Dashboard.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/application/controllers/Dashboard.php b/application/controllers/Dashboard.php index 7991d82c8..7655bebd9 100644 --- a/application/controllers/Dashboard.php +++ b/application/controllers/Dashboard.php @@ -24,11 +24,11 @@ class Dashboard extends CI_Controller $this->load->model('logbooks_model'); $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - + // Calculate Lat/Lng from Locator to use on Maps if ($this->session->userdata('user_locator')) { $this->load->library('qra'); - + $qra_position = $this->qra->qra2latlong($this->session->userdata('user_locator')); if ($qra_position) { $data['qra'] = "set"; @@ -40,26 +40,26 @@ class Dashboard extends CI_Controller } else { $data['qra'] = "none"; } - + $this->load->model('stations'); $this->load->model('setup_model'); - + $data['countryCount'] = $this->setup_model->getCountryCount(); $data['logbookCount'] = $this->setup_model->getLogbookCount(); $data['locationCount'] = $this->setup_model->getLocationCount(); - + $data['current_active'] = $this->stations->find_active(); - + $data['themesWithoutMode'] = $this->setup_model->checkThemesWithoutMode(); $data['dashboard_map'] = $this->optionslib->get_option('dashboard_map'); - + $data['user_map_custom'] = $this->optionslib->get_map_custom(); - + $this->load->model('cat'); $this->load->model('vucc'); - + $data['radio_status'] = $this->cat->recent_status(); - + // Store info $data['todays_qsos'] = $this->logbook_model->todays_qsos($logbooks_locations_array); $data['total_qsos'] = $this->logbook_model->total_qsos($logbooks_locations_array); From bd5c841cfef9d09ba1ba721bd1b9fb61ebf51dfe Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Tue, 2 Jul 2024 22:36:45 +0200 Subject: [PATCH 4/7] renaming --- application/controllers/Lotw.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php index 96a50ec68..8eb670f20 100644 --- a/application/controllers/Lotw.php +++ b/application/controllers/Lotw.php @@ -53,7 +53,7 @@ class Lotw extends CI_Controller { $this->load->model('Lotw'); // Get Array of the logged in users LoTW certs. - $data['lotw_cert_results'] = $this->LotwCert->lotw_certs($this->session->userdata('user_id')); + $data['lotw_cert_results'] = $this->Lotw->lotw_certs($this->session->userdata('user_id')); // Set Page Title $data['page_title'] = __("Logbook of the World"); @@ -150,20 +150,20 @@ class Lotw extends CI_Controller { $info = $this->decrypt_key($data['upload_data']['full_path']); // Check to see if certificate is already in the system - $new_certificate = $this->LotwCert->find_cert($info['issued_callsign'], $info['dxcc-id'], $this->session->userdata('user_id')); + $new_certificate = $this->Lotw->find_cert($info['issued_callsign'], $info['dxcc-id'], $this->session->userdata('user_id')); if($new_certificate == 0) { // New Certificate Store in Database // Store Certificate Data into MySQL - $this->LotwCert->store_certificate($this->session->userdata('user_id'), $info['issued_callsign'], $info['dxcc-id'], $info['validFrom'], $info['validTo_Date'], $info['qso-first-date'], $info['qso-end-date'], $info['pem_key'], $info['general_cert']); + $this->Lotw->store_certificate($this->session->userdata('user_id'), $info['issued_callsign'], $info['dxcc-id'], $info['validFrom'], $info['validTo_Date'], $info['qso-first-date'], $info['qso-end-date'], $info['pem_key'], $info['general_cert']); // Cert success flash message $this->session->set_flashdata('Success', $info['issued_callsign'].' Certificate Imported.'); } else { // Certificate is in the system time to update - $this->LotwCert->update_certificate($this->session->userdata('user_id'), $info['issued_callsign'], $info['dxcc-id'], $info['validFrom'], $info['validTo_Date'], $info['qso-first-date'], $info['qso-end-date'], $info['pem_key'], $info['general_cert']); + $this->Lotw->update_certificate($this->session->userdata('user_id'), $info['issued_callsign'], $info['dxcc-id'], $info['validFrom'], $info['validTo_Date'], $info['qso-first-date'], $info['qso-end-date'], $info['pem_key'], $info['general_cert']); // Cert success flash message $this->session->set_flashdata('Success', $info['issued_callsign'].' Certificate Updated.'); @@ -228,7 +228,7 @@ class Lotw extends CI_Controller { // Get Certificate Data $this->load->model('Lotw'); $data['station_profile'] = $station_profile; - $data['lotw_cert_info'] = $this->LotwCert->lotw_cert_details($station_profile->station_callsign, $station_profile->station_dxcc); + $data['lotw_cert_info'] = $this->Lotw->lotw_cert_details($station_profile->station_callsign, $station_profile->station_dxcc); // If Station Profile has no LoTW Cert continue on. if(!isset($data['lotw_cert_info']->cert_dxcc_id)) { @@ -324,7 +324,7 @@ class Lotw extends CI_Controller { if(curl_errno($ch)){ echo $station_profile->station_callsign." (".$station_profile->station_profile_name."): Upload Failed - ".curl_strerror(curl_errno($ch))." (".curl_errno($ch).")
"; - $this->LotwCert->last_upload($data['lotw_cert_info']->lotw_cert_id, "Upload failed"); + $this->Lotw->last_upload($data['lotw_cert_info']->lotw_cert_id, "Upload failed"); if (curl_errno($ch) == 28) { // break on timeout echo "Timeout reached. Stopping subsequent uploads.
"; break; @@ -338,7 +338,7 @@ class Lotw extends CI_Controller { if ($pos === false) { // Upload of TQ8 Failed for unknown reason echo $station_profile->station_callsign." (".$station_profile->station_profile_name."): Upload Failed - ".curl_strerror(curl_errno($ch))." (".curl_errno($ch).")
"; - $this->LotwCert->last_upload($data['lotw_cert_info']->lotw_cert_id, "Upload failed"); + $this->Lotw->last_upload($data['lotw_cert_info']->lotw_cert_id, "Upload failed"); if (curl_errno($ch) == 28) { // break on timeout echo "Timeout reached. Stopping subsequent uploads.
"; break; @@ -350,7 +350,7 @@ class Lotw extends CI_Controller { echo $station_profile->station_callsign." (".$station_profile->station_profile_name."): Upload Successful - ".$filename_for_saving."
"; - $this->LotwCert->last_upload($data['lotw_cert_info']->lotw_cert_id, "Success"); + $this->Lotw->last_upload($data['lotw_cert_info']->lotw_cert_id, "Success"); // Mark QSOs as Sent foreach ($qso_id_array as $qso_number) { @@ -391,7 +391,7 @@ class Lotw extends CI_Controller { $this->load->model('Lotw'); - $this->LotwCert->delete_certificate($this->session->userdata('user_id'), $cert_id); + $this->Lotw->delete_certificate($this->session->userdata('user_id'), $cert_id); $this->session->set_flashdata('Success', 'Certificate Deleted.'); From 5db5ed775e9f3214f8ff812fa9ae1ea0ab2d52aa Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Thu, 4 Jul 2024 06:59:58 +0200 Subject: [PATCH 5/7] lotw_model is the better name --- application/controllers/Dashboard.php | 6 +++--- application/controllers/Lotw.php | 26 +++++++++++++------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/application/controllers/Dashboard.php b/application/controllers/Dashboard.php index 7655bebd9..78c5b8c60 100644 --- a/application/controllers/Dashboard.php +++ b/application/controllers/Dashboard.php @@ -16,10 +16,10 @@ class Dashboard extends CI_Controller $this->load->model('logbook_model'); // LoTW infos - $this->load->model('Lotw'); + $this->load->model('Lotw_model'); $current_date = date('Y-m-d H:i:s'); - $data['lotw_cert_expired'] = $this->Lotw->lotw_cert_expired($this->session->userdata('user_id'), $current_date); - $data['lotw_cert_expiring'] = $this->Lotw->lotw_cert_expiring($this->session->userdata('user_id'), $current_date); + $data['lotw_cert_expired'] = $this->Lotw_model->lotw_cert_expired($this->session->userdata('user_id'), $current_date); + $data['lotw_cert_expiring'] = $this->Lotw_model->lotw_cert_expiring($this->session->userdata('user_id'), $current_date); $this->load->model('logbooks_model'); diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php index 8eb670f20..c92aaa466 100644 --- a/application/controllers/Lotw.php +++ b/application/controllers/Lotw.php @@ -50,10 +50,10 @@ class Lotw extends CI_Controller { } // Load required models for page generation - $this->load->model('Lotw'); + $this->load->model('Lotw_model'); // Get Array of the logged in users LoTW certs. - $data['lotw_cert_results'] = $this->Lotw->lotw_certs($this->session->userdata('user_id')); + $data['lotw_cert_results'] = $this->Lotw_model->lotw_certs($this->session->userdata('user_id')); // Set Page Title $data['page_title'] = __("Logbook of the World"); @@ -142,7 +142,7 @@ class Lotw extends CI_Controller { else { // Load database queries - $this->load->model('Lotw'); + $this->load->model('Lotw_model'); //Upload of P12 successful $data = array('upload_data' => $this->upload->data()); @@ -150,20 +150,20 @@ class Lotw extends CI_Controller { $info = $this->decrypt_key($data['upload_data']['full_path']); // Check to see if certificate is already in the system - $new_certificate = $this->Lotw->find_cert($info['issued_callsign'], $info['dxcc-id'], $this->session->userdata('user_id')); + $new_certificate = $this->Lotw_model->find_cert($info['issued_callsign'], $info['dxcc-id'], $this->session->userdata('user_id')); if($new_certificate == 0) { // New Certificate Store in Database // Store Certificate Data into MySQL - $this->Lotw->store_certificate($this->session->userdata('user_id'), $info['issued_callsign'], $info['dxcc-id'], $info['validFrom'], $info['validTo_Date'], $info['qso-first-date'], $info['qso-end-date'], $info['pem_key'], $info['general_cert']); + $this->Lotw_model->store_certificate($this->session->userdata('user_id'), $info['issued_callsign'], $info['dxcc-id'], $info['validFrom'], $info['validTo_Date'], $info['qso-first-date'], $info['qso-end-date'], $info['pem_key'], $info['general_cert']); // Cert success flash message $this->session->set_flashdata('Success', $info['issued_callsign'].' Certificate Imported.'); } else { // Certificate is in the system time to update - $this->Lotw->update_certificate($this->session->userdata('user_id'), $info['issued_callsign'], $info['dxcc-id'], $info['validFrom'], $info['validTo_Date'], $info['qso-first-date'], $info['qso-end-date'], $info['pem_key'], $info['general_cert']); + $this->Lotw_model->update_certificate($this->session->userdata('user_id'), $info['issued_callsign'], $info['dxcc-id'], $info['validFrom'], $info['validTo_Date'], $info['qso-first-date'], $info['qso-end-date'], $info['pem_key'], $info['general_cert']); // Cert success flash message $this->session->set_flashdata('Success', $info['issued_callsign'].' Certificate Updated.'); @@ -226,9 +226,9 @@ class Lotw extends CI_Controller { foreach ($station_profiles->result() as $station_profile) { // Get Certificate Data - $this->load->model('Lotw'); + $this->load->model('Lotw_model'); $data['station_profile'] = $station_profile; - $data['lotw_cert_info'] = $this->Lotw->lotw_cert_details($station_profile->station_callsign, $station_profile->station_dxcc); + $data['lotw_cert_info'] = $this->Lotw_model->lotw_cert_details($station_profile->station_callsign, $station_profile->station_dxcc); // If Station Profile has no LoTW Cert continue on. if(!isset($data['lotw_cert_info']->cert_dxcc_id)) { @@ -324,7 +324,7 @@ class Lotw extends CI_Controller { if(curl_errno($ch)){ echo $station_profile->station_callsign." (".$station_profile->station_profile_name."): Upload Failed - ".curl_strerror(curl_errno($ch))." (".curl_errno($ch).")
"; - $this->Lotw->last_upload($data['lotw_cert_info']->lotw_cert_id, "Upload failed"); + $this->Lotw_model->last_upload($data['lotw_cert_info']->lotw_cert_id, "Upload failed"); if (curl_errno($ch) == 28) { // break on timeout echo "Timeout reached. Stopping subsequent uploads.
"; break; @@ -338,7 +338,7 @@ class Lotw extends CI_Controller { if ($pos === false) { // Upload of TQ8 Failed for unknown reason echo $station_profile->station_callsign." (".$station_profile->station_profile_name."): Upload Failed - ".curl_strerror(curl_errno($ch))." (".curl_errno($ch).")
"; - $this->Lotw->last_upload($data['lotw_cert_info']->lotw_cert_id, "Upload failed"); + $this->Lotw_model->last_upload($data['lotw_cert_info']->lotw_cert_id, "Upload failed"); if (curl_errno($ch) == 28) { // break on timeout echo "Timeout reached. Stopping subsequent uploads.
"; break; @@ -350,7 +350,7 @@ class Lotw extends CI_Controller { echo $station_profile->station_callsign." (".$station_profile->station_profile_name."): Upload Successful - ".$filename_for_saving."
"; - $this->Lotw->last_upload($data['lotw_cert_info']->lotw_cert_id, "Success"); + $this->Lotw_model->last_upload($data['lotw_cert_info']->lotw_cert_id, "Success"); // Mark QSOs as Sent foreach ($qso_id_array as $qso_number) { @@ -389,9 +389,9 @@ class Lotw extends CI_Controller { $this->load->model('user_model'); if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } - $this->load->model('Lotw'); + $this->load->model('Lotw_model'); - $this->Lotw->delete_certificate($this->session->userdata('user_id'), $cert_id); + $this->Lotw_model->delete_certificate($this->session->userdata('user_id'), $cert_id); $this->session->set_flashdata('Success', 'Certificate Deleted.'); From e2cd77cf995144083b3c04584a99a0619973ca9b Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Thu, 4 Jul 2024 07:00:54 +0200 Subject: [PATCH 6/7] file rename --- application/models/{Lotw.php => Lotw_model.php} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename application/models/{Lotw.php => Lotw_model.php} (99%) diff --git a/application/models/Lotw.php b/application/models/Lotw_model.php similarity index 99% rename from application/models/Lotw.php rename to application/models/Lotw_model.php index be66849b6..b58398a9a 100644 --- a/application/models/Lotw.php +++ b/application/models/Lotw_model.php @@ -1,6 +1,6 @@ Date: Thu, 4 Jul 2024 07:09:33 +0200 Subject: [PATCH 7/7] we don't need the openssl messages anymore --- application/controllers/Lotw.php | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php index c92aaa466..d43e4e5da 100644 --- a/application/controllers/Lotw.php +++ b/application/controllers/Lotw.php @@ -44,11 +44,6 @@ class Lotw extends CI_Controller { $this->load->model('user_model'); if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } - // Fire OpenSSL missing error if not found - if (!extension_loaded('openssl')) { - echo "You must install php OpenSSL for LoTW functions to work"; - } - // Load required models for page generation $this->load->model('Lotw_model'); @@ -108,12 +103,7 @@ class Lotw extends CI_Controller { $this->load->model('dxcc'); if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } - // Fire OpenSSL missing error if not found - if (!extension_loaded('openssl')) { - echo "You must install php OpenSSL for LoTW functions to work"; - } - - // create folder to store certs while processing + // create folder to store certs while processing if (!file_exists('./uploads/lotw/certs')) { mkdir('./uploads/lotw/certs', 0755, true); } @@ -190,11 +180,6 @@ class Lotw extends CI_Controller { $this->load->model('user_model'); $this->user_model->authorize(2); - // Fire OpenSSL missing error if not found - if (!extension_loaded('openssl')) { - echo "You must install php OpenSSL for LoTW functions to work"; - } - // set the last run in cron table for the correct cron id $this->load->model('cron_model'); $this->cron_model->set_last_run($this->router->class.'_'.$this->router->method);