added missing named parameters, added strict_types
Signed-off-by: tracer <tracer@24unix.net>
This commit is contained in:
parent
367c6f7d2c
commit
ec156db4aa
|
@ -1,7 +1,8 @@
|
|||
<?php
|
||||
|
||||
<?php declare(strict_types=1);
|
||||
namespace App\Controller;
|
||||
|
||||
error_reporting(error_level: E_ALL);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -22,27 +23,27 @@ class CheckController
|
|||
{
|
||||
$curl = curl_init();
|
||||
if ($type == "panel") {
|
||||
curl_setopt($curl, option: CURLOPT_URL, value: "https://$serverName/api/v2/" . $command);
|
||||
curl_setopt(handle: $curl, option: CURLOPT_URL, value: "https://$serverName/api/v2/" . $command);
|
||||
} else {
|
||||
curl_setopt($curl, option: CURLOPT_URL, value: "https://$serverName/api/" . $command);
|
||||
curl_setopt(handle: $curl, option: CURLOPT_URL, value: "https://$serverName/api/" . $command);
|
||||
}
|
||||
curl_setopt($curl, option: CURLOPT_RETURNTRANSFER, value: 1);
|
||||
curl_setopt($curl, option: CURLOPT_TIMEOUT_MS, value: 1000);
|
||||
curl_setopt(handle: $curl, option: CURLOPT_RETURNTRANSFER, value: 1);
|
||||
curl_setopt(handle: $curl, option: CURLOPT_TIMEOUT_MS, value: 1000);
|
||||
|
||||
if ($versionIP == 4) {
|
||||
curl_setopt($curl, option: CURLOPT_IPRESOLVE, value: CURL_IPRESOLVE_V4);
|
||||
curl_setopt(handle: $curl, option: CURLOPT_IPRESOLVE, value: CURL_IPRESOLVE_V4);
|
||||
} else {
|
||||
curl_setopt($curl, option: CURLOPT_IPRESOLVE, value: CURL_IPRESOLVE_V6);
|
||||
curl_setopt(handle: $curl, option: CURLOPT_IPRESOLVE, value: CURL_IPRESOLVE_V6);
|
||||
}
|
||||
|
||||
curl_setopt($curl, option: CURLOPT_HTTPHEADER, value: ["X-API-Key:$apiKey"]);
|
||||
curl_setopt(handle: $curl, option: CURLOPT_HTTPHEADER, value: ["X-API-Key:$apiKey"]);
|
||||
|
||||
if ($resultJSON = curl_exec($curl)) {
|
||||
$httpResponse = curl_getinfo($curl)['http_code'];
|
||||
if ($resultJSON = curl_exec(handle: $curl)) {
|
||||
$httpResponse = curl_getinfo(handle: $curl)['http_code'];
|
||||
|
||||
switch($httpResponse) {
|
||||
case 200:
|
||||
$apiResult = json_decode($resultJSON);
|
||||
$apiResult = json_decode(json: $resultJSON);
|
||||
if ($command == "ping" ) {
|
||||
if ($apiResult->response == "pong") {
|
||||
$result = $apiResult->response;
|
||||
|
@ -60,9 +61,9 @@ class CheckController
|
|||
$result = 'Unhandled error: ' . $httpResponse;
|
||||
}
|
||||
} else {
|
||||
$result = curl_error($curl);
|
||||
$result = curl_error(handle: $curl);
|
||||
}
|
||||
curl_close($curl);
|
||||
curl_close(handle: $curl);
|
||||
return [
|
||||
'data' => $result,
|
||||
'header' => $httpResponse ?? ''
|
||||
|
|
Loading…
Reference in New Issue