Skip to content

Commit

Permalink
Merge pull request wavelog#1459 from zone11/dev
Browse files Browse the repository at this point in the history
Add API Endpoint to retrieve the version of Wavelog running
  • Loading branch information
HB9HIL authored Jan 5, 2025
2 parents 2b45c21 + e8b1bc9 commit 9613e39
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions application/controllers/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -970,4 +970,25 @@ function qralatlng($qra) {
$latlng = $this->qra->qra2latlong($qra);
return $latlng;
}

function version() {
// This API endpoint provides the version of Wavelog if the provide key has at least read permissions
$data = json_decode(file_get_contents('php://input'), true);
$valid = false;

if (!empty($data['key'])) {
$this->load->model('api_model');
if (substr($this->api_model->access($data['key']), 0, 1) == 'r') {
$valid = true;
}
}

header("Content-type: application/json");
if ($valid) {
echo json_encode(['status' => 'ok', 'version' => $this->optionslib->get_option('version')]);
} else {
http_response_code(401);
echo json_encode(['status' => 'failed', 'reason' => "missing or invalid api key"]);
}
}
}

0 comments on commit 9613e39

Please sign in to comment.