From f7420d2786bd99da58771318c4652834c1c16a6b Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Mon, 6 Mar 2017 18:00:27 -0500 Subject: [PATCH 1/4] Merge pull request #432 from pi-hole/tweak/teleporter Some tweaks for the Pi-hole Teleporter --- scripts/pi-hole/php/teleporter.php | 34 ++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/scripts/pi-hole/php/teleporter.php b/scripts/pi-hole/php/teleporter.php index 02eacbfc..43092806 100644 --- a/scripts/pi-hole/php/teleporter.php +++ b/scripts/pi-hole/php/teleporter.php @@ -7,7 +7,9 @@ * Please see LICENSE file for your rights under this license. */ require "password.php"; -if(!$auth) die("Not authorized"); +if (php_sapi_name() !== "cli") { + if(!$auth) die("Not authorized"); +} require('func.php'); function process_zip($name) @@ -36,6 +38,22 @@ function add_to_zip($path,$name) $zip->addFile($path.$name,$name); } +function add_dir_to_zip($path) +{ + global $zip; + if($dir = opendir($path)) + { + while(false !== ($entry = readdir($dir))) + { + if($entry !== "." && $entry !== "..") + { + $zip->addFile($path.$entry,$entry); + } + } + closedir($dir); + } +} + function check_domains($domains) { foreach($domains as $domain) @@ -67,9 +85,9 @@ function getWildcardListContent() { return ""; } -if($_POST["action"] == "in") +if(isset($_POST["action"])) { - if($_FILES["zip_file"]["name"]) + if($_FILES["zip_file"]["name"] && $_POST["action"] == "in") { $filename = $_FILES["zip_file"]["name"]; $source = $_FILES["zip_file"]["tmp_name"]; @@ -122,12 +140,13 @@ if($_POST["action"] == "in") } else { - die("No file transmitted."); + die("No file transmitted or parameter error."); } } else { - $archive_file_name = "/var/www/html/pi-hole-teleporter_".microtime(true).".zip"; + $filename = "pi-hole-teleporter_".date("Y-m-d_h-i-s").".zip"; + $archive_file_name = "/var/www/html/".$filename; $zip = new ZipArchive(); touch($archive_file_name); $res = $zip->open($archive_file_name, ZipArchive::CREATE | ZipArchive::OVERWRITE); @@ -140,17 +159,18 @@ else add_to_zip("/etc/pihole/","blacklist.txt"); add_to_zip("/etc/pihole/","adlists.list"); add_to_zip("/etc/pihole/","setupVars.conf"); + add_dir_to_zip("/etc/dnsmasq.d/"); $zip->addFromString("wildcardblocking.txt", getWildcardListContent()); $zip->close(); header("Content-type: application/zip"); header('Content-Transfer-Encoding: binary'); - header("Content-Disposition: attachment; filename=pi-hole-teleporter.zip"); + header("Content-Disposition: attachment; filename=".$filename); header("Content-length: " . filesize($archive_file_name)); header("Pragma: no-cache"); header("Expires: 0"); - ob_end_clean(); + if(ob_get_length() > 0) ob_end_clean(); readfile($archive_file_name); exit; } From 832c7f07011f0a0e8fb5c9c06a128c66cc8e4762 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 6 Mar 2017 12:11:56 +0100 Subject: [PATCH 2/4] Merge pull request #434 from pi-hole/fix/SettingsFallbackDNSlistening Fix fallback for default listening behavior --- settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.php b/settings.php index ad92ac15..8d57c879 100644 --- a/settings.php +++ b/settings.php @@ -483,7 +483,7 @@ $DNSinterface = "local"; } } else { - $DNSinterface = "local"; + $DNSinterface = "single"; } ?>
From 898b458a3825cc2eb449ee9319811a7eb0e8164b Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 7 Mar 2017 00:13:06 +0100 Subject: [PATCH 3/4] Merge pull request #435 from pi-hole/tweak/canWhiteWild Can now whitelist wildcard domains. --- list.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/list.php b/list.php index afb1fb64..9edbdbcb 100644 --- a/list.php +++ b/list.php @@ -45,7 +45,8 @@ function getFullName() {
-

Note that whitelisting domains which are blocked using the wildcard method won't work.

+

Note: Whitelisting a subdomain of a wildcard blocked domain is not possible.

+