From 8b1313b864041baca46cb777ea9f49ac1b923b62 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Wed, 8 Aug 2018 12:06:59 +0200 Subject: [PATCH 1/2] Don't require adlists to start in "http". This also displays lists that start in e.g., "ftp://" or "file://" or without a protocol. Signed-off-by: DL6ER --- scripts/pi-hole/php/savesettings.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/pi-hole/php/savesettings.php b/scripts/pi-hole/php/savesettings.php index c1226fd5..6b536357 100644 --- a/scripts/pi-hole/php/savesettings.php +++ b/scripts/pi-hole/php/savesettings.php @@ -137,12 +137,17 @@ function readAdlists() { while (($line = fgets($handle)) !== false) { - if(substr($line, 0, 5) === "#http") + if(substr($line, 0, 1) === "#") { - // Commented list - array_push($list, [false,rtrim(substr($line, 1))]); + // Comments start either with "##" or "# " + if(substr($line, 1, 1) !== "#" && + substr($line, 1, 1) !== " ") + { + // Commented list + array_push($list, [false,rtrim(substr($line, 1))]); + } } - elseif(substr($line, 0, 4) === "http") + elseif(strlen($line) > 1) { // Active list array_push($list, [true,rtrim($line)]); From 2df4a0d05205109195538fcb91132da7895b136e Mon Sep 17 00:00:00 2001 From: DL6ER Date: Wed, 8 Aug 2018 21:17:10 +0200 Subject: [PATCH 2/2] Improve logic Signed-off-by: DL6ER --- scripts/pi-hole/php/savesettings.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/pi-hole/php/savesettings.php b/scripts/pi-hole/php/savesettings.php index 6b536357..b558bba7 100644 --- a/scripts/pi-hole/php/savesettings.php +++ b/scripts/pi-hole/php/savesettings.php @@ -137,17 +137,21 @@ function readAdlists() { while (($line = fgets($handle)) !== false) { - if(substr($line, 0, 1) === "#") + if(strlen($line) < 3) + { + continue; + } + elseif($line[0] === "#") { // Comments start either with "##" or "# " - if(substr($line, 1, 1) !== "#" && - substr($line, 1, 1) !== " ") + if($line[1] !== "#" && + $line[1] !== " ") { // Commented list array_push($list, [false,rtrim(substr($line, 1))]); } } - elseif(strlen($line) > 1) + else { // Active list array_push($list, [true,rtrim($line)]);