diff --git a/scripts/pi-hole/js/groups-adlists.js b/scripts/pi-hole/js/groups-adlists.js index 87a7292f..fc223019 100644 --- a/scripts/pi-hole/js/groups-adlists.js +++ b/scripts/pi-hole/js/groups-adlists.js @@ -210,10 +210,12 @@ function initTable() { // Disable autocorrect in the search box var input = document.querySelector("input[type=search]"); - input.setAttribute("autocomplete", "off"); - input.setAttribute("autocorrect", "off"); - input.setAttribute("autocapitalize", "off"); - input.setAttribute("spellcheck", false); + if (input !== null) { + input.setAttribute("autocomplete", "off"); + input.setAttribute("autocorrect", "off"); + input.setAttribute("autocapitalize", "off"); + input.setAttribute("spellcheck", false); + } } function addAdlist() { diff --git a/scripts/pi-hole/js/groups-clients.js b/scripts/pi-hole/js/groups-clients.js index 74614de9..bcd6666e 100644 --- a/scripts/pi-hole/js/groups-clients.js +++ b/scripts/pi-hole/js/groups-clients.js @@ -244,10 +244,12 @@ function initTable() { // Disable autocorrect in the search box var input = document.querySelector("input[type=search]"); - input.setAttribute("autocomplete", "off"); - input.setAttribute("autocorrect", "off"); - input.setAttribute("autocapitalize", "off"); - input.setAttribute("spellcheck", false); + if (input !== null) { + input.setAttribute("autocomplete", "off"); + input.setAttribute("autocorrect", "off"); + input.setAttribute("autocapitalize", "off"); + input.setAttribute("spellcheck", false); + } table.on("order.dt", function () { var order = table.order(); @@ -257,6 +259,7 @@ function initTable() { $("#resetButton").hide(); } }); + $("#resetButton").on("click", function () { table.order([[0, "asc"]]).draw(); $("#resetButton").hide(); @@ -264,7 +267,7 @@ function initTable() { } function addClient() { - var ip = $("#select").val(); + var ip = $("#select").val().trim(); var comment = $("#new_comment").val(); utils.disableAll(); diff --git a/scripts/pi-hole/js/groups-domains.js b/scripts/pi-hole/js/groups-domains.js index ebacb62d..3869d966 100644 --- a/scripts/pi-hole/js/groups-domains.js +++ b/scripts/pi-hole/js/groups-domains.js @@ -52,12 +52,6 @@ $(document).ready(function () { $("#wildcard_checkbox").prop("checked", false); } }); - // Disable autocorrect in the search box - var input = document.querySelector("input[type=search]"); - input.setAttribute("autocomplete", "off"); - input.setAttribute("autocorrect", "off"); - input.setAttribute("autocapitalize", "off"); - input.setAttribute("spellcheck", false); $("#add2black, #add2white").on("click", addDomain); @@ -286,6 +280,14 @@ function initTable() { } } }); + // Disable autocorrect in the search box + var input = document.querySelector("input[type=search]"); + if (input !== null) { + input.setAttribute("autocomplete", "off"); + input.setAttribute("autocorrect", "off"); + input.setAttribute("autocapitalize", "off"); + input.setAttribute("spellcheck", false); + } table.on("order.dt", function () { var order = table.order(); diff --git a/scripts/pi-hole/js/groups.js b/scripts/pi-hole/js/groups.js index 5ca900e5..879f457a 100644 --- a/scripts/pi-hole/js/groups.js +++ b/scripts/pi-hole/js/groups.js @@ -110,6 +110,15 @@ $(document).ready(function () { } }); + // Disable autocorrect in the search box + var input = document.querySelector("input[type=search]"); + if (input !== null) { + input.setAttribute("autocomplete", "off"); + input.setAttribute("autocorrect", "off"); + input.setAttribute("autocapitalize", "off"); + input.setAttribute("spellcheck", false); + } + table.on("order.dt", function () { var order = table.order(); if (order[0][0] !== 0 || order[0][1] !== "asc") { diff --git a/scripts/pi-hole/js/network.js b/scripts/pi-hole/js/network.js index 9eaf733b..82f48f21 100644 --- a/scripts/pi-hole/js/network.js +++ b/scripts/pi-hole/js/network.js @@ -68,6 +68,8 @@ $(document).ready(function () { rowCallback: function (row, data) { var color, mark, + maxiter, + index, lastQuery = parseInt(data.lastQuery); var network_recent = $(".network-recent").css("background-color"); var network_old = $(".network-old").css("background-color"); @@ -110,8 +112,9 @@ $(document).ready(function () { $("td:eq(3)", row).html("unknown"); } else { var names = []; - var maxiter = Math.min(data.name.length, MAXIPDISPLAY); - for (var index = 0; index < maxiter; index++) { + maxiter = Math.min(data.name.length, MAXIPDISPLAY); + index = 0; + for (index = 0; index < maxiter; index++) { var name = data.name[index]; names.push('' + name + ""); } @@ -121,19 +124,20 @@ $(document).ready(function () { // have more to show here names.push("..."); } + $("td:eq(3)", row).html(names.join("
")); $("td:eq(3)", row).hover(function () { this.title = data.name.join("\n"); }); } - // Set number of queries to localized string (add thousand separators) $("td:eq(6)", row).html(data.numQueries.toLocaleString()); var ips = []; - var maxiter = Math.min(data.ip.length, MAXIPDISPLAY); - for (var index = 0; index < maxiter; index++) { + maxiter = Math.min(data.ip.length, MAXIPDISPLAY); + index = 0; + for (index = 0; index < maxiter; index++) { var ip = data.ip[index]; ips.push('' + ip + ""); } diff --git a/scripts/pi-hole/php/func.php b/scripts/pi-hole/php/func.php index ebd100c0..37eb8e9d 100644 --- a/scripts/pi-hole/php/func.php +++ b/scripts/pi-hole/php/func.php @@ -137,10 +137,10 @@ function addCustomDNSEntry($ip="", $domain="", $json_reply=true) try { if(isset($_REQUEST['ip'])) - $ip = $_REQUEST['ip']; + $ip = trim($_REQUEST['ip']); if(isset($_REQUEST['domain'])) - $domain = $_REQUEST['domain']; + $domain = trim($_REQUEST['domain']); if (empty($ip)) return error("IP must be set"); diff --git a/scripts/pi-hole/php/groups.php b/scripts/pi-hole/php/groups.php index b1957945..7a8c6c25 100644 --- a/scripts/pi-hole/php/groups.php +++ b/scripts/pi-hole/php/groups.php @@ -488,7 +488,7 @@ if ($_POST['action'] == 'get_groups') { $domains = explode(' ', trim($_POST['domain'])); $total = count($domains); $added = 0; - $stmt = $db->prepare('INSERT INTO domainlist (domain,type,comment) VALUES (:domain,:type,:comment)'); + $stmt = $db->prepare('REPLACE INTO domainlist (domain,type,comment) VALUES (:domain,:type,:comment)'); if (!$stmt) { throw new Exception('While preparing statement: ' . $db->lastErrorMsg()); } diff --git a/scripts/pi-hole/php/savesettings.php b/scripts/pi-hole/php/savesettings.php index d329eea1..d537ae8b 100644 --- a/scripts/pi-hole/php/savesettings.php +++ b/scripts/pi-hole/php/savesettings.php @@ -262,10 +262,10 @@ function addStaticDHCPLease($mac, $ip, $hostname) { if(array_key_exists("custom".$i,$_POST)) { $exploded = explode("#", $_POST["custom".$i."val"], 2); - $IP = $exploded[0]; + $IP = trim($exploded[0]); if(count($exploded) > 1) { - $port = $exploded[1]; + $port = trim($exploded[1]); } else { @@ -326,22 +326,25 @@ function addStaticDHCPLease($mac, $ip, $hostname) { // Check if Conditional Forwarding is requested if(isset($_POST["conditionalForwarding"])) { + $conditionalForwardingIP = trim($_POST["conditionalForwardingIP"]); + $conditionalForwardingDomain = trim($_POST["conditionalForwardingDomain"]); + // Validate conditional forwarding IP - if (!validIP($_POST["conditionalForwardingIP"])) + if (!validIP($conditionalForwardingIP)) { - $error .= "Conditional forwarding IP (".htmlspecialchars($_POST["conditionalForwardingIP"]).") is invalid!
"; + $error .= "Conditional forwarding IP (".htmlspecialchars($conditionalForwardingIP).") is invalid!
"; } // Validate conditional forwarding domain name - if(!validDomain($_POST["conditionalForwardingDomain"])) + if(!validDomain($conditionalForwardingDomain)) { - $error .= "Conditional forwarding domain name (".htmlspecialchars($_POST["conditionalForwardingDomain"]).") is invalid!
"; + $error .= "Conditional forwarding domain name (".htmlspecialchars($conditionalForwardingDomain).") is invalid!
"; } if(!$error) { - $addressArray = explode(".", $_POST["conditionalForwardingIP"]); + $addressArray = explode(".", $conditionalForwardingIP); $reverseAddress = $addressArray[2].".".$addressArray[1].".".$addressArray[0].".in-addr.arpa"; - $extra .= " conditional_forwarding ".$_POST["conditionalForwardingIP"]." ".$_POST["conditionalForwardingDomain"]." $reverseAddress"; + $extra .= " conditional_forwarding ".$conditionalForwardingIP." ".$conditionalForwardingDomain." $reverseAddress"; } } @@ -588,9 +591,9 @@ function addStaticDHCPLease($mac, $ip, $hostname) { if(isset($_POST["addstatic"])) { - $mac = $_POST["AddMAC"]; - $ip = $_POST["AddIP"]; - $hostname = $_POST["AddHostname"]; + $mac = trim($_POST["AddMAC"]); + $ip = trim($_POST["AddIP"]); + $hostname = trim($_POST["AddHostname"]); addStaticDHCPLease($mac, $ip, $hostname); break;