"enabled")); } else { $data = array_merge($data, array("status" => "disabled")); } } elseif (isset($_GET['enable']) && $auth) { if(isset($_GET["auth"])) { if($_GET["auth"] !== $pwhash) die("Not authorized!"); } else { // Skip token validation if explicit auth string is given check_csrf($_GET['token']); } exec('sudo pihole enable'); $data = array_merge($data, array("status" => "enabled")); unlink("../custom_disable_timer"); } elseif (isset($_GET['disable']) && $auth) { if(isset($_GET["auth"])) { if($_GET["auth"] !== $pwhash) die("Not authorized!"); } else { // Skip token validation if explicit auth string is given check_csrf($_GET['token']); } $disable = intval($_GET['disable']); // intval returns the integer value on success, or 0 on failure if($disable > 0) { $timestamp = time(); exec("sudo pihole disable ".$disable."s"); file_put_contents("../custom_disable_timer",($timestamp+$disable)*1000); } else { exec('sudo pihole disable'); unlink("../custom_disable_timer"); } $data = array_merge($data, array("status" => "disabled")); } elseif (isset($_GET['updatecheck'])) { // Determine if updates are available for Pi-hole // using the same script that we use for the footer // on the dashboard (update notifications are // suppressed if on development branches) require "scripts/pi-hole/php/update_checker.php"; $updates = array("core_update" => $core_update, "web_update" => $web_update, "FTL_update" => $FTL_update); $data = array_merge($data, $updates); } // Other API functions require("api_FTL.php"); if(isset($_GET["jsonForceObject"])) { echo json_encode($data, JSON_FORCE_OBJECT); } else { echo json_encode($data); } ?>