changed some variables
Signed-off-by: tracer <tracer@24unix.net>
This commit is contained in:
parent
d83126ac79
commit
545e09636c
@ -11,19 +11,21 @@ class CheckController
|
||||
{
|
||||
|
||||
/**
|
||||
* @param String $requestType
|
||||
* @param String $serverName
|
||||
* @param int $versionIP
|
||||
* @param String $apiKey
|
||||
* @param String $command
|
||||
* @param String $type
|
||||
* @param String $serverType
|
||||
* @param array $body
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function sendCommand(String $serverName, int $versionIP, String $apiKey, String $command, String $type, bool $post = false, array $body = []): array
|
||||
function sendCommand(String $requestType, String $serverName, int $versionIP, String $apiKey, String $command, String $serverType, array $body = []): array
|
||||
{
|
||||
$error = false;
|
||||
$curl = curl_init();
|
||||
if ($type == "panel") {
|
||||
if ($serverType == "panel") {
|
||||
curl_setopt(handle: $curl, option: CURLOPT_URL, value: "https://$serverName/api/v2/" . $command);
|
||||
} else {
|
||||
curl_setopt(handle: $curl, option: CURLOPT_URL, value: "https://$serverName/api/" . $command);
|
||||
@ -40,10 +42,13 @@ class CheckController
|
||||
|
||||
curl_setopt(handle: $curl, option: CURLOPT_HTTPHEADER, value: ["X-API-Key:$apiKey"]);
|
||||
|
||||
if ($post) {
|
||||
curl_setopt($curl, option: CURLOPT_POST, value: true);
|
||||
curl_setopt($curl, option: CURLOPT_POSTFIELDS, value: $body);
|
||||
if ($requestType == "POST") {
|
||||
curl_setopt(handle: $curl, option: CURLOPT_POST, value: true);
|
||||
curl_setopt(handle: $curl, option: CURLOPT_POSTFIELDS, value: $body);
|
||||
}
|
||||
|
||||
curl_setopt(handle: $curl, option: CURLOPT_CUSTOMREQUEST, value: $requestType);
|
||||
|
||||
if ($resultJSON = curl_exec(handle: $curl)) {
|
||||
$httpResponse = curl_getinfo(handle: $curl)['http_code'];
|
||||
|
||||
@ -65,6 +70,7 @@ class CheckController
|
||||
break;
|
||||
case 404:
|
||||
$result = '404 Not Found';
|
||||
break;
|
||||
default:
|
||||
$result = 'Unhandled error: ' . $httpResponse;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user