modified PUT options

Signed-off-by: tracer <tracer@24unix.net>
This commit is contained in:
tracer 2022-03-01 16:44:07 +01:00
parent 77808f84cf
commit a92c445725
1 changed files with 8 additions and 3 deletions

View File

@ -28,13 +28,11 @@ class ApiController
{ {
$error = false; $error = false;
$curl = curl_init(); $curl = curl_init();
try { try {
match ($serverType) { match ($serverType) {
'panel' => curl_setopt(handle: $curl, option: CURLOPT_URL, value: "https://$serverName/api/v2/" . $command), 'panel' => curl_setopt(handle: $curl, option: CURLOPT_URL, value: "https://$serverName/api/v2/" . $command),
'nameserver' => curl_setopt(handle: $curl, option: CURLOPT_URL, value: "https://$serverName/api/" . $command) 'nameserver' => curl_setopt(handle: $curl, option: CURLOPT_URL, value: "https://$serverName/api/" . $command)
}; };
} catch (UnhandledMatchError) { } catch (UnhandledMatchError) {
echo 'Unhandled match: ' . $serverType; echo 'Unhandled match: ' . $serverType;
@ -56,6 +54,10 @@ class ApiController
curl_setopt(handle: $curl, option: CURLOPT_POST, value: true); curl_setopt(handle: $curl, option: CURLOPT_POST, value: true);
curl_setopt(handle: $curl, option: CURLOPT_POSTFIELDS, value: $body); curl_setopt(handle: $curl, option: CURLOPT_POSTFIELDS, value: $body);
} }
if ($requestType == "PUT") {
curl_setopt(handle: $curl, option: CURLOPT_CUSTOMREQUEST, value: 'PUT');
curl_setopt(handle: $curl, option: CURLOPT_POSTFIELDS, value: json_encode(value: $body));
}
curl_setopt(handle: $curl, option: CURLOPT_CUSTOMREQUEST, value: $requestType); curl_setopt(handle: $curl, option: CURLOPT_CUSTOMREQUEST, value: $requestType);
@ -75,6 +77,9 @@ class ApiController
$result = $resultJSON; $result = $resultJSON;
} }
break; break;
case 400:
$result = $resultJSON;
break;
case 401: case 401:
$result = 'Missing or wrong API Key'; $result = 'Missing or wrong API Key';
break; break;