Support custom ports in the custom DNS server tab on the settings page

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2018-05-04 19:14:31 +02:00
parent d2a20b1f0c
commit 6d8c3de5ba
2 changed files with 18 additions and 9 deletions
+16 -3
View File
@@ -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!<br>";
}
elseif(!is_numeric($port))
{
$error .= "Port (".htmlspecialchars($port).") is invalid!<br>";
}
else
{
array_push($DNSservers,$IP."#".$port);
}
}
}
$DNSservercount = count($DNSservers);
+2 -6
View File
@@ -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"
<?php if (isset($custom1)){ ?>checked<?php } ?>>
</div>
<input type="text" name="custom1val" class="form-control"
data-inputmask="'alias': 'ip'" data-mask
<?php if (isset($custom1)){ ?>value="<?php echo $custom1; ?>"<?php } ?>>
</div>
<label>Custom 2 (IPv4)</label>
@@ -727,7 +726,6 @@ if (isset($_GET['tab']) && in_array($_GET['tab'], array("sysadmin", "blocklists"
<?php if (isset($custom2)){ ?>checked<?php } ?>>
</div>
<input type="text" name="custom2val" class="form-control"
data-inputmask="'alias': 'ip'" data-mask
<?php if (isset($custom2)){ ?>value="<?php echo $custom2; ?>"<?php } ?>>
</div>
<label>Custom 3 (IPv6)</label>
@@ -737,7 +735,6 @@ if (isset($_GET['tab']) && in_array($_GET['tab'], array("sysadmin", "blocklists"
<?php if (isset($custom3)){ ?>checked<?php } ?>>
</div>
<input type="text" name="custom3val" class="form-control"
data-inputmask="'alias': 'ipv6'" data-mask
<?php if (isset($custom3)){ ?>value="<?php echo $custom3; ?>"<?php } ?>>
</div>
<label>Custom 4 (IPv6)</label>
@@ -747,7 +744,6 @@ if (isset($_GET['tab']) && in_array($_GET['tab'], array("sysadmin", "blocklists"
<?php if (isset($custom4)){ ?>checked<?php } ?>>
</div>
<input type="text" name="custom4val" class="form-control"
data-inputmask="'alias': 'ipv6'" data-mask
<?php if (isset($custom4)){ ?>value="<?php echo $custom4; ?>"<?php } ?>>
</div>
<label>Local DNS server on custom port</label>