From db9f224ad92515a4fd04af2b7e5f5ce785572ef1 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Fri, 20 Jan 2017 15:18:07 +0100 Subject: [PATCH] Export wildcard blocked domains --- scripts/pi-hole/php/takeout.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/scripts/pi-hole/php/takeout.php b/scripts/pi-hole/php/takeout.php index 9de89543..5dc210f8 100644 --- a/scripts/pi-hole/php/takeout.php +++ b/scripts/pi-hole/php/takeout.php @@ -25,6 +25,29 @@ function add_to_zip($path,$name) $zip->addFromString($name, ""); } +function getWildcardListContent() { + if(file_exists("/etc/dnsmasq.d/03-pihole-wildcard.conf")) + { + $rawList = file_get_contents("/etc/dnsmasq.d/03-pihole-wildcard.conf"); + $wclist = explode("\n", $rawList); + $list = []; + + foreach ($wclist as $entry) { + $expl = explode("/", $entry); + if(count($expl) == 3) + { + array_push($list,$expl[1]); + } + } + + return implode("\n",array_unique($list)); + } + else + { + return ""; + } +} + if($_POST["action"] == "in") { if($_FILES["zip_file"]["name"]) @@ -81,6 +104,8 @@ else add_to_zip("/etc/pihole/","adlists.default"); add_to_zip("/etc/pihole/","adlists.list"); // $zip->addFile("/etc/pihole/setupVars.conf"); + + $zip->addFromString("wildcardblocking.txt", getWildcardListContent()); $zip->close(); header("Content-type: application/zip");