Use getCustomDNSEntries in deleteAllCustomDNSEntries

Signed-off-by: yubiuser <ckoenig@posteo.de>
This commit is contained in:
yubiuser
2021-10-12 20:50:37 +02:00
parent 49c84e58dd
commit 9f0e5fa67e

View File

@@ -277,37 +277,21 @@ function deleteCustomDNSEntry()
function deleteAllCustomDNSEntries()
{
if (isset($customDNSFile))
{
$handle = fopen($customDNSFile, "r");
if ($handle)
{
try
{
while (($line = fgets($handle)) !== false) {
$line = str_replace("\r","", $line);
$line = str_replace("\n","", $line);
$explodedLine = explode (" ", $line);
try
{
$existingEntries = getCustomDNSEntries();
if (count($explodedLine) != 2)
continue;
foreach ($existingEntries as $entry) {
pihole_execute("-a removecustomdns ".$entry->ip." ".$entry->domain);
}
$ip = $explodedLine[0];
$domain = $explodedLine[1];
}
catch (\Exception $ex)
{
return returnError($ex->getMessage());
}
pihole_execute("-a removecustomdns ".$ip." ".$domain);
}
}
catch (\Exception $ex)
{
return returnError($ex->getMessage());
}
fclose($handle);
}
}
return returnSuccess();
return returnSuccess();
}
// CNAME