diff --git a/application/controllers/Api.php b/application/controllers/Api.php index ed8df449..55dc6e27 100644 --- a/application/controllers/Api.php +++ b/application/controllers/Api.php @@ -388,7 +388,11 @@ class API extends CI_Controller { return $arguments; } - + /* + * + * Function: QSO + * Task: allows passing of ADIF data to Cloudlog + */ function qso() { header('Content-type: application/json'); @@ -397,12 +401,14 @@ class API extends CI_Controller { // Decode JSON and store $obj = json_decode(file_get_contents("php://input"), true); + if(!isset($obj['key']) || $this->api_model->authorize($obj['key']) == 0) { http_response_code(401); echo json_encode(['status' => 'failed', 'reason' => "missing api key"]); die(); } + if($obj['type'] == "adif" && $obj['string'] != "") { // Load the logbook model for adding QSO records $this->load->model('logbook_model'); @@ -420,8 +426,13 @@ class API extends CI_Controller { { break; }; + - $this->logbook_model->import($record, 0, NULL, NULL, NULL); + if(isset($obj['station_profile_id'])) { + $this->logbook_model->import($record, $obj['station_profile_id'], NULL, NULL, NULL); + } else { + $this->logbook_model->import($record, 0, NULL, NULL, NULL); + } }; http_response_code(201);