mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
Merge pull request #1459 from zone11/dev
Add API Endpoint to retrieve the version of Wavelog running
This commit is contained in:
@@ -970,4 +970,25 @@ class API extends CI_Controller {
|
||||
$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"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user