From 17df978be04a42a0276e57f219d029eb1e7e8e21 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 2 Jan 2017 11:55:01 +0100 Subject: [PATCH 01/42] Add 'Flush Logs' button also to the Query Logging dialog box --- settings.php | 1 + 1 file changed, 1 insertion(+) diff --git a/settings.php b/settings.php index 21e89fc1..9da34f46 100644 --- a/settings.php +++ b/settings.php @@ -455,6 +455,7 @@

Privacy mode

-
-
+
+
+
+
+

Warning: PHP has been compiled without IPv6 support.

From 4209320b8727447f5285bdb6443135cae6fe59be Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 2 Jan 2017 13:17:45 +0100 Subject: [PATCH 06/42] Add glowing notification that users should disabled their router's DHCP server when first activating the DHCP server --- scripts/pi-hole/js/settings.js | 1 + settings.php | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js index e7e613ea..27620f5a 100644 --- a/scripts/pi-hole/js/settings.js +++ b/scripts/pi-hole/js/settings.js @@ -55,6 +55,7 @@ $(".confirm-flushlogs").confirm({ $("#DHCPchk").click(function() { $("input.DHCPgroup").prop("disabled", !this.checked); + $("#dhcpnotice").prop("hidden", !this.checked).addClass("lookatme"); }); var leasetable; diff --git a/settings.php b/settings.php index 37f01c09..175af9f1 100644 --- a/settings.php +++ b/settings.php @@ -9,6 +9,16 @@ max-width: none; white-space: nowrap; } + @-webkit-keyframes Pulse{ + from {color:#630030;-webkit-text-shadow:0 0 9px #333;} + 50% {color:#e33100;-webkit-text-shadow:0 0 18px #e33100;} + to {color:#630030;-webkit-text-shadow:0 0 9px #333;} + } + p.lookatme { + -webkit-animation-name: Pulse; + -webkit-animation-duration: 2s; + -webkit-animation-iteration-count: infinite; + } @@ -152,8 +162,13 @@
-
-
+
+
+
+
+
+
+

hidden>Make sure your router's DHCP server is disabled when using the Pi-hole DHCP server!

From ed014345061cfc59eb446c2b298a55e65bb63689 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 2 Jan 2017 13:24:48 +0100 Subject: [PATCH 07/42] Strg+Return -> Go immediately to Settings page --- scripts/pi-hole/js/footer.js | 9 +++++++++ scripts/pi-hole/php/loginpage.php | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/pi-hole/js/footer.js b/scripts/pi-hole/js/footer.js index b9029236..eb1ba71b 100644 --- a/scripts/pi-hole/js/footer.js +++ b/scripts/pi-hole/js/footer.js @@ -196,3 +196,12 @@ if(versionCompare(piholeVersion, "v2.9.5") < 1) { $("#btnSearchExact").hide(); } + +// Handle Strg + Enter button on Login page +$(document).keypress(function(e) { + console.log(e.which); + if(e.which === 10 && $("#loginpw").is(":focus")) { + $("#loginform").attr('action', 'settings.php'); + $("#loginform").submit(); + } +}); diff --git a/scripts/pi-hole/php/loginpage.php b/scripts/pi-hole/php/loginpage.php index a0366dfb..bc38ac60 100644 --- a/scripts/pi-hole/php/loginpage.php +++ b/scripts/pi-hole/php/loginpage.php @@ -13,9 +13,9 @@
- +
- +
From 207be6ba6d87eb21b8014fa61d87543ae59f75fb Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 2 Jan 2017 13:30:03 +0100 Subject: [PATCH 08/42] Codacy fixes ( Strings must use doublequote. ) --- scripts/pi-hole/js/footer.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/pi-hole/js/footer.js b/scripts/pi-hole/js/footer.js index eb1ba71b..46ffbf37 100644 --- a/scripts/pi-hole/js/footer.js +++ b/scripts/pi-hole/js/footer.js @@ -199,9 +199,8 @@ if(versionCompare(piholeVersion, "v2.9.5") < 1) // Handle Strg + Enter button on Login page $(document).keypress(function(e) { - console.log(e.which); if(e.which === 10 && $("#loginpw").is(":focus")) { - $("#loginform").attr('action', 'settings.php'); + $("#loginform").attr("action", "settings.php"); $("#loginform").submit(); } }); From 6da6805c5c859c9cb0478607c3ac57072b521ee1 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 2 Jan 2017 16:17:37 +0100 Subject: [PATCH 09/42] Fix three codacy issues --- scripts/pi-hole/php/auth.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/pi-hole/php/auth.php b/scripts/pi-hole/php/auth.php index f6757ffa..d0c39a4b 100644 --- a/scripts/pi-hole/php/auth.php +++ b/scripts/pi-hole/php/auth.php @@ -107,6 +107,7 @@ function check_domain() { } function list_verify($type) { + global $pwhash, $wrongpassword; if(!isset($_POST['domain']) || !isset($_POST['list']) || !(isset($_POST['pw']) || isset($_POST['token']))) { log_and_die("Missing POST variables"); } @@ -121,11 +122,11 @@ function list_verify($type) { require("password.php"); if(strlen($pwhash) == 0) { - log_and_die("No password set - ${type}listing with password not supported"); + log_and_die("No password set - ".$type."listing with password not supported"); } elseif($wrongpassword) { - log_and_die("Wrong password - ${type}listing of ${_POST['domain']} not permitted"); + log_and_die("Wrong password - ".$type."listing of ${_POST['domain']} not permitted"); } } else From b41e4e0a0ae6e43eede6d9d19b158540a17286af Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 2 Jan 2017 16:29:53 +0100 Subject: [PATCH 10/42] Add infotext --- scripts/pi-hole/php/loginpage.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/pi-hole/php/loginpage.php b/scripts/pi-hole/php/loginpage.php index bc38ac60..a41f8ae8 100644 --- a/scripts/pi-hole/php/loginpage.php +++ b/scripts/pi-hole/php/loginpage.php @@ -19,7 +19,13 @@
-
+
+
    +
  • Return → Log in and go to Main page
  • +
  • Ctrl+Return → Log in and go to Settings page
  • +
+
+
From 06cc3ca550f38ff2fa20c38fb706659bcc826778 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 2 Jan 2017 16:33:27 +0100 Subject: [PATCH 11/42] Logout -> Go to Settings page instead of Main page (will show log in page again) --- scripts/pi-hole/php/header.php | 2 +- scripts/pi-hole/php/loginpage.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/pi-hole/php/header.php b/scripts/pi-hole/php/header.php index c889ab24..30223124 100644 --- a/scripts/pi-hole/php/header.php +++ b/scripts/pi-hole/php/header.php @@ -442,7 +442,7 @@ // Show Logout button if $auth is set and authorization is required if(strlen($pwhash) > 0) { ?>
  • - + Logout
  • diff --git a/scripts/pi-hole/php/loginpage.php b/scripts/pi-hole/php/loginpage.php index a41f8ae8..34235db0 100644 --- a/scripts/pi-hole/php/loginpage.php +++ b/scripts/pi-hole/php/loginpage.php @@ -21,8 +21,8 @@
      -
    • Return → Log in and go to Main page
    • -
    • Ctrl+Return → Log in and go to Settings page
    • +
    • Return → Log in and go to Main page
    • +
    • Ctrl+Return → Log in and go to Settings page
    From fba19e66cff17ffe05c8cf6f2f9d57e46d11921f Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 2 Jan 2017 16:46:13 +0100 Subject: [PATCH 12/42] Rephrase explaination what the code is doing because it is doing more than we expected --- scripts/pi-hole/php/auth.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/pi-hole/php/auth.php b/scripts/pi-hole/php/auth.php index d0c39a4b..690daed3 100644 --- a/scripts/pi-hole/php/auth.php +++ b/scripts/pi-hole/php/auth.php @@ -35,7 +35,11 @@ function check_cors() { // to validate that the client is authorized, only unauthorized. $server_host = $_SERVER['HTTP_HOST']; - // If HTTP_HOST contains a non-standard port (!= 80) we have to strip the port + // Use parse_url if HTTP_HOST contains a colon (:) to get the host name + // e.g. + // https://pi.hole + // pi.hole:8080 + // However, we don't use parse_url(...) if there is no colon, since it will fail for e.g. "pi.hole" if(strpos($server_host, ":")) { $server_host = parse_url($_SERVER['HTTP_HOST'], PHP_URL_HOST); @@ -48,7 +52,7 @@ function check_cors() { if(isset($_SERVER['HTTP_ORIGIN'])) { $server_origin = $_SERVER['HTTP_ORIGIN']; - // If HTTP_ORIGIN contains a non-standard port (!= 80) we have to strip the port + // Detect colon in $_SERVER['HTTP_ORIGIN'] (see comment above) if(strpos($server_origin, ":")) { $server_origin = parse_url($_SERVER['HTTP_ORIGIN'], PHP_URL_HOST); From 8220c27a20aaa4174221d0f2de7c884ece7951dd Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 2 Jan 2017 17:05:46 +0100 Subject: [PATCH 13/42] Try to detect it also on non-Unix platforms --- scripts/pi-hole/js/footer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pi-hole/js/footer.js b/scripts/pi-hole/js/footer.js index 46ffbf37..b7438a3c 100644 --- a/scripts/pi-hole/js/footer.js +++ b/scripts/pi-hole/js/footer.js @@ -199,7 +199,7 @@ if(versionCompare(piholeVersion, "v2.9.5") < 1) // Handle Strg + Enter button on Login page $(document).keypress(function(e) { - if(e.which === 10 && $("#loginpw").is(":focus")) { + if((e.keyCode == 10 || e.keyCode == 13) && e.ctrlKey && $("#loginpw").is(":focus")) { $("#loginform").attr("action", "settings.php"); $("#loginform").submit(); } From 1438a9d71af28f7257707de916596cf65ae93f13 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 2 Jan 2017 17:13:54 +0100 Subject: [PATCH 14/42] Display which page will be shown when hitting Return + Logout always goes to the very same URL --- scripts/pi-hole/php/header.php | 2 +- scripts/pi-hole/php/loginpage.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/pi-hole/php/header.php b/scripts/pi-hole/php/header.php index 30223124..b5c1b66b 100644 --- a/scripts/pi-hole/php/header.php +++ b/scripts/pi-hole/php/header.php @@ -442,7 +442,7 @@ // Show Logout button if $auth is set and authorization is required if(strlen($pwhash) > 0) { ?>
  • - + Logout
  • diff --git a/scripts/pi-hole/php/loginpage.php b/scripts/pi-hole/php/loginpage.php index 34235db0..beba3c87 100644 --- a/scripts/pi-hole/php/loginpage.php +++ b/scripts/pi-hole/php/loginpage.php @@ -21,7 +21,7 @@
      -
    • Return → Log in and go to Main page
    • +
    • Return → Log in and go to requested page ()
    • Ctrl+Return → Log in and go to Settings page
    From 0e37bc89a9b80d867ba403bafd17ffdbf74dc8d2 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 2 Jan 2017 17:18:54 +0100 Subject: [PATCH 15/42] Fix codacy --- scripts/pi-hole/js/footer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pi-hole/js/footer.js b/scripts/pi-hole/js/footer.js index b7438a3c..e59beed3 100644 --- a/scripts/pi-hole/js/footer.js +++ b/scripts/pi-hole/js/footer.js @@ -199,7 +199,7 @@ if(versionCompare(piholeVersion, "v2.9.5") < 1) // Handle Strg + Enter button on Login page $(document).keypress(function(e) { - if((e.keyCode == 10 || e.keyCode == 13) && e.ctrlKey && $("#loginpw").is(":focus")) { + if((e.keyCode === 10 || e.keyCode === 13) && e.ctrlKey && $("#loginpw").is(":focus")) { $("#loginform").attr("action", "settings.php"); $("#loginform").submit(); } From ae9a2ad6167aa341a34f8a80aa9fc81a11783ce9 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 3 Jan 2017 10:57:39 +0100 Subject: [PATCH 16/42] Fix responsive icon on Gecko engine (Firefox + derivatives) --- scripts/pi-hole/php/header.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pi-hole/php/header.php b/scripts/pi-hole/php/header.php index b5c1b66b..35d6269c 100644 --- a/scripts/pi-hole/php/header.php +++ b/scripts/pi-hole/php/header.php @@ -249,7 +249,7 @@
    - Pi-hole logo + Pi-hole logo

    Status

    From 9221d8a5e74c8c39bae44b15e8f969e7103ed3d0 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 3 Jan 2017 13:44:24 +0100 Subject: [PATCH 17/42] Avoid double " --- scripts/pi-hole/php/header.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/pi-hole/php/header.php b/scripts/pi-hole/php/header.php index b5c1b66b..cc2c8714 100644 --- a/scripts/pi-hole/php/header.php +++ b/scripts/pi-hole/php/header.php @@ -293,33 +293,33 @@ ?>
    $nproc) { - echo '#FF0000'; + echo "#FF0000"; } else { - echo '#7FFF00'; + echo "#7FFF00"; } - echo '""> Load:  ' . $loaddata[0] . '  ' . $loaddata[1] . '  '. $loaddata[2] . ''; + echo "\"> Load:  " . $loaddata[0] . "  " . $loaddata[1] . "  ". $loaddata[2] . ""; ?>
    0.75 || $memory_usage < 0.0) { - echo '#FF0000'; + echo "#FF0000"; } else { - echo '#7FFF00'; + echo "#7FFF00"; } if($memory_usage > 0.0) { - echo '""> Memory usage:  ' . sprintf("%.1f",100.0*$memory_usage) . '%'; + echo "\"> Memory usage:  " . sprintf("%.1f",100.0*$memory_usage) . "%"; } else { - echo '""> Memory usage:   N/A'; + echo "\"> Memory usage:   N/A"; } ?>
    From 5d0da1a8eb30b6bc39c9e93ebbc61a50bdbe82ef Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 3 Jan 2017 13:48:02 +0100 Subject: [PATCH 18/42] Fix JS inconsistency that is tolerated by FF and Chrome but not IE --- scripts/pi-hole/js/footer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/pi-hole/js/footer.js b/scripts/pi-hole/js/footer.js index e59beed3..ce640155 100644 --- a/scripts/pi-hole/js/footer.js +++ b/scripts/pi-hole/js/footer.js @@ -40,7 +40,7 @@ function piholeChange(action, duration) case "enable": btnStatus = $("#flip-status-enable"); btnStatus.html(" "); - $.getJSON("api.php?enable&token=" + token, (data) => { + $.getJSON("api.php?enable&token=" + token, function(data) { if(data.status === "enabled") { btnStatus.html(""); piholeChanged("enabled"); @@ -51,7 +51,7 @@ function piholeChange(action, duration) case "disable": btnStatus = $("#flip-status-disable"); btnStatus.html(" "); - $.getJSON("api.php?disable=" + duration + "&token=" + token, (data) => { + $.getJSON("api.php?disable=" + duration + "&token=" + token, function(data) { if(data.status === "disabled") { btnStatus.html(""); piholeChanged("disabled"); From 645aab6571b4aca82fd6fd7d24d78f8eb40a05c2 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 3 Jan 2017 14:07:16 +0100 Subject: [PATCH 19/42] Add option to disable IPv6 part of the DHCP server --- scripts/pi-hole/php/savesettings.php | 11 ++++++++++- settings.php | 15 +++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/scripts/pi-hole/php/savesettings.php b/scripts/pi-hole/php/savesettings.php index e65a7a61..ddda5138 100644 --- a/scripts/pi-hole/php/savesettings.php +++ b/scripts/pi-hole/php/savesettings.php @@ -355,9 +355,18 @@ function validDomain($domain_name) $error .= "Lease time ".$leasetime." is invalid!
    "; } + if(isset($_POST["useIPv6"])) + { + $ipv6 = "useIPv6"; + } + else + { + $ipv6 = "noIPv6"; + } + if(!strlen($error)) { - exec("sudo pihole -a enabledhcp ".$from." ".$to." ".$router." ".$leasetime." ".$domain); + exec("sudo pihole -a enabledhcp ".$from." ".$to." ".$router." ".$leasetime." ".$domain." ".$ipv6); $success .= "The DHCP server has been activated"; } } diff --git a/settings.php b/settings.php index 175af9f1..9fd34070 100644 --- a/settings.php +++ b/settings.php @@ -132,6 +132,15 @@ { $DHCPleasetime = 24; } + if(isset($setupVars["DHCP_IPV6"])) + { + $DHCPIPv6 = $setupVars["DHCP_IPV6"]; + } + else + { + $DHCPIPv6 = true; + } + } else { @@ -149,6 +158,7 @@ $DHCProuter = ""; } $DHCPleasetime = 24; + $DHCPIPv6 = true; } if(isset($setupVars["PIHOLE_DOMAIN"])){ $piHoleDomain = $setupVars["PIHOLE_DOMAIN"]; @@ -205,6 +215,11 @@
    +
    +
    +
    +
    +
    From a04c89f12f710bc704904e3d67c15df0b15d92bf Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 3 Jan 2017 14:25:38 +0100 Subject: [PATCH 20/42] Pass true/false to backend --- scripts/pi-hole/php/savesettings.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/pi-hole/php/savesettings.php b/scripts/pi-hole/php/savesettings.php index ddda5138..751ab12d 100644 --- a/scripts/pi-hole/php/savesettings.php +++ b/scripts/pi-hole/php/savesettings.php @@ -357,11 +357,11 @@ function validDomain($domain_name) if(isset($_POST["useIPv6"])) { - $ipv6 = "useIPv6"; + $ipv6 = "true"; } else { - $ipv6 = "noIPv6"; + $ipv6 = "false"; } if(!strlen($error)) From c6d98a88e4209619f7d30bbd6a90fa9061c61b0b Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 3 Jan 2017 14:29:20 +0100 Subject: [PATCH 21/42] Tell if IPv6 has been enabled or not in success message --- scripts/pi-hole/php/savesettings.php | 4 +++- settings.php | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/pi-hole/php/savesettings.php b/scripts/pi-hole/php/savesettings.php index 751ab12d..050165ec 100644 --- a/scripts/pi-hole/php/savesettings.php +++ b/scripts/pi-hole/php/savesettings.php @@ -358,16 +358,18 @@ function validDomain($domain_name) if(isset($_POST["useIPv6"])) { $ipv6 = "true"; + $type = "(IPv4 + IPv6)"; } else { $ipv6 = "false"; + $type = "(IPv4)"; } if(!strlen($error)) { exec("sudo pihole -a enabledhcp ".$from." ".$to." ".$router." ".$leasetime." ".$domain." ".$ipv6); - $success .= "The DHCP server has been activated"; + $success .= "The DHCP server has been activated ".$type; } } else diff --git a/settings.php b/settings.php index 9fd34070..7f5a9ef1 100644 --- a/settings.php +++ b/settings.php @@ -132,9 +132,9 @@ { $DHCPleasetime = 24; } - if(isset($setupVars["DHCP_IPV6"])) + if(isset($setupVars["DHCP_IPv6"])) { - $DHCPIPv6 = $setupVars["DHCP_IPV6"]; + $DHCPIPv6 = $setupVars["DHCP_IPv6"]; } else { From 810b994af25cf34bd799ddcb6b7fb6dc3e72f797 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 3 Jan 2017 14:59:37 +0100 Subject: [PATCH 22/42] Fix IE support for main page (untested). Has been broken because codacy enforces Object Literal Shorthand Syntax --- scripts/pi-hole/js/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index 3eec3bea..0edfc22b 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -291,7 +291,7 @@ $(document).ready(function() { enabled: true, mode: "x-axis", callbacks: { - title(tooltipItem, data) { + title: function(tooltipItem, data){ var label = tooltipItem[0].xLabel; var time = label.match(/(\d?\d):?(\d?\d?)/); var h = parseInt(time[1], 10); @@ -300,7 +300,7 @@ $(document).ready(function() { var to = padNumber(h)+":"+padNumber(m+9)+":59"; return "Queries from "+from+" to "+to; }, - label(tooltipItems, data) { + label: function(tooltipItems, data) { if(tooltipItems.datasetIndex === 1) { var percentage = 0.0; From e84f2e49a0d8fbe611ae95b4edcf24e99fc91496 Mon Sep 17 00:00:00 2001 From: The Codacy Badger Date: Tue, 3 Jan 2017 14:07:53 +0000 Subject: [PATCH 23/42] Add Codacy badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6e225856..c9770800 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ Pi-hole Admin Dashboard ============ +[![Codacy Badge](https://api.codacy.com/project/badge/Grade/938b4d9e61b7487da77cf63ba05c683d)](https://www.codacy.com/app/Pi-hole/AdminLTE?utm_source=github.com&utm_medium=referral&utm_content=pi-hole/AdminLTE&utm_campaign=badger) [![Join the chat at https://gitter.im/pi-hole/AdminLTE](https://badges.gitter.im/pi-hole/AdminLTE.svg)](https://gitter.im/pi-hole/AdminLTE?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif "AdminLTE Presentation")](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY "Donate") From cd0c62665db62fa56eb5fed9f67045deb647349c Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 3 Jan 2017 15:54:45 +0100 Subject: [PATCH 24/42] Minor change to kick codacy --- scripts/pi-hole/js/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index 0edfc22b..5030af14 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -291,7 +291,7 @@ $(document).ready(function() { enabled: true, mode: "x-axis", callbacks: { - title: function(tooltipItem, data){ + title: function(tooltipItem, data) { var label = tooltipItem[0].xLabel; var time = label.match(/(\d?\d):?(\d?\d?)/); var h = parseInt(time[1], 10); From c5f99af46c1ee905122cbafd7ffffbdf00415cc5 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 3 Jan 2017 18:04:20 +0100 Subject: [PATCH 25/42] Detect if IPv6 is used --- settings.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/settings.php b/settings.php index 7f5a9ef1..7983e107 100644 --- a/settings.php +++ b/settings.php @@ -104,6 +104,17 @@
    0 && $piHoleIPv6 != "unknown") + { + if(substr($piHoleIPv6, 0, 4) != "fe80") + { + $usingipv6 = true; + } + } + if(isset($setupVars["DHCP_ACTIVE"])) { if($setupVars["DHCP_ACTIVE"] == 1) @@ -138,7 +149,7 @@ } else { - $DHCPIPv6 = true; + $DHCPIPv6 = $usingipv6; } } @@ -158,7 +169,7 @@ $DHCProuter = ""; } $DHCPleasetime = 24; - $DHCPIPv6 = true; + $DHCPIPv6 = $usingipv6; } if(isset($setupVars["PIHOLE_DOMAIN"])){ $piHoleDomain = $setupVars["PIHOLE_DOMAIN"]; From d7afada93c582611e9dfce25aacf4974548b478f Mon Sep 17 00:00:00 2001 From: DL6ER Date: Fri, 6 Jan 2017 10:19:41 +0100 Subject: [PATCH 26/42] Fix overTime algorithms --- scripts/pi-hole/php/data.php | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/scripts/pi-hole/php/data.php b/scripts/pi-hole/php/data.php index 73176ca0..562da5fc 100644 --- a/scripts/pi-hole/php/data.php +++ b/scripts/pi-hole/php/data.php @@ -623,14 +623,12 @@ $byTimeAds[$time] = 1; } } - else - { - if (isset($byTimeDomains[$time])) { - $byTimeDomains[$time]++; - } - else { - $byTimeDomains[$time] = 1; - } + + if (isset($byTimeDomains[$time])) { + $byTimeDomains[$time]++; + } + else { + $byTimeDomains[$time] = 1; } } return [$byTimeDomains,$byTimeAds]; @@ -665,14 +663,12 @@ $byTimeAds[$time] = 1; } } - else - { - if (isset($byTimeDomains[$time])) { - $byTimeDomains[$time]++; - } - else { - $byTimeDomains[$time] = 1; - } + + if (isset($byTimeDomains[$time])) { + $byTimeDomains[$time]++; + } + else { + $byTimeDomains[$time] = 1; } } return [$byTimeDomains,$byTimeAds]; From 7765eeea347dcc2ba68d15489cb608cafbfa52ee Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Fri, 6 Jan 2017 10:53:01 -0500 Subject: [PATCH 27/42] Only show token when authorized --- scripts/pi-hole/php/header.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/scripts/pi-hole/php/header.php b/scripts/pi-hole/php/header.php index f5b79528..029b08ab 100644 --- a/scripts/pi-hole/php/header.php +++ b/scripts/pi-hole/php/header.php @@ -83,15 +83,16 @@ $memory_usage = -1; } + if($auth) { + // For session timer + $maxlifetime = ini_get("session.gc_maxlifetime"); - // For session timer - $maxlifetime = ini_get("session.gc_maxlifetime"); - - // Generate CSRF token - if(empty($_SESSION['token'])) { - $_SESSION['token'] = base64_encode(openssl_random_pseudo_bytes(32)); + // Generate CSRF token + if(empty($_SESSION['token'])) { + $_SESSION['token'] = base64_encode(openssl_random_pseudo_bytes(32)); + } + $token = $_SESSION['token']; } - $token = $_SESSION['token']; if(isset($setupVars['WEBUIBOXEDLAYOUT'])) { @@ -171,7 +172,7 @@ - +
    @@ -215,7 +216,9 @@ +
    Session is valid for 0){echo $maxlifetime;}else{echo "0";} ?>
    +
    From bac5bd7fcda16b7dac1949385686f1aa43581aca Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Sat, 7 Jan 2017 19:03:37 -0500 Subject: [PATCH 34/42] Preserve but take off href Need the styling provided by --- scripts/pi-hole/php/header.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/scripts/pi-hole/php/header.php b/scripts/pi-hole/php/header.php index 04bc1adc..e554d76a 100644 --- a/scripts/pi-hole/php/header.php +++ b/scripts/pi-hole/php/header.php @@ -257,18 +257,18 @@ Active'; + echo ' Active'; } elseif ($pistatus == "0") { - echo ' Offline'; + echo ' Offline'; } elseif ($pistatus == "-1") { - echo ' DNS service not running'; + echo ' DNS service not running'; } else { - echo ' Unknown'; + echo ' Unknown'; } // CPU Temp if ($celsius >= -273.15) { - echo " 60) { echo "#FF0000"; } @@ -289,11 +289,12 @@ { echo round($celsius,1) . "°C"; } + echo ""; } ?>
    $nproc) { echo "#FF0000"; } @@ -301,11 +302,11 @@ { echo "#7FFF00"; } - echo "\"> Load:  " . $loaddata[0] . "  " . $loaddata[1] . "  ". $loaddata[2]; + echo "\">
    Load:  " . $loaddata[0] . "  " . $loaddata[1] . "  ". $loaddata[2] . ""; ?>
    0.75 || $memory_usage < 0.0) { echo "#FF0000"; } @@ -315,11 +316,11 @@ } if($memory_usage > 0.0) { - echo "\"> Memory usage:  " . sprintf("%.1f",100.0*$memory_usage) . "%"; + echo "\">
    Memory usage:  " . sprintf("%.1f",100.0*$memory_usage) . "%"; } else { - echo "\"> Memory usage:   N/A"; + echo "\"> Memory usage:   N/A"; } ?>
    From 066bb140444566e48bd5c0bb3d0f3c5606ae9337 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Sat, 7 Jan 2017 19:46:45 -0500 Subject: [PATCH 35/42] Add multiple domains separated by whitespace --- scripts/pi-hole/js/list.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/scripts/pi-hole/js/list.js b/scripts/pi-hole/js/list.js index de2692ad..35b6687d 100644 --- a/scripts/pi-hole/js/list.js +++ b/scripts/pi-hole/js/list.js @@ -65,9 +65,8 @@ function refresh(fade) { window.onload = refresh(false); -function add() { - var domain = $("#domain"); - if(domain.val().length === 0){ +function add(domain) { + if(domain.length === 0){ return; } @@ -80,7 +79,7 @@ function add() { $.ajax({ url: "scripts/pi-hole/php/add.php", method: "post", - data: {"domain":domain.val(), "list":listType, "token":token}, + data: {"domain":domain, "list":listType, "token":token}, success: function(response) { if (response.indexOf("not a valid argument") >= 0 || response.indexOf("is not a valid domain") >= 0) { @@ -99,7 +98,6 @@ function add() { alInfo.delay(1000).fadeOut(2000, function() { alInfo.hide(); }); - domain.val(""); refresh(true); } }, @@ -113,21 +111,26 @@ function add() { }); } }); + $("#domain").val(""); } - +function handleAdd() { + $("#domain").val().split(/\s+/).forEach(function (domain) { + add(domain); + }); +} // Handle enter button for adding domains $(document).keypress(function(e) { if(e.which === 13 && $("#domain").is(":focus")) { // Enter was pressed, and the input has focus - add(); + handleAdd(); } }); // Handle buttons $("#btnAdd").on("click", function() { - add(); + handleAdd(); }); $("#btnRefresh").on("click", function() { refresh(true); From f5ac5105e38ce7a3721d852342ea6c265630f057 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 8 Jan 2017 10:34:45 +0100 Subject: [PATCH 36/42] Revert "Add multiple domains separated by whitespace" This reverts commit 066bb140444566e48bd5c0bb3d0f3c5606ae9337. --- scripts/pi-hole/js/list.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/scripts/pi-hole/js/list.js b/scripts/pi-hole/js/list.js index 35b6687d..de2692ad 100644 --- a/scripts/pi-hole/js/list.js +++ b/scripts/pi-hole/js/list.js @@ -65,8 +65,9 @@ function refresh(fade) { window.onload = refresh(false); -function add(domain) { - if(domain.length === 0){ +function add() { + var domain = $("#domain"); + if(domain.val().length === 0){ return; } @@ -79,7 +80,7 @@ function add(domain) { $.ajax({ url: "scripts/pi-hole/php/add.php", method: "post", - data: {"domain":domain, "list":listType, "token":token}, + data: {"domain":domain.val(), "list":listType, "token":token}, success: function(response) { if (response.indexOf("not a valid argument") >= 0 || response.indexOf("is not a valid domain") >= 0) { @@ -98,6 +99,7 @@ function add(domain) { alInfo.delay(1000).fadeOut(2000, function() { alInfo.hide(); }); + domain.val(""); refresh(true); } }, @@ -111,26 +113,21 @@ function add(domain) { }); } }); - $("#domain").val(""); } -function handleAdd() { - $("#domain").val().split(/\s+/).forEach(function (domain) { - add(domain); - }); -} + // Handle enter button for adding domains $(document).keypress(function(e) { if(e.which === 13 && $("#domain").is(":focus")) { // Enter was pressed, and the input has focus - handleAdd(); + add(); } }); // Handle buttons $("#btnAdd").on("click", function() { - handleAdd(); + add(); }); $("#btnRefresh").on("click", function() { refresh(true); From 3808f74d4d40511981e9281e13085c25feccc240 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 8 Jan 2017 10:37:20 +0100 Subject: [PATCH 37/42] Change function check_domain() to validate multiple domains separated by spaces --- scripts/pi-hole/php/auth.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/pi-hole/php/auth.php b/scripts/pi-hole/php/auth.php index 3283bab5..188b47b6 100644 --- a/scripts/pi-hole/php/auth.php +++ b/scripts/pi-hole/php/auth.php @@ -103,9 +103,13 @@ function check_csrf($token) { function check_domain() { if(isset($_POST['domain'])){ - $validDomain = is_valid_domain_name($_POST['domain']); - if(!$validDomain){ - log_and_die(htmlspecialchars($_POST['domain']. ' is not a valid domain')); + $domains = explode(" ",$_POST['domain']); + foreach($domains as $domain) + { + $validDomain = is_valid_domain_name($domain); + if(!$validDomain){ + log_and_die(htmlspecialchars($domain. ' is not a valid domain')); + } } } } From b6695f98826cb2025f5233f5aef094c465f436ea Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 8 Jan 2017 10:40:21 +0100 Subject: [PATCH 38/42] Show failure response in error message (e.g. abd<>.de is not a valid domain) --- list.php | 2 +- scripts/pi-hole/js/list.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/list.php b/list.php index dc8097c1..7b62afd9 100644 --- a/list.php +++ b/list.php @@ -45,7 +45,7 @@ function getFullName() {
    diff --git a/scripts/pi-hole/js/list.js b/scripts/pi-hole/js/list.js index de2692ad..573cd499 100644 --- a/scripts/pi-hole/js/list.js +++ b/scripts/pi-hole/js/list.js @@ -74,6 +74,7 @@ function add() { var alInfo = $("#alInfo"); var alSuccess = $("#alSuccess"); var alFailure = $("#alFailure"); + var err = $("#err"); alInfo.show(); alSuccess.hide(); alFailure.hide(); @@ -85,10 +86,11 @@ function add() { if (response.indexOf("not a valid argument") >= 0 || response.indexOf("is not a valid domain") >= 0) { alFailure.show(); - alFailure.delay(1000).fadeOut(2000, function() { + err.html(response); + alFailure.delay(4000).fadeOut(2000, function() { alFailure.hide(); }); - alInfo.delay(1000).fadeOut(2000, function() { + alInfo.delay(4000).fadeOut(2000, function() { alInfo.hide(); }); } else { From 9db9eff3d833431bef00353cdb8e5e9c80487daa Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 8 Jan 2017 10:18:20 +0100 Subject: [PATCH 39/42] Ensure that $auth is always set --- scripts/pi-hole/php/password.php | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/pi-hole/php/password.php b/scripts/pi-hole/php/password.php index 1c1ce4c0..4abe9cfc 100644 --- a/scripts/pi-hole/php/password.php +++ b/scripts/pi-hole/php/password.php @@ -21,6 +21,7 @@ } $wrongpassword = false; + $auth = false; // Test if password is set if(strlen($pwhash) > 0) From 6fd6af5d624602f4a62824479244a09ac41da075 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 8 Jan 2017 14:32:36 +0100 Subject: [PATCH 40/42] Prevent query log action buttons from line breaking --- scripts/pi-hole/js/queries.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/pi-hole/js/queries.js b/scripts/pi-hole/js/queries.js index 19aa2b53..ecc51b84 100644 --- a/scripts/pi-hole/js/queries.js +++ b/scripts/pi-hole/js/queries.js @@ -103,11 +103,11 @@ $(document).ready(function() { "rowCallback": function( row, data, index ){ if (data[4] === "Pi-holed") { $(row).css("color","red"); - $("td:eq(5)", row).html( "" ); + $("td:eq(5)", row).html( "" ); } else{ $(row).css("color","green"); - $("td:eq(5)", row).html( "" ); + $("td:eq(5)", row).html( "" ); } }, From a004b90ea169e7fd269025638fcc425adaa00efb Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 8 Jan 2017 16:23:54 +0100 Subject: [PATCH 41/42] Top Clients List: Show IP address of host name when hovering over the link --- scripts/pi-hole/js/index.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index 5030af14..0c26b22d 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -132,7 +132,7 @@ function escapeHtml(text) { function updateTopClientsChart() { $.getJSON("api.php?summaryRaw&getQuerySources", function(data) { var clienttable = $("#client-frequency").find("tbody:last"); - var domain, percentage, domainname; + var domain, percentage, domainname, domainip; for (domain in data.top_sources) { if ({}.hasOwnProperty.call(data.top_sources, domain)){ @@ -140,14 +140,17 @@ function updateTopClientsChart() { domain = escapeHtml(domain); if(domain.indexOf("|") > -1) { - domainname = domain.substr(0, domain.indexOf("|")); + var idx = domain.indexOf("|"); + domainname = domain.substr(0, idx); + domainip = domain.substr(idx+1, domain.length-idx); } else { domainname = domain; + domainip = domain; } - var url = ""+domainname+""; + var url = ""+domainname+""; percentage = data.top_sources[domain] / data.dns_queries_today * 100; clienttable.append(" " + url + " " + data.top_sources[domain] + "
    Date: Sun, 8 Jan 2017 16:26:37 +0100 Subject: [PATCH 42/42] Show IP for forward destination (if available) --- scripts/pi-hole/js/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index 0c26b22d..89b1d2ba 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -175,7 +175,8 @@ function updateForwardDestinations() { c.push(colors.shift()); if(key.indexOf("|") > -1) { - key = key.substr(0, key.indexOf("|")); + var idx = key.indexOf("|"); + key = key.substr(0, idx)+" ("+key.substr(idx+1, key.length-idx)+")"; } forwardDestinationChart.data.labels.push(key); });