mirror of
https://github.com/pi-hole/web.git
synced 2026-04-23 10:19:47 +01:00
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:
@@ -483,4 +483,31 @@ function getQueryTypeStr($querytype)
|
||||
return "TYPE".($qtype - 100);
|
||||
}
|
||||
|
||||
// Returns an integer representing pihole blocking status
|
||||
function piholeStatus()
|
||||
{
|
||||
// Receive the return of "pihole status web"
|
||||
$pistatus = pihole_execute('status web');
|
||||
return isset($pistatus[0]) ? intval($pistatus[0]) : -2;
|
||||
}
|
||||
|
||||
// Returns pihole status, using only valid API responses (enabled/disabled)
|
||||
function piholeStatusAPI()
|
||||
{
|
||||
// Receive the return of "pihole status web"
|
||||
$pistatus = piholeStatus();
|
||||
|
||||
switch ($pistatus) {
|
||||
case -2: // Unkown
|
||||
case -1: // DNS service not running"
|
||||
case 0: // Offline
|
||||
$response = "disabled";
|
||||
break;
|
||||
|
||||
default:
|
||||
// DNS service running on port $returncode
|
||||
$response = "enabled";
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user