diff --git a/application/config/migration.php b/application/config/migration.php index 98fd0f82..2fe2273e 100644 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE; | */ -$config['migration_version'] = 154; +$config['migration_version'] = 155; /* |-------------------------------------------------------------------------- diff --git a/application/controllers/Clublog.php b/application/controllers/Clublog.php index e4b77fdf..8472b5da 100644 --- a/application/controllers/Clublog.php +++ b/application/controllers/Clublog.php @@ -137,73 +137,6 @@ class Clublog extends CI_Controller { } - public function realtime($username) { - $clean_username = $this->security->xss_clean($username); - - $this->load->model('stations'); - $this->load->model('clublog_model'); - - $clublog_info = $this->clublog_model->get_clublog_auth_info($clean_username); - - if(!isset($clublog_info['user_name'])) { - echo "Username unknown"; - exit; - } - - $station_profiles = $this->stations->all_with_count(); - - // if station profiles exist - if($station_profiles->num_rows()){ - // Loop through station profiles - foreach ($station_profiles->result() as $station_row) - { - // if the station profile has more than 1 qso - if($station_row->qso_total > 0) { - $myqsos = $this->clublog_model->get_last_five($station_row->station_id); - - foreach ($myqsos->result() as $qso) - { - $data['qso'] = $qso; - $adif_string = $this->load->view('adif/data/clublog_realtime', $data, true); - - // initialise the curl request - $request = curl_init('https://clublog.org/realtime.php'); - - curl_setopt($request, CURLOPT_POST, true); - curl_setopt( - $request, - CURLOPT_POSTFIELDS, - array( - 'email' => $clublog_info['user_clublog_name'], - 'password' => $clublog_info['user_clublog_password'], - 'callsign' => $station_row->station_callsign, - 'adif' => $adif_string, - 'api' => "a11c3235cd74b88212ce726857056939d52372bd", - )); - - // output the response - curl_setopt($request, CURLOPT_RETURNTRANSFER, true); - $response = curl_exec($request); - $info = curl_getinfo($request); - - // If Clublog Accepts mark the QSOs - if (preg_match('/\bOK\b/', $response)) { - echo "QSOs uploaded and Logbook QSOs marked as sent to Clublog
"; - - $this->clublog_model->mark_qso_sent($qso->COL_PRIMARY_KEY); - echo "Clublog upload for ".$station_row->station_callsign."
"; - } else { - echo "Error ".$response."
"; - } - curl_close ($request); - } - } else { - echo "No QSOs to upload"; - } - } - } - } - // Find DXCC function find_dxcc($callsign) { $clean_callsign = $this->security->xss_clean($callsign); diff --git a/application/language/bulgarian/station_lang.php b/application/language/bulgarian/station_lang.php index 6c0d8c6b..7d4576d5 100644 --- a/application/language/bulgarian/station_lang.php +++ b/application/language/bulgarian/station_lang.php @@ -106,5 +106,6 @@ $lang['station_location_oqrs_email_alert'] = "OQRS Email alert"; $lang['station_location_oqrs_email_hint'] = "Make sure email is set up under admin and global options."; $lang['station_location_oqrs_text'] = "OQRS Text"; $lang['station_location_oqrs_text_hint'] = "Some info you want to add regarding QSL'ing."; +$lang['station_location_clublog_realtime_upload']='ClubLog Realtime Upload'; diff --git a/application/language/chinese_simplified/station_lang.php b/application/language/chinese_simplified/station_lang.php index 6c0d8c6b..7d4576d5 100644 --- a/application/language/chinese_simplified/station_lang.php +++ b/application/language/chinese_simplified/station_lang.php @@ -106,5 +106,6 @@ $lang['station_location_oqrs_email_alert'] = "OQRS Email alert"; $lang['station_location_oqrs_email_hint'] = "Make sure email is set up under admin and global options."; $lang['station_location_oqrs_text'] = "OQRS Text"; $lang['station_location_oqrs_text_hint'] = "Some info you want to add regarding QSL'ing."; +$lang['station_location_clublog_realtime_upload']='ClubLog Realtime Upload'; diff --git a/application/language/czech/station_lang.php b/application/language/czech/station_lang.php index 6c0d8c6b..7d4576d5 100644 --- a/application/language/czech/station_lang.php +++ b/application/language/czech/station_lang.php @@ -106,5 +106,6 @@ $lang['station_location_oqrs_email_alert'] = "OQRS Email alert"; $lang['station_location_oqrs_email_hint'] = "Make sure email is set up under admin and global options."; $lang['station_location_oqrs_text'] = "OQRS Text"; $lang['station_location_oqrs_text_hint'] = "Some info you want to add regarding QSL'ing."; +$lang['station_location_clublog_realtime_upload']='ClubLog Realtime Upload'; diff --git a/application/language/dutch/station_lang.php b/application/language/dutch/station_lang.php index 6c0d8c6b..7d4576d5 100644 --- a/application/language/dutch/station_lang.php +++ b/application/language/dutch/station_lang.php @@ -106,5 +106,6 @@ $lang['station_location_oqrs_email_alert'] = "OQRS Email alert"; $lang['station_location_oqrs_email_hint'] = "Make sure email is set up under admin and global options."; $lang['station_location_oqrs_text'] = "OQRS Text"; $lang['station_location_oqrs_text_hint'] = "Some info you want to add regarding QSL'ing."; +$lang['station_location_clublog_realtime_upload']='ClubLog Realtime Upload'; diff --git a/application/language/english/station_lang.php b/application/language/english/station_lang.php index 6c0d8c6b..130bf8e5 100644 --- a/application/language/english/station_lang.php +++ b/application/language/english/station_lang.php @@ -106,5 +106,4 @@ $lang['station_location_oqrs_email_alert'] = "OQRS Email alert"; $lang['station_location_oqrs_email_hint'] = "Make sure email is set up under admin and global options."; $lang['station_location_oqrs_text'] = "OQRS Text"; $lang['station_location_oqrs_text_hint'] = "Some info you want to add regarding QSL'ing."; - - +$lang['station_location_clublog_realtime_upload']='ClubLog Realtime Upload'; diff --git a/application/language/finnish/station_lang.php b/application/language/finnish/station_lang.php index 6c0d8c6b..7d4576d5 100644 --- a/application/language/finnish/station_lang.php +++ b/application/language/finnish/station_lang.php @@ -106,5 +106,6 @@ $lang['station_location_oqrs_email_alert'] = "OQRS Email alert"; $lang['station_location_oqrs_email_hint'] = "Make sure email is set up under admin and global options."; $lang['station_location_oqrs_text'] = "OQRS Text"; $lang['station_location_oqrs_text_hint'] = "Some info you want to add regarding QSL'ing."; +$lang['station_location_clublog_realtime_upload']='ClubLog Realtime Upload'; diff --git a/application/language/french/station_lang.php b/application/language/french/station_lang.php index 8147c90a..80678096 100644 --- a/application/language/french/station_lang.php +++ b/application/language/french/station_lang.php @@ -106,5 +106,6 @@ $lang['station_location_oqrs_email_alert'] = "OQRS Email alert"; $lang['station_location_oqrs_email_hint'] = "Make sure email is set up under admin and global options."; $lang['station_location_oqrs_text'] = "OQRS Text"; $lang['station_location_oqrs_text_hint'] = "Some info you want to add regarding QSL'ing."; +$lang['station_location_clublog_realtime_upload']='ClubLog Realtime Upload'; diff --git a/application/language/german/station_lang.php b/application/language/german/station_lang.php index 261734cd..3293a979 100644 --- a/application/language/german/station_lang.php +++ b/application/language/german/station_lang.php @@ -106,6 +106,4 @@ $lang['station_location_oqrs_email_alert'] = "OQRS Email Benachrichtigung"; $lang['station_location_oqrs_email_hint'] = "Stelle sicher, dass du E-Mail unter Admin/Globale Optionen konfiguriert hast."; $lang['station_location_oqrs_text'] = "OQRS Text"; $lang['station_location_oqrs_text_hint'] = "Einige Informationen, die du zum QSL-Vorgang hinzufügen möchtest."; - - - +$lang['station_location_clublog_realtime_upload']='ClubLog Realtime Upload'; diff --git a/application/language/greek/station_lang.php b/application/language/greek/station_lang.php index 6c0d8c6b..7d4576d5 100644 --- a/application/language/greek/station_lang.php +++ b/application/language/greek/station_lang.php @@ -106,5 +106,6 @@ $lang['station_location_oqrs_email_alert'] = "OQRS Email alert"; $lang['station_location_oqrs_email_hint'] = "Make sure email is set up under admin and global options."; $lang['station_location_oqrs_text'] = "OQRS Text"; $lang['station_location_oqrs_text_hint'] = "Some info you want to add regarding QSL'ing."; +$lang['station_location_clublog_realtime_upload']='ClubLog Realtime Upload'; diff --git a/application/language/italian/station_lang.php b/application/language/italian/station_lang.php index 6c0d8c6b..7d4576d5 100644 --- a/application/language/italian/station_lang.php +++ b/application/language/italian/station_lang.php @@ -106,5 +106,6 @@ $lang['station_location_oqrs_email_alert'] = "OQRS Email alert"; $lang['station_location_oqrs_email_hint'] = "Make sure email is set up under admin and global options."; $lang['station_location_oqrs_text'] = "OQRS Text"; $lang['station_location_oqrs_text_hint'] = "Some info you want to add regarding QSL'ing."; +$lang['station_location_clublog_realtime_upload']='ClubLog Realtime Upload'; diff --git a/application/language/polish/station_lang.php b/application/language/polish/station_lang.php index 6c0d8c6b..7d4576d5 100644 --- a/application/language/polish/station_lang.php +++ b/application/language/polish/station_lang.php @@ -106,5 +106,6 @@ $lang['station_location_oqrs_email_alert'] = "OQRS Email alert"; $lang['station_location_oqrs_email_hint'] = "Make sure email is set up under admin and global options."; $lang['station_location_oqrs_text'] = "OQRS Text"; $lang['station_location_oqrs_text_hint'] = "Some info you want to add regarding QSL'ing."; +$lang['station_location_clublog_realtime_upload']='ClubLog Realtime Upload'; diff --git a/application/language/russian/station_lang.php b/application/language/russian/station_lang.php index a1eb2166..ae4ecc21 100644 --- a/application/language/russian/station_lang.php +++ b/application/language/russian/station_lang.php @@ -106,5 +106,4 @@ $lang['station_location_oqrs_email_alert'] = "Оповещение о OQRS о е $lang['station_location_oqrs_email_hint'] = "Убедитесь, что емэйл сконфигурирован администратором в общих настройках."; $lang['station_location_oqrs_text'] = "Текст OQRS"; $lang['station_location_oqrs_text_hint'] = "Информация, которую вы хотите добавить, касающаяся QSL."; - - +$lang['station_location_clublog_realtime_upload']='ClubLog Realtime Upload'; diff --git a/application/language/spanish/station_lang.php b/application/language/spanish/station_lang.php index 6c0d8c6b..7d4576d5 100644 --- a/application/language/spanish/station_lang.php +++ b/application/language/spanish/station_lang.php @@ -106,5 +106,6 @@ $lang['station_location_oqrs_email_alert'] = "OQRS Email alert"; $lang['station_location_oqrs_email_hint'] = "Make sure email is set up under admin and global options."; $lang['station_location_oqrs_text'] = "OQRS Text"; $lang['station_location_oqrs_text_hint'] = "Some info you want to add regarding QSL'ing."; +$lang['station_location_clublog_realtime_upload']='ClubLog Realtime Upload'; diff --git a/application/language/swedish/station_lang.php b/application/language/swedish/station_lang.php index 6c0d8c6b..7d4576d5 100644 --- a/application/language/swedish/station_lang.php +++ b/application/language/swedish/station_lang.php @@ -106,5 +106,6 @@ $lang['station_location_oqrs_email_alert'] = "OQRS Email alert"; $lang['station_location_oqrs_email_hint'] = "Make sure email is set up under admin and global options."; $lang['station_location_oqrs_text'] = "OQRS Text"; $lang['station_location_oqrs_text_hint'] = "Some info you want to add regarding QSL'ing."; +$lang['station_location_clublog_realtime_upload']='ClubLog Realtime Upload'; diff --git a/application/language/turkish/station_lang.php b/application/language/turkish/station_lang.php index 6c0d8c6b..7d4576d5 100644 --- a/application/language/turkish/station_lang.php +++ b/application/language/turkish/station_lang.php @@ -106,5 +106,6 @@ $lang['station_location_oqrs_email_alert'] = "OQRS Email alert"; $lang['station_location_oqrs_email_hint'] = "Make sure email is set up under admin and global options."; $lang['station_location_oqrs_text'] = "OQRS Text"; $lang['station_location_oqrs_text_hint'] = "Some info you want to add regarding QSL'ing."; +$lang['station_location_clublog_realtime_upload']='ClubLog Realtime Upload'; diff --git a/application/migrations/155_add_clublog_realtime.php b/application/migrations/155_add_clublog_realtime.php new file mode 100644 index 00000000..cdd8ef64 --- /dev/null +++ b/application/migrations/155_add_clublog_realtime.php @@ -0,0 +1,24 @@ +db->field_exists('clublogrealtime', 'station_profile')) { + $this->dbforge->add_column('station_profile', $fields); + } + } + + public function down() + { + + if ($this->db->field_exists('clublogrealtime', 'station_profile')) { + $this->dbforge->drop_column('station_profile', 'clublogrealtime'); + } + } +} diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 69f06e15..200b28ce 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -565,6 +565,20 @@ class Logbook_model extends CI_Model { if (!$skipexport) { + $result = $this->exists_clublog_credentials($data['station_id']); + if (isset($result->ucp) && isset($result->ucn) && (($result->ucp ?? '') != '') && (($result->ucn ?? '') != '') && ($result->clublogrealtime == 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_clublog($result->ucn, $result->ucp, $data['COL_STATION_CALLSIGN'], $adif); + if ( ($result['status'] == 'OK') || ( ($result['status'] == 'error') || ($result['status'] == 'duplicate') || ($result['status'] == 'auth_error') )){ + $this->mark_clublog_qsos_sent($last_id); + } + } + + $result = ''; $result = $this->exists_hrdlog_code($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) { @@ -619,9 +633,9 @@ class Logbook_model extends CI_Model { */ function exists_hrdlog_code($station_id) { $sql = 'select hrdlog_code, hrdlogrealtime from station_profile - where station_id = ' . $station_id; + where station_id = ?'; - $query = $this->db->query($sql); + $query = $this->db->query($sql,$station_id); $result = $query->row(); @@ -632,14 +646,32 @@ class Logbook_model extends CI_Model { } } + /* + * Function checks if a Clublog Credebtials exists in the table with the given station id + */ + function exists_clublog_credentials($station_id) { + $sql = 'select auth.user_clublog_name ucn, auth.user_clublog_password ucp, prof.clublogrealtime from '.$this->config->item('auth_table').' auth inner join station_profile prof on (auth.user_id=prof.user_id) where prof.station_id = ? and prof.clublogrealtime=1'; + + $query = $this->db->query($sql, $station_id); + + $result = $query->row(); + + if ($result) { + return $result; + } else { + return false; + } + } + + /* * Function checks if a QRZ API Key exists in the table with the given station id */ function exists_qrz_api_key($station_id) { $sql = 'select qrzapikey, qrzrealtime from station_profile - where station_id = ' . $station_id; + where station_id = ?'; - $query = $this->db->query($sql); + $query = $this->db->query($sql, $station_id); $result = $query->row(); @@ -654,21 +686,54 @@ class Logbook_model extends CI_Model { /* * Function checks if a WebADIF API Key exists in the table with the given station id */ - function exists_webadif_api_key($station_id) { - $sql = 'select webadifapikey, webadifapiurl, webadifrealtime from station_profile - where station_id = ' . $station_id; + function exists_webadif_api_key($station_id) { + $sql = 'select webadifapikey, webadifapiurl, webadifrealtime from station_profile + where station_id = ?'; - $query = $this->db->query($sql); + $query = $this->db->query($sql, $station_id); - $result = $query->row(); + $result = $query->row(); - if ($result) { - return $result; - } - else { - return false; - } - } + if ($result) { + return $result; + } + else { + return false; + } + } + + function push_qso_to_clublog($cl_username, $cl_password, $station_callsign, $adif) { + + // initialise the curl request + $returner=[]; + $request = curl_init('https://clublog.org/realtime.php'); + + curl_setopt($request, CURLOPT_POST, true); + curl_setopt( + $request, + CURLOPT_POSTFIELDS, + array( + 'email' => $cl_username, + 'password' => $cl_password, + 'callsign' => $station_callsign, + 'adif' => $adif, + 'api' => "a11c3235cd74b88212ce726857056939d52372bd", + )); + + // output the response + curl_setopt($request, CURLOPT_RETURNTRANSFER, true); + $response = curl_exec($request); + $info = curl_getinfo($request); + + // If Clublog Accepts mark the QSOs + if (preg_match('/\bOK\b/', $response)) { + $returner['status']='OK'; + } else { + $returner['status']=$response; + } + curl_close ($request); + return ($returner); + } /* * Function uploads a QSO to HRDLog with the API given. @@ -795,6 +860,24 @@ class Logbook_model extends CI_Model { return $response === 200; } + /* + * Function marks QSOs as uploaded to Clublog + * $primarykey is the unique id for that QSO in the logbook + */ + function mark_clublog_qsos_sent($primarykey) { + $data = array( + 'COL_CLUBLOG_QSO_UPLOAD_DATE' => date("Y-m-d H:i:s", strtotime("now")), + 'COL_CLUBLOG_QSO_UPLOAD_STATUS' => 'Y', + ); + + $this->db->where('COL_PRIMARY_KEY', $primarykey); + + $this->db->update($this->config->item('table_name'), $data); + + return true; + } + + /* * Function marks QSOs as uploaded to HRDLog. * $primarykey is the unique id for that QSO in the logbook diff --git a/application/models/Stations.php b/application/models/Stations.php index 03b89aa7..6a51e018 100644 --- a/application/models/Stations.php +++ b/application/models/Stations.php @@ -103,6 +103,7 @@ class Stations extends CI_Model { 'eqslqthnickname' => xss_clean($this->input->post('eqslnickname', 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)), 'qrzapikey' => xss_clean($this->input->post('qrzapikey', true)), 'qrzrealtime' => xss_clean($this->input->post('qrzrealtime', true)), 'oqrs' => xss_clean($this->input->post('oqrs', true)), @@ -146,6 +147,7 @@ class Stations extends CI_Model { 'eqslqthnickname' => xss_clean($this->input->post('eqslnickname', 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)), 'qrzapikey' => xss_clean($this->input->post('qrzapikey', true)), 'qrzrealtime' => xss_clean($this->input->post('qrzrealtime', true)), 'oqrs' => xss_clean($this->input->post('oqrs', true)), diff --git a/application/views/station_profile/create.php b/application/views/station_profile/create.php index bfd9b201..4418fa0a 100644 --- a/application/views/station_profile/create.php +++ b/application/views/station_profile/create.php @@ -249,6 +249,13 @@ +
+ + +
diff --git a/application/views/station_profile/edit.php b/application/views/station_profile/edit.php index 31034384..d261df12 100644 --- a/application/views/station_profile/edit.php +++ b/application/views/station_profile/edit.php @@ -379,6 +379,22 @@
+
+
+
ClubLog
+
+
+ + +
+
+
+
+
+
HRDLog.net