mirror of
https://github.com/pi-hole/web.git
synced 2025-12-24 12:48:29 +00:00
Merge branch 'devel' into fix/IEonceagain
This commit is contained in:
@@ -24,7 +24,7 @@ function eventsource() {
|
||||
}
|
||||
|
||||
var host = window.location.host;
|
||||
var source = new EventSource("http://"+host+"/admin/scripts/pi-hole/php/queryads.php?domain="+domain.val().toLowerCase()+"&"+exact);
|
||||
var source = new EventSource("/admin/scripts/pi-hole/php/queryads.php?domain="+domain.val().toLowerCase()+"&"+exact);
|
||||
|
||||
// Reset and show field
|
||||
ta.empty();
|
||||
|
||||
@@ -2,6 +2,17 @@ $(function () {
|
||||
$("[data-mask]").inputmask();
|
||||
});
|
||||
|
||||
$(function(){
|
||||
$("#custom1val").ipAddress({s:4});
|
||||
$("#custom2val").ipAddress({s:4});
|
||||
$("#custom3val").ipAddress({v:6});
|
||||
$("#custom4val").ipAddress({v:6});
|
||||
|
||||
$("#DHCPfrom").ipAddress({s:4});
|
||||
$("#DHCPto").ipAddress({s:4});
|
||||
$("#DHCProuter").ipAddress({s:4});
|
||||
});
|
||||
|
||||
$(".confirm-reboot").confirm({
|
||||
text: "Are you sure you want to send a reboot command to your Pi-Hole?",
|
||||
title: "Confirmation required",
|
||||
|
||||
@@ -150,6 +150,7 @@
|
||||
|
||||
<link href="style/vendor/AdminLTE.min.css" rel="stylesheet" type="text/css" />
|
||||
<link href="style/vendor/skin-blue.min.css" rel="stylesheet" type="text/css" />
|
||||
<link href="style/pi-hole.css" rel="stylesheet" type="text/css" />
|
||||
<link rel="icon" type="image/png" sizes="160x160" href="img/logo.svg" />
|
||||
<style type="text/css">
|
||||
.glow { text-shadow: 0px 0px 5px #fff; }
|
||||
|
||||
@@ -6,7 +6,7 @@ if(basename($_SERVER['SCRIPT_FILENAME']) !== "settings.php")
|
||||
}
|
||||
|
||||
function validIP($address){
|
||||
return !filter_var($address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === false;
|
||||
return !filter_var($address, FILTER_VALIDATE_IP) === false;
|
||||
}
|
||||
|
||||
// Check for existance of variable
|
||||
@@ -32,20 +32,17 @@ function validDomain($domain_name)
|
||||
return ( $validChars && $lengthCheck && $labelLengthCheck ); //length of each label
|
||||
}
|
||||
|
||||
$primaryDNSservers = [
|
||||
"8.8.8.8" => "Google",
|
||||
"208.67.222.222" => "OpenDNS",
|
||||
"4.2.2.1" => "Level3",
|
||||
"199.85.126.10" => "Norton",
|
||||
"8.26.56.26" => "Comodo"
|
||||
];
|
||||
|
||||
$secondaryDNSservers = [
|
||||
"8.8.4.4" => "Google",
|
||||
"208.67.220.220" => "OpenDNS",
|
||||
"4.2.2.2" => "Level3",
|
||||
"199.85.127.10" => "Norton",
|
||||
"8.20.247.20" => "Comodo"
|
||||
$DNSserverslist = [
|
||||
"8.8.8.8" => "Google (Primary)",
|
||||
"208.67.222.222" => "OpenDNS (Primary)",
|
||||
"4.2.2.1" => "Level3 (Primary)",
|
||||
"199.85.126.10" => "Norton (Primary)",
|
||||
"8.26.56.26" => "Comodo (Primary)",
|
||||
"8.8.4.4" => "Google (Secondary)",
|
||||
"208.67.220.220" => "OpenDNS (Secondary)",
|
||||
"4.2.2.2" => "Level3 (Secondary)",
|
||||
"199.85.127.10" => "Norton (Secondary)",
|
||||
"8.20.247.20" => "Comodo (Secondary)"
|
||||
];
|
||||
|
||||
$error = "";
|
||||
@@ -57,46 +54,38 @@ function validDomain($domain_name)
|
||||
switch ($_POST["field"]) {
|
||||
// Set DNS server
|
||||
case "DNS":
|
||||
$primaryDNS = $_POST["primaryDNS"];
|
||||
$secondaryDNS = $_POST["secondaryDNS"];
|
||||
|
||||
// Get primary DNS server IP address
|
||||
if($primaryDNS === "Custom")
|
||||
$DNSservers = [];
|
||||
// Add selected predefined servers to list
|
||||
foreach ($DNSserverslist as $key => $value)
|
||||
{
|
||||
$primaryIP = $_POST["DNS1IP"];
|
||||
}
|
||||
else
|
||||
{
|
||||
$primaryIP = array_flip($primaryDNSservers)[$primaryDNS];
|
||||
}
|
||||
|
||||
// Validate primary IP
|
||||
if (!validIP($primaryIP))
|
||||
{
|
||||
$error .= "Primary IP (".$primaryIP.") is invalid!<br>";
|
||||
}
|
||||
|
||||
// Get secondary DNS server IP address
|
||||
if($secondaryDNS === "Custom")
|
||||
{
|
||||
if(strlen($_POST["DNS2IP"]) > 0)
|
||||
if(array_key_exists("DNSserver".str_replace(".","_",$key),$_POST))
|
||||
{
|
||||
$secondaryIP = $_POST["DNS2IP"];
|
||||
}
|
||||
else
|
||||
{
|
||||
$secondaryIP = "none";
|
||||
array_push($DNSservers,$key);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
// Test custom server fields
|
||||
for($i=1;$i<=4;$i++)
|
||||
{
|
||||
$secondaryIP = array_flip($secondaryDNSservers)[$secondaryDNS];
|
||||
if(array_key_exists("custom".$i,$_POST))
|
||||
{
|
||||
$IP = $_POST["custom".$i."val"];
|
||||
if(validIP($IP))
|
||||
{
|
||||
array_push($DNSservers,$IP);
|
||||
}
|
||||
else
|
||||
{
|
||||
$error .= "IP (".$IP.") is invalid!<br>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Validate secondary IP
|
||||
if (!validIP($secondaryIP) && $secondaryIP != "none" && strlen($secondaryIP) > 0)
|
||||
// Check if at least one DNS server has been added
|
||||
if(count($DNSservers) < 1)
|
||||
{
|
||||
$error .= "Secondary IP (".$secondaryIP.") is invalid!<br>";
|
||||
$error .= "No DNS server has been selected.<br>";
|
||||
}
|
||||
|
||||
// Check if domain-needed is requested
|
||||
@@ -132,8 +121,9 @@ function validDomain($domain_name)
|
||||
// If there has been no error we can save the new DNS server IPs
|
||||
if(!strlen($error))
|
||||
{
|
||||
exec("sudo pihole -a setdns ".$primaryIP." ".$secondaryIP." ".$extra);
|
||||
$success .= "The DNS settings have been updated";
|
||||
$IPs = implode (",", $DNSservers);
|
||||
exec("sudo pihole -a setdns ".$IPs." ".$extra);
|
||||
$success .= "The DNS settings have been updated (using ".count($DNSservers)." DNS servers)";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
7
scripts/vendor/jquery.input-ip-address-control-1.0.min.js
generated
vendored
Normal file
7
scripts/vendor/jquery.input-ip-address-control-1.0.min.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/*!
|
||||
* jQuery Input Ip Address Control : v0.1beta (2010/11/09 16:15:43)
|
||||
* Copyright (c) 2010 jquery-input-ip-address-control@googlecode.com
|
||||
* Licensed under the MIT license and GPL licenses.
|
||||
*
|
||||
*/
|
||||
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(l($){Q.1o.1t=l(){E=/\\b(?:(?:25[0-5]|2[0-4][0-9]|[1m]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[1m]?[0-9][0-9]?)\\b/;h E.1a(p.1i())};Q.1o.1S=l(){E=/\\b([A-16-9]{1,4}:){7}([A-16-9]{1,4})\\b/i;h E.1a(p.1i())};$.1X.1h({y:l(u,c){f(p.z==0)h;f(1k u==\'1f\'){c=(1k c==\'1f\')?c:u;h p.1d(l(){f(p.18){p.1s();p.18(u,c)}w f(p.1e){t C=p.1e();C.1L(S);C.1z(\'10\',c);C.1b(\'10\',u);C.1w()}})}w{f(p[0].18){u=p[0].1u;c=p[0].1C}w f(14.12&&14.12.19){t C=14.12.19();u=0-C.1D().1b(\'10\',-1E);c=u+C.1H.z}h{u:u,c:c}}},1B:l(s){s=$.1h({v:4},s);f(s.v==4){s.W=M I(\'[0-9]\',\'g\');s.r=\'R.R.R.R\'}f(s.v==6){s.W=M I(\'[A-16-9]\',\'1x\');s.r=\'x:x:x:x:x:x:x:x\'}s.D=s.r.K(\'\').Y();s.q=s.r.X(M I(s.D,\'g\'),\'\').K(\'\').Y();s.O=s.r.K(s.q).Y();h $(p).1d(l(){t a={k:T,n:T,o:T,d:T};a.d=$(p);f(a.d.m()==\'\'||!J(a.d.m()))a.d.m(s.r);a.d.1j(\'1Z\',(s.v==4?15:1c)).1j(\'1W\',(s.v==4?15:1c));l J(o){h 24("o.21"+s.v+"()")};l P(){a.k=a.d.y();a.o=J(L(a.d.m()))?L(a.d.m()):a.o;a.n=a.d.m().K(\'\')};l 1n(o){t G=o.K(s.q);1p(t j=0;j<G.z;j++){1M((s.O.z-G[j].z)>0)G[j]+=s.D}h G.H(s.q)};l L(o){t E=M I(s.O,\'g\');t 1g=M I(s.D,\'g\');h o.X(E,\'0\').X(1g,\'\')};l 11(e){1R(e.1Q){U 8:f(a.n[a.k.c-1]!=s.q){a.n[a.k.c-1]=s.D;a.d.m(a.n.H("")).m()}a.d.y(a.k.c-1);h B;V;U 13:U 1T:a.d.17();V;U 1P:f(a.n[a.k.c]!=s.q&&a.k.c<s.r.z){a.n[a.k.c]=s.D;a.d.m(a.n.H(""))}f(a.k.c<s.r.z)a.d.y(a.k.c+1);h B;V}h S};a.d.N(\'1O\',l(e){P();f($.1l.1K||$.1l.1V){h 11(e)}}).N(\'1U\',l(e){P();f(e.23||e.22||e.1Y)h S;w f((e.F>=20&&e.F<=1N)||e.F>1J){f(Q.1q(e.F).1y(s.W)){a.n[a.k.c]=Q.1q(e.F);f(!J(L(a.n.H(\'\')))){f((a.k.c==0||a.n[a.k.c-1]==s.q)){1p(t i=a.k.c+1;i<a.k.c+s.O.z;i++){a.n[i]=s.D}}w h B}a.d.m(a.n.H(\'\'));f(a.n[a.k.c+1]==s.q){a.d.y(a.k.c+2)}w{a.d.y(a.k.c+1)}h B}w f(s.q.1v(0)==e.F){t Z=a.d.m().1A(s.q,a.k.c);f(Z==-1)h B;f(a.n[a.k.c-1]==s.q)h B;a.k.c=Z;a.d.y(a.k.c+1);h B}w h B}h 11(e)}).N(\'17\',l(){f(a.d.m()==s.r)h S;t o=L($.1G(a.d.m()));f(J(o))a.d.m(o);w a.d.m(a.o)}).N(\'1s\',l(){1r(l(){P();f(a.d.m()!=s.r)a.d.m(1n(a.o));a.d.y(0)},0)}).N(\'1I\',l(e){a.d.m(\'\');1r(l(){a.d.17()},0)})})}})})(1F);',62,130,'||||||||||ctx||end|input||if||return|||cursor|function|val|buffer|ip|this|separator|label||var|begin||else|____|caret|length||false|range|place|rgx|which|part|join|RegExp|isIp|split|unmask|new|bind|partplace|loadCtx|String|___|true|null|case|break|rgxcase|replace|pop|pos|character|entryNoCharacter|selection||document||F0|blur|setSelectionRange|createRange|test|moveStart|39|each|createTextRange|number|rgx2|extend|toString|attr|typeof|browser|01|mask|prototype|for|fromCharCode|setTimeout|focus|isIpv4|selectionStart|charCodeAt|select|gi|match|moveEnd|indexOf|ipAddress|selectionEnd|duplicate|100000|jQuery|trim|text|paste|186|webkit|collapse|while|125|keydown|46|keyCode|switch|isIpv6|27|keypress|msie|size|fn|metaKey|maxlength|32|isIpv|altKey|ctrlKey|eval|'.split('|'),0,{}))
|
||||
110
settings.php
110
settings.php
@@ -198,7 +198,7 @@
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon">From</div>
|
||||
<input type="text" class="form-control DHCPgroup" name="from" value="<?php echo $DHCPstart; ?>" data-inputmask="'alias': 'ip'" data-mask <?php if(!$DHCP){ ?>disabled<?php } ?>>
|
||||
<input type="text" class="form-control DHCPgroup" name="from" id="DHCPfrom" value="<?php echo $DHCPstart; ?>" <?php if(!$DHCP){ ?>disabled<?php } ?>>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -206,7 +206,7 @@
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon">To</div>
|
||||
<input type="text" class="form-control DHCPgroup" name="to" value="<?php echo $DHCPend; ?>" data-inputmask="'alias': 'ip'" data-mask <?php if(!$DHCP){ ?>disabled<?php } ?>>
|
||||
<input type="text" class="form-control DHCPgroup" name="to" id="DHCPto" value="<?php echo $DHCPend; ?>" <?php if(!$DHCP){ ?>disabled<?php } ?>>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -215,7 +215,7 @@
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon">Router</div>
|
||||
<input type="text" class="form-control DHCPgroup" name="router" value="<?php echo $DHCProuter; ?>" data-inputmask="'alias': 'ip'" data-mask <?php if(!$DHCP){ ?>disabled<?php } ?>>
|
||||
<input type="text" class="form-control DHCPgroup" name="router" id="DHCProuter" value="<?php echo $DHCProuter; ?>" <?php if(!$DHCP){ ?>disabled<?php } ?>>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -360,30 +360,41 @@
|
||||
|
||||
<?php
|
||||
// DNS settings
|
||||
if(isset($setupVars["PIHOLE_DNS_1"])){
|
||||
if(isset($primaryDNSservers[$setupVars["PIHOLE_DNS_1"]]))
|
||||
{
|
||||
$piHoleDNS1 = $primaryDNSservers[$setupVars["PIHOLE_DNS_1"]];
|
||||
$DNSservers = [];
|
||||
$DNSactive = [];
|
||||
for($i=1;$i<=12;$i++)
|
||||
{
|
||||
if(isset($setupVars["PIHOLE_DNS_".$i])){
|
||||
if(isset($DNSserverslist[$setupVars["PIHOLE_DNS_".$i]]))
|
||||
{
|
||||
$DNSservers[] = [$setupVars["PIHOLE_DNS_".$i],$DNSserverslist[$setupVars["PIHOLE_DNS_".$i]]];
|
||||
array_push($DNSactive,$setupVars["PIHOLE_DNS_".$i]);
|
||||
}
|
||||
elseif(strpos($setupVars["PIHOLE_DNS_".$i],"."))
|
||||
{
|
||||
$DNSservers[] = [$setupVars["PIHOLE_DNS_".$i],"CustomIPv4"];
|
||||
if(!isset($custom1))
|
||||
{
|
||||
$custom1 = $setupVars["PIHOLE_DNS_".$i];
|
||||
}
|
||||
else
|
||||
{
|
||||
$custom2 = $setupVars["PIHOLE_DNS_".$i];
|
||||
}
|
||||
}
|
||||
elseif(strpos($setupVars["PIHOLE_DNS_".$i],":"))
|
||||
{
|
||||
$DNSservers[] = [$setupVars["PIHOLE_DNS_".$i],"CustomIPv6"];
|
||||
if(!isset($custom3))
|
||||
{
|
||||
$custom3 = $setupVars["PIHOLE_DNS_".$i];
|
||||
}
|
||||
else
|
||||
{
|
||||
$custom4 = $setupVars["PIHOLE_DNS_".$i];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$piHoleDNS1 = "Custom";
|
||||
}
|
||||
} else {
|
||||
$piHoleDNS1 = "unknown";
|
||||
}
|
||||
|
||||
if(isset($setupVars["PIHOLE_DNS_2"])){
|
||||
if(isset($secondaryDNSservers[$setupVars["PIHOLE_DNS_2"]]))
|
||||
{
|
||||
$piHoleDNS2 = $secondaryDNSservers[$setupVars["PIHOLE_DNS_2"]];
|
||||
}
|
||||
else
|
||||
{
|
||||
$piHoleDNS2 = "Custom";
|
||||
}
|
||||
} else {
|
||||
$piHoleDNS2 = "unknown";
|
||||
}
|
||||
|
||||
if(isset($setupVars["DNS_FQDN_REQUIRED"])){
|
||||
@@ -432,28 +443,41 @@
|
||||
<div class="box-body">
|
||||
<form role="form" method="post">
|
||||
<div class="col-lg-6">
|
||||
<label>Primary DNS Server</label>
|
||||
<label>Upstream DNS Servers</label>
|
||||
<div class="form-group">
|
||||
<?php foreach ($primaryDNSservers as $key => $value) { ?> <div class="radio"><label><input type="radio" name="primaryDNS" value="<?php echo $value;?>" <?php if($piHoleDNS1 === $value){ ?>checked<?php } ?> ><?php echo $value;?> (<?php echo $key;?>)</label></div> <?php } ?>
|
||||
<label>Custom</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon"><input type="radio" name="primaryDNS" value="Custom"
|
||||
<?php if($piHoleDNS1 === "Custom"){ ?>checked<?php } ?>></div>
|
||||
<input type="text" name="DNS1IP" class="form-control" data-inputmask="'alias': 'ip'" data-mask
|
||||
<?php if($piHoleDNS1 === "Custom"){ ?>value="<?php echo $setupVars["PIHOLE_DNS_1"]; ?>"<?php } ?>>
|
||||
</div>
|
||||
<?php foreach ($DNSserverslist as $key => $value) { ?>
|
||||
<div class="checkbox">
|
||||
<label title="<?php echo $key;?>">
|
||||
<input type="checkbox" name="DNSserver<?php echo $key;?>" value="true" <?php if(in_array($key,$DNSactive)){ ?>checked<?php } ?> ><?php echo $value;?></label>
|
||||
</div> <?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<label>Secondary DNS Server</label>
|
||||
<label> </label>
|
||||
<div class="form-group">
|
||||
<?php foreach ($secondaryDNSservers as $key => $value) { ?> <div class="radio"><label><input type="radio" name="secondaryDNS" value="<?php echo $value;?>" <?php if($piHoleDNS2 === $value){ ?>checked<?php } ?> ><?php echo $value;?> (<?php echo $key;?>)</label></div> <?php } ?>
|
||||
<label>Custom</label>
|
||||
<label>Custom 1 (IPv4)</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon"><input type="radio" name="secondaryDNS" value="Custom"
|
||||
<?php if($piHoleDNS2 === "Custom"){ ?>checked<?php } ?>></div>
|
||||
<input type="text" name="DNS2IP" class="form-control" data-inputmask="'alias': 'ip'" data-mask
|
||||
<?php if($piHoleDNS2 === "Custom"){ ?>value="<?php echo $setupVars["PIHOLE_DNS_2"]; ?>"<?php } ?>>
|
||||
<div class="input-group-addon"><input type="checkbox" name="custom1" value="Customv4"
|
||||
<?php if(isset($custom1)){ ?>checked<?php } ?>></div>
|
||||
<input type="text" name="custom1val" class="form-control" id="custom1val" <?php if(isset($custom1)){ ?>value="<?php echo $custom1; ?>"<?php } ?>>
|
||||
</div>
|
||||
<label>Custom 2 (IPv4)</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon"><input type="checkbox" name="custom2" value="Customv4"
|
||||
<?php if(isset($custom2)){ ?>checked<?php } ?>></div>
|
||||
<input type="text" name="custom2val" class="form-control" id="custom2val" <?php if(isset($custom2)){ ?>value="<?php echo $custom2; ?>"<?php } ?>>
|
||||
</div>
|
||||
<label>Custom 3 (IPv6)</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon"><input type="checkbox" name="custom3" value="Customv6"
|
||||
<?php if(isset($custom3)){ ?>checked<?php } ?>></div>
|
||||
<input type="text" name="custom3val" class="form-control" id="custom3val" <?php if(isset($custom3)){ ?>value="<?php echo $custom3; ?>"<?php } ?>>
|
||||
</div>
|
||||
<label>Custom 4 (IPv6)</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon"><input type="checkbox" name="custom4" value="Customv6"
|
||||
<?php if(isset($custom4)){ ?>checked<?php } ?>></div>
|
||||
<input type="text" name="custom4val" class="form-control" id="custom4val" <?php if(isset($custom4)){ ?>value="<?php echo $custom4; ?>"<?php } ?>>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -736,6 +760,6 @@
|
||||
?>
|
||||
|
||||
<script src="scripts/vendor/jquery.inputmask.js"></script>
|
||||
<script src="scripts/vendor/jquery.inputmask.extensions.js"></script>
|
||||
<script src="scripts/vendor/jquery.input-ip-address-control-1.0.min.js"></script>
|
||||
<script src="scripts/vendor/jquery.confirm.min.js"></script>
|
||||
<script src="scripts/pi-hole/js/settings.js"></script>
|
||||
|
||||
9
style/pi-hole.css
Normal file
9
style/pi-hole.css
Normal file
@@ -0,0 +1,9 @@
|
||||
.small-box {
|
||||
-webkit-user-select: none; /* Chrome/Safari */
|
||||
-moz-user-select: none; /* Firefox */
|
||||
-ms-user-select: none; /* IE10+ */
|
||||
|
||||
/* Rules below not implemented in browsers yet */
|
||||
-o-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
Reference in New Issue
Block a user