diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php index c5cbfd0e5..c879f0fc7 100644 --- a/application/controllers/Lotw.php +++ b/application/controllers/Lotw.php @@ -527,10 +527,11 @@ class Lotw extends CI_Controller { $state = ""; } // Present only if the QSLing station specified a single valid grid square value in its station location uploaded to LoTW. + $qsl_gridsquare = ""; if (isset($record['gridsquare'])) { - $qsl_gridsquare = $record['gridsquare']; - } else { - $qsl_gridsquare = ""; + if (strlen($record['gridsquare']) > strlen($status[2]) || substr(strtoupper($status[2]), 0, 4) != substr(strtoupper($record['gridsquare']), 0, 4)) { + $qsl_gridsquare = $record['gridsquare']; + } } if (isset($record['vucc_grids'])) { diff --git a/application/controllers/Qrz.php b/application/controllers/Qrz.php index 446b0208c..3de9c0a3a 100644 --- a/application/controllers/Qrz.php +++ b/application/controllers/Qrz.php @@ -21,6 +21,46 @@ class Qrz extends CI_Controller { $this->config->load('config'); } + /* + * API Key Status Test + */ + + public function qrz_apitest() { + $apikey = xss_clean($this->input->post('APIKEY')); + $url = 'http://logbook.qrz.com/api'; // TODO: Move this to database + + $post_data['KEY'] = $apikey; + $post_data['ACTION'] = 'STATUS'; + + $ch = curl_init( $url ); + curl_setopt( $ch, CURLOPT_POST, true); + curl_setopt( $ch, CURLOPT_POSTFIELDS, $post_data); + curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1); + curl_setopt( $ch, CURLOPT_HEADER, 0); + curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 20); + curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true); + + $content = curl_exec($ch); + curl_close($ch); + + if ($content){ + if (stristr($content,'RESULT=OK')) { + $result['status'] = 'OK'; + $result['message'] = $content; + } + else { + $result['status'] = 'Failed'; + $result['message'] = $content; + } + } + if(curl_errno($ch)){ + $result['status'] = 'error'; + $result['message'] = 'Curl error: '. curl_errno($ch); + } + header('Content-Type: application/json'); + echo json_encode($result); + } + /* * Upload QSO to QRZ.com * When called from the url wavelog/qrz/upload, the function loops through all station_id's with a qrz api key defined. @@ -39,12 +79,14 @@ class Qrz extends CI_Controller { if ($station_ids) { foreach ($station_ids as $station) { $qrz_api_key = $station->qrzapikey; - if($this->mass_upload_qsos($station->station_id, $qrz_api_key, true)) { - echo "QSOs have been uploaded to QRZ.com."; - log_message('info', 'QSOs have been uploaded to QRZ.com.'); - } else{ - echo "No QSOs found for upload."; - log_message('info', 'No QSOs found for upload.'); + if ($station->qrzrealtime>=0) { + if($this->mass_upload_qsos($station->station_id, $qrz_api_key, true)) { + echo "QSOs have been uploaded to QRZ.com. for station_id ".$station->station_id; + } else{ + echo "No QSOs found for upload and station_id ".$station->station_id; + } + } else { + echo "Station ".$station->station_id." disabled for upload to QRZ.com."; } } } else { @@ -87,11 +129,11 @@ class Qrz extends CI_Controller { $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); + log_message('error', 'QRZ upload failed for qso for Station_ID '.$station_id.' // Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON . ' // 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'; + $sql = 'update station_profile set qrzrealtime = -1 where station_id = ?'; + $this->db->query($sql,$station_id); 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); @@ -151,21 +193,27 @@ class Qrz extends CI_Controller { $this->load->model('logbook_model'); $result = $this->logbook_model->exists_qrz_api_key($postData['station_id']); $qrz_api_key = $result->qrzapikey; + $qrz_enabled = $result->qrzrealtime; header('Content-type: application/json'); - $result = $this->mass_upload_qsos($postData['station_id'], $qrz_api_key); - if ($result['status'] == 'OK') { - $stationinfo = $this->stations->stations_with_qrz_api_key(); - $info = $stationinfo->result(); + if ($qrz_enabled>=0) { + $result = $this->mass_upload_qsos($postData['station_id'], $qrz_api_key); + if ($result['status'] == 'OK') { + $stationinfo = $this->stations->stations_with_qrz_api_key(); + $info = $stationinfo->result(); - $data['status'] = 'OK'; - $data['info'] = $info; - $data['infomessage'] = $result['count'] . " QSOs are now uploaded to QRZ.com"; - $data['errormessages'] = $result['errormessages']; - echo json_encode($data); + $data['status'] = 'OK'; + $data['info'] = $info; + $data['infomessage'] = $result['count'] . " QSOs are now uploaded to QRZ.com"; + $data['errormessages'] = $result['errormessages']; + echo json_encode($data); + } else { + $data['status'] = 'Error'; + $data['info'] = 'Error: No QSOs found to upload.'; + $data['errormessages'] = $result['errormessages']; + echo json_encode($data); + } } else { - $data['status'] = 'Error'; - $data['info'] = 'Error: No QSOs found to upload.'; - $data['errormessages'] = $result['errormessages']; + $data['status']='QRZ Disabled for station'.$this->security->xss_clean($postData['station_id']); echo json_encode($data); } } diff --git a/application/language/bulgarian/general_words_lang.php b/application/language/bulgarian/general_words_lang.php index 2c99aeeda..e8777dec4 100644 --- a/application/language/bulgarian/general_words_lang.php +++ b/application/language/bulgarian/general_words_lang.php @@ -67,6 +67,7 @@ $lang['general_word_worked'] = 'Работени'; $lang['general_word_worked_not_confirmed'] = "Worked not confirmed"; $lang['general_word_not_worked'] = "Not worked"; $lang['general_word_confirmed'] = 'Потвърдени'; +$lang['general_word_not_confirmed'] = "Not Confirmed"; $lang['general_word_confirmation'] = "Confirmation"; $lang['general_word_needed'] = 'Необходими'; @@ -237,4 +238,5 @@ $lang['dashboard_logbooks_warning'] = 'You have no station logbook. Go here to create it!'; $lang['gen_add_to_contest'] = "Add QSOs to Contest"; +$lang['general_word_realtime'] = "Realtime"; $lang['hams_at_no_activations_found'] = 'No upcoming activations found. Please check back later.'; +$lang['general_word_realtime'] = "Realtime"; $lang['datatables_language'] = "en-GB"; diff --git a/application/language/swedish/station_lang.php b/application/language/swedish/station_lang.php index b27687efe..b52282ff6 100644 --- a/application/language/swedish/station_lang.php +++ b/application/language/swedish/station_lang.php @@ -100,7 +100,7 @@ $lang['station_location_eqsl_defaultqslmsg'] = "Default QSLMSG"; $lang['station_location_eqsl_defaultqslmsg_hint'] = "Define a default message that will be populated and sent for each QSO for this station location."; $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_qrz_realtime_upload'] = 'QRZ.com Logbook 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"; diff --git a/application/language/turkish/general_words_lang.php b/application/language/turkish/general_words_lang.php index a30b52580..b26e86495 100644 --- a/application/language/turkish/general_words_lang.php +++ b/application/language/turkish/general_words_lang.php @@ -67,6 +67,7 @@ $lang['general_word_worked'] = 'Çalışılanlar'; $lang['general_word_worked_not_confirmed'] = "Worked not confirmed"; $lang['general_word_not_worked'] = "Not worked"; $lang['general_word_confirmed'] = 'Onaylanan'; +$lang['general_word_not_confirmed'] = "Not Confirmed"; $lang['general_word_confirmation'] = "Confirmation"; $lang['general_word_needed'] = 'İstenenler'; @@ -237,4 +238,5 @@ $lang['dashboard_logbooks_warning'] = 'You have no station logbook. Go optionslib->get_option('version').' DXLookup'); + curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $jsonraw = curl_exec($ch); diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 55f544e58..958a5b2f0 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -1875,7 +1875,7 @@ class Logbook_model extends CI_Model { * Function returns all the station_id's with QRZ API Key's */ function get_station_id_with_qrz_api() { - $sql = 'select station_id, qrzapikey from station_profile + $sql = 'select station_id, qrzapikey, qrzrealtime from station_profile where coalesce(qrzapikey, "") <> ""'; $query = $this->db->query($sql); @@ -2085,7 +2085,6 @@ function check_if_callsign_worked_in_logbook($callsign, $StationLocationsArray = $this->db->limit('2'); $query = $this->db->get($this->config->item('table_name')); - return $query->num_rows(); } @@ -3184,7 +3183,7 @@ function check_if_callsign_worked_in_logbook($callsign, $StationLocationsArray = function import_check($datetime, $callsign, $band, $mode, $station_callsign, $station_id = null) { $mode=$this->get_main_mode_from_mode($mode); - $this->db->select('COL_PRIMARY_KEY, COL_TIME_ON, COL_CALL, COL_BAND'); + $this->db->select('COL_PRIMARY_KEY, COL_TIME_ON, COL_CALL, COL_BAND, COL_GRIDSQUARE'); $this->db->where('COL_TIME_ON >= DATE_ADD(DATE_FORMAT("'.$datetime.'", \'%Y-%m-%d %H:%i\' ), INTERVAL -15 MINUTE )'); $this->db->where('COL_TIME_ON <= DATE_ADD(DATE_FORMAT("'.$datetime.'", \'%Y-%m-%d %H:%i\' ), INTERVAL 15 MINUTE )'); $this->db->where('COL_CALL', $callsign); @@ -3201,9 +3200,9 @@ function check_if_callsign_worked_in_logbook($callsign, $StationLocationsArray = if ($query->num_rows() > 0) { $ret = $query->row(); - return ["Found", $ret->COL_PRIMARY_KEY]; + return ["Found", $ret->COL_PRIMARY_KEY, $ret->COL_GRIDSQUARE]; } else { - return ["No Match", 0]; + return ["No Match", 0, '']; } } diff --git a/application/views/bandmap/list.php b/application/views/bandmap/list.php index 3b63c8d49..7b5b9dda2 100644 --- a/application/views/bandmap/list.php +++ b/application/views/bandmap/list.php @@ -66,9 +66,16 @@ } ?>>radio; ?> + + +
+ + +
+
diff --git a/application/views/station_profile/edit.php b/application/views/station_profile/edit.php index deb19ec84..7667a59cf 100644 --- a/application/views/station_profile/edit.php +++ b/application/views/station_profile/edit.php @@ -298,15 +298,20 @@
- qrzapikey; } ?>"> +
+ qrzapikey; } ?>"> + +
+
diff --git a/assets/js/sections/bandmap_list.js b/assets/js/sections/bandmap_list.js index b3ef7f639..4c60e12fa 100644 --- a/assets/js/sections/bandmap_list.js +++ b/assets/js/sections/bandmap_list.js @@ -35,7 +35,7 @@ $(function() { return table; } - function fill_list(band,de,maxAgeMinutes) { + function fill_list(band,de,maxAgeMinutes,cwn) { // var table = $('.spottable').DataTable(); var table = get_dtable(); if ((band != '') && (band !== undefined)) { @@ -48,9 +48,14 @@ $(function() { table.page.len(50); let oldtable=table.data(); table.clear(); + let spots2render=0; if (dxspots.length>0) { dxspots.sort(SortByQrg); dxspots.forEach((single) => { + if ((cwn == 'wkd') && (!(single.worked_dxcc))) { return; } + if ((cwn == 'cnf') && (!(single.cnfmd_dxcc))) { return; } + if ((cwn == 'ucnf') && ((single.cnfmd_dxcc))) { return; } + spots2render++; var data=[]; if (single.cnfmd_dxcc) { dxcc_wked_info="text-success"; @@ -117,6 +122,10 @@ $(function() { table.clear(); table.draw(); } + if (spots2render == 0) { + table.clear(); + table.draw(); + } }); } else { table.clear(); @@ -145,17 +154,22 @@ $(function() { var table=get_dtable(); table.order([1, 'asc']); table.clear(); - fill_list($('#band option:selected').val(), $('#decontSelect option:selected').val(),dxcluster_maxage); - setInterval(function () { fill_list($('#band option:selected').val(), $('#decontSelect option:selected').val(),dxcluster_maxage); },60000); + fill_list($('#band option:selected').val(), $('#decontSelect option:selected').val(),dxcluster_maxage,$('#cwnSelect option:selected').val()); + setInterval(function () { fill_list($('#band option:selected').val(), $('#decontSelect option:selected').val(),dxcluster_maxage,$('#cwnSelect option:selected').val()); },60000); + + $("#cwnSelect").on("change",function() { + table.clear(); + fill_list($('#band option:selected').val(), $('#decontSelect option:selected').val(),dxcluster_maxage,$('#cwnSelect option:selected').val()); + }); $("#decontSelect").on("change",function() { table.clear(); - fill_list($('#band option:selected').val(), $('#decontSelect option:selected').val(),dxcluster_maxage); + fill_list($('#band option:selected').val(), $('#decontSelect option:selected').val(),dxcluster_maxage,$('#cwnSelect option:selected').val()); }); $("#band").on("change",function() { table.clear(); - fill_list($('#band option:selected').val(), $('#decontSelect option:selected').val(),dxcluster_maxage); + fill_list($('#band option:selected').val(), $('#decontSelect option:selected').val(),dxcluster_maxage,$('#cwnSelect option:selected').val()); }); $("#spottertoggle").on("click", function() { diff --git a/assets/js/sections/station_locations.js b/assets/js/sections/station_locations.js index 8fbd37d6b..43268951d 100644 --- a/assets/js/sections/station_locations.js +++ b/assets/js/sections/station_locations.js @@ -12,6 +12,41 @@ $(document).ready(function () { $("#dxcc_id").change(function () { updateStateDropdown('#dxcc_id', '#stateInputLabel', '#location_us_county', '#stationCntyInputEdit'); }); + + $('#qrz_apitest_btn').click(function(){ + + var apikey = $('#qrzApiKey').val(); + var msg_div = $('#qrz_apitest_msg'); + + msg_div.hide(); + msg_div.removeClass('alert-success alert-danger') + + $.ajax({ + url: base_url+'index.php/qrz/qrz_apitest', + type: 'POST', + data: { + 'APIKEY': apikey + }, + success: function(res) { + if(res.status == 'OK') { + msg_div.addClass('alert-success'); + msg_div.text('Your API Key works. You are good to go!'); + msg_div.show(); + } else { + msg_div.addClass('alert-danger'); + msg_div.text('Your API Key failed. Are you sure you have a valid QRZ subsription?'); + msg_div.show(); + $('#qrzrealtime').val(-1); + } + }, + error: function(res) { + msg_div.addClass('alert-danger'); + msg_div.text('ERROR: Something went wrong on serverside. We\'re sorry..'); + msg_div.show(); + }, + }); + }); + } });