From 99e46bf1fc0b8ec8992c5c410893deb5177ef28e Mon Sep 17 00:00:00 2001 From: int2001 Date: Fri, 21 Jul 2023 04:48:28 +0000 Subject: [PATCH 1/8] Added Controller for DXCluster --- application/controllers/Dxcluster.php | 36 +++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 application/controllers/Dxcluster.php diff --git a/application/controllers/Dxcluster.php b/application/controllers/Dxcluster.php new file mode 100644 index 00000000..703106f9 --- /dev/null +++ b/application/controllers/Dxcluster.php @@ -0,0 +1,36 @@ +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('logbook_model'); + } + + + function qrg_lookup($qrg) { + $call_found=$this->logbook_model->qrg_lookup($qrg); + if ($call_found) { + header('Content-Type: application/json'); + echo json_encode($call_found, JSON_PRETTY_PRINT); + } else { + echo '{ error: "not found" }'; + } + } + + function call($call) { + + $date = date('Ymd', time()); + $dxcc = $this->logbook_model->dxcc_lookup($call, $date); + + if ($dxcc) { + header('Content-Type: application/json'); + echo json_encode($dxcc, JSON_PRETTY_PRINT); + } else { + echo '{ error: "not found" }'; + } + } +} From 45161142ef66bd24eb72be9f1975e1814495ee50 Mon Sep 17 00:00:00 2001 From: int2001 Date: Fri, 21 Jul 2023 05:45:56 +0000 Subject: [PATCH 2/8] Implemented enrichment of spot --- application/controllers/Dxcluster.php | 8 ++--- application/models/Logbook_model.php | 36 +++++++++++++++++++ application/views/interface_assets/footer.php | 4 +-- 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/application/controllers/Dxcluster.php b/application/controllers/Dxcluster.php index 703106f9..1bb0d3e3 100644 --- a/application/controllers/Dxcluster.php +++ b/application/controllers/Dxcluster.php @@ -12,12 +12,12 @@ class Dxcluster extends CI_Controller { function qrg_lookup($qrg) { - $call_found=$this->logbook_model->qrg_lookup($qrg); + $call_found=$this->logbook_model->dxc_qrg_lookup($this->security->xss_clean($qrg)); + header('Content-Type: application/json'); if ($call_found) { - header('Content-Type: application/json'); echo json_encode($call_found, JSON_PRETTY_PRINT); } else { - echo '{ error: "not found" }'; + echo '{ "error": "not found" }'; } } @@ -30,7 +30,7 @@ class Dxcluster extends CI_Controller { header('Content-Type: application/json'); echo json_encode($dxcc, JSON_PRETTY_PRINT); } else { - echo '{ error: "not found" }'; + echo '{ "error": "not found" }'; } } } diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index cec2811f..2fd68597 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -3993,6 +3993,42 @@ class Logbook_model extends CI_Model { return false; } + public function dxc_qrg_lookup($qrg, $maxage = 120) { + if ( ($this->optionslib->get_option('dxcache_url') != '') && (is_numeric($qrg)) ) { + $dxcache_url = $this->optionslib->get_option('dxcache_url').'/spot/'.$qrg; + + // CURL Functions + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $dxcache_url); + curl_setopt($ch, CURLOPT_USERAGENT, 'Cloudlog DXLookup'); + curl_setopt($ch, CURLOPT_HEADER, false); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + $jsonraw = curl_exec($ch); + curl_close($ch); + $json = json_decode($jsonraw); + + // Create JSON object + if (strlen($jsonraw)>20) { + $datetimecurrent = new DateTime("now", new DateTimeZone('UTC')); // Today's Date/Time + $datetimespot = new DateTime($json->when, new DateTimeZone('UTC')); + $spotage = $datetimecurrent->diff($datetimespot); + $minutes = $spotage->days * 24 * 60; + $minutes += $spotage->h * 60; + $minutes += $spotage->i; + $json->age=$minutes; + if ($minutes<=$maxage) { + $dxcc=$this->dxcc_lookup($json->spotted,date('Ymd', time())); + $json->dxcc=$dxcc; + return ($json); + } else { + return ''; + } + } else { + return ''; + } + } + } + } function validateADIFDate($date, $format = 'Ymd') diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index db2d2fb2..b9acafc4 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -937,10 +937,10 @@ $(document).on('keypress',function(e) { if ($this->optionslib->get_option('dxcache_url') != ''){ ?> +

+
+ + +
+

From e6668443714b47a689aee4a1d9615653b8e3cf99 Mon Sep 17 00:00:00 2001 From: int2001 Date: Fri, 21 Jul 2023 09:19:59 +0000 Subject: [PATCH 6/8] Modified Bandmap --- assets/js/sections/bandmap.js | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/assets/js/sections/bandmap.js b/assets/js/sections/bandmap.js index 23a0731f..d5de46f9 100644 --- a/assets/js/sections/bandmap.js +++ b/assets/js/sections/bandmap.js @@ -47,7 +47,6 @@ $(function() { } }(Highcharts)); - var dxcluster_provider = 'https://dxc.jo30.de/dxcache'; var bandMapChart; var color = ifDarkModeThemeReturn('white', 'grey'); @@ -123,9 +122,10 @@ $(function() { return ret; } - function update_chart(lowerQrg,upperQrg,maxAgeMinutes) { + function update_chart(band,maxAgeMinutes) { + let dxurl = dxcluster_provider + "/spots/" + band + "/" +maxAgeMinutes; $.ajax({ - url: dxcluster_provider + "/spots", + url: dxurl, cache: false, dataType: "json" }).done(function(dxspots) { @@ -133,9 +133,7 @@ $(function() { dxspots.sort(SortByQrg); dxspots=reduce_spots(dxspots); dxspots.forEach((single) => { - if ( (single.frequency >= lowerQrg) && (single.frequency <= upperQrg) && (Date.parse(single.when)>(Date.now() - 1000 * 60 * maxAgeMinutes)) ) { - spots4chart.push(convert2high(single)); - } + spots4chart.push(convert2high(single)); }); // console.log(spots4chart); bandMapChart.series[0].setData(spots4chart); @@ -144,9 +142,10 @@ $(function() { } - function set_chart(lowerQrg,upperQrg,maxAgeMinutes) { + function set_chart(band,maxAgeMinutes) { + let dxurl = dxcluster_provider + "/spots/" + band + "/" +maxAgeMinutes; $.ajax({ - url: dxcluster_provider + "/spots", + url: dxurl, cache: false, dataType: "json" }).done(function(dxspots) { @@ -154,14 +153,12 @@ $(function() { dxspots.sort(SortByQrg); dxspots=reduce_spots(dxspots); dxspots.forEach((single) => { - if ( (single.frequency >= lowerQrg) && (single.frequency <= upperQrg) && (Date.parse(single.when)>(Date.now() - 1000 * 60 * maxAgeMinutes)) ) { - spots4chart.push(convert2high(single)); - } + spots4chart.push(convert2high(single)); }); - bandMapChart=render_chart('20m',spots4chart); + bandMapChart=render_chart(band,spots4chart); }); } - set_chart(14000,14350,30); - setInterval(function () { update_chart(14000,14350,30); },60000); + set_chart($('#band option:selected').val(),30); + setInterval(function () { update_chart($('#band option:selected').val(),30); },60000); }); From c24a2fc1137594a064828612d043aaea8a06a6b1 Mon Sep 17 00:00:00 2001 From: int2001 Date: Fri, 21 Jul 2023 09:44:05 +0000 Subject: [PATCH 7/8] Changed hard-url to base_url --- application/views/interface_assets/footer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index 2d755e2c..1acd0bc5 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -937,7 +937,7 @@ $(document).on('keypress',function(e) { if ($this->optionslib->get_option('dxcache_url') != ''){ ?>