From 297c1b019fe824510a126c346de2335c6285d655 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Thu, 25 Jun 2020 17:46:22 +0100 Subject: [PATCH 1/3] response is expected to be empty here, as far as I can tell. Reverting this logic change prevents a misleading message being displayed to the user Signed-off-by: Adam Warner --- scripts/pi-hole/php/savesettings.php | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/scripts/pi-hole/php/savesettings.php b/scripts/pi-hole/php/savesettings.php index bdcdec63..18ea0083 100644 --- a/scripts/pi-hole/php/savesettings.php +++ b/scripts/pi-hole/php/savesettings.php @@ -376,16 +376,8 @@ function addStaticDHCPLease($mac, $ip, $hostname) { { $IPs = implode (",", $DNSservers); $return = pihole_execute("-a setdns \"".$IPs."\" ".$extra); - if(!empty($return)) - { - $success .= htmlspecialchars(end($return))."
"; - $success .= "The DNS settings have been updated (using ".$DNSservercount." DNS servers)"; - } - else - { - $success .= "Updating DNS settings failed. Result:"; - $success .= implode($return); - } + $success .= htmlspecialchars(end($return))."
"; + $success .= "The DNS settings have been updated (using ".$DNSservercount." DNS servers)"; } else { From f51705b675c8e3fd5be94f9a90cf5ce5c835eda5 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Thu, 25 Jun 2020 17:54:23 +0100 Subject: [PATCH 2/3] Don't add #53 to any passed IP value by default, only add custom port if it is specified by the user Signed-off-by: Adam Warner --- scripts/pi-hole/php/savesettings.php | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/scripts/pi-hole/php/savesettings.php b/scripts/pi-hole/php/savesettings.php index 18ea0083..81d9c003 100644 --- a/scripts/pi-hole/php/savesettings.php +++ b/scripts/pi-hole/php/savesettings.php @@ -263,25 +263,27 @@ function addStaticDHCPLease($mac, $ip, $hostname) { { $exploded = explode("#", $_POST["custom".$i."val"], 2); $IP = trim($exploded[0]); - if(count($exploded) > 1) - { - $port = trim($exploded[1]); - } - else - { - $port = "53"; - } + if(!validIP($IP)) { $error .= "IP (".htmlspecialchars($IP).") is invalid!
"; } - elseif(!is_numeric($port)) - { - $error .= "Port (".htmlspecialchars($port).") is invalid!
"; - } else { - array_push($DNSservers,$IP."#".$port); + if(count($exploded) > 1) + { + $port = trim($exploded[1]); + if(!is_numeric($port)) + { + $error .= "Port (".htmlspecialchars($port).") is invalid!
"; + } + else + { + $IP = $IP."#".$port; + } + } + + array_push($DNSservers,$IP); } } } From 1482b9055d5b4f518dad955fa2472da1dce284bd Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 30 Jun 2020 22:55:06 +0200 Subject: [PATCH 3/3] Update scripts/pi-hole/php/savesettings.php Co-authored-by: Adam Warner --- scripts/pi-hole/php/savesettings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pi-hole/php/savesettings.php b/scripts/pi-hole/php/savesettings.php index 81d9c003..9f8c2366 100644 --- a/scripts/pi-hole/php/savesettings.php +++ b/scripts/pi-hole/php/savesettings.php @@ -279,7 +279,7 @@ function addStaticDHCPLease($mac, $ip, $hostname) { } else { - $IP = $IP."#".$port; + $IP .= "#".$port; } }