diff --git a/scripts/pi-hole/php/func.php b/scripts/pi-hole/php/func.php index 15230f1f..90fd9abc 100644 --- a/scripts/pi-hole/php/func.php +++ b/scripts/pi-hole/php/func.php @@ -278,14 +278,17 @@ function deleteCustomDNSEntry() } } -function deleteAllCustomDNSEntries() +function deleteAllCustomDNSEntries($reload="") { try { + if(isset($_REQUEST['reload'])) + $reload = $_REQUEST['reload']; + $existingEntries = getCustomDNSEntries(); // passing false to pihole_execute stops pihole from reloading after each enty has been deleted foreach ($existingEntries as $entry) { - pihole_execute("-a removecustomdns ".$entry->ip." ".$entry->domain." false"); + pihole_execute("-a removecustomdns ".$entry->ip." ".$entry->domain." ".$reload); } } @@ -427,14 +430,17 @@ function deleteCustomCNAMEEntry() } } -function deleteAllCustomCNAMEEntries() +function deleteAllCustomCNAMEEntries($reload="") { try { + if(isset($_REQUEST['reload'])) + $reload = $_REQUEST['reload']; + $existingEntries = getCustomCNAMEEntries(); // passing false to pihole_execute stops pihole from reloading after each enty has been deleted foreach ($existingEntries as $entry) { - pihole_execute("-a removecustomcname ".$entry->domain." ".$entry->target." false"); + pihole_execute("-a removecustomcname ".$entry->domain." ".$entry->target." ".$reload); } } diff --git a/scripts/pi-hole/php/teleporter.php b/scripts/pi-hole/php/teleporter.php index 5af1c35b..d25f0509 100644 --- a/scripts/pi-hole/php/teleporter.php +++ b/scripts/pi-hole/php/teleporter.php @@ -519,14 +519,14 @@ if(isset($_POST["action"])) if(isset($_POST["localdnsrecords"]) && $file->getFilename() === "custom.list") { ob_start(); + $reload="false"; if($flushtables) { // Defined in func.php included via auth.php - // will not restart Pi-hole - deleteAllCustomDNSEntries(); + // passing reload="false" will not restart Pi-hole + deleteAllCustomDNSEntries($reload); } $num = 0; $localdnsrecords = process_file(file_get_contents($file)); - $reload="false"; foreach($localdnsrecords as $record) { list($ip,$domain) = explode(" ",$record); if(addCustomDNSEntry($ip, $domain, $reload, false)) @@ -543,15 +543,15 @@ if(isset($_POST["action"])) if(isset($_POST["localcnamerecords"]) && $file->getFilename() === "05-pihole-custom-cname.conf") { ob_start(); + $reload="false"; if($flushtables) { // Defined in func.php included via auth.php - // will not restart Pi-hole - deleteAllCustomCNAMEEntries(); + //passing reload="false" will not restart Pi-hole + deleteAllCustomCNAMEEntries($reload); } $num = 0; $localcnamerecords = process_file(file_get_contents($file)); - $reload="false"; foreach($localcnamerecords as $record) { $line = str_replace("cname=","", $record); $line = str_replace("\r","", $line);