Merge branch 'dev' of https://github.com/magicbug/Cloudlog into dev
这个提交包含在:
当前提交
58492cd4b7
共有 10 个文件被更改,包括 249 次插入 和 19 次删除
|
|
@ -9,7 +9,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Folder location for storing P12 certficiate files on the system
|
||||
| Folder location for storing P12 certificate files on the system
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This folder must be outside of your www root for security reasons
|
||||
|
|
|
|||
|
|
@ -471,6 +471,152 @@ class API extends CI_Controller {
|
|||
|
||||
}
|
||||
|
||||
// API function to check if a callsign is in the logbook already
|
||||
function logbook_check_callsign() {
|
||||
header('Content-type: application/json');
|
||||
|
||||
$this->load->model('api_model');
|
||||
|
||||
// Decode JSON and store
|
||||
$obj = json_decode(file_get_contents("php://input"), true);
|
||||
if ($obj === NULL) {
|
||||
echo json_encode(['status' => 'failed', 'reason' => "wrong JSON"]);
|
||||
}
|
||||
|
||||
if(!isset($obj['key']) || $this->api_model->authorize($obj['key']) == 0) {
|
||||
http_response_code(401);
|
||||
echo json_encode(['status' => 'failed', 'reason' => "missing api key"]);
|
||||
}
|
||||
|
||||
if($obj['logbook_public_slug'] != "" && $obj['callsign'] != "") {
|
||||
|
||||
$logbook_slug = $obj['logbook_public_slug'];
|
||||
$callsign = $obj['callsign'];
|
||||
|
||||
// If $obj['band'] exists
|
||||
if(isset($obj['band'])) {
|
||||
$band = $obj['band'];
|
||||
} else {
|
||||
$band = null;
|
||||
}
|
||||
|
||||
$this->load->model('logbooks_model');
|
||||
|
||||
if($this->logbooks_model->public_slug_exists($logbook_slug)) {
|
||||
$logbook_id = $this->logbooks_model->public_slug_exists_logbook_id($logbook_slug);
|
||||
if($logbook_id != false)
|
||||
{
|
||||
// Get associated station locations for mysql queries
|
||||
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($logbook_id);
|
||||
|
||||
if (!$logbooks_locations_array) {
|
||||
// Logbook not found
|
||||
http_response_code(404);
|
||||
echo json_encode(['status' => 'failed', 'reason' => "Empty Logbook"]);
|
||||
die();
|
||||
}
|
||||
} else {
|
||||
// Logbook not found
|
||||
http_response_code(404);
|
||||
echo json_encode(['status' => 'failed', 'reason' => $logbook_slug." has no associated station locations"]);
|
||||
die();
|
||||
}
|
||||
// Search Logbook for callsign
|
||||
$this->load->model('logbook_model');
|
||||
|
||||
$result = $this->logbook_model->check_if_callsign_worked_in_logbook($callsign, $logbooks_locations_array, $band);
|
||||
|
||||
http_response_code(201);
|
||||
if($result > 0)
|
||||
{
|
||||
echo json_encode(['callsign' => $callsign, 'result' => 'Found']);
|
||||
} else {
|
||||
echo json_encode(['callsign' => $callsign, 'result' => 'Not Found']);
|
||||
}
|
||||
} else {
|
||||
// Logbook not found
|
||||
http_response_code(404);
|
||||
echo json_encode(['status' => 'failed', 'reason' => "logbook not found"]);
|
||||
die();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// API function to check if a grid is in the logbook already
|
||||
function logbook_check_grid() {
|
||||
header('Content-type: application/json');
|
||||
|
||||
$this->load->model('api_model');
|
||||
|
||||
// Decode JSON and store
|
||||
$obj = json_decode(file_get_contents("php://input"), true);
|
||||
if ($obj === NULL) {
|
||||
echo json_encode(['status' => 'failed', 'reason' => "wrong JSON"]);
|
||||
}
|
||||
|
||||
if(!isset($obj['key']) || $this->api_model->authorize($obj['key']) == 0) {
|
||||
http_response_code(401);
|
||||
echo json_encode(['status' => 'failed', 'reason' => "missing api key"]);
|
||||
}
|
||||
|
||||
if($obj['logbook_public_slug'] != "" && $obj['grid'] != "") {
|
||||
|
||||
$logbook_slug = $obj['logbook_public_slug'];
|
||||
$grid = $obj['grid'];
|
||||
|
||||
// If $obj['band'] exists
|
||||
if(isset($obj['band'])) {
|
||||
$band = $obj['band'];
|
||||
} else {
|
||||
$band = null;
|
||||
}
|
||||
|
||||
$this->load->model('logbooks_model');
|
||||
|
||||
if($this->logbooks_model->public_slug_exists($logbook_slug)) {
|
||||
$logbook_id = $this->logbooks_model->public_slug_exists_logbook_id($logbook_slug);
|
||||
if($logbook_id != false)
|
||||
{
|
||||
// Get associated station locations for mysql queries
|
||||
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($logbook_id);
|
||||
|
||||
if (!$logbooks_locations_array) {
|
||||
// Logbook not found
|
||||
http_response_code(404);
|
||||
echo json_encode(['status' => 'failed', 'reason' => "Empty Logbook"]);
|
||||
die();
|
||||
}
|
||||
} else {
|
||||
// Logbook not found
|
||||
http_response_code(404);
|
||||
echo json_encode(['status' => 'failed', 'reason' => $logbook_slug." has no associated station locations"]);
|
||||
die();
|
||||
}
|
||||
// Search Logbook for callsign
|
||||
$this->load->model('logbook_model');
|
||||
|
||||
$result = $this->logbook_model->check_if_grid_worked_in_logbook($grid, $logbooks_locations_array, $band);
|
||||
|
||||
http_response_code(201);
|
||||
if($result > 0)
|
||||
{
|
||||
echo json_encode(['gridsquare' => strtoupper($grid), 'result' => 'Found']);
|
||||
} else {
|
||||
echo json_encode(['gridsquare' => strtoupper($grid), 'result' => 'Not Found']);
|
||||
}
|
||||
} else {
|
||||
// Logbook not found
|
||||
http_response_code(404);
|
||||
echo json_encode(['status' => 'failed', 'reason' => "logbook not found"]);
|
||||
die();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function country_worked($dxcc_num, $band, $mode = NULL) {
|
||||
$this->load->model('api_model');
|
||||
|
||||
|
|
@ -695,4 +841,4 @@ class API extends CI_Controller {
|
|||
$latlng = $this->qra->qra2latlong($qra);
|
||||
return $latlng;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -153,23 +153,23 @@ class Lotw extends CI_Controller {
|
|||
}
|
||||
|
||||
// Check to see if certificate is already in the system
|
||||
$new_certficiate = $this->LotwCert->find_cert($info['issued_callsign'], $dxcc, $this->session->userdata('user_id'));
|
||||
$new_certificate = $this->LotwCert->find_cert($info['issued_callsign'], $dxcc, $this->session->userdata('user_id'));
|
||||
|
||||
if($new_certficiate == 0) {
|
||||
if($new_certificate == 0) {
|
||||
// New Certificate Store in Database
|
||||
|
||||
// Store Certificate Data into MySQL
|
||||
$this->LotwCert->store_certificate($this->session->userdata('user_id'), $info['issued_callsign'], $dxcc, $info['validFrom'], $info['validTo_Date'], $info['qso-first-date'], $info['qso-end-date'], $info['pem_key'], $info['general_cert']);
|
||||
|
||||
// Cert success flash message
|
||||
$this->session->set_flashdata('Success', $info['issued_callsign'].' Certficiate Imported.');
|
||||
$this->session->set_flashdata('Success', $info['issued_callsign'].' Certificate Imported.');
|
||||
} else {
|
||||
// Certficiate is in the system time to update
|
||||
// Certificate is in the system time to update
|
||||
|
||||
$this->LotwCert->update_certficiate($this->session->userdata('user_id'), $info['issued_callsign'], $dxcc, $info['validFrom'], $info['validTo_Date'], $info['pem_key'], $info['general_cert']);
|
||||
$this->LotwCert->update_certificate($this->session->userdata('user_id'), $info['issued_callsign'], $dxcc, $info['validFrom'], $info['validTo_Date'], $info['pem_key'], $info['general_cert']);
|
||||
|
||||
// Cert success flash message
|
||||
$this->session->set_flashdata('Success', $info['issued_callsign'].' Certficiate Updated.');
|
||||
$this->session->set_flashdata('Success', $info['issued_callsign'].' Certificate Updated.');
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -378,9 +378,9 @@ class Lotw extends CI_Controller {
|
|||
|
||||
$this->load->model('LotwCert');
|
||||
|
||||
$this->LotwCert->delete_certficiate($this->session->userdata('user_id'), $cert_id);
|
||||
$this->LotwCert->delete_certificate($this->session->userdata('user_id'), $cert_id);
|
||||
|
||||
$this->session->set_flashdata('Success', 'Certficiate Deleted.');
|
||||
$this->session->set_flashdata('Success', 'Certificate Deleted.');
|
||||
|
||||
redirect('/lotw/');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1287,6 +1287,7 @@ class Logbook_model extends CI_Model {
|
|||
INNER JOIN station_profile ON qsos.station_id = station_profile.station_id
|
||||
LEFT JOIN webadif ON qsos.COL_PRIMARY_KEY = webadif.qso_id
|
||||
WHERE qsos.station_id = %d
|
||||
AND qsos.COL_SAT_NAME = 'QO-100'
|
||||
AND webadif.upload_date IS NULL
|
||||
";
|
||||
$sql = sprintf(
|
||||
|
|
@ -1386,6 +1387,61 @@ class Logbook_model extends CI_Model {
|
|||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function check_if_callsign_worked_in_logbook($callsign, $StationLocationsArray = null, $band = null) {
|
||||
|
||||
if($StationLocationsArray == null) {
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
} else {
|
||||
$logbooks_locations_array = $StationLocationsArray;
|
||||
}
|
||||
|
||||
$this->db->select('COL_CALL');
|
||||
$this->db->where_in('station_id', $logbooks_locations_array);
|
||||
$this->db->where('COL_CALL', $callsign);
|
||||
|
||||
if($band != null && $band != 'SAT') {
|
||||
$this->db->where('COL_BAND', $band);
|
||||
} else if($band == 'SAT') {
|
||||
// Where col_sat_name is not empty
|
||||
$this->db->where('COL_SAT_NAME !=', '');
|
||||
}
|
||||
$this->db->limit('2');
|
||||
$query = $this->db->get($this->config->item('table_name'));
|
||||
|
||||
return $query->num_rows();
|
||||
|
||||
}
|
||||
|
||||
function check_if_grid_worked_in_logbook($grid, $StationLocationsArray = null, $band = null) {
|
||||
|
||||
if($StationLocationsArray == null) {
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
} else {
|
||||
$logbooks_locations_array = $StationLocationsArray;
|
||||
}
|
||||
|
||||
$this->db->select('COL_GRIDSQUARE');
|
||||
$this->db->where_in('station_id', $logbooks_locations_array);
|
||||
$this->db->like('COL_GRIDSQUARE', $grid);
|
||||
|
||||
if($band != null && $band != 'SAT') {
|
||||
$this->db->where('COL_BAND', $band);
|
||||
} else if($band == 'SAT') {
|
||||
// Where col_sat_name is not empty
|
||||
$this->db->where('COL_SAT_NAME !=', '');
|
||||
}
|
||||
$this->db->limit('2');
|
||||
|
||||
$query = $this->db->get($this->config->item('table_name'));
|
||||
|
||||
return $query->num_rows();
|
||||
|
||||
}
|
||||
|
||||
/* Get all QSOs with a valid grid for use in the KML export */
|
||||
|
|
@ -2488,6 +2544,10 @@ class Logbook_model extends CI_Model {
|
|||
|
||||
// Show all QSOs we need to send to eQSL
|
||||
function eqsl_not_yet_sent() {
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
|
||||
$this->db->select('station_profile.*, '.$this->config->item('table_name').'.COL_PRIMARY_KEY, '.$this->config->item('table_name').'.COL_TIME_ON, '.$this->config->item('table_name').'.COL_CALL, '.$this->config->item('table_name').'.COL_MODE, '.$this->config->item('table_name').'.COL_SUBMODE, '.$this->config->item('table_name').'.COL_BAND, '.$this->config->item('table_name').'.COL_COMMENT, '.$this->config->item('table_name').'.COL_RST_SENT, '.$this->config->item('table_name').'.COL_PROP_MODE, '.$this->config->item('table_name').'.COL_SAT_NAME, '.$this->config->item('table_name').'.COL_SAT_MODE, '.$this->config->item('table_name').'.COL_QSLMSG');
|
||||
$this->db->from('station_profile');
|
||||
$this->db->join($this->config->item('table_name'),'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
|
||||
|
|
@ -2500,6 +2560,7 @@ class Logbook_model extends CI_Model {
|
|||
$this->db->or_where($this->config->item('table_name').'.COL_EQSL_QSL_SENT', 'Q');
|
||||
$this->db->or_where($this->config->item('table_name').'.COL_EQSL_QSL_SENT', 'N');
|
||||
$this->db->group_end();
|
||||
$this->db->where_in('station_profile.station_id', $logbooks_locations_array);
|
||||
|
||||
return $this->db->get();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ class LotwCert extends CI_Model {
|
|||
$this->db->insert('lotw_certs', $data);
|
||||
}
|
||||
|
||||
function update_certficiate($user_id, $callsign, $dxcc, $date_created, $date_expires, $cert_key, $general_cert) {
|
||||
function update_certificate($user_id, $callsign, $dxcc, $date_created, $date_expires, $cert_key, $general_cert) {
|
||||
$data = array(
|
||||
'cert_dxcc' => $dxcc,
|
||||
'date_created' => $date_created,
|
||||
|
|
@ -67,7 +67,7 @@ class LotwCert extends CI_Model {
|
|||
$this->db->update('lotw_certs', $data);
|
||||
}
|
||||
|
||||
function delete_certficiate($user_id, $lotw_cert_id) {
|
||||
function delete_certificate($user_id, $lotw_cert_id) {
|
||||
$this->db->where('lotw_cert_id', $lotw_cert_id);
|
||||
$this->db->where('user_id', $user_id);
|
||||
$this->db->delete('lotw_certs');
|
||||
|
|
|
|||
|
|
@ -353,12 +353,13 @@ class Stations extends CI_Model {
|
|||
SELECT qsos.station_id, COUNT(qsos.COL_PRIMARY_KEY) c
|
||||
FROM %s qsos
|
||||
LEFT JOIN webadif ON qsos.COL_PRIMARY_KEY = webadif.qso_id
|
||||
WHERE webadif.qso_id IS NULL
|
||||
WHERE webadif.qso_id IS NULL AND qsos.COL_SAT_NAME = 'QO-100'
|
||||
GROUP BY qsos.station_id
|
||||
) notc ON station_profile.station_id = notc.station_id
|
||||
INNER JOIN (
|
||||
SELECT qsos.station_id, COUNT(qsos.COL_PRIMARY_KEY) c
|
||||
FROM %s qsos
|
||||
WHERE qsos.COL_SAT_NAME = 'QO-100'
|
||||
GROUP BY qsos.station_id
|
||||
) totc ON station_profile.station_id = totc.station_id
|
||||
WHERE COALESCE(station_profile.webadifapikey, '') <> ''
|
||||
|
|
|
|||
|
|
@ -544,13 +544,29 @@ document.onkeyup = function(e) {
|
|||
|
||||
function newpath(latlng1, latlng2, locator1, locator2) {
|
||||
// If map is already initialized
|
||||
var container = L.DomUtil.get('mapqrb');
|
||||
var container = L.DomUtil.get('mapqrbcontainer');
|
||||
|
||||
if(container != null){
|
||||
container._leaflet_id = null;
|
||||
container.remove();
|
||||
$("#mapqrb").append('<div id="mapqrbcontainer" style="Height: 500px"></div>');
|
||||
}
|
||||
|
||||
var map = new L.Map('mapqrbcontainer', {
|
||||
fullscreenControl: true,
|
||||
fullscreenControlOptions: {
|
||||
position: 'topleft'
|
||||
},
|
||||
}).setView([30, 0], 1.5);
|
||||
|
||||
// Need to fix so that marker is placed at same place as end of line, but this only needs to be done when longitude is < -170
|
||||
if (latlng2[1] < -170) {
|
||||
latlng2[1] = parseFloat(latlng2[1])+360;
|
||||
}
|
||||
if (latlng1[1] < -170) {
|
||||
latlng1[1] = parseFloat(latlng1[1])+360;
|
||||
}
|
||||
|
||||
const map = new L.map('mapqrb').setView([30, 0], 1.5);
|
||||
map.fitBounds([
|
||||
[latlng1[0], latlng1[1]],
|
||||
[latlng2[0], latlng2[1]]
|
||||
|
|
@ -570,6 +586,7 @@ function newpath(latlng1, latlng2, locator1, locator2) {
|
|||
map.addLayer(osm);
|
||||
|
||||
var marker = L.marker([latlng1[0], latlng1[1]], {closeOnClick: false, autoClose: false}).addTo(map).bindPopup(locator1);
|
||||
|
||||
var marker2 = L.marker([latlng2[0], latlng2[1]], {closeOnClick: false, autoClose: false}).addTo(map).bindPopup(locator2);
|
||||
|
||||
const multiplelines = [];
|
||||
|
|
|
|||
|
|
@ -22,4 +22,4 @@
|
|||
</div>
|
||||
</form>
|
||||
<div class="qrbResult"></div>
|
||||
<div id="mapqrb" style="Height: 500px"></div>
|
||||
<div id="mapqrb"><div id="mapqrbcontainer" style="Height: 500px"></div></div>
|
||||
|
|
@ -57,7 +57,7 @@
|
|||
<div class="alert alert-danger">
|
||||
None of your Logbooks are configured to export data to the QO-100 Dx Club's API.<br />
|
||||
To configure this feature, go to your profile page at the <a href="https://qo100dx.club" target="_blank">QO-100 Dx Club</a> and <strong>Create</strong> an API key.
|
||||
Then, navigate to your <a href="<?php echo site_url('stations');?>">Station Locations</a> and configure you station with the key you have created at the club.
|
||||
Then, navigate to your <a href="<?php echo site_url('station');?>">Station Locations</a> and configure you station with the key you have created at the club.
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,8 +95,13 @@ document.onkeyup = function (e) {
|
|||
// CTRL-Enter logs QSO
|
||||
} else if ((e.keyCode == 10 || e.keyCode == 13) && (e.ctrlKey || e.metaKey)) {
|
||||
logQso();
|
||||
// Enter in sent exchange logs QSO
|
||||
} else if ((e.which == 13) && ($(document.activeElement).attr("id") == "exch_rcvd")) {
|
||||
// Enter in received exchange logs QSO
|
||||
} else if ((e.which == 13) && (
|
||||
($(document.activeElement).attr("id") == "exch_rcvd")
|
||||
|| ($(document.activeElement).attr("id") == "exch_gridsquare_r")
|
||||
|| ($(document.activeElement).attr("id") == "exch_serial_r")
|
||||
)
|
||||
) {
|
||||
logQso();
|
||||
} else if (e.which == 27) {
|
||||
reset_log_fields();
|
||||
|
|
|
|||
正在加载…
在新工单中引用