Change pihole status in api_FTL.php (#2059)

Using "pihole status web" info

Signed-off-by: rdwebdesign <github@rdwebdesign.com.br>
This commit is contained in:
RD WebDesign
2022-01-08 16:21:43 -03:00
committed by GitHub
parent 33755f1775
commit ab6b7ae326
3 changed files with 35 additions and 28 deletions

23
api.php
View File

@@ -19,28 +19,7 @@ $data = array();
// Common API functions
if (isset($_GET['status'])) {
// Receive the return of "pihole status web"
$pistatus = pihole_execute('status web');
if (isset($pistatus[0])) {
$pistatus = intval($pistatus[0]);
} else {
// If no response, status="Unknown" (-2)
$pistatus = -2;
}
switch ($pistatus) {
case -2: // Unkown
case -1: // DNS service not running"
case 0: // Offline
$data = array_merge($data, array("status" => "disabled"));
break;
default:
// DNS service on port $returncode
$data = array_merge($data, array("status" => "enabled"));
}
$data = array_merge($data, array("status" => piholeStatusAPI()));
} elseif (isset($_GET['enable']) && $auth) {
if(isset($_GET["auth"]))
{