当前提交
d348f175ae
共有 6 个文件被更改,包括 289 次插入 和 272 次删除
|
|
@ -198,6 +198,9 @@ case 'finnish':
|
||||||
case 'russian':
|
case 'russian':
|
||||||
$config['language'] = $lang;
|
$config['language'] = $lang;
|
||||||
break;
|
break;
|
||||||
|
case 'portuguese':
|
||||||
|
$config['language'] = $lang;
|
||||||
|
break;
|
||||||
case 'english':
|
case 'english':
|
||||||
$config['language'] = $lang;
|
$config['language'] = $lang;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||||
|
|
||||||
class adif extends CI_Controller {
|
class adif extends CI_Controller
|
||||||
|
{
|
||||||
|
|
||||||
/* Controls ADIF Import/Export Functions */
|
/* Controls ADIF Import/Export Functions */
|
||||||
|
|
||||||
|
|
@ -10,11 +11,15 @@ class adif extends CI_Controller {
|
||||||
$this->load->helper(array('form', 'url'));
|
$this->load->helper(array('form', 'url'));
|
||||||
|
|
||||||
$this->load->model('user_model');
|
$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'); }
|
if (!$this->user_model->authorize(2)) {
|
||||||
|
$this->session->set_flashdata('notice', 'You\'re not allowed to do that!');
|
||||||
|
redirect('dashboard');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Shows Export Views */
|
/* Shows Export Views */
|
||||||
public function export() {
|
public function export()
|
||||||
|
{
|
||||||
|
|
||||||
$data['page_title'] = "ADIF Export";
|
$data['page_title'] = "ADIF Export";
|
||||||
|
|
||||||
|
|
@ -65,7 +70,8 @@ class adif extends CI_Controller {
|
||||||
$this->load->view('adif/data/exportsat', $data);
|
$this->load->view('adif/data/exportsat', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function export_custom() {
|
public function export_custom()
|
||||||
|
{
|
||||||
// Set memory limit to unlimited to allow heavy usage
|
// Set memory limit to unlimited to allow heavy usage
|
||||||
ini_set('memory_limit', '-1');
|
ini_set('memory_limit', '-1');
|
||||||
|
|
||||||
|
|
@ -74,10 +80,10 @@ class adif extends CI_Controller {
|
||||||
$station_id = $this->security->xss_clean($this->input->post('station_profile'));
|
$station_id = $this->security->xss_clean($this->input->post('station_profile'));
|
||||||
|
|
||||||
// Used for exporting QSOs not previously exported to LoTW
|
// Used for exporting QSOs not previously exported to LoTW
|
||||||
if ($this->input->post('exportLotw') == 1) {
|
if ($this->input->post('exportLotw') == 1) {
|
||||||
$exportLotw = true;
|
$exportLotw = true;
|
||||||
} else {
|
} else {
|
||||||
$exportLotw = false;
|
$exportLotw = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data['qsos'] = $this->adif_data->export_custom($this->input->post('from'), $this->input->post('to'), $station_id, $exportLotw);
|
$data['qsos'] = $this->adif_data->export_custom($this->input->post('from'), $this->input->post('to'), $station_id, $exportLotw);
|
||||||
|
|
@ -87,29 +93,28 @@ class adif extends CI_Controller {
|
||||||
|
|
||||||
|
|
||||||
if ($this->input->post('markLotw') == 1) {
|
if ($this->input->post('markLotw') == 1) {
|
||||||
foreach ($data['qsos']->result() as $qso)
|
foreach ($data['qsos']->result() as $qso) {
|
||||||
{
|
$this->adif_data->mark_lotw_sent($qso->COL_PRIMARY_KEY);
|
||||||
$this->adif_data->mark_lotw_sent($qso->COL_PRIMARY_KEY);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public function mark_lotw() {
|
public function mark_lotw()
|
||||||
// Set memory limit to unlimited to allow heavy usage
|
{
|
||||||
ini_set('memory_limit', '-1');
|
// Set memory limit to unlimited to allow heavy usage
|
||||||
|
ini_set('memory_limit', '-1');
|
||||||
|
|
||||||
$station_id = $this->security->xss_clean($this->input->post('station_profile'));
|
$station_id = $this->security->xss_clean($this->input->post('station_profile'));
|
||||||
$this->load->model('adif_data');
|
$this->load->model('adif_data');
|
||||||
|
|
||||||
$data['qsos'] = $this->adif_data->export_custom($this->input->post('from'), $this->input->post('to'), $station_id);
|
$data['qsos'] = $this->adif_data->export_custom($this->input->post('from'), $this->input->post('to'), $station_id);
|
||||||
|
|
||||||
foreach ($data['qsos']->result() as $qso)
|
foreach ($data['qsos']->result() as $qso) {
|
||||||
{
|
$this->adif_data->mark_lotw_sent($qso->COL_PRIMARY_KEY);
|
||||||
$this->adif_data->mark_lotw_sent($qso->COL_PRIMARY_KEY);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$this->load->view('adif/mark_lotw', $data);
|
$this->load->view('adif/mark_lotw', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function export_lotw()
|
public function export_lotw()
|
||||||
{
|
{
|
||||||
|
|
@ -122,21 +127,21 @@ class adif extends CI_Controller {
|
||||||
|
|
||||||
$this->load->view('adif/data/exportall', $data);
|
$this->load->view('adif/data/exportall', $data);
|
||||||
|
|
||||||
foreach ($data['qsos']->result() as $qso)
|
foreach ($data['qsos']->result() as $qso) {
|
||||||
{
|
|
||||||
$this->adif_data->mark_lotw_sent($qso->COL_PRIMARY_KEY);
|
$this->adif_data->mark_lotw_sent($qso->COL_PRIMARY_KEY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index() {
|
public function index()
|
||||||
|
{
|
||||||
$this->load->model('stations');
|
$this->load->model('stations');
|
||||||
|
|
||||||
$data['page_title'] = "ADIF Import / Export";
|
$data['page_title'] = "ADIF Import / Export";
|
||||||
$data['max_upload'] = ini_get('upload_max_filesize');
|
$data['max_upload'] = ini_get('upload_max_filesize');
|
||||||
|
|
||||||
$data['station_profile'] = $this->stations->all_of_user();
|
$data['station_profile'] = $this->stations->all_of_user();
|
||||||
$active_station_id = $this->stations->find_active();
|
$active_station_id = $this->stations->find_active();
|
||||||
$station_profile = $this->stations->profile($active_station_id);
|
$station_profile = $this->stations->profile($active_station_id);
|
||||||
|
|
||||||
$data['active_station_info'] = $station_profile->row();
|
$data['active_station_info'] = $station_profile->row();
|
||||||
|
|
||||||
|
|
@ -145,13 +150,14 @@ class adif extends CI_Controller {
|
||||||
$this->load->view('interface_assets/footer');
|
$this->load->view('interface_assets/footer');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function import() {
|
public function import()
|
||||||
|
{
|
||||||
$this->load->model('stations');
|
$this->load->model('stations');
|
||||||
$data['station_profile'] = $this->stations->all_of_user();
|
$data['station_profile'] = $this->stations->all_of_user();
|
||||||
log_message("debug","Started ADIF Import");
|
log_message("debug", "Started ADIF Import");
|
||||||
|
|
||||||
$active_station_id = $this->stations->find_active();
|
$active_station_id = $this->stations->find_active();
|
||||||
$station_profile = $this->stations->profile($active_station_id);
|
$station_profile = $this->stations->profile($active_station_id);
|
||||||
|
|
||||||
$data['active_station_info'] = $station_profile->row();
|
$data['active_station_info'] = $station_profile->row();
|
||||||
|
|
||||||
|
|
@ -163,7 +169,7 @@ class adif extends CI_Controller {
|
||||||
|
|
||||||
$this->load->library('upload', $config);
|
$this->load->library('upload', $config);
|
||||||
|
|
||||||
if ( ! $this->upload->do_upload()) {
|
if (! $this->upload->do_upload()) {
|
||||||
$data['error'] = $this->upload->display_errors();
|
$data['error'] = $this->upload->display_errors();
|
||||||
|
|
||||||
$data['max_upload'] = ini_get('upload_max_filesize');
|
$data['max_upload'] = ini_get('upload_max_filesize');
|
||||||
|
|
@ -181,39 +187,38 @@ class adif extends CI_Controller {
|
||||||
|
|
||||||
$this->load->library('adif_parser');
|
$this->load->library('adif_parser');
|
||||||
|
|
||||||
$this->adif_parser->load_from_file('./uploads/'.$data['upload_data']['file_name']);
|
$this->adif_parser->load_from_file('./uploads/' . $data['upload_data']['file_name']);
|
||||||
unlink('./uploads/'.$data['upload_data']['file_name']);
|
unlink('./uploads/' . $data['upload_data']['file_name']);
|
||||||
$data['upload_data']=''; // free memory
|
$data['upload_data'] = ''; // free memory
|
||||||
|
|
||||||
$this->adif_parser->initialize();
|
$this->adif_parser->initialize();
|
||||||
$custom_errors = "";
|
$custom_errors = "";
|
||||||
$alladif=[];
|
$alladif = [];
|
||||||
while($record = $this->adif_parser->get_record())
|
while ($record = $this->adif_parser->get_record()) {
|
||||||
{
|
if (count($record) == 0) {
|
||||||
if(count($record) == 0) {
|
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
array_push($alladif,$record);
|
array_push($alladif, $record);
|
||||||
};
|
};
|
||||||
$record=''; // free memory
|
$record = ''; // free memory
|
||||||
$custom_errors = $this->logbook_model->import_bulk($alladif, $this->input->post('station_profile'), $this->input->post('skipDuplicate'), $this->input->post('markClublog'),$this->input->post('markLotw'), $this->input->post('dxccAdif'), $this->input->post('markQrz'), $this->input->post('markHrd'), true, $this->input->post('operatorName'), false, $this->input->post('skipStationCheck'));
|
$custom_errors = $this->logbook_model->import_bulk($alladif, $this->input->post('station_profile'), $this->input->post('skipDuplicate'), $this->input->post('markClublog'), $this->input->post('markLotw'), $this->input->post('dxccAdif'), $this->input->post('markQrz'), $this->input->post('markHrd'), true, $this->input->post('operatorName'), false, $this->input->post('skipStationCheck'));
|
||||||
} else {
|
} else {
|
||||||
$custom_errors='Station Profile not valid for User';
|
$custom_errors = 'Station Profile not valid for User';
|
||||||
}
|
}
|
||||||
|
|
||||||
$data['adif_errors'] = $custom_errors;
|
$data['adif_errors'] = $custom_errors;
|
||||||
$data['skip_dupes'] = $this->input->post('skipDuplicate');
|
$data['skip_dupes'] = $this->input->post('skipDuplicate');
|
||||||
|
|
||||||
log_message("debug","Finished ADIF Import");
|
log_message("debug", "Finished ADIF Import");
|
||||||
$data['page_title'] = "ADIF Imported";
|
$data['page_title'] = "ADIF Imported";
|
||||||
$this->load->view('interface_assets/header', $data);
|
$this->load->view('interface_assets/header', $data);
|
||||||
$this->load->view('adif/import_success');
|
$this->load->view('adif/import_success');
|
||||||
$this->load->view('interface_assets/footer');
|
$this->load->view('interface_assets/footer');
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dcl() {
|
public function dcl()
|
||||||
|
{
|
||||||
$this->load->model('stations');
|
$this->load->model('stations');
|
||||||
$data['station_profile'] = $this->stations->all_of_user();
|
$data['station_profile'] = $this->stations->all_of_user();
|
||||||
|
|
||||||
|
|
@ -225,7 +230,7 @@ class adif extends CI_Controller {
|
||||||
|
|
||||||
$this->load->library('upload', $config);
|
$this->load->library('upload', $config);
|
||||||
|
|
||||||
if ( ! $this->upload->do_upload()) {
|
if (! $this->upload->do_upload()) {
|
||||||
$data['error'] = $this->upload->display_errors();
|
$data['error'] = $this->upload->display_errors();
|
||||||
|
|
||||||
$data['max_upload'] = ini_get('upload_max_filesize');
|
$data['max_upload'] = ini_get('upload_max_filesize');
|
||||||
|
|
@ -243,34 +248,33 @@ class adif extends CI_Controller {
|
||||||
|
|
||||||
$this->load->library('adif_parser');
|
$this->load->library('adif_parser');
|
||||||
|
|
||||||
$this->adif_parser->load_from_file('./uploads/'.$data['upload_data']['file_name']);
|
$this->adif_parser->load_from_file('./uploads/' . $data['upload_data']['file_name']);
|
||||||
|
|
||||||
$this->adif_parser->initialize();
|
$this->adif_parser->initialize();
|
||||||
$error_count = array(0, 0, 0);
|
$error_count = array(0, 0, 0);
|
||||||
$custom_errors = "";
|
$custom_errors = "";
|
||||||
while($record = $this->adif_parser->get_record())
|
while ($record = $this->adif_parser->get_record()) {
|
||||||
{
|
if (count($record) == 0) {
|
||||||
if(count($record) == 0) {
|
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
|
|
||||||
$dok_result = $this->logbook_model->update_dok($record, $this->input->post('ignoreAmbiguous'), $this->input->post('onlyConfirmed'), $this->input->post('overwriteDok'));
|
$dok_result = $this->logbook_model->update_dok($record, $this->input->post('ignoreAmbiguous'), $this->input->post('onlyConfirmed'), $this->input->post('overwriteDok'));
|
||||||
if (!empty($dok_result)) {
|
if (!empty($dok_result)) {
|
||||||
switch ($dok_result[0]) {
|
switch ($dok_result[0]) {
|
||||||
case 0:
|
case 0:
|
||||||
$error_count[0]++;
|
$error_count[0]++;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
$custom_errors .= $dok_result[1];
|
$custom_errors .= $dok_result[1];
|
||||||
$error_count[1]++;
|
$error_count[1]++;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
$custom_errors .= $dok_result[1];
|
$custom_errors .= $dok_result[1];
|
||||||
$error_count[2]++;
|
$error_count[2]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
unlink('./uploads/'.$data['upload_data']['file_name']);
|
unlink('./uploads/' . $data['upload_data']['file_name']);
|
||||||
$data['dcl_error_count'] = $error_count;
|
$data['dcl_error_count'] = $error_count;
|
||||||
$data['dcl_errors'] = $custom_errors;
|
$data['dcl_errors'] = $custom_errors;
|
||||||
$data['page_title'] = "DCL Data Imported";
|
$data['page_title'] = "DCL Data Imported";
|
||||||
|
|
@ -278,7 +282,7 @@ class adif extends CI_Controller {
|
||||||
$this->load->view('adif/dcl_success');
|
$this->load->view('adif/dcl_success');
|
||||||
$this->load->view('interface_assets/footer');
|
$this->load->view('interface_assets/footer');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file adif.php */
|
/* End of file adif.php */
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||||
|
|
||||||
class API extends CI_Controller {
|
class API extends CI_Controller
|
||||||
|
{
|
||||||
|
|
||||||
// Do absolutely nothing
|
// Do absolutely nothing
|
||||||
function index()
|
function index()
|
||||||
|
|
@ -14,7 +15,7 @@ class API extends CI_Controller {
|
||||||
|
|
||||||
// Check if users logged in
|
// Check if users logged in
|
||||||
|
|
||||||
if($this->user_model->validate_session() == 0) {
|
if ($this->user_model->validate_session() == 0) {
|
||||||
// user is not logged in
|
// user is not logged in
|
||||||
redirect('user/login');
|
redirect('user/login');
|
||||||
}
|
}
|
||||||
|
|
@ -31,12 +32,13 @@ class API extends CI_Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function edit($key) {
|
function edit($key)
|
||||||
|
{
|
||||||
$this->load->model('user_model');
|
$this->load->model('user_model');
|
||||||
|
|
||||||
// Check if users logged in
|
// Check if users logged in
|
||||||
|
|
||||||
if($this->user_model->validate_session() == 0) {
|
if ($this->user_model->validate_session() == 0) {
|
||||||
// user is not logged in
|
// user is not logged in
|
||||||
redirect('user/login');
|
redirect('user/login');
|
||||||
}
|
}
|
||||||
|
|
@ -45,40 +47,37 @@ class API extends CI_Controller {
|
||||||
|
|
||||||
$this->load->helper(array('form', 'url'));
|
$this->load->helper(array('form', 'url'));
|
||||||
|
|
||||||
$this->load->library('form_validation');
|
$this->load->library('form_validation');
|
||||||
|
|
||||||
$this->form_validation->set_rules('api_desc', 'API Description', 'required');
|
$this->form_validation->set_rules('api_desc', 'API Description', 'required');
|
||||||
$this->form_validation->set_rules('api_key', 'API Key is required do not change this field', 'required');
|
$this->form_validation->set_rules('api_key', 'API Key is required do not change this field', 'required');
|
||||||
|
|
||||||
$data['api_info'] = $this->api_model->key_description($key);
|
$data['api_info'] = $this->api_model->key_description($key);
|
||||||
|
|
||||||
if ($this->form_validation->run() == FALSE)
|
if ($this->form_validation->run() == FALSE) {
|
||||||
{
|
$data['page_title'] = "Edit API Description";
|
||||||
$data['page_title'] = "Edit API Description";
|
|
||||||
|
|
||||||
$this->load->view('interface_assets/header', $data);
|
$this->load->view('interface_assets/header', $data);
|
||||||
$this->load->view('api/description');
|
$this->load->view('api/description');
|
||||||
$this->load->view('interface_assets/footer');
|
$this->load->view('interface_assets/footer');
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// Success!
|
// Success!
|
||||||
|
|
||||||
$this->api_model->update_key_description($this->input->post('api_key'), $this->input->post('api_desc'));
|
$this->api_model->update_key_description($this->input->post('api_key'), $this->input->post('api_desc'));
|
||||||
|
|
||||||
$this->session->set_flashdata('notice', 'API Key <b>'.$this->input->post('api_key')."</b> description has been updated.");
|
$this->session->set_flashdata('notice', 'API Key <b>' . $this->input->post('api_key') . "</b> description has been updated.");
|
||||||
|
|
||||||
redirect('api/help');
|
redirect('api/help');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function generate($rights) {
|
function generate($rights)
|
||||||
|
{
|
||||||
$this->load->model('user_model');
|
$this->load->model('user_model');
|
||||||
|
|
||||||
// Check if users logged in
|
// Check if users logged in
|
||||||
|
|
||||||
if($this->user_model->validate_session() == 0) {
|
if ($this->user_model->validate_session() == 0) {
|
||||||
// user is not logged in
|
// user is not logged in
|
||||||
redirect('user/login');
|
redirect('user/login');
|
||||||
}
|
}
|
||||||
|
|
@ -91,12 +90,13 @@ class API extends CI_Controller {
|
||||||
redirect('api/help');
|
redirect('api/help');
|
||||||
}
|
}
|
||||||
|
|
||||||
function delete($key) {
|
function delete($key)
|
||||||
|
{
|
||||||
$this->load->model('user_model');
|
$this->load->model('user_model');
|
||||||
|
|
||||||
// Check if users logged in
|
// Check if users logged in
|
||||||
|
|
||||||
if($this->user_model->validate_session() == 0) {
|
if ($this->user_model->validate_session() == 0) {
|
||||||
// user is not logged in
|
// user is not logged in
|
||||||
redirect('user/login');
|
redirect('user/login');
|
||||||
}
|
}
|
||||||
|
|
@ -106,31 +106,33 @@ class API extends CI_Controller {
|
||||||
|
|
||||||
$this->api_model->delete_key($key);
|
$this->api_model->delete_key($key);
|
||||||
|
|
||||||
$this->session->set_flashdata('notice', 'API Key <b>'.$key."</b> has been deleted");
|
$this->session->set_flashdata('notice', 'API Key <b>' . $key . "</b> has been deleted");
|
||||||
|
|
||||||
redirect('api/help');
|
redirect('api/help');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Example of authing
|
// Example of authing
|
||||||
function auth($key) {
|
function auth($key)
|
||||||
|
{
|
||||||
$this->load->model('api_model');
|
$this->load->model('api_model');
|
||||||
header("Content-type: text/xml");
|
header("Content-type: text/xml");
|
||||||
if($this->api_model->access($key) == "No Key Found" || $this->api_model->access($key) == "Key Disabled") {
|
if ($this->api_model->access($key) == "No Key Found" || $this->api_model->access($key) == "Key Disabled") {
|
||||||
echo "<auth>";
|
echo "<auth>";
|
||||||
echo "<message>Key Invalid - either not found or disabled</message>";
|
echo "<message>Key Invalid - either not found or disabled</message>";
|
||||||
echo "</auth>";
|
echo "</auth>";
|
||||||
} else {
|
} else {
|
||||||
echo "<auth>";
|
echo "<auth>";
|
||||||
echo "<status>Valid</status>";
|
echo "<status>Valid</status>";
|
||||||
echo "<rights>".$this->api_model->access($key)."</rights>";
|
echo "<rights>" . $this->api_model->access($key) . "</rights>";
|
||||||
echo "</auth>";
|
echo "</auth>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_auth($key) {
|
function check_auth($key)
|
||||||
|
{
|
||||||
$this->load->model('api_model');
|
$this->load->model('api_model');
|
||||||
header("Content-type: text/xml");
|
header("Content-type: text/xml");
|
||||||
if($this->api_model->access($key) == "No Key Found" || $this->api_model->access($key) == "Key Disabled") {
|
if ($this->api_model->access($key) == "No Key Found" || $this->api_model->access($key) == "Key Disabled") {
|
||||||
// set the content type as json
|
// set the content type as json
|
||||||
header("Content-type: application/json");
|
header("Content-type: application/json");
|
||||||
|
|
||||||
|
|
@ -150,23 +152,24 @@ class API extends CI_Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function station_info($key) {
|
function station_info($key)
|
||||||
|
{
|
||||||
$this->load->model('api_model');
|
$this->load->model('api_model');
|
||||||
$this->load->model('stations');
|
$this->load->model('stations');
|
||||||
header("Content-type: application/json");
|
header("Content-type: application/json");
|
||||||
if(substr($this->api_model->access($key),0,1) == 'r') { /* Checkpermission for _r_eading */
|
if (substr($this->api_model->access($key), 0, 1) == 'r') { /* Checkpermission for _r_eading */
|
||||||
$this->api_model->update_last_used($key);
|
$this->api_model->update_last_used($key);
|
||||||
$userid = $this->api_model->key_userid($key);
|
$userid = $this->api_model->key_userid($key);
|
||||||
$station_ids = array();
|
$station_ids = array();
|
||||||
$stations=$this->stations->all_of_user($userid);
|
$stations = $this->stations->all_of_user($userid);
|
||||||
foreach ($stations->result() as $row) {
|
foreach ($stations->result() as $row) {
|
||||||
$result['station_id']=$row->station_id;
|
$result['station_id'] = $row->station_id;
|
||||||
$result['station_profile_name']=$row->station_profile_name;
|
$result['station_profile_name'] = $row->station_profile_name;
|
||||||
$result['station_gridsquare']=$row->station_gridsquare;
|
$result['station_gridsquare'] = $row->station_gridsquare;
|
||||||
$result['station_callsign']=$row->station_callsign;;
|
$result['station_callsign'] = $row->station_callsign;;
|
||||||
$result['station_active']=$row->station_active;
|
$result['station_active'] = $row->station_active;
|
||||||
array_push($station_ids, $result);
|
array_push($station_ids, $result);
|
||||||
}
|
}
|
||||||
echo json_encode($station_ids);
|
echo json_encode($station_ids);
|
||||||
} else {
|
} else {
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
|
|
@ -175,12 +178,13 @@ class API extends CI_Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Function: QSO
|
* Function: QSO
|
||||||
* Task: allows passing of ADIF data to Cloudlog
|
* Task: allows passing of ADIF data to Cloudlog
|
||||||
*/
|
*/
|
||||||
function qso() {
|
function qso()
|
||||||
|
{
|
||||||
header('Content-type: application/json');
|
header('Content-type: application/json');
|
||||||
|
|
||||||
$this->load->model('api_model');
|
$this->load->model('api_model');
|
||||||
|
|
@ -194,29 +198,29 @@ class API extends CI_Controller {
|
||||||
$obj = json_decode(file_get_contents("php://input"), true);
|
$obj = json_decode(file_get_contents("php://input"), true);
|
||||||
if ($obj === NULL) {
|
if ($obj === NULL) {
|
||||||
// Decoding not valid try simple www-x-form-urlencoded
|
// Decoding not valid try simple www-x-form-urlencoded
|
||||||
$objTmp = file_get_contents("php://input");
|
$objTmp = file_get_contents("php://input");
|
||||||
parse_str($objTmp, $obj);
|
parse_str($objTmp, $obj);
|
||||||
if ($obj === NULL) {
|
if ($obj === NULL) {
|
||||||
echo json_encode(['status' => 'failed', 'reason' => "wrong JSON"]);
|
echo json_encode(['status' => 'failed', 'reason' => "wrong JSON"]);
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isset($obj['key']) || $this->api_model->authorize($obj['key']) == 0) {
|
if (!isset($obj['key']) || $this->api_model->authorize($obj['key']) == 0) {
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
echo json_encode(['status' => 'failed', 'reason' => "missing api key"]);
|
echo json_encode(['status' => 'failed', 'reason' => "missing api key"]);
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
$userid = $this->api_model->key_userid($obj['key']);
|
$userid = $this->api_model->key_userid($obj['key']);
|
||||||
|
|
||||||
if(!isset($obj['station_profile_id']) || $this->stations->check_station_against_user($obj['station_profile_id'], $userid) == false) {
|
if (!isset($obj['station_profile_id']) || $this->stations->check_station_against_user($obj['station_profile_id'], $userid) == false) {
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
echo json_encode(['status' => 'failed', 'reason' => "station id does not belong to the API key owner."]);
|
echo json_encode(['status' => 'failed', 'reason' => "station id does not belong to the API key owner."]);
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
if($obj['type'] == "adif" && $obj['string'] != "") {
|
if ($obj['type'] == "adif" && $obj['string'] != "") {
|
||||||
// Load the logbook model for adding QSO records
|
// Load the logbook model for adding QSO records
|
||||||
$this->load->model('logbook_model');
|
$this->load->model('logbook_model');
|
||||||
|
|
||||||
|
|
@ -227,22 +231,20 @@ class API extends CI_Controller {
|
||||||
$this->adif_parser->feed($obj['string']);
|
$this->adif_parser->feed($obj['string']);
|
||||||
|
|
||||||
// Create QSO Record
|
// Create QSO Record
|
||||||
while($record = $this->adif_parser->get_record())
|
while ($record = $this->adif_parser->get_record()) {
|
||||||
{
|
if (count($record) == 0) {
|
||||||
if(count($record) == 0)
|
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
if(isset($obj['station_profile_id'])) {
|
if (isset($obj['station_profile_id'])) {
|
||||||
if(isset($record['station_callsign']) && $this->stations->check_station_against_callsign($obj['station_profile_id'], $record['station_callsign']) == false) {
|
if (isset($record['station_callsign']) && $this->stations->check_station_against_callsign($obj['station_profile_id'], $record['station_callsign']) == false) {
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
echo json_encode(['status' => 'failed', 'reason' => "station callsign does not match station callsign in station profile."]);
|
echo json_encode(['status' => 'failed', 'reason' => "station callsign does not match station callsign in station profile."]);
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!(isset($record['call'])) || (trim($record['call']) == '')) {
|
if (!(isset($record['call'])) || (trim($record['call']) == '')) {
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
echo json_encode(['status' => 'failed', 'reason' => "QSO Call is empty."]);
|
echo json_encode(['status' => 'failed', 'reason' => "QSO Call is empty."]);
|
||||||
die();
|
die();
|
||||||
|
|
@ -252,23 +254,21 @@ class API extends CI_Controller {
|
||||||
|
|
||||||
$msg = $this->logbook_model->import($record, $obj['station_profile_id'], NULL, NULL, NULL, NULL, NULL, NULL, false, false, true);
|
$msg = $this->logbook_model->import($record, $obj['station_profile_id'], NULL, NULL, NULL, NULL, NULL, NULL, false, false, true);
|
||||||
|
|
||||||
if ( $msg == "" ) {
|
if ($msg == "") {
|
||||||
$return_count++;
|
$return_count++;
|
||||||
} else {
|
} else {
|
||||||
$return_msg[] = $msg;
|
$return_msg[] = $msg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
http_response_code(201);
|
http_response_code(201);
|
||||||
echo json_encode(['status' => 'created', 'type' => $obj['type'], 'string' => $obj['string'], 'imported_count' => $return_count, 'messages' => $return_msg ]);
|
echo json_encode(['status' => 'created', 'type' => $obj['type'], 'string' => $obj['string'], 'imported_count' => $return_count, 'messages' => $return_msg]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// API function to check if a callsign is in the logbook already
|
// API function to check if a callsign is in the logbook already
|
||||||
function logbook_check_callsign() {
|
function logbook_check_callsign()
|
||||||
|
{
|
||||||
header('Content-type: application/json');
|
header('Content-type: application/json');
|
||||||
|
|
||||||
$this->load->model('api_model');
|
$this->load->model('api_model');
|
||||||
|
|
@ -276,29 +276,29 @@ class API extends CI_Controller {
|
||||||
// Decode JSON and store
|
// Decode JSON and store
|
||||||
$obj = json_decode(file_get_contents("php://input"), true);
|
$obj = json_decode(file_get_contents("php://input"), true);
|
||||||
if ($obj === NULL) {
|
if ($obj === NULL) {
|
||||||
echo json_encode(['status' => 'failed', 'reason' => "wrong JSON"]);
|
echo json_encode(['status' => 'failed', 'reason' => "wrong JSON"]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isset($obj['key']) || $this->api_model->authorize($obj['key']) == 0) {
|
if (!isset($obj['key']) || $this->api_model->authorize($obj['key']) == 0) {
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
echo json_encode(['status' => 'failed', 'reason' => "missing api key"]);
|
echo json_encode(['status' => 'failed', 'reason' => "missing api key"]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isset($obj['logbook_public_slug']) || !isset($obj['callsign'])) {
|
if (!isset($obj['logbook_public_slug']) || !isset($obj['callsign'])) {
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
echo json_encode(['status' => 'failed', 'reason' => "missing fields"]);
|
echo json_encode(['status' => 'failed', 'reason' => "missing fields"]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($obj['logbook_public_slug'] != "" && $obj['callsign'] != "") {
|
if ($obj['logbook_public_slug'] != "" && $obj['callsign'] != "") {
|
||||||
|
|
||||||
$logbook_slug = $obj['logbook_public_slug'];
|
$logbook_slug = $obj['logbook_public_slug'];
|
||||||
$callsign = $obj['callsign'];
|
$callsign = $obj['callsign'];
|
||||||
|
|
||||||
// If $obj['band'] exists
|
// If $obj['band'] exists
|
||||||
if(isset($obj['band'])) {
|
if (isset($obj['band'])) {
|
||||||
$band = $obj['band'];
|
$band = $obj['band'];
|
||||||
} else {
|
} else {
|
||||||
$band = null;
|
$band = null;
|
||||||
|
|
@ -306,13 +306,12 @@ class API extends CI_Controller {
|
||||||
|
|
||||||
$this->load->model('logbooks_model');
|
$this->load->model('logbooks_model');
|
||||||
|
|
||||||
if($this->logbooks_model->public_slug_exists($logbook_slug)) {
|
if ($this->logbooks_model->public_slug_exists($logbook_slug)) {
|
||||||
$logbook_id = $this->logbooks_model->public_slug_exists_logbook_id($logbook_slug);
|
$logbook_id = $this->logbooks_model->public_slug_exists_logbook_id($logbook_slug);
|
||||||
if($logbook_id != false)
|
if ($logbook_id != false) {
|
||||||
{
|
|
||||||
// Get associated station locations for mysql queries
|
// Get associated station locations for mysql queries
|
||||||
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($logbook_id);
|
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($logbook_id);
|
||||||
|
|
||||||
if (!$logbooks_locations_array) {
|
if (!$logbooks_locations_array) {
|
||||||
// Logbook not found
|
// Logbook not found
|
||||||
http_response_code(404);
|
http_response_code(404);
|
||||||
|
|
@ -322,7 +321,7 @@ class API extends CI_Controller {
|
||||||
} else {
|
} else {
|
||||||
// Logbook not found
|
// Logbook not found
|
||||||
http_response_code(404);
|
http_response_code(404);
|
||||||
echo json_encode(['status' => 'failed', 'reason' => $logbook_slug." has no associated station locations"]);
|
echo json_encode(['status' => 'failed', 'reason' => $logbook_slug . " has no associated station locations"]);
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
// Search Logbook for callsign
|
// Search Logbook for callsign
|
||||||
|
|
@ -331,8 +330,7 @@ class API extends CI_Controller {
|
||||||
$result = $this->logbook_model->check_if_callsign_worked_in_logbook($callsign, $logbooks_locations_array, $band);
|
$result = $this->logbook_model->check_if_callsign_worked_in_logbook($callsign, $logbooks_locations_array, $band);
|
||||||
|
|
||||||
http_response_code(201);
|
http_response_code(201);
|
||||||
if($result > 0)
|
if ($result > 0) {
|
||||||
{
|
|
||||||
echo json_encode(['callsign' => $callsign, 'result' => 'Found']);
|
echo json_encode(['callsign' => $callsign, 'result' => 'Found']);
|
||||||
} else {
|
} else {
|
||||||
echo json_encode(['callsign' => $callsign, 'result' => 'Not Found']);
|
echo json_encode(['callsign' => $callsign, 'result' => 'Not Found']);
|
||||||
|
|
@ -343,13 +341,12 @@ class API extends CI_Controller {
|
||||||
echo json_encode(['status' => 'failed', 'reason' => "logbook not found"]);
|
echo json_encode(['status' => 'failed', 'reason' => "logbook not found"]);
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// API function to check if a grid is in the logbook already
|
// API function to check if a grid is in the logbook already
|
||||||
function logbook_check_grid() {
|
function logbook_check_grid()
|
||||||
|
{
|
||||||
header('Content-type: application/json');
|
header('Content-type: application/json');
|
||||||
|
|
||||||
$this->load->model('api_model');
|
$this->load->model('api_model');
|
||||||
|
|
@ -357,27 +354,27 @@ class API extends CI_Controller {
|
||||||
// Decode JSON and store
|
// Decode JSON and store
|
||||||
$obj = json_decode(file_get_contents("php://input"), true);
|
$obj = json_decode(file_get_contents("php://input"), true);
|
||||||
if ($obj === NULL) {
|
if ($obj === NULL) {
|
||||||
echo json_encode(['status' => 'failed', 'reason' => "wrong JSON"]);
|
echo json_encode(['status' => 'failed', 'reason' => "wrong JSON"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isset($obj['key']) || $this->api_model->authorize($obj['key']) == 0) {
|
if (!isset($obj['key']) || $this->api_model->authorize($obj['key']) == 0) {
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
echo json_encode(['status' => 'failed', 'reason' => "missing api key"]);
|
echo json_encode(['status' => 'failed', 'reason' => "missing api key"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isset($obj['logbook_public_slug']) || !isset($obj['grid'])) {
|
if (!isset($obj['logbook_public_slug']) || !isset($obj['grid'])) {
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
echo json_encode(['status' => 'failed', 'reason' => "missing fields"]);
|
echo json_encode(['status' => 'failed', 'reason' => "missing fields"]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($obj['logbook_public_slug'] != "" && $obj['grid'] != "") {
|
if ($obj['logbook_public_slug'] != "" && $obj['grid'] != "") {
|
||||||
|
|
||||||
$logbook_slug = $obj['logbook_public_slug'];
|
$logbook_slug = $obj['logbook_public_slug'];
|
||||||
$grid = $obj['grid'];
|
$grid = $obj['grid'];
|
||||||
|
|
||||||
// If $obj['band'] exists
|
// If $obj['band'] exists
|
||||||
if(isset($obj['band'])) {
|
if (isset($obj['band'])) {
|
||||||
$band = $obj['band'];
|
$band = $obj['band'];
|
||||||
} else {
|
} else {
|
||||||
$band = null;
|
$band = null;
|
||||||
|
|
@ -385,13 +382,12 @@ class API extends CI_Controller {
|
||||||
|
|
||||||
$this->load->model('logbooks_model');
|
$this->load->model('logbooks_model');
|
||||||
|
|
||||||
if($this->logbooks_model->public_slug_exists($logbook_slug)) {
|
if ($this->logbooks_model->public_slug_exists($logbook_slug)) {
|
||||||
$logbook_id = $this->logbooks_model->public_slug_exists_logbook_id($logbook_slug);
|
$logbook_id = $this->logbooks_model->public_slug_exists_logbook_id($logbook_slug);
|
||||||
if($logbook_id != false)
|
if ($logbook_id != false) {
|
||||||
{
|
|
||||||
// Get associated station locations for mysql queries
|
// Get associated station locations for mysql queries
|
||||||
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($logbook_id);
|
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($logbook_id);
|
||||||
|
|
||||||
if (!$logbooks_locations_array) {
|
if (!$logbooks_locations_array) {
|
||||||
// Logbook not found
|
// Logbook not found
|
||||||
http_response_code(404);
|
http_response_code(404);
|
||||||
|
|
@ -401,7 +397,7 @@ class API extends CI_Controller {
|
||||||
} else {
|
} else {
|
||||||
// Logbook not found
|
// Logbook not found
|
||||||
http_response_code(404);
|
http_response_code(404);
|
||||||
echo json_encode(['status' => 'failed', 'reason' => $logbook_slug." has no associated station locations"]);
|
echo json_encode(['status' => 'failed', 'reason' => $logbook_slug . " has no associated station locations"]);
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
// Search Logbook for callsign
|
// Search Logbook for callsign
|
||||||
|
|
@ -410,8 +406,7 @@ class API extends CI_Controller {
|
||||||
$result = $this->logbook_model->check_if_grid_worked_in_logbook($grid, $logbooks_locations_array, $band);
|
$result = $this->logbook_model->check_if_grid_worked_in_logbook($grid, $logbooks_locations_array, $band);
|
||||||
|
|
||||||
http_response_code(201);
|
http_response_code(201);
|
||||||
if($result > 0)
|
if ($result > 0) {
|
||||||
{
|
|
||||||
echo json_encode(['gridsquare' => strtoupper($grid), 'result' => 'Found']);
|
echo json_encode(['gridsquare' => strtoupper($grid), 'result' => 'Found']);
|
||||||
} else {
|
} else {
|
||||||
echo json_encode(['gridsquare' => strtoupper($grid), 'result' => 'Not Found']);
|
echo json_encode(['gridsquare' => strtoupper($grid), 'result' => 'Not Found']);
|
||||||
|
|
@ -422,9 +417,7 @@ class API extends CI_Controller {
|
||||||
echo json_encode(['status' => 'failed', 'reason' => "logbook not found"]);
|
echo json_encode(['status' => 'failed', 'reason' => "logbook not found"]);
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -487,16 +480,16 @@ class API extends CI_Controller {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isset($obj['key']) || $this->api_model->authorize($obj['key']) == 0) {
|
if (!isset($obj['key']) || $this->api_model->authorize($obj['key']) == 0) {
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
echo json_encode(['status' => 'failed', 'reason' => "missing api key"]);
|
echo json_encode(['status' => 'failed', 'reason' => "missing api key"]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isset($obj['logbook_public_slug']) || !isset($obj['callsign'])) {
|
if (!isset($obj['logbook_public_slug']) || !isset($obj['callsign'])) {
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
echo json_encode(['status' => 'failed', 'reason' => "missing fields"]);
|
echo json_encode(['status' => 'failed', 'reason' => "missing fields"]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load models
|
// Load models
|
||||||
|
|
@ -523,10 +516,9 @@ class API extends CI_Controller {
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
if($this->logbooks_model->public_slug_exists($logbook_slug)) {
|
if ($this->logbooks_model->public_slug_exists($logbook_slug)) {
|
||||||
$logbook_id = $this->logbooks_model->public_slug_exists_logbook_id($logbook_slug);
|
$logbook_id = $this->logbooks_model->public_slug_exists_logbook_id($logbook_slug);
|
||||||
if($logbook_id != false)
|
if ($logbook_id != false) {
|
||||||
{
|
|
||||||
// Get associated station locations for mysql queries
|
// Get associated station locations for mysql queries
|
||||||
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($logbook_id);
|
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($logbook_id);
|
||||||
|
|
||||||
|
|
@ -539,7 +531,7 @@ class API extends CI_Controller {
|
||||||
} else {
|
} else {
|
||||||
// Logbook not found
|
// Logbook not found
|
||||||
http_response_code(404);
|
http_response_code(404);
|
||||||
echo json_encode(['status' => 'failed', 'reason' => $logbook_slug." has no associated station locations"]);
|
echo json_encode(['status' => 'failed', 'reason' => $logbook_slug . " has no associated station locations"]);
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -604,7 +596,8 @@ class API extends CI_Controller {
|
||||||
|
|
||||||
/* ENDPOINT for Rig Control */
|
/* ENDPOINT for Rig Control */
|
||||||
|
|
||||||
function radio() {
|
function radio()
|
||||||
|
{
|
||||||
header('Content-type: application/json');
|
header('Content-type: application/json');
|
||||||
|
|
||||||
$this->load->model('api_model');
|
$this->load->model('api_model');
|
||||||
|
|
@ -618,7 +611,7 @@ class API extends CI_Controller {
|
||||||
// Decode JSON and store
|
// Decode JSON and store
|
||||||
$obj = json_decode(file_get_contents("php://input"), true);
|
$obj = json_decode(file_get_contents("php://input"), true);
|
||||||
|
|
||||||
if(!isset($obj['key']) || $this->api_model->authorize($obj['key']) == 0) {
|
if (!isset($obj['key']) || $this->api_model->authorize($obj['key']) == 0) {
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
echo json_encode(['status' => 'failed', 'reason' => "missing api key"]);
|
echo json_encode(['status' => 'failed', 'reason' => "missing api key"]);
|
||||||
die();
|
die();
|
||||||
|
|
@ -636,7 +629,6 @@ class API extends CI_Controller {
|
||||||
$arr = array('status' => 'success');
|
$arr = array('status' => 'success');
|
||||||
|
|
||||||
echo json_encode($arr);
|
echo json_encode($arr);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -645,7 +637,8 @@ class API extends CI_Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function statistics($key = null) {
|
function statistics($key = null)
|
||||||
|
{
|
||||||
header('Content-type: application/json');
|
header('Content-type: application/json');
|
||||||
$this->load->model('logbook_model');
|
$this->load->model('logbook_model');
|
||||||
|
|
||||||
|
|
@ -656,10 +649,10 @@ class API extends CI_Controller {
|
||||||
|
|
||||||
http_response_code(201);
|
http_response_code(201);
|
||||||
echo json_encode(['Today' => $data['todays_qsos'], 'total_qsos' => $data['total_qsos'], 'month_qsos' => $data['month_qsos'], 'year_qsos' => $data['year_qsos']]);
|
echo json_encode(['Today' => $data['todays_qsos'], 'total_qsos' => $data['total_qsos'], 'month_qsos' => $data['month_qsos'], 'year_qsos' => $data['year_qsos']]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function lookup() {
|
function lookup()
|
||||||
|
{
|
||||||
// start benchmarking
|
// start benchmarking
|
||||||
$this->output->enable_profiler(TRUE);
|
$this->output->enable_profiler(TRUE);
|
||||||
/*
|
/*
|
||||||
|
|
@ -679,7 +672,9 @@ class API extends CI_Controller {
|
||||||
|
|
||||||
// Make sure users logged in
|
// Make sure users logged in
|
||||||
$this->load->model('user_model');
|
$this->load->model('user_model');
|
||||||
if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; }
|
if (!$this->user_model->authorize($this->config->item('auth_mode'))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->load->model("logbook_model");
|
$this->load->model("logbook_model");
|
||||||
|
|
@ -711,9 +706,9 @@ class API extends CI_Controller {
|
||||||
* Handle POST data being sent to check lookups
|
* Handle POST data being sent to check lookups
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
$raw_input = json_decode(file_get_contents("php://input"), true);
|
$raw_input = json_decode(file_get_contents("php://input"), true);
|
||||||
|
|
||||||
$lookup_callsign = strtoupper($raw_input['callsign']);
|
$lookup_callsign = strtoupper($raw_input['callsign']);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -721,7 +716,7 @@ class API extends CI_Controller {
|
||||||
* Handle Callsign field
|
* Handle Callsign field
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
$return['callsign'] = $lookup_callsign;
|
$return['callsign'] = $lookup_callsign;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
|
|
@ -729,65 +724,63 @@ class API extends CI_Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$callsign_dxcc_lookup = $this->logbook_model->dxcc_lookup($lookup_callsign, $date);
|
$callsign_dxcc_lookup = $this->logbook_model->dxcc_lookup($lookup_callsign, $date);
|
||||||
|
|
||||||
$last_slash_pos = strrpos($lookup_callsign, '/');
|
$last_slash_pos = strrpos($lookup_callsign, '/');
|
||||||
|
|
||||||
if(isset($last_slash_pos) && $last_slash_pos > 4) {
|
if (isset($last_slash_pos) && $last_slash_pos > 4) {
|
||||||
$suffix_slash = $last_slash_pos === false ? $lookup_callsign : substr($lookup_callsign, $last_slash_pos + 1);
|
$suffix_slash = $last_slash_pos === false ? $lookup_callsign : substr($lookup_callsign, $last_slash_pos + 1);
|
||||||
switch ($suffix_slash) {
|
switch ($suffix_slash) {
|
||||||
case "P":
|
case "P":
|
||||||
$suffix_slash_item = "Portable";
|
$suffix_slash_item = "Portable";
|
||||||
break;
|
break;
|
||||||
case "M":
|
case "M":
|
||||||
$suffix_slash_item = "Mobile";
|
$suffix_slash_item = "Mobile";
|
||||||
case "MM":
|
case "MM":
|
||||||
$suffix_slash_item = "Maritime Mobile";
|
$suffix_slash_item = "Maritime Mobile";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// If its not one of the above suffix slashes its likely dxcc
|
// If its not one of the above suffix slashes its likely dxcc
|
||||||
$ans2 = $this->logbook_model->dxcc_lookup($suffix_slash, $date);
|
$ans2 = $this->logbook_model->dxcc_lookup($suffix_slash, $date);
|
||||||
$suffix_slash_item = null;
|
$suffix_slash_item = null;
|
||||||
}
|
|
||||||
|
|
||||||
$return['suffix_slash'] = $suffix_slash_item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the final slash is a DXCC then find it!
|
$return['suffix_slash'] = $suffix_slash_item;
|
||||||
if (isset($ans2['call'])) {
|
}
|
||||||
$return['dxcc'] = $ans2['entity'];
|
|
||||||
$return['dxcc_lat'] = $ans2['lat'];
|
// If the final slash is a DXCC then find it!
|
||||||
$return['dxcc_long'] = $ans2['long'];
|
if (isset($ans2['call'])) {
|
||||||
$return['dxcc_cqz'] = $ans2['cqz'];
|
$return['dxcc'] = $ans2['entity'];
|
||||||
} else {
|
$return['dxcc_lat'] = $ans2['lat'];
|
||||||
$return['dxcc'] = $callsign_dxcc_lookup['entity'];
|
$return['dxcc_long'] = $ans2['long'];
|
||||||
$return['dxcc_lat'] = $callsign_dxcc_lookup['lat'];
|
$return['dxcc_cqz'] = $ans2['cqz'];
|
||||||
$return['dxcc_long'] = $callsign_dxcc_lookup['long'];
|
} else {
|
||||||
$return['dxcc_cqz'] = $callsign_dxcc_lookup['cqz'];
|
$return['dxcc'] = $callsign_dxcc_lookup['entity'];
|
||||||
}
|
$return['dxcc_lat'] = $callsign_dxcc_lookup['lat'];
|
||||||
|
$return['dxcc_long'] = $callsign_dxcc_lookup['long'];
|
||||||
|
$return['dxcc_cqz'] = $callsign_dxcc_lookup['cqz'];
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Pool any local data we have for a callsign
|
* Pool any local data we have for a callsign
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
$call_lookup_results = $this->logbook_model->call_lookup_result($lookup_callsign);
|
$call_lookup_results = $this->logbook_model->call_lookup_result($lookup_callsign);
|
||||||
|
|
||||||
if($call_lookup_results != null)
|
if ($call_lookup_results != null) {
|
||||||
{
|
$return['name'] = $call_lookup_results->COL_NAME;
|
||||||
$return['name'] = $call_lookup_results->COL_NAME;
|
$return['gridsquare'] = $call_lookup_results->COL_GRIDSQUARE;
|
||||||
$return['gridsquare'] = $call_lookup_results->COL_GRIDSQUARE;
|
$return['location'] = $call_lookup_results->COL_QTH;
|
||||||
$return['location'] = $call_lookup_results->COL_QTH;
|
$return['iota_ref'] = $call_lookup_results->COL_IOTA;
|
||||||
$return['iota_ref'] = $call_lookup_results->COL_IOTA;
|
$return['qsl_manager'] = $call_lookup_results->COL_QSL_VIA;
|
||||||
$return['qsl_manager'] = $call_lookup_results->COL_QSL_VIA;
|
$return['state'] = $call_lookup_results->COL_STATE;
|
||||||
$return['state'] = $call_lookup_results->COL_STATE;
|
$return['us_county'] = $call_lookup_results->COL_CNTY;
|
||||||
$return['us_county'] = $call_lookup_results->COL_CNTY;
|
|
||||||
|
|
||||||
if ($return['gridsquare'] != "") {
|
|
||||||
$return['latlng'] = $this->qralatlng($return['gridsquare']);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if ($return['gridsquare'] != "") {
|
||||||
|
$return['latlng'] = $this->qralatlng($return['gridsquare']);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -809,7 +802,8 @@ class API extends CI_Controller {
|
||||||
$this->output->enable_profiler(FALSE);
|
$this->output->enable_profiler(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
function qralatlng($qra) {
|
function qralatlng($qra)
|
||||||
|
{
|
||||||
$this->load->library('Qra');
|
$this->load->library('Qra');
|
||||||
$latlng = $this->qra->qra2latlong($qra);
|
$latlng = $this->qra->qra2latlong($qra);
|
||||||
return $latlng;
|
return $latlng;
|
||||||
|
|
@ -848,30 +842,34 @@ class API extends CI_Controller {
|
||||||
* "logbook_slug": "my-public-logbook"
|
* "logbook_slug": "my-public-logbook"
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
function recent_qsos($public_slug = null, $limit = 10) {
|
function recent_qsos($public_slug = null, $limit = 10)
|
||||||
|
{
|
||||||
header('Content-type: application/json');
|
header('Content-type: application/json');
|
||||||
|
|
||||||
if($public_slug == null) {
|
// Validate and sanitize $limit
|
||||||
|
if (!is_numeric($limit)) {
|
||||||
|
$limit = 10; // Default to 10 if not numeric
|
||||||
|
} else {
|
||||||
|
$limit = intval($limit);
|
||||||
|
if ($limit < 1) {
|
||||||
|
$limit = 1; // Minimum limit of 1
|
||||||
|
} elseif ($limit > 50) {
|
||||||
|
$limit = 50; // Maximum limit of 50
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($public_slug == null) {
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
echo json_encode(['status' => 'failed', 'reason' => 'missing public_slug parameter']);
|
echo json_encode(['status' => 'failed', 'reason' => 'missing public_slug parameter']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate and sanitize limit parameter
|
|
||||||
$limit = intval($limit);
|
|
||||||
if ($limit <= 0) {
|
|
||||||
$limit = 10; // default
|
|
||||||
}
|
|
||||||
if ($limit > 50) {
|
|
||||||
$limit = 50; // maximum
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->load->model('logbooks_model');
|
$this->load->model('logbooks_model');
|
||||||
$this->load->model('logbook_model');
|
$this->load->model('logbook_model');
|
||||||
|
|
||||||
if($this->logbooks_model->public_slug_exists($public_slug)) {
|
if ($this->logbooks_model->public_slug_exists($public_slug)) {
|
||||||
$logbook_id = $this->logbooks_model->public_slug_exists_logbook_id($public_slug);
|
$logbook_id = $this->logbooks_model->public_slug_exists_logbook_id($public_slug);
|
||||||
if($logbook_id != false) {
|
if ($logbook_id != false) {
|
||||||
// Get associated station locations for mysql queries
|
// Get associated station locations for mysql queries
|
||||||
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($logbook_id);
|
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($logbook_id);
|
||||||
|
|
||||||
|
|
@ -883,7 +881,7 @@ class API extends CI_Controller {
|
||||||
|
|
||||||
// Get recent QSOs using existing method
|
// Get recent QSOs using existing method
|
||||||
$recent_qsos_query = $this->logbook_model->get_last_qsos($limit, $logbooks_locations_array);
|
$recent_qsos_query = $this->logbook_model->get_last_qsos($limit, $logbooks_locations_array);
|
||||||
|
|
||||||
if ($recent_qsos_query == null) {
|
if ($recent_qsos_query == null) {
|
||||||
http_response_code(404);
|
http_response_code(404);
|
||||||
echo json_encode(['status' => 'failed', 'reason' => 'No QSOs found']);
|
echo json_encode(['status' => 'failed', 'reason' => 'No QSOs found']);
|
||||||
|
|
@ -902,7 +900,7 @@ class API extends CI_Controller {
|
||||||
'rst_sent' => $row->COL_RST_SENT,
|
'rst_sent' => $row->COL_RST_SENT,
|
||||||
'rst_rcvd' => $row->COL_RST_RCVD
|
'rst_rcvd' => $row->COL_RST_RCVD
|
||||||
);
|
);
|
||||||
|
|
||||||
// Add optional fields if they exist
|
// Add optional fields if they exist
|
||||||
if ($row->COL_STX_STRING) {
|
if ($row->COL_STX_STRING) {
|
||||||
$qso['stx_string'] = $row->COL_STX_STRING;
|
$qso['stx_string'] = $row->COL_STX_STRING;
|
||||||
|
|
@ -919,7 +917,16 @@ class API extends CI_Controller {
|
||||||
if ($row->COL_NAME) {
|
if ($row->COL_NAME) {
|
||||||
$qso['name'] = $row->COL_NAME;
|
$qso['name'] = $row->COL_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$dxcc = $this->logbook_model->check_dxcc_table(strtoupper(trim(strtoupper($row->COL_CALL))), $row->COL_TIME_ON);
|
||||||
|
if (empty($dxcc[0])) {
|
||||||
|
$dxcc_id = null;
|
||||||
|
} else {
|
||||||
|
$qso['country'] = $dxcc[1];
|
||||||
|
$qso['lat'] = $dxcc[4];
|
||||||
|
$qso['long'] = $dxcc[5];
|
||||||
|
}
|
||||||
|
|
||||||
$qsos[] = $qso;
|
$qsos[] = $qso;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -929,10 +936,9 @@ class API extends CI_Controller {
|
||||||
'count' => count($qsos),
|
'count' => count($qsos),
|
||||||
'logbook_slug' => $public_slug
|
'logbook_slug' => $public_slug
|
||||||
], JSON_PRETTY_PRINT);
|
], JSON_PRETTY_PRINT);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
http_response_code(404);
|
http_response_code(404);
|
||||||
echo json_encode(['status' => 'failed', 'reason' => $public_slug.' has no associated station locations']);
|
echo json_encode(['status' => 'failed', 'reason' => $public_slug . ' has no associated station locations']);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
http_response_code(404);
|
http_response_code(404);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
<<<<<<< HEAD
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
|
|
|
||||||
|
|
@ -1932,7 +1932,9 @@ class Logbook_model extends CI_Model
|
||||||
|
|
||||||
function get_last_qsos($num, $StationLocationsArray = null)
|
function get_last_qsos($num, $StationLocationsArray = null)
|
||||||
{
|
{
|
||||||
|
// Ensure $num is always an integer to prevent SQL injection
|
||||||
|
$num = intval($num);
|
||||||
|
|
||||||
if ($StationLocationsArray == null) {
|
if ($StationLocationsArray == null) {
|
||||||
$CI = &get_instance();
|
$CI = &get_instance();
|
||||||
$CI->load->model('logbooks_model');
|
$CI->load->model('logbooks_model');
|
||||||
|
|
@ -1945,13 +1947,13 @@ class Logbook_model extends CI_Model
|
||||||
$location_list = "'" . implode("','", $logbooks_locations_array) . "'";
|
$location_list = "'" . implode("','", $logbooks_locations_array) . "'";
|
||||||
|
|
||||||
$sql = "SELECT * FROM ( select * from " . $this->config->item('table_name') . "
|
$sql = "SELECT * FROM ( select * from " . $this->config->item('table_name') . "
|
||||||
WHERE station_id IN(" . $location_list . ")
|
WHERE station_id IN(" . $location_list . ")
|
||||||
order by col_time_on desc, col_primary_key desc
|
order by col_time_on desc, col_primary_key desc
|
||||||
limit " . $num .
|
limit " . $num .
|
||||||
") hrd
|
") hrd
|
||||||
JOIN station_profile ON station_profile.station_id = hrd.station_id
|
LEFT JOIN station_profile ON station_profile.station_id = hrd.station_id
|
||||||
LEFT JOIN dxcc_entities ON hrd.col_dxcc = dxcc_entities.adif
|
LEFT JOIN dxcc_entities ON hrd.col_dxcc = dxcc_entities.adif
|
||||||
order by col_time_on desc, col_primary_key desc";
|
order by col_time_on desc, col_primary_key desc";
|
||||||
|
|
||||||
$query = $this->db->query($sql);
|
$query = $this->db->query($sql);
|
||||||
|
|
||||||
|
|
@ -4082,7 +4084,7 @@ class Logbook_model extends CI_Model
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check the dxxc_prefixes table and return (dxcc, country)
|
* Check the dxxc_prefixes table and return (dxcc, country)
|
||||||
*/
|
*/
|
||||||
|
|
@ -4091,7 +4093,7 @@ class Logbook_model extends CI_Model
|
||||||
|
|
||||||
$csadditions = '/^P$|^R$|^A$|^M$/';
|
$csadditions = '/^P$|^R$|^A$|^M$/';
|
||||||
|
|
||||||
$dxcc_exceptions = $this->db->select('`entity`, `adif`, `cqz`, `cont`')
|
$dxcc_exceptions = $this->db->select('`entity`, `adif`, `cqz`, `cont`,`lat`,`long`')
|
||||||
->where('call', $call)
|
->where('call', $call)
|
||||||
->where('(start <= ', $date)
|
->where('(start <= ', $date)
|
||||||
->or_where('start is null)', NULL, false)
|
->or_where('start is null)', NULL, false)
|
||||||
|
|
@ -4101,7 +4103,7 @@ class Logbook_model extends CI_Model
|
||||||
|
|
||||||
if ($dxcc_exceptions->num_rows() > 0) {
|
if ($dxcc_exceptions->num_rows() > 0) {
|
||||||
$row = $dxcc_exceptions->row_array();
|
$row = $dxcc_exceptions->row_array();
|
||||||
return array($row['adif'], $row['entity'], $row['cqz'], $row['cont']);
|
return array($row['adif'], $row['entity'], $row['cqz'], $row['cont'], $row['lat'], $row['long']);
|
||||||
}
|
}
|
||||||
if (preg_match('/(^KG4)[A-Z09]{3}/', $call)) { // KG4/ and KG4 5 char calls are Guantanamo Bay. If 4 or 6 char, it is USA
|
if (preg_match('/(^KG4)[A-Z09]{3}/', $call)) { // KG4/ and KG4 5 char calls are Guantanamo Bay. If 4 or 6 char, it is USA
|
||||||
$call = "K";
|
$call = "K";
|
||||||
|
|
@ -4156,7 +4158,7 @@ class Logbook_model extends CI_Model
|
||||||
// query the table, removing a character from the right until a match
|
// query the table, removing a character from the right until a match
|
||||||
for ($i = $len; $i > 0; $i--) {
|
for ($i = $len; $i > 0; $i--) {
|
||||||
//printf("searching for %s\n", substr($call, 0, $i));
|
//printf("searching for %s\n", substr($call, 0, $i));
|
||||||
$dxcc_result = $this->db->select('`call`, `entity`, `adif`, `cqz`, `cont`')
|
$dxcc_result = $this->db->select('`call`, `entity`, `adif`, `cqz`, `cont`,`lat`,`long`')
|
||||||
->where('call', substr($call, 0, $i))
|
->where('call', substr($call, 0, $i))
|
||||||
->where('(start <= ', $date)
|
->where('(start <= ', $date)
|
||||||
->or_where("start is null)", NULL, false)
|
->or_where("start is null)", NULL, false)
|
||||||
|
|
@ -4169,7 +4171,7 @@ class Logbook_model extends CI_Model
|
||||||
|
|
||||||
if ($dxcc_result->num_rows() > 0) {
|
if ($dxcc_result->num_rows() > 0) {
|
||||||
$row = $dxcc_result->row_array();
|
$row = $dxcc_result->row_array();
|
||||||
return array($row['adif'], $row['entity'], $row['cqz'], $row['cont']);
|
return array($row['adif'], $row['entity'], $row['cqz'], $row['cont'], $row['lat'], $row['long']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -200,6 +200,9 @@ case 'finnish':
|
||||||
case 'russian':
|
case 'russian':
|
||||||
$config['language'] = $lang;
|
$config['language'] = $lang;
|
||||||
break;
|
break;
|
||||||
|
case 'portuguese':
|
||||||
|
$config['language'] = $lang;
|
||||||
|
break;
|
||||||
case 'english':
|
case 'english':
|
||||||
$config['language'] = $lang;
|
$config['language'] = $lang;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
正在加载…
在新工单中引用