Added authentication for api/radio

这个提交包含在:
Tobias Mädel 2018-12-17 22:16:06 +01:00 提交者 GitHub
父节点 624536379c
当前提交 556a4bd768
找不到此签名对应的密钥
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);