pi hole
This commit is contained in:
@@ -91,8 +91,8 @@ $httpRequest = function (string $method, string $url, array $headers, ?string $b
|
||||
};
|
||||
|
||||
$v5Request = function (array $instance, array $params) use ($normalizeApiPath, $httpRequest): array {
|
||||
if (!empty($instance['token']) && !isset($params['auth'])) {
|
||||
$params['auth'] = $instance['token'];
|
||||
if (!empty($instance['password']) && !isset($params['auth'])) {
|
||||
$params['auth'] = $instance['password'];
|
||||
}
|
||||
|
||||
$url = $normalizeApiPath((string)$instance['url'], (string)$instance['api_path']);
|
||||
@@ -116,7 +116,7 @@ $v6Auth = function (array $instance) use ($httpRequest): array {
|
||||
$timeout = 8;
|
||||
}
|
||||
$verify = !empty($instance['verify_tls']);
|
||||
$payload = ['password' => (string)($instance['token'] ?? '')];
|
||||
$payload = ['password' => (string)($instance['password'] ?? '')];
|
||||
$body = json_encode($payload, JSON_UNESCAPED_UNICODE);
|
||||
$res = $httpRequest('POST', $url, ['Accept: application/json', 'Content-Type: application/json'], $body, $verify, $timeout);
|
||||
if (!$res['ok']) {
|
||||
@@ -159,7 +159,7 @@ $v6Request = function (array $instance, string $path, string $method, array $pay
|
||||
$detectApi = function (array $instance) use ($v6Auth, $v6Request, $v5Request): array {
|
||||
$sid = '';
|
||||
$authRes = null;
|
||||
if (!empty($instance['token'])) {
|
||||
if (!empty($instance['password'])) {
|
||||
$authRes = $v6Auth($instance);
|
||||
if (($authRes['ok'] ?? false) && !empty($authRes['sid'])) {
|
||||
$sid = (string)$authRes['sid'];
|
||||
@@ -621,7 +621,7 @@ if ($action === 'test') {
|
||||
$message = 'Host nicht erreichbar oder kein HTTP-Response.';
|
||||
} elseif ($httpCode === 401 || $httpCode === 403) {
|
||||
$status = 'auth';
|
||||
$message = 'API Passwort falsch oder nicht berechtigt.';
|
||||
$message = 'Passwort oder App-Passwort falsch oder nicht berechtigt.';
|
||||
} elseif ($error === 'invalid_json') {
|
||||
$status = 'invalid';
|
||||
$message = 'API antwortet nicht mit JSON. URL pruefen.';
|
||||
@@ -659,7 +659,7 @@ if ($action === 'test') {
|
||||
$message = 'Host nicht erreichbar oder kein HTTP-Response.';
|
||||
} elseif ($httpCode === 401 || $httpCode === 403) {
|
||||
$status = 'auth';
|
||||
$message = 'API Token/Passwort falsch oder nicht berechtigt.';
|
||||
$message = 'Passwort oder Legacy-API-Token falsch oder nicht berechtigt.';
|
||||
} elseif ($error === 'invalid_json') {
|
||||
$status = 'invalid';
|
||||
$message = 'API antwortet nicht mit JSON. URL oder API-Pfad pruefen.';
|
||||
|
||||
Reference in New Issue
Block a user