32 lines
731 B
PHP
32 lines
731 B
PHP
<?php
|
|
|
|
require '../backend.php';
|
|
|
|
ob_start();
|
|
|
|
$token = $savvyext->cfgReadChar('savvyext.token');
|
|
|
|
$headers = getallheaders();
|
|
|
|
if (is_array($headers) && array_key_exists('server-token',$headers) && $headers['server-token']==$token) {
|
|
unset($headers);
|
|
unset($token);
|
|
} else {
|
|
header('HTTP/1.1 401 Unauthorized');
|
|
header('Status: 401 Unauthorized');
|
|
echo "{\"status\":\"Missing authorization\"}";
|
|
exit();
|
|
}
|
|
$raw_json = file_get_contents("php://input");
|
|
$raw_array = json_decode($raw_json, true);
|
|
|
|
$in = $raw_array; // I do not think we need to flatten here...
|
|
$out = $savvyext->savvyext_api($in);
|
|
|
|
header("HTTP/1.1 200 OK");
|
|
header("Status: 200 OK");
|
|
// $out = array_merge($in, $out); // DEBUG
|
|
|
|
echo json_encode($out);
|
|
|