Also use variable to disable reload in delteALL functions

Signed-off-by: yubiuser <ckoenig@posteo.de>
This commit is contained in:
yubiuser
2021-10-13 20:47:02 +02:00
parent b80c97f6d3
commit ab9454a582
2 changed files with 16 additions and 10 deletions
+10 -4
View File
@@ -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);
}
}
+6 -6
View File
@@ -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);