diff --git a/scripts/pi-hole/php/savesettings.php b/scripts/pi-hole/php/savesettings.php index dbf49778..114ac41f 100644 --- a/scripts/pi-hole/php/savesettings.php +++ b/scripts/pi-hole/php/savesettings.php @@ -187,15 +187,28 @@ function readAdlists() { if(array_key_exists("custom".$i,$_POST)) { - $IP = $_POST["custom".$i."val"]; - if(validIP($IP)) + $exploded = explode("#", $_POST["custom".$i."val"], 2); + $IP = $exploded[0]; + if(count($exploded) > 1) { - array_push($DNSservers,$IP); + $port = $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); + } } } $DNSservercount = count($DNSservers); diff --git a/settings.php b/settings.php index 09d28f84..217cd4b2 100644 --- a/settings.php +++ b/settings.php @@ -128,13 +128,13 @@ $i = 1; while (isset($setupVars["PIHOLE_DNS_" . $i])) { if (isinserverlist($setupVars["PIHOLE_DNS_" . $i])) { array_push($DNSactive, $setupVars["PIHOLE_DNS_" . $i]); - } elseif (strpos($setupVars["PIHOLE_DNS_" . $i], ".")) { + } elseif (strpos($setupVars["PIHOLE_DNS_" . $i], ".") !== false) { if (!isset($custom1)) { $custom1 = $setupVars["PIHOLE_DNS_" . $i]; } else { $custom2 = $setupVars["PIHOLE_DNS_" . $i]; } - } elseif (strpos($setupVars["PIHOLE_DNS_" . $i], ":")) { + } elseif (strpos($setupVars["PIHOLE_DNS_" . $i], ":") !== false) { if (!isset($custom3)) { $custom3 = $setupVars["PIHOLE_DNS_" . $i]; } else { @@ -717,7 +717,6 @@ if (isset($_GET['tab']) && in_array($_GET['tab'], array("sysadmin", "blocklists" checked> value=""> @@ -727,7 +726,6 @@ if (isset($_GET['tab']) && in_array($_GET['tab'], array("sysadmin", "blocklists" checked> value=""> @@ -737,7 +735,6 @@ if (isset($_GET['tab']) && in_array($_GET['tab'], array("sysadmin", "blocklists" checked> value=""> @@ -747,7 +744,6 @@ if (isset($_GET['tab']) && in_array($_GET['tab'], array("sysadmin", "blocklists" checked> value="">