From fc793a11603874e1574199fc9bcbf754e6ddcc33 Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Fri, 15 Dec 2023 23:04:34 +0100 Subject: [PATCH 1/9] added hrdlog_username --- application/config/migration.php | 2 +- application/controllers/Hrdlog.php | 14 ++++++---- .../migrations/162_hrdlog_username.php | 28 +++++++++++++++++++ application/models/Logbook_model.php | 28 ++++++++++--------- application/models/Stations.php | 2 ++ application/views/station_profile/create.php | 9 ++++-- application/views/station_profile/edit.php | 5 ++++ 7 files changed, 66 insertions(+), 22 deletions(-) create mode 100644 application/migrations/162_hrdlog_username.php diff --git a/application/config/migration.php b/application/config/migration.php index f18b8cfec..ed1cc07ac 100644 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE; | */ -$config['migration_version'] = 161; +$config['migration_version'] = 162; /* |-------------------------------------------------------------------------- diff --git a/application/controllers/Hrdlog.php b/application/controllers/Hrdlog.php index eca9ef476..78e449adf 100644 --- a/application/controllers/Hrdlog.php +++ b/application/controllers/Hrdlog.php @@ -20,8 +20,9 @@ class Hrdlog extends CI_Controller { if ($station_ids) { foreach ($station_ids as $station) { + $hrdlog_username = $station->hrdlog_username; $hrdlog_code = $station->hrdlog_code; - if($this->mass_upload_qsos($station->station_id, $hrdlog_code)) { + if($this->mass_upload_qsos($station->station_id, $hrdlog_username, $hrdlog_code)) { echo "QSOs have been uploaded to hrdlog.net."; log_message('info', 'QSOs have been uploaded to hrdlog.net.'); } else{ @@ -48,7 +49,7 @@ class Hrdlog extends CI_Controller { * Function gets all QSOs from given station_id, that are not previously uploaded to hrdlog. * Adif is build for each qso, and then uploaded, one at a time */ - function mass_upload_qsos($station_id, $hrdlog_code) { + function mass_upload_qsos($station_id, $hrdlog_username, $hrdlog_code) { $i = 0; $data['qsos'] = $this->logbook_model->get_hrdlog_qsos($station_id); $errormessages=array(); @@ -61,9 +62,9 @@ class Hrdlog extends CI_Controller { $adif = $CI->adifhelper->getAdifLine($qso); if ($qso->COL_HRDLOG_QSO_UPLOAD_STATUS == 'M') { - $result = $this->logbook_model->push_qso_to_hrdlog($hrdlog_code, $qso->COL_STATION_CALLSIGN,$adif, true); + $result = $this->logbook_model->push_qso_to_hrdlog($hrdlog_username, $hrdlog_code, $adif, true); } else { - $result = $this->logbook_model->push_qso_to_hrdlog($hrdlog_code, $qso->COL_STATION_CALLSIGN,$adif); + $result = $this->logbook_model->push_qso_to_hrdlog($hrdlog_username, $hrdlog_code, $adif); } if ( ($result['status'] == 'OK') || ( ($result['status'] == 'error') || ($result['status'] == 'duplicate')) ){ @@ -126,10 +127,11 @@ class Hrdlog extends CI_Controller { $postData = $this->input->post(); $this->load->model('logbook_model'); - $result = $this->logbook_model->exists_hrdlog_code($postData['station_id']); + $result = $this->logbook_model->exists_hrdlog_credentials($postData['station_id']); + $hrdlog_username = $result->hrdlog_username; $hrdlog_code = $result->hrdlog_code; header('Content-type: application/json'); - $result = $this->mass_upload_qsos($postData['station_id'], $hrdlog_code); + $result = $this->mass_upload_qsos($postData['station_id'], $hrdlog_username, $hrdlog_code); if ($result['status'] == 'OK') { $stationinfo = $this->stations->stations_with_hrdlog_code(); $info = $stationinfo->result(); diff --git a/application/migrations/162_hrdlog_username.php b/application/migrations/162_hrdlog_username.php new file mode 100644 index 000000000..bdfab65ca --- /dev/null +++ b/application/migrations/162_hrdlog_username.php @@ -0,0 +1,28 @@ +db->field_exists('hrdlog_username', 'station_profile')) { + $fields = array( + 'hrdlog_username VARCHAR(20) DEFAULT NULL AFTER hrdlog_code', + ); + $this->dbforge->add_column('station_profile', $fields); + } + } + + public function down() + { + if ($this->db->field_exists('hrdlog_username', 'station_profile')) { + $this->dbforge->drop_column('station_profile', 'hrdlog_username'); + } + } +} \ No newline at end of file diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 5ea0f8711..0df5ed62e 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -278,7 +278,7 @@ class Logbook_model extends CI_Model { $data['COL_MY_GRIDSQUARE'] = strtoupper(trim($station['station_gridsquare'])); } - if ($this->exists_hrdlog_code($station_id)) { + if ($this->exists_hrdlog_credentials($station_id)) { $data['COL_HRDLOG_QSO_UPLOAD_STATUS'] = 'N'; } @@ -602,15 +602,15 @@ class Logbook_model extends CI_Model { } $result = ''; - $result = $this->exists_hrdlog_code($data['station_id']); + $result = $this->exists_hrdlog_credentials($data['station_id']); // Push qso to hrdlog if code is set, and realtime upload is enabled, and we're not importing an adif-file - if (isset($result->hrdlog_code) && $result->hrdlogrealtime == 1) { + if (isset($result->hrdlog_code) && isset($result->hrdlog_username) && $result->hrdlogrealtime == 1) { $CI =& get_instance(); $CI->load->library('AdifHelper'); $qso = $this->get_qso($last_id,true)->result(); $adif = $CI->adifhelper->getAdifLine($qso[0]); - $result = $this->push_qso_to_hrdlog($result->hrdlog_code, $data['COL_STATION_CALLSIGN'], $adif); + $result = $this->push_qso_to_hrdlog($result->hrdlog_username, $result->hrdlog_code, $adif); if ( ($result['status'] == 'OK') || ( ($result['status'] == 'error') || ($result['status'] == 'duplicate') || ($result['status'] == 'auth_error') )){ $this->mark_hrdlog_qsos_sent($last_id); } @@ -652,10 +652,10 @@ class Logbook_model extends CI_Model { } /* - * Function checks if a HRDLog Code exists in the table with the given station id + * Function checks if a HRDLog Code and Username exists in the table with the given station id */ - function exists_hrdlog_code($station_id) { - $sql = 'select hrdlog_code, hrdlogrealtime from station_profile + function exists_hrdlog_credentials($station_id) { + $sql = 'select hrdlog_username, hrdlog_code, hrdlogrealtime from station_profile where station_id = ?'; $query = $this->db->query($sql,$station_id); @@ -762,7 +762,7 @@ class Logbook_model extends CI_Model { * Function uploads a QSO to HRDLog with the API given. * $adif contains a line with the QSO in the ADIF format. QSO ends with an */ - function push_qso_to_hrdlog($apikey, $station_callsign, $adif, $replaceoption = false) { + function push_qso_to_hrdlog($hrdlog_username, $apikey, $adif, $replaceoption = false) { $url = 'https://robot.hrdlog.net/newentry.aspx'; $post_data['Code'] = $apikey; @@ -772,7 +772,7 @@ class Logbook_model extends CI_Model { } $post_data['ADIFData'] = $adif; - $post_data['Callsign'] = $station_callsign; + $post_data['Callsign'] = $hrdlog_username; $post_encoded=http_build_query($post_data); @@ -1213,7 +1213,7 @@ class Logbook_model extends CI_Model { 'COL_CNTY' => $uscounty ); - if ($this->exists_hrdlog_code($data['station_id'])) { + if ($this->exists_hrdlog_credentials($data['station_id'])) { $data['COL_HRDLOG_QSO_UPLOAD_STATUS'] = 'M'; } @@ -1745,9 +1745,11 @@ class Logbook_model extends CI_Model { * Function returns all the station_id's with HRDLOG Code */ function get_station_id_with_hrdlog_code() { - $sql = 'select station_id, hrdlog_code from station_profile - where coalesce(hrdlog_code, "") <> ""'; - + $sql = 'SELECT station_id, hrdlog_username, hrdlog_code + FROM station_profile + WHERE coalesce(hrdlog_username, "") <> "" + AND coalesce(hrdlog_code, "") <> ""'; + $query = $this->db->query($sql); $result = $query->result(); diff --git a/application/models/Stations.php b/application/models/Stations.php index 46ae25e36..a3e71ac4e 100644 --- a/application/models/Stations.php +++ b/application/models/Stations.php @@ -101,6 +101,7 @@ class Stations extends CI_Model { 'station_itu' => xss_clean($this->input->post('station_itu', true)), 'state' => $state, 'eqslqthnickname' => xss_clean($this->input->post('eqslnickname', true)), + 'hrdlog_username' => xss_clean($this->input->post('hrdlog_username', true)), 'hrdlog_code' => xss_clean($this->input->post('hrdlog_code', true)), 'hrdlogrealtime' => xss_clean($this->input->post('hrdlogrealtime', true)), 'clublogrealtime' => xss_clean($this->input->post('clublogrealtime', true)), @@ -150,6 +151,7 @@ class Stations extends CI_Model { 'station_itu' => xss_clean($this->input->post('station_itu', true)), 'state' => $state, 'eqslqthnickname' => xss_clean($this->input->post('eqslnickname', true)), + 'hrdlog_username' => xss_clean($this->input->post('hrdlog_username', true)), 'hrdlog_code' => xss_clean($this->input->post('hrdlog_code', true)), 'hrdlogrealtime' => xss_clean($this->input->post('hrdlogrealtime', true)), 'clublogrealtime' => xss_clean($this->input->post('clublogrealtime', true)), diff --git a/application/views/station_profile/create.php b/application/views/station_profile/create.php index 833ab867f..34ae4f439 100644 --- a/application/views/station_profile/create.php +++ b/application/views/station_profile/create.php @@ -265,12 +265,17 @@
-
+
+ + + Your HRDlog Username +
+
-
+
hrdlog_username; } ?>"> + Your HRDlog Username +
hrdlog_code; } ?>"> From 965f776b7bc5031e02eab842e7771dba47628464 Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Fri, 15 Dec 2023 23:23:06 +0100 Subject: [PATCH 2/9] hrdlog language --- application/language/bulgarian/station_lang.php | 5 ++++- application/language/chinese_simplified/station_lang.php | 5 ++++- application/language/czech/station_lang.php | 5 ++++- application/language/dutch/station_lang.php | 5 ++++- application/language/english/station_lang.php | 5 ++++- application/language/finnish/station_lang.php | 5 ++++- application/language/french/station_lang.php | 5 ++++- application/language/german/station_lang.php | 5 ++++- application/language/greek/station_lang.php | 5 ++++- application/language/italian/station_lang.php | 5 ++++- application/language/polish/station_lang.php | 5 ++++- application/language/russian/station_lang.php | 5 ++++- application/language/spanish/station_lang.php | 5 ++++- application/language/swedish/station_lang.php | 5 ++++- application/language/turkish/station_lang.php | 5 ++++- application/views/station_profile/create.php | 8 ++++---- application/views/station_profile/edit.php | 8 ++++---- 17 files changed, 68 insertions(+), 23 deletions(-) diff --git a/application/language/bulgarian/station_lang.php b/application/language/bulgarian/station_lang.php index 172d9af23..e83e8c469 100644 --- a/application/language/bulgarian/station_lang.php +++ b/application/language/bulgarian/station_lang.php @@ -99,8 +99,11 @@ $lang['station_location_eqsl_defaultqslmsg_hint'] = "Define a default message th $lang['station_location_qrz_subscription'] = 'Subscription Required'; $lang['station_location_qrz_hint'] = "Find your API key on the QRZ.com Logbook settings page"; $lang['station_location_qrz_realtime_upload'] = 'QRZ.com Logbook Realtime Upload'; +$lang['station_location_hrdlog_username'] = "HRDLog.net Username"; +$lang['station_location_hrdlog_username_hint'] = "The username you are registered with at HRDlog.net (usually your callsign)."; +$lang['station_location_hrdlog_code'] = "HRDLog.net API Key"; $lang['station_location_hrdlog_realtime_upload'] = "HRDLog.net Logbook Realtime Upload"; -$lang['station_location_hrdlog_hint'] = "Create your API Code on HRDLog.net Userprofile page"; +$lang['station_location_hrdlog_code_hint'] = "Create your API Code on HRDLog.net Userprofile page"; $lang['station_location_qo100_hint'] = "Create your API key on your QO-100 Dx Club's profile page"; $lang['station_location_qo100_realtime_upload'] = "QO-100 Dx Club Realtime Upload"; $lang['station_location_oqrs_enabled'] = "OQRS Enabled"; diff --git a/application/language/chinese_simplified/station_lang.php b/application/language/chinese_simplified/station_lang.php index 172d9af23..e83e8c469 100644 --- a/application/language/chinese_simplified/station_lang.php +++ b/application/language/chinese_simplified/station_lang.php @@ -99,8 +99,11 @@ $lang['station_location_eqsl_defaultqslmsg_hint'] = "Define a default message th $lang['station_location_qrz_subscription'] = 'Subscription Required'; $lang['station_location_qrz_hint'] = "Find your API key on the QRZ.com Logbook settings page"; $lang['station_location_qrz_realtime_upload'] = 'QRZ.com Logbook Realtime Upload'; +$lang['station_location_hrdlog_username'] = "HRDLog.net Username"; +$lang['station_location_hrdlog_username_hint'] = "The username you are registered with at HRDlog.net (usually your callsign)."; +$lang['station_location_hrdlog_code'] = "HRDLog.net API Key"; $lang['station_location_hrdlog_realtime_upload'] = "HRDLog.net Logbook Realtime Upload"; -$lang['station_location_hrdlog_hint'] = "Create your API Code on HRDLog.net Userprofile page"; +$lang['station_location_hrdlog_code_hint'] = "Create your API Code on HRDLog.net Userprofile page"; $lang['station_location_qo100_hint'] = "Create your API key on your QO-100 Dx Club's profile page"; $lang['station_location_qo100_realtime_upload'] = "QO-100 Dx Club Realtime Upload"; $lang['station_location_oqrs_enabled'] = "OQRS Enabled"; diff --git a/application/language/czech/station_lang.php b/application/language/czech/station_lang.php index 172d9af23..e83e8c469 100644 --- a/application/language/czech/station_lang.php +++ b/application/language/czech/station_lang.php @@ -99,8 +99,11 @@ $lang['station_location_eqsl_defaultqslmsg_hint'] = "Define a default message th $lang['station_location_qrz_subscription'] = 'Subscription Required'; $lang['station_location_qrz_hint'] = "Find your API key on the QRZ.com Logbook settings page"; $lang['station_location_qrz_realtime_upload'] = 'QRZ.com Logbook Realtime Upload'; +$lang['station_location_hrdlog_username'] = "HRDLog.net Username"; +$lang['station_location_hrdlog_username_hint'] = "The username you are registered with at HRDlog.net (usually your callsign)."; +$lang['station_location_hrdlog_code'] = "HRDLog.net API Key"; $lang['station_location_hrdlog_realtime_upload'] = "HRDLog.net Logbook Realtime Upload"; -$lang['station_location_hrdlog_hint'] = "Create your API Code on HRDLog.net Userprofile page"; +$lang['station_location_hrdlog_code_hint'] = "Create your API Code on HRDLog.net Userprofile page"; $lang['station_location_qo100_hint'] = "Create your API key on your QO-100 Dx Club's profile page"; $lang['station_location_qo100_realtime_upload'] = "QO-100 Dx Club Realtime Upload"; $lang['station_location_oqrs_enabled'] = "OQRS Enabled"; diff --git a/application/language/dutch/station_lang.php b/application/language/dutch/station_lang.php index 172d9af23..e83e8c469 100644 --- a/application/language/dutch/station_lang.php +++ b/application/language/dutch/station_lang.php @@ -99,8 +99,11 @@ $lang['station_location_eqsl_defaultqslmsg_hint'] = "Define a default message th $lang['station_location_qrz_subscription'] = 'Subscription Required'; $lang['station_location_qrz_hint'] = "Find your API key on the QRZ.com Logbook settings page"; $lang['station_location_qrz_realtime_upload'] = 'QRZ.com Logbook Realtime Upload'; +$lang['station_location_hrdlog_username'] = "HRDLog.net Username"; +$lang['station_location_hrdlog_username_hint'] = "The username you are registered with at HRDlog.net (usually your callsign)."; +$lang['station_location_hrdlog_code'] = "HRDLog.net API Key"; $lang['station_location_hrdlog_realtime_upload'] = "HRDLog.net Logbook Realtime Upload"; -$lang['station_location_hrdlog_hint'] = "Create your API Code on HRDLog.net Userprofile page"; +$lang['station_location_hrdlog_code_hint'] = "Create your API Code on HRDLog.net Userprofile page"; $lang['station_location_qo100_hint'] = "Create your API key on your QO-100 Dx Club's profile page"; $lang['station_location_qo100_realtime_upload'] = "QO-100 Dx Club Realtime Upload"; $lang['station_location_oqrs_enabled'] = "OQRS Enabled"; diff --git a/application/language/english/station_lang.php b/application/language/english/station_lang.php index d3206d8aa..51a487c78 100644 --- a/application/language/english/station_lang.php +++ b/application/language/english/station_lang.php @@ -99,8 +99,11 @@ $lang['station_location_eqsl_defaultqslmsg_hint'] = "Define a default message th $lang['station_location_qrz_subscription'] = 'Subscription Required'; $lang['station_location_qrz_hint'] = "Find your API key on the QRZ.com Logbook settings page"; $lang['station_location_qrz_realtime_upload'] = 'QRZ.com Logbook Realtime Upload'; +$lang['station_location_hrdlog_username'] = "HRDLog.net Username"; +$lang['station_location_hrdlog_username_hint'] = "The username you are registered with at HRDlog.net (usually your callsign)."; +$lang['station_location_hrdlog_code'] = "HRDLog.net API Key"; $lang['station_location_hrdlog_realtime_upload'] = "HRDLog.net Logbook Realtime Upload"; -$lang['station_location_hrdlog_hint'] = "Create your API Code on HRDLog.net Userprofile page"; +$lang['station_location_hrdlog_code_hint'] = "Create your API Code on HRDLog.net Userprofile page"; $lang['station_location_qo100_hint'] = "Create your API key on your QO-100 Dx Club's profile page"; $lang['station_location_qo100_realtime_upload'] = "QO-100 Dx Club Realtime Upload"; $lang['station_location_oqrs_enabled'] = "OQRS Enabled"; diff --git a/application/language/finnish/station_lang.php b/application/language/finnish/station_lang.php index 172d9af23..e83e8c469 100644 --- a/application/language/finnish/station_lang.php +++ b/application/language/finnish/station_lang.php @@ -99,8 +99,11 @@ $lang['station_location_eqsl_defaultqslmsg_hint'] = "Define a default message th $lang['station_location_qrz_subscription'] = 'Subscription Required'; $lang['station_location_qrz_hint'] = "Find your API key on the QRZ.com Logbook settings page"; $lang['station_location_qrz_realtime_upload'] = 'QRZ.com Logbook Realtime Upload'; +$lang['station_location_hrdlog_username'] = "HRDLog.net Username"; +$lang['station_location_hrdlog_username_hint'] = "The username you are registered with at HRDlog.net (usually your callsign)."; +$lang['station_location_hrdlog_code'] = "HRDLog.net API Key"; $lang['station_location_hrdlog_realtime_upload'] = "HRDLog.net Logbook Realtime Upload"; -$lang['station_location_hrdlog_hint'] = "Create your API Code on HRDLog.net Userprofile page"; +$lang['station_location_hrdlog_code_hint'] = "Create your API Code on HRDLog.net Userprofile page"; $lang['station_location_qo100_hint'] = "Create your API key on your QO-100 Dx Club's profile page"; $lang['station_location_qo100_realtime_upload'] = "QO-100 Dx Club Realtime Upload"; $lang['station_location_oqrs_enabled'] = "OQRS Enabled"; diff --git a/application/language/french/station_lang.php b/application/language/french/station_lang.php index da43bc0d7..eedb61fcc 100644 --- a/application/language/french/station_lang.php +++ b/application/language/french/station_lang.php @@ -99,8 +99,11 @@ $lang['station_location_eqsl_defaultqslmsg_hint'] = "Vous pouvez définir un mes $lang['station_location_qrz_subscription'] = 'Subscription Required'; $lang['station_location_qrz_hint'] = "Find your API key on the QRZ.com Logbook settings page"; $lang['station_location_qrz_realtime_upload'] = 'QRZ.com Logbook Realtime Upload'; +$lang['station_location_hrdlog_username'] = "HRDLog.net Username"; +$lang['station_location_hrdlog_username_hint'] = "The username you are registered with at HRDlog.net (usually your callsign)."; +$lang['station_location_hrdlog_code'] = "HRDLog.net API Key"; $lang['station_location_hrdlog_realtime_upload'] = "HRDLog.net Logbook Realtime Upload"; -$lang['station_location_hrdlog_hint'] = "Create your API Code on HRDLog.net Userprofile page"; +$lang['station_location_hrdlog_code_hint'] = "Create your API Code on HRDLog.net Userprofile page"; $lang['station_location_qo100_hint'] = "Create your API key on your QO-100 Dx Club's profile page"; $lang['station_location_qo100_realtime_upload'] = "QO-100 Dx Club Realtime Upload"; $lang['station_location_oqrs_enabled'] = "OQRS Enabled"; diff --git a/application/language/german/station_lang.php b/application/language/german/station_lang.php index 597c95bf4..6133bdfa2 100644 --- a/application/language/german/station_lang.php +++ b/application/language/german/station_lang.php @@ -99,8 +99,11 @@ $lang['station_location_eqsl_defaultqslmsg_hint'] = "Definiere eine Standard-Nac $lang['station_location_qrz_subscription'] = 'Abonnement erforderlich'; $lang['station_location_qrz_hint'] = "Finde deinen 'QRZ Logbook API Key' in den QRZ.com Logbuch Einstellungen"; $lang['station_location_qrz_realtime_upload'] = 'QRZ.com Logbuch Echtzeit Upload'; +$lang['station_location_hrdlog_username'] = "HRDLog.net Benutzername"; +$lang['station_location_hrdlog_username_hint'] = "Der Benutzername mit dem du bei HRDlog.net registriert bist (normalerweise dein Rufzeichen)."; +$lang['station_location_hrdlog_code'] = "HRDLog.net API Key"; $lang['station_location_hrdlog_realtime_upload'] = "HRDLog.net Logbuch Echtzeit Upload"; -$lang['station_location_hrdlog_hint'] = "Erstelle deinen API Key auf HRDLog.net Benutzerprofil Seite"; +$lang['station_location_hrdlog_code_hint'] = "Erstelle deinen API Key auf HRDLog.net Benutzerprofil Seite"; $lang['station_location_qo100_hint'] = "Erstelle deinen API Key auf deiner QO-100 Dx Club's Profil Seite"; $lang['station_location_qo100_realtime_upload'] = "QO-100 Dx Club Echtzeit Upload"; $lang['station_location_oqrs_enabled'] = "OQRS aktivieren"; diff --git a/application/language/greek/station_lang.php b/application/language/greek/station_lang.php index 172d9af23..e83e8c469 100644 --- a/application/language/greek/station_lang.php +++ b/application/language/greek/station_lang.php @@ -99,8 +99,11 @@ $lang['station_location_eqsl_defaultqslmsg_hint'] = "Define a default message th $lang['station_location_qrz_subscription'] = 'Subscription Required'; $lang['station_location_qrz_hint'] = "Find your API key on the QRZ.com Logbook settings page"; $lang['station_location_qrz_realtime_upload'] = 'QRZ.com Logbook Realtime Upload'; +$lang['station_location_hrdlog_username'] = "HRDLog.net Username"; +$lang['station_location_hrdlog_username_hint'] = "The username you are registered with at HRDlog.net (usually your callsign)."; +$lang['station_location_hrdlog_code'] = "HRDLog.net API Key"; $lang['station_location_hrdlog_realtime_upload'] = "HRDLog.net Logbook Realtime Upload"; -$lang['station_location_hrdlog_hint'] = "Create your API Code on HRDLog.net Userprofile page"; +$lang['station_location_hrdlog_code_hint'] = "Create your API Code on HRDLog.net Userprofile page"; $lang['station_location_qo100_hint'] = "Create your API key on your QO-100 Dx Club's profile page"; $lang['station_location_qo100_realtime_upload'] = "QO-100 Dx Club Realtime Upload"; $lang['station_location_oqrs_enabled'] = "OQRS Enabled"; diff --git a/application/language/italian/station_lang.php b/application/language/italian/station_lang.php index 172d9af23..e83e8c469 100644 --- a/application/language/italian/station_lang.php +++ b/application/language/italian/station_lang.php @@ -99,8 +99,11 @@ $lang['station_location_eqsl_defaultqslmsg_hint'] = "Define a default message th $lang['station_location_qrz_subscription'] = 'Subscription Required'; $lang['station_location_qrz_hint'] = "Find your API key on the QRZ.com Logbook settings page"; $lang['station_location_qrz_realtime_upload'] = 'QRZ.com Logbook Realtime Upload'; +$lang['station_location_hrdlog_username'] = "HRDLog.net Username"; +$lang['station_location_hrdlog_username_hint'] = "The username you are registered with at HRDlog.net (usually your callsign)."; +$lang['station_location_hrdlog_code'] = "HRDLog.net API Key"; $lang['station_location_hrdlog_realtime_upload'] = "HRDLog.net Logbook Realtime Upload"; -$lang['station_location_hrdlog_hint'] = "Create your API Code on HRDLog.net Userprofile page"; +$lang['station_location_hrdlog_code_hint'] = "Create your API Code on HRDLog.net Userprofile page"; $lang['station_location_qo100_hint'] = "Create your API key on your QO-100 Dx Club's profile page"; $lang['station_location_qo100_realtime_upload'] = "QO-100 Dx Club Realtime Upload"; $lang['station_location_oqrs_enabled'] = "OQRS Enabled"; diff --git a/application/language/polish/station_lang.php b/application/language/polish/station_lang.php index 172d9af23..e83e8c469 100644 --- a/application/language/polish/station_lang.php +++ b/application/language/polish/station_lang.php @@ -99,8 +99,11 @@ $lang['station_location_eqsl_defaultqslmsg_hint'] = "Define a default message th $lang['station_location_qrz_subscription'] = 'Subscription Required'; $lang['station_location_qrz_hint'] = "Find your API key on the QRZ.com Logbook settings page"; $lang['station_location_qrz_realtime_upload'] = 'QRZ.com Logbook Realtime Upload'; +$lang['station_location_hrdlog_username'] = "HRDLog.net Username"; +$lang['station_location_hrdlog_username_hint'] = "The username you are registered with at HRDlog.net (usually your callsign)."; +$lang['station_location_hrdlog_code'] = "HRDLog.net API Key"; $lang['station_location_hrdlog_realtime_upload'] = "HRDLog.net Logbook Realtime Upload"; -$lang['station_location_hrdlog_hint'] = "Create your API Code on HRDLog.net Userprofile page"; +$lang['station_location_hrdlog_code_hint'] = "Create your API Code on HRDLog.net Userprofile page"; $lang['station_location_qo100_hint'] = "Create your API key on your QO-100 Dx Club's profile page"; $lang['station_location_qo100_realtime_upload'] = "QO-100 Dx Club Realtime Upload"; $lang['station_location_oqrs_enabled'] = "OQRS Enabled"; diff --git a/application/language/russian/station_lang.php b/application/language/russian/station_lang.php index 6726851ef..92b5cbd74 100644 --- a/application/language/russian/station_lang.php +++ b/application/language/russian/station_lang.php @@ -99,8 +99,11 @@ $lang['station_location_eqsl_defaultqslmsg_hint'] = "Define a default message th $lang['station_location_qrz_subscription'] = 'Требуется подписка'; $lang['station_location_qrz_hint'] = "Ваш ключ API находится на странице настроек журнала QRZ.com"; $lang['station_location_qrz_realtime_upload'] = 'Загрузка в журнал QRZ.com в реальном времени'; +$lang['station_location_hrdlog_username'] = "HRDLog.net Username"; +$lang['station_location_hrdlog_username_hint'] = "The username you are registered with at HRDlog.net (usually your callsign)."; +$lang['station_location_hrdlog_code'] = "HRDLog.net API Key"; $lang['station_location_hrdlog_realtime_upload'] = "Загрузка в журнал HRDLog.net в реальном времени"; -$lang['station_location_hrdlog_hint'] = "Создайте свой код к API наn странице профиля пользователя HRDLog.net"; +$lang['station_location_hrdlog_code_hint'] = "Создайте свой код к API наn странице профиля пользователя HRDLog.net"; $lang['station_location_qo100_hint'] = "Создайте свой ключ API на странице вашего профиля в QO-100 Dx Club"; $lang['station_location_qo100_realtime_upload'] = "Загрузка QO-100 Dx Club в реальном времени"; $lang['station_location_oqrs_enabled'] = "OQRS включен"; diff --git a/application/language/spanish/station_lang.php b/application/language/spanish/station_lang.php index 172d9af23..e83e8c469 100644 --- a/application/language/spanish/station_lang.php +++ b/application/language/spanish/station_lang.php @@ -99,8 +99,11 @@ $lang['station_location_eqsl_defaultqslmsg_hint'] = "Define a default message th $lang['station_location_qrz_subscription'] = 'Subscription Required'; $lang['station_location_qrz_hint'] = "Find your API key on the QRZ.com Logbook settings page"; $lang['station_location_qrz_realtime_upload'] = 'QRZ.com Logbook Realtime Upload'; +$lang['station_location_hrdlog_username'] = "HRDLog.net Username"; +$lang['station_location_hrdlog_username_hint'] = "The username you are registered with at HRDlog.net (usually your callsign)."; +$lang['station_location_hrdlog_code'] = "HRDLog.net API Key"; $lang['station_location_hrdlog_realtime_upload'] = "HRDLog.net Logbook Realtime Upload"; -$lang['station_location_hrdlog_hint'] = "Create your API Code on HRDLog.net Userprofile page"; +$lang['station_location_hrdlog_code_hint'] = "Create your API Code on HRDLog.net Userprofile page"; $lang['station_location_qo100_hint'] = "Create your API key on your QO-100 Dx Club's profile page"; $lang['station_location_qo100_realtime_upload'] = "QO-100 Dx Club Realtime Upload"; $lang['station_location_oqrs_enabled'] = "OQRS Enabled"; diff --git a/application/language/swedish/station_lang.php b/application/language/swedish/station_lang.php index 172d9af23..e83e8c469 100644 --- a/application/language/swedish/station_lang.php +++ b/application/language/swedish/station_lang.php @@ -99,8 +99,11 @@ $lang['station_location_eqsl_defaultqslmsg_hint'] = "Define a default message th $lang['station_location_qrz_subscription'] = 'Subscription Required'; $lang['station_location_qrz_hint'] = "Find your API key on the QRZ.com Logbook settings page"; $lang['station_location_qrz_realtime_upload'] = 'QRZ.com Logbook Realtime Upload'; +$lang['station_location_hrdlog_username'] = "HRDLog.net Username"; +$lang['station_location_hrdlog_username_hint'] = "The username you are registered with at HRDlog.net (usually your callsign)."; +$lang['station_location_hrdlog_code'] = "HRDLog.net API Key"; $lang['station_location_hrdlog_realtime_upload'] = "HRDLog.net Logbook Realtime Upload"; -$lang['station_location_hrdlog_hint'] = "Create your API Code on HRDLog.net Userprofile page"; +$lang['station_location_hrdlog_code_hint'] = "Create your API Code on HRDLog.net Userprofile page"; $lang['station_location_qo100_hint'] = "Create your API key on your QO-100 Dx Club's profile page"; $lang['station_location_qo100_realtime_upload'] = "QO-100 Dx Club Realtime Upload"; $lang['station_location_oqrs_enabled'] = "OQRS Enabled"; diff --git a/application/language/turkish/station_lang.php b/application/language/turkish/station_lang.php index 172d9af23..e83e8c469 100644 --- a/application/language/turkish/station_lang.php +++ b/application/language/turkish/station_lang.php @@ -99,8 +99,11 @@ $lang['station_location_eqsl_defaultqslmsg_hint'] = "Define a default message th $lang['station_location_qrz_subscription'] = 'Subscription Required'; $lang['station_location_qrz_hint'] = "Find your API key on the QRZ.com Logbook settings page"; $lang['station_location_qrz_realtime_upload'] = 'QRZ.com Logbook Realtime Upload'; +$lang['station_location_hrdlog_username'] = "HRDLog.net Username"; +$lang['station_location_hrdlog_username_hint'] = "The username you are registered with at HRDlog.net (usually your callsign)."; +$lang['station_location_hrdlog_code'] = "HRDLog.net API Key"; $lang['station_location_hrdlog_realtime_upload'] = "HRDLog.net Logbook Realtime Upload"; -$lang['station_location_hrdlog_hint'] = "Create your API Code on HRDLog.net Userprofile page"; +$lang['station_location_hrdlog_code_hint'] = "Create your API Code on HRDLog.net Userprofile page"; $lang['station_location_qo100_hint'] = "Create your API key on your QO-100 Dx Club's profile page"; $lang['station_location_qo100_realtime_upload'] = "QO-100 Dx Club Realtime Upload"; $lang['station_location_oqrs_enabled'] = "OQRS Enabled"; diff --git a/application/views/station_profile/create.php b/application/views/station_profile/create.php index 34ae4f439..8cdcaca07 100644 --- a/application/views/station_profile/create.php +++ b/application/views/station_profile/create.php @@ -266,14 +266,14 @@
- + - +
diff --git a/application/views/station_profile/edit.php b/application/views/station_profile/edit.php index 00182cbaa..b3a7ce254 100644 --- a/application/views/station_profile/edit.php +++ b/application/views/station_profile/edit.php @@ -407,14 +407,14 @@
HRDLog.net
- + hrdlog_username; } ?>"> - Your HRDlog Username +
- + hrdlog_code; } ?>"> - +
From 1fd5b75076a12afe9daab36617e4699831f7d62b Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Sat, 16 Dec 2023 07:48:19 +0100 Subject: [PATCH 3/9] add check if username is not empty --- application/models/Stations.php | 64 ++++++++++++++++----------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/application/models/Stations.php b/application/models/Stations.php index a3e71ac4e..28bcb691b 100644 --- a/application/models/Stations.php +++ b/application/models/Stations.php @@ -365,58 +365,58 @@ class Stations extends CI_Model { } function stations_with_hrdlog_code() { - $sql = "select station_profile.station_id, station_profile.station_profile_name, station_profile.station_callsign, modc.modcount, notc.notcount, totc.totcount - from station_profile - left outer join ( - select count(*) modcount, station_id - from ". $this->config->item('table_name') . - " where COL_HRDLOG_QSO_UPLOAD_STATUS = 'M' + $sql = "SELECT station_profile.station_id, station_profile.station_profile_name, station_profile.station_callsign, modc.modcount, notc.notcount, totc.totcount + FROM station_profile + LEFT OUTER JOIN ( + SELECT count(*) modcount, station_id + FROM ". $this->config->item('table_name') . + " WHERE COL_HRDLOG_QSO_UPLOAD_STATUS = 'M' group by station_id ) as modc on station_profile.station_id = modc.station_id - left outer join ( - select count(*) notcount, station_id - from " . $this->config->item('table_name') . - " where (coalesce(COL_HRDLOG_QSO_UPLOAD_STATUS, '') = '' + LEFT OUTER JOIN ( + SELECT count(*) notcount, station_id + FROM " . $this->config->item('table_name') . + " WHERE (coalesce(COL_HRDLOG_QSO_UPLOAD_STATUS, '') = '' or COL_HRDLOG_QSO_UPLOAD_STATUS = 'N') group by station_id ) as notc on station_profile.station_id = notc.station_id - left outer join ( - select count(*) totcount, station_id - from " . $this->config->item('table_name') . - " where COL_HRDLOG_QSO_UPLOAD_STATUS = 'Y' + LEFT OUTER JOIN ( + SELECT count(*) totcount, station_id + FROM " . $this->config->item('table_name') . + " WHERE COL_HRDLOG_QSO_UPLOAD_STATUS = 'Y' group by station_id ) as totc on station_profile.station_id = totc.station_id - where coalesce(station_profile.hrdlog_code, '') <> '' - and station_profile.user_id = " . $this->session->userdata('user_id'); + WHERE coalesce(station_profile.hrdlog_code, '') <> '' AND coalesce(station_profile.hrdlog_username, '') <> '' + AND station_profile.user_id = " . $this->session->userdata('user_id'); $query = $this->db->query($sql); return $query; } function stations_with_qrz_api_key() { - $sql = "select station_profile.station_id, station_profile.station_profile_name, station_profile.station_callsign, modc.modcount, notc.notcount, totc.totcount - from station_profile - left outer join ( - select count(*) modcount, station_id - from ". $this->config->item('table_name') . - " where COL_QRZCOM_QSO_UPLOAD_STATUS = 'M' + $sql = "SELECT station_profile.station_id, station_profile.station_profile_name, station_profile.station_callsign, modc.modcount, notc.notcount, totc.totcount + FROM station_profile + LEFT OUTER JOIN ( + SELECT count(*) modcount, station_id + FROM ". $this->config->item('table_name') . + " WHERE COL_QRZCOM_QSO_UPLOAD_STATUS = 'M' group by station_id ) as modc on station_profile.station_id = modc.station_id - left outer join ( - select count(*) notcount, station_id - from " . $this->config->item('table_name') . - " where (coalesce(COL_QRZCOM_QSO_UPLOAD_STATUS, '') = '' + LEFT OUTER JOIN ( + SELECT count(*) notcount, station_id + FROM " . $this->config->item('table_name') . + " WHERE (coalesce(COL_QRZCOM_QSO_UPLOAD_STATUS, '') = '' or COL_QRZCOM_QSO_UPLOAD_STATUS = 'N') group by station_id ) as notc on station_profile.station_id = notc.station_id - left outer join ( - select count(*) totcount, station_id - from " . $this->config->item('table_name') . - " where COL_QRZCOM_QSO_UPLOAD_STATUS = 'Y' + LEFT OUTER JOIN ( + SELECT count(*) totcount, station_id + FROM " . $this->config->item('table_name') . + " WHERE COL_QRZCOM_QSO_UPLOAD_STATUS = 'Y' group by station_id ) as totc on station_profile.station_id = totc.station_id - where coalesce(station_profile.qrzapikey, '') <> '' - and station_profile.user_id = " . $this->session->userdata('user_id'); + WHERE coalesce(station_profile.qrzapikey, '') <> '' + AND station_profile.user_id = " . $this->session->userdata('user_id'); $query = $this->db->query($sql); return $query; From ac17102d53cd051b4dbbc120b1ab37b112df1455 Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Sat, 16 Dec 2023 07:56:02 +0100 Subject: [PATCH 4/9] changed warning text --- application/views/hrdlog/export.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/views/hrdlog/export.php b/application/views/hrdlog/export.php index d8e9b4a19..18b08c559 100644 --- a/application/views/hrdlog/export.php +++ b/application/views/hrdlog/export.php @@ -53,7 +53,7 @@ } else { - echo ''; + echo ''; } ?> From ee989de98829ad458aceff7d1ec7371c59f108b3 Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Sat, 16 Dec 2023 09:37:45 +0100 Subject: [PATCH 5/9] added logic to auto-populate the hrd_username from station_callsign --- .../migrations/162_hrdlog_username.php | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/application/migrations/162_hrdlog_username.php b/application/migrations/162_hrdlog_username.php index bdfab65ca..51b71d13b 100644 --- a/application/migrations/162_hrdlog_username.php +++ b/application/migrations/162_hrdlog_username.php @@ -1,14 +1,14 @@ db->field_exists('hrdlog_username', 'station_profile')) { @@ -17,6 +17,23 @@ class Migration_hrdlog_username extends CI_Migration { ); $this->dbforge->add_column('station_profile', $fields); } + + // SELECT all rows where hrdlog_code is not empty + $this->db->where("(hrdlog_code IS NOT NULL AND hrdlog_code != '')"); + $query = $this->db->get('station_profile'); + $rows = $query->result(); + + // Iterate through all selected rows + foreach ($rows as $row) { + // Extract the username using the regex pattern + $regex = '/^((\d|[A-Z])+\/)?((\d|[A-Z]){3,})(\/(\d|[A-Z])+)?(\/(\d|[A-Z])+)?$/'; + preg_match($regex, $row->station_callsign, $matches); + $username = $matches[3]; + + // Update the row with the extracted username + $this->db->where('station_id', $row->station_id); + $this->db->update('station_profile', array('hrdlog_username' => $username)); + } } public function down() @@ -25,4 +42,4 @@ class Migration_hrdlog_username extends CI_Migration { $this->dbforge->drop_column('station_profile', 'hrdlog_username'); } } -} \ No newline at end of file +} From e71f782a835f200d4a89eb25aff72269821cafe1 Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Sat, 16 Dec 2023 11:42:56 +0100 Subject: [PATCH 6/9] fixed success and error messages --- application/controllers/Hrdlog.php | 58 +++++++++++++++-------------- application/controllers/Qrz.php | 4 +- application/views/adif/import.php | 2 +- application/views/hrdlog/export.php | 2 +- application/views/qrz/export.php | 2 +- assets/js/sections/hrdlog.js | 29 ++++++++------- assets/js/sections/qrzlogbook.js | 28 +++++++------- assets/js/sections/webadif.js | 26 +++++++------ 8 files changed, 81 insertions(+), 70 deletions(-) diff --git a/application/controllers/Hrdlog.php b/application/controllers/Hrdlog.php index 78e449adf..5bbbfdc4d 100644 --- a/application/controllers/Hrdlog.php +++ b/application/controllers/Hrdlog.php @@ -1,4 +1,4 @@ -hrdlog_username; $hrdlog_code = $station->hrdlog_code; - if($this->mass_upload_qsos($station->station_id, $hrdlog_username, $hrdlog_code)) { + if ($this->mass_upload_qsos($station->station_id, $hrdlog_username, $hrdlog_code)) { echo "QSOs have been uploaded to hrdlog.net."; log_message('info', 'QSOs have been uploaded to hrdlog.net.'); - } else{ + } else { echo "No QSOs found for upload."; log_message('info', 'No QSOs found for upload.'); } @@ -52,9 +52,9 @@ class Hrdlog extends CI_Controller { function mass_upload_qsos($station_id, $hrdlog_username, $hrdlog_code) { $i = 0; $data['qsos'] = $this->logbook_model->get_hrdlog_qsos($station_id); - $errormessages=array(); + $errormessages = array(); - $CI =& get_instance(); + $CI = &get_instance(); $CI->load->library('AdifHelper'); if ($data['qsos']) { @@ -67,25 +67,27 @@ class Hrdlog extends CI_Controller { $result = $this->logbook_model->push_qso_to_hrdlog($hrdlog_username, $hrdlog_code, $adif); } - if ( ($result['status'] == 'OK') || ( ($result['status'] == 'error') || ($result['status'] == 'duplicate')) ){ + if (($result['status'] == 'OK') || (($result['status'] == 'error') || ($result['status'] == 'duplicate'))) { $this->markqso($qso->COL_PRIMARY_KEY); $i++; - } elseif ((substr($result['status'],0,11) == 'auth_error')) { + $result['status'] = 'OK'; + } elseif ((substr($result['status'], 0, 11) == 'auth_error')) { log_message('error', 'hrdlog upload failed for qso: Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON); - log_message('error', 'hrdlog upload failed with the following message: ' .$result['message']); - log_message('error', 'hrdlog upload stopped for Station_ID: ' .$station_id); + log_message('error', 'hrdlog upload failed with the following message: ' . $result['message']); + log_message('error', 'hrdlog upload stopped for Station_ID: ' . $station_id); $errormessages[] = $result['message'] . 'Invalid HRDLog-Code, stopped at Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON; - break; /* If key is invalid, immediate stop syncing for more QSOs of this station */ + $result['status'] = 'Error'; + break; /* If key is invalid, immediate stop syncing for more QSOs of this station */ } else { log_message('error', 'hrdlog upload failed for qso: Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON); - log_message('error', 'hrdlog upload failed with the following message: ' .$result['message']); + log_message('error', 'hrdlog upload failed with the following message: ' . $result['message']); + $result['status'] = 'Error'; $errormessages[] = $result['message'] . ' Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON; } } - $result['status'] = 'OK'; $result['count'] = $i; $result['errormessages'] = $errormessages; - return $result; + return $result; } else { $result['status'] = 'Error'; $result['count'] = $i; @@ -109,7 +111,7 @@ class Hrdlog extends CI_Controller { $data['page_title'] = "HRDlog.net Logbook"; - $data['station_profiles'] = $this->stations->all_of_user(); + $data['station_profiles'] = $this->stations->all_of_user(); $data['station_profile'] = $this->stations->stations_with_hrdlog_code(); $this->load->view('interface_assets/header', $data); @@ -149,25 +151,25 @@ class Hrdlog extends CI_Controller { } } - public function mark_hrdlog() { - // Set memory limit to unlimited to allow heavy usage - ini_set('memory_limit', '-1'); + public function mark_hrdlog() { + // Set memory limit to unlimited to allow heavy usage + ini_set('memory_limit', '-1'); - $station_id = $this->security->xss_clean($this->input->post('station_profile')); + $station_id = $this->security->xss_clean($this->input->post('station_profile')); - $this->load->model('adif_data'); + $this->load->model('adif_data'); - $data['qsos'] = $this->adif_data->export_custom($this->input->post('from'), $this->input->post('to'), $station_id); + $data['qsos'] = $this->adif_data->export_custom($this->input->post('from'), $this->input->post('to'), $station_id); - $this->load->model('logbook_model'); + $this->load->model('logbook_model'); - foreach ($data['qsos']->result() as $qso) + foreach ($data['qsos']->result() as $qso) { - $this->logbook_model->mark_hrdlog_qsos_sent($qso->COL_PRIMARY_KEY); - } + $this->logbook_model->mark_hrdlog_qsos_sent($qso->COL_PRIMARY_KEY); + } - $this->load->view('interface_assets/header', $data); - $this->load->view('hrdlog/mark_hrdlog', $data); - $this->load->view('interface_assets/footer'); - } + $this->load->view('interface_assets/header', $data); + $this->load->view('hrdlog/mark_hrdlog', $data); + $this->load->view('interface_assets/footer'); + } } diff --git a/application/controllers/Qrz.php b/application/controllers/Qrz.php index 89647626d..efc8449ed 100644 --- a/application/controllers/Qrz.php +++ b/application/controllers/Qrz.php @@ -74,19 +74,21 @@ class Qrz extends CI_Controller { if ( ($result['status'] == 'OK') || ( ($result['status'] == 'error') && ($result['message'] == 'STATUS=FAIL&REASON=Unable to add QSO to database: duplicate&EXTENDED=')) ){ $this->markqso($qso->COL_PRIMARY_KEY); $i++; + $result['status'] = 'OK'; } elseif ( ($result['status']=='error') && (substr($result['message'],0,11) == 'STATUS=AUTH')) { log_message('error', 'QRZ upload failed for qso: Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON); log_message('error', 'QRZ upload failed with the following message: ' .$result['message']); log_message('error', 'QRZ upload stopped for Station_ID: ' .$station_id); $errormessages[] = $result['message'] . ' Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON; + $result['status'] = 'Error'; break; /* If key is invalid, immediate stop syncing for more QSOs of this station */ } else { log_message('error', 'QRZ upload failed for qso: Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON); log_message('error', 'QRZ upload failed with the following message: ' .$result['message']); $errormessages[] = $result['message'] . ' Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON; + $result['status'] = 'Error'; } } - $result['status'] = 'OK'; $result['count'] = $i; $result['errormessages'] = $errormessages; return $result; diff --git a/application/views/adif/import.php b/application/views/adif/import.php index 9375649b5..2de271658 100644 --- a/application/views/adif/import.php +++ b/application/views/adif/import.php @@ -1,4 +1,4 @@ -
+

+

diff --git a/application/views/qrz/export.php b/application/views/qrz/export.php index 6d64af5b7..4c65be05c 100644 --- a/application/views/qrz/export.php +++ b/application/views/qrz/export.php @@ -1,5 +1,5 @@ -
+

diff --git a/assets/js/sections/hrdlog.js b/assets/js/sections/hrdlog.js index 9b3ce0e39..671536854 100644 --- a/assets/js/sections/hrdlog.js +++ b/assets/js/sections/hrdlog.js @@ -21,27 +21,30 @@ function ExportHrd(station_id) { $('#notcount'+value.station_id).html(value.notcount); $('#totcount'+value.station_id).html(value.totcount); }); - $(".card-body").append(''); + $(".card-body").append(''); } else { - $(".card-body").append(''); + $(".card-body").append(''); } if (data.errormessages.length > 0) { - $(".card-body").append('' + - '

\n' + - ' \n' + - '

\n' + - '
\n' + - '
\n' + - '
\n' + - '
'); - $.each(data.errormessages, function(index, value) { + $("#hrdlog_export").append( + '
\n' + + '
\n' + + '
\n' + + ' Error Message\n' + + '
\n' + + '
\n' + + '
\n' + + '
\n' + + '
\n' + + '
' + ); + $.each(data.errormessages, function (index, value) { $(".errors").append('
  • ' + value); }); } + } }); } diff --git a/assets/js/sections/qrzlogbook.js b/assets/js/sections/qrzlogbook.js index 84cb92686..c7563046d 100644 --- a/assets/js/sections/qrzlogbook.js +++ b/assets/js/sections/qrzlogbook.js @@ -21,24 +21,26 @@ function ExportQrz(station_id) { $('#notcount'+value.station_id).html(value.notcount); $('#totcount'+value.station_id).html(value.totcount); }); - $(".card-body").append(''); + $(".card-body").append(''); } else { - $(".card-body").append(''); + $(".card-body").append(''); } if (data.errormessages.length > 0) { - $(".card-body").append('' + - '

    \n' + - ' \n' + - '

    \n' + - '
    \n' + - '
    \n' + - '
    \n' + - '
    '); - $.each(data.errormessages, function(index, value) { + $("#qrz_export").append( + '
    \n' + + '
    \n' + + '
    \n' + + ' Error Message\n' + + '
    \n' + + '
    \n' + + '
    \n' + + '
    \n' + + '
    \n' + + '
    ' + ); + $.each(data.errormessages, function (index, value) { $(".errors").append('
  • ' + value); }); } diff --git a/assets/js/sections/webadif.js b/assets/js/sections/webadif.js index 6203b8662..196d5f58f 100644 --- a/assets/js/sections/webadif.js +++ b/assets/js/sections/webadif.js @@ -35,21 +35,23 @@ function ExportWebADIF(station_id) { $(".card-body").append(''); } else { - $(".card-body").append(''); + $(".card-body").append(''); } if (data.errormessages.length > 0) { - $(".card-body").append('' + - '

    \n' + - ' \n' + - '

    \n' + - '
    \n' + - '
    \n' + - '
    \n' + - '
    '); - $.each(data.errormessages, function(index, value) { + $("#adif_import").append( + '
    \n' + + '
    \n' + + '
    \n' + + ' Error Message\n' + + '
    \n' + + '
    \n' + + '
    \n' + + '
    \n' + + '
    \n' + + '
    ' + ); + $.each(data.errormessages, function (index, value) { $(".errors").append('
  • ' + value); }); } From 28fd5d597845c2bacfcf4ba90755261ee00f9474 Mon Sep 17 00:00:00 2001 From: int2001 Date: Sat, 16 Dec 2023 12:31:33 +0000 Subject: [PATCH 7/9] Set status if no QSO found in upload-loop --- application/controllers/Hrdlog.php | 82 +++++++++++++++--------------- 1 file changed, 42 insertions(+), 40 deletions(-) diff --git a/application/controllers/Hrdlog.php b/application/controllers/Hrdlog.php index 5bbbfdc4d..547651116 100644 --- a/application/controllers/Hrdlog.php +++ b/application/controllers/Hrdlog.php @@ -50,50 +50,52 @@ class Hrdlog extends CI_Controller { * Adif is build for each qso, and then uploaded, one at a time */ function mass_upload_qsos($station_id, $hrdlog_username, $hrdlog_code) { - $i = 0; - $data['qsos'] = $this->logbook_model->get_hrdlog_qsos($station_id); - $errormessages = array(); + $i = 0; + $data['qsos'] = $this->logbook_model->get_hrdlog_qsos($station_id); + $errormessages = array(); - $CI = &get_instance(); - $CI->load->library('AdifHelper'); + $this->load->library('AdifHelper'); - if ($data['qsos']) { - foreach ($data['qsos']->result() as $qso) { - $adif = $CI->adifhelper->getAdifLine($qso); + if ($data['qsos']) { + foreach ($data['qsos']->result() as $qso) { + $adif = $this->adifhelper->getAdifLine($qso); - if ($qso->COL_HRDLOG_QSO_UPLOAD_STATUS == 'M') { - $result = $this->logbook_model->push_qso_to_hrdlog($hrdlog_username, $hrdlog_code, $adif, true); - } else { - $result = $this->logbook_model->push_qso_to_hrdlog($hrdlog_username, $hrdlog_code, $adif); - } + if ($qso->COL_HRDLOG_QSO_UPLOAD_STATUS == 'M') { + $result = $this->logbook_model->push_qso_to_hrdlog($hrdlog_username, $hrdlog_code, $adif, true); + } else { + $result = $this->logbook_model->push_qso_to_hrdlog($hrdlog_username, $hrdlog_code, $adif); + } - if (($result['status'] == 'OK') || (($result['status'] == 'error') || ($result['status'] == 'duplicate'))) { - $this->markqso($qso->COL_PRIMARY_KEY); - $i++; - $result['status'] = 'OK'; - } elseif ((substr($result['status'], 0, 11) == 'auth_error')) { - log_message('error', 'hrdlog upload failed for qso: Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON); - log_message('error', 'hrdlog upload failed with the following message: ' . $result['message']); - log_message('error', 'hrdlog upload stopped for Station_ID: ' . $station_id); - $errormessages[] = $result['message'] . 'Invalid HRDLog-Code, stopped at Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON; - $result['status'] = 'Error'; - break; /* If key is invalid, immediate stop syncing for more QSOs of this station */ - } else { - log_message('error', 'hrdlog upload failed for qso: Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON); - log_message('error', 'hrdlog upload failed with the following message: ' . $result['message']); - $result['status'] = 'Error'; - $errormessages[] = $result['message'] . ' Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON; - } - } - $result['count'] = $i; - $result['errormessages'] = $errormessages; - return $result; - } else { - $result['status'] = 'Error'; - $result['count'] = $i; - $result['errormessages'] = $errormessages; - return $result; - } + if (($result['status'] == 'OK') || (($result['status'] == 'error') || ($result['status'] == 'duplicate'))) { + $this->markqso($qso->COL_PRIMARY_KEY); + $i++; + $result['status'] = 'OK'; + } elseif ((substr($result['status'], 0, 11) == 'auth_error')) { + log_message('error', 'hrdlog upload failed for qso: Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON); + log_message('error', 'hrdlog upload failed with the following message: ' . $result['message']); + log_message('error', 'hrdlog upload stopped for Station_ID: ' . $station_id); + $errormessages[] = $result['message'] . 'Invalid HRDLog-Code, stopped at Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON; + $result['status'] = 'Error'; + break; /* If key is invalid, immediate stop syncing for more QSOs of this station */ + } else { + log_message('error', 'hrdlog upload failed for qso: Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON); + log_message('error', 'hrdlog upload failed with the following message: ' . $result['message']); + $result['status'] = 'Error'; + $errormessages[] = $result['message'] . ' Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON; + } + } + if ($i == 0) { + $result['status']='OK'; + } + $result['count'] = $i; + $result['errormessages'] = $errormessages; + return $result; + } else { + $result['status'] = 'Error'; + $result['count'] = $i; + $result['errormessages'] = $errormessages; + return $result; + } } /* From 2591d3aef6c0e563867dfbaa18ceb9de10cfe6ab Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Sat, 16 Dec 2023 13:44:39 +0100 Subject: [PATCH 8/9] fix error message bug --- application/controllers/Hrdlog.php | 4 ++-- assets/js/sections/hrdlog.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/application/controllers/Hrdlog.php b/application/controllers/Hrdlog.php index 547651116..547458da0 100644 --- a/application/controllers/Hrdlog.php +++ b/application/controllers/Hrdlog.php @@ -85,7 +85,7 @@ class Hrdlog extends CI_Controller { } } if ($i == 0) { - $result['status']='OK'; + $result['status']='Error'; } $result['count'] = $i; $result['errormessages'] = $errormessages; @@ -147,7 +147,7 @@ class Hrdlog extends CI_Controller { echo json_encode($data); } else { $data['status'] = 'Error'; - $data['info'] = 'Error: No QSOs found to upload.'; + $data['info'] = 'No QSOs found to upload.'; $data['errormessages'] = $result['errormessages']; echo json_encode($data); } diff --git a/assets/js/sections/hrdlog.js b/assets/js/sections/hrdlog.js index 671536854..bf7779d26 100644 --- a/assets/js/sections/hrdlog.js +++ b/assets/js/sections/hrdlog.js @@ -24,7 +24,7 @@ function ExportHrd(station_id) { $(".card-body").append(''); } else { - $(".card-body").append(''); + $(".card-body").append(''); } if (data.errormessages.length > 0) { From 7c9b678b8a0d3625ecb009542677c3782de06ea6 Mon Sep 17 00:00:00 2001 From: int2001 Date: Sat, 16 Dec 2023 12:53:14 +0000 Subject: [PATCH 9/9] Catch "invalid token" --- application/models/Logbook_model.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 4ff7f1340..bf659eea9 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -797,6 +797,10 @@ class Logbook_model extends CI_Model { $result['status'] = 'auth_error'; $result['message'] = $content; return $result; + } elseif (stristr($content,'Invalid token')) { + $result['status'] = 'auth_error'; + $result['message'] = $content; + return $result; } else { $result['status'] = 'error'; $result['message'] = $content;