Merge pull request #239 from Manawyrm/master

Added authentication for api/radio this uses the API key function already in Cloudlog, note I need to update CloudlogCAT & SatPC32 interface apps for desktop so before those are released I wouldn't use the master till then :)
这个提交包含在:
Peter Goodhall 2018-12-17 22:14:54 +00:00 提交者 GitHub
当前提交 bdc9a86426
找不到此签名对应的密钥
GPG 密钥 ID: 4AEE18F83AFDEB23

查看文件

@ -351,6 +351,8 @@ class API extends CI_Controller {
function radio() { function radio() {
header('Content-type: application/json'); header('Content-type: application/json');
$this->load->model('api_model');
//$json = '{"radio":"FT-950","frequency":14075,"mode":"SSB","timestamp":"2012/04/07 16:47"}'; //$json = '{"radio":"FT-950","frequency":14075,"mode":"SSB","timestamp":"2012/04/07 16:47"}';
$this->load->model('cat'); $this->load->model('cat');
@ -360,6 +362,11 @@ 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) {
echo json_encode(['status' => 'failed', 'reason' => "missing api key"]);
die();
}
// Store Result to Database // Store Result to Database
$this->cat->update($obj); $this->cat->update($obj);