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 String $serverName
|
||||||
* @param int $versionIP
|
* @param int $versionIP
|
||||||
* @param String $apiKey
|
* @param String $apiKey
|
||||||
* @param String $command
|
* @param String $command
|
||||||
* @param String $type
|
* @param String $serverType
|
||||||
|
* @param array $body
|
||||||
*
|
*
|
||||||
* @return array
|
* @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;
|
$error = false;
|
||||||
$curl = curl_init();
|
$curl = curl_init();
|
||||||
if ($type == "panel") {
|
if ($serverType == "panel") {
|
||||||
curl_setopt(handle: $curl, option: CURLOPT_URL, value: "https://$serverName/api/v2/" . $command);
|
curl_setopt(handle: $curl, option: CURLOPT_URL, value: "https://$serverName/api/v2/" . $command);
|
||||||
} else {
|
} else {
|
||||||
curl_setopt(handle: $curl, option: CURLOPT_URL, value: "https://$serverName/api/" . $command);
|
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"]);
|
curl_setopt(handle: $curl, option: CURLOPT_HTTPHEADER, value: ["X-API-Key:$apiKey"]);
|
||||||
|
|
||||||
if ($post) {
|
if ($requestType == "POST") {
|
||||||
curl_setopt($curl, option: CURLOPT_POST, value: true);
|
curl_setopt(handle: $curl, option: CURLOPT_POST, value: true);
|
||||||
curl_setopt($curl, option: CURLOPT_POSTFIELDS, value: $body);
|
curl_setopt(handle: $curl, option: CURLOPT_POSTFIELDS, value: $body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
curl_setopt(handle: $curl, option: CURLOPT_CUSTOMREQUEST, value: $requestType);
|
||||||
|
|
||||||
if ($resultJSON = curl_exec(handle: $curl)) {
|
if ($resultJSON = curl_exec(handle: $curl)) {
|
||||||
$httpResponse = curl_getinfo(handle: $curl)['http_code'];
|
$httpResponse = curl_getinfo(handle: $curl)['http_code'];
|
||||||
|
|
||||||
|
@ -65,6 +70,7 @@ class CheckController
|
||||||
break;
|
break;
|
||||||
case 404:
|
case 404:
|
||||||
$result = '404 Not Found';
|
$result = '404 Not Found';
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
$result = 'Unhandled error: ' . $httpResponse;
|
$result = 'Unhandled error: ' . $httpResponse;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue