kopia lustrzana https://github.com/magicbug/Cloudlog
commit
11c39879ef
|
@ -7,6 +7,7 @@ class Bandmap extends CI_Controller {
|
|||
|
||||
$this->load->model('user_model');
|
||||
if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
|
||||
$this->load->model('bands');
|
||||
}
|
||||
|
||||
function index() {
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Dxcluster extends CI_Controller {
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('user_model');
|
||||
if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
|
||||
$this->load->model('logbook_model');
|
||||
}
|
||||
|
||||
|
||||
function spots($band,$age = 60) {
|
||||
$calls_found=$this->logbook_model->dxc_spotlist($band, $age);
|
||||
header('Content-Type: application/json');
|
||||
if ($calls_found) {
|
||||
echo json_encode($calls_found, JSON_PRETTY_PRINT);
|
||||
} else {
|
||||
echo '{ "error": "not found" }';
|
||||
}
|
||||
}
|
||||
|
||||
function qrg_lookup($qrg) {
|
||||
$call_found=$this->logbook_model->dxc_qrg_lookup($this->security->xss_clean($qrg));
|
||||
header('Content-Type: application/json');
|
||||
if ($call_found) {
|
||||
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" }';
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3993,6 +3993,86 @@ class Logbook_model extends CI_Model {
|
|||
return false;
|
||||
}
|
||||
|
||||
public function dxc_spotlist($band = '20m',$maxage = 60) {
|
||||
$CI =& get_instance();
|
||||
if ( ($this->optionslib->get_option('dxcache_url') != '') ) {
|
||||
$dxcache_url = $this->optionslib->get_option('dxcache_url').'/spots/';
|
||||
|
||||
// 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) {
|
||||
$spotsout=[];
|
||||
foreach($json as $singlespot){
|
||||
$spotband = $CI->frequency->GetBand($singlespot->frequency*1000);
|
||||
$singlespot->band=$spotband;
|
||||
if ($band != $spotband) { continue; }
|
||||
$datetimecurrent = new DateTime("now", new DateTimeZone('UTC')); // Today's Date/Time
|
||||
$datetimespot = new DateTime($singlespot->when, new DateTimeZone('UTC'));
|
||||
$spotage = $datetimecurrent->diff($datetimespot);
|
||||
$minutes = $spotage->days * 24 * 60;
|
||||
$minutes += $spotage->h * 60;
|
||||
$minutes += $spotage->i;
|
||||
$singlespot->age=$minutes;
|
||||
if ($minutes<=$maxage) {
|
||||
$dxcc=$this->dxcc_lookup($singlespot->spotter,date('Ymd', time()));
|
||||
$singlespot->dxcc_spotter=$dxcc;
|
||||
array_push($spotsout,$singlespot);
|
||||
}
|
||||
}
|
||||
return ($spotsout);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
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->spotter,date('Ymd', time()));
|
||||
$json->dxcc_spotter=$dxcc;
|
||||
return ($json);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function validateADIFDate($date, $format = 'Ymd')
|
||||
|
|
|
@ -1,9 +1,31 @@
|
|||
<script>
|
||||
var dxcluster_provider="<?php echo base_url(); ?>index.php/dxcluster";
|
||||
</script>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<br>
|
||||
|
||||
<h2><?php echo $page_title; ?></h2>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="band"><?php echo lang('gen_hamradio_band'); ?></label>
|
||||
|
||||
<select id="band" class="form-control form-control-sm" name="band">
|
||||
<?php
|
||||
$bands = $this->bands->get_user_bands_for_qso_entry();
|
||||
foreach($bands as $key=>$bandgroup) {
|
||||
echo '<optgroup label="' . strtoupper($key) . '">';
|
||||
foreach($bandgroup as $band) {
|
||||
echo '<option value="' . $band . '"';
|
||||
if ($band == "20m") echo ' selected';
|
||||
echo '>' . $band . '</option>'."\n";
|
||||
}
|
||||
echo '</optgroup>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<figure class="highcharts-figure">
|
||||
<div id="bandmap"></div>
|
||||
<p class="highcharts-description">
|
||||
|
|
|
@ -937,10 +937,10 @@ $(document).on('keypress',function(e) {
|
|||
|
||||
if ($this->optionslib->get_option('dxcache_url') != ''){ ?>
|
||||
<script type="text/javascript">
|
||||
var dxcluster_provider =' <?php echo $this->optionslib->get_option('dxcache_url'); ?>';
|
||||
var dxcluster_provider = <?php echo base_url(); ?>'index.php/dxcluster';
|
||||
$(document).ready(function() {
|
||||
$("#check_cluster").on("click", function() {
|
||||
$.ajax({ url: dxcluster_provider+"/spot/"+$("#frequency").val()/1000, cache: false, dataType: "json" }).done(
|
||||
$.ajax({ url: dxcluster_provider+"/qrg_lookup/"+$("#frequency").val()/1000, cache: false, dataType: "json" }).done(
|
||||
function(dxspot) {
|
||||
$("#callsign").val(dxspot.spotted);
|
||||
$("#callsign").trigger("blur");
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
Ładowanie…
Reference in New Issue