From ae58c6c60ed5767e7413bf891b2e662375e6c419 Mon Sep 17 00:00:00 2001 From: TheME Date: Sat, 10 Jun 2017 23:26:41 +0200 Subject: [PATCH 001/172] header.php: removed inline-stylesheet move it to pi-hole.css --- scripts/pi-hole/php/header.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/scripts/pi-hole/php/header.php b/scripts/pi-hole/php/header.php index cb9eecf5..79d82808 100644 --- a/scripts/pi-hole/php/header.php +++ b/scripts/pi-hole/php/header.php @@ -189,10 +189,6 @@ -
From dda0bed8ee63c9c53b60610590416b564e73fe4c Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 11 Feb 2018 18:00:52 +0100 Subject: [PATCH 019/172] :codacy: doesn't like non-curly ifs Signed-off-by: DL6ER --- scripts/pi-hole/js/queries.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/pi-hole/js/queries.js b/scripts/pi-hole/js/queries.js index 6921b306..f54f22e5 100644 --- a/scripts/pi-hole/js/queries.js +++ b/scripts/pi-hole/js/queries.js @@ -242,9 +242,13 @@ $(document).ready(function() { if(!blocked) { if(data.length > 7) + { $("td:eq(2)", row).html($("td:eq(2)", row).html() + "TTL " + data[7] + ")"); + } else + { $("td:eq(2)", row).html($("td:eq(2)", row).html() + ")"); + } } }, dom: "<'row'<'col-sm-12'f>>" + From 60dde5314075494ba245785846afafbd31058cc8 Mon Sep 17 00:00:00 2001 From: FoXFTW Date: Tue, 13 Feb 2018 12:54:06 +0100 Subject: [PATCH 020/172] Sort IPs in DHCP Table numerically instead of lexicographically Signed-off-by: FoXFTW --- settings.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/settings.php b/settings.php index a032c9ee..3008ff9a 100644 --- a/settings.php +++ b/settings.php @@ -554,7 +554,7 @@ if (isset($_GET['tab']) && in_array($_GET['tab'], array("sysadmin", "blocklists"
Remaining lease time:
DHCP UID: "> - + ">
-

+

 
-

+

 
Date: Fri, 16 Feb 2018 20:34:43 +0100 Subject: [PATCH 022/172] Remove TTL display, highlight NODATA and NXDOMAIN with different colors Signed-off-by: DL6ER --- scripts/pi-hole/js/queries.js | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/scripts/pi-hole/js/queries.js b/scripts/pi-hole/js/queries.js index f54f22e5..f702eb3f 100644 --- a/scripts/pi-hole/js/queries.js +++ b/scripts/pi-hole/js/queries.js @@ -220,36 +220,25 @@ $(document).ready(function() { { if (data[6] === "1") { - $("td:eq(2)", row).html(data[2] + " (NODATA-" + data[1] + ", "); + $("td:eq(2)", row).html(data[2] + " (NODATA-" + data[1] + ")"); } else if (data[6] === "2") { - $("td:eq(2)", row).html(data[2] + " (NXDOMAIN, "); + $("td:eq(2)", row).html(data[2] + " (NXDOMAIN)"); } else if (data[6] === "3") { - $("td:eq(2)", row).html(data[2] + " (CNAME, "); + $("td:eq(2)", row).html(data[2] + " (CNAME)"); } else if (data[6] === "4") { - $("td:eq(2)", row).html(data[2] + " (IP, "); + $("td:eq(2)", row).html(data[2] + " (IP)"); } // else // { // $("td:eq(2)", row).html(data[2] + " (" + data[6] + ", "); // } } - if(!blocked) - { - if(data.length > 7) - { - $("td:eq(2)", row).html($("td:eq(2)", row).html() + "TTL " + data[7] + ")"); - } - else - { - $("td:eq(2)", row).html($("td:eq(2)", row).html() + ")"); - } - } }, dom: "<'row'<'col-sm-12'f>>" + "<'row'<'col-sm-4'l><'col-sm-8'p>>" + From 5d38af4332be236fd2ec8a08145485fd27792c71 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Fri, 16 Feb 2018 20:51:14 +0100 Subject: [PATCH 023/172] Add reply type column Signed-off-by: DL6ER --- queries.php | 2 ++ scripts/pi-hole/js/queries.js | 68 ++++++++++++++++++++--------------- 2 files changed, 41 insertions(+), 29 deletions(-) diff --git a/queries.php b/queries.php index 89ed91d7..f949583d 100644 --- a/queries.php +++ b/queries.php @@ -135,6 +135,7 @@ if(strlen($showing) > 0) Domain Client Status + Reply DNSSEC Action @@ -146,6 +147,7 @@ if(strlen($showing) > 0) Domain Client Status + Reply DNSSEC Action diff --git a/scripts/pi-hole/js/queries.js b/scripts/pi-hole/js/queries.js index f702eb3f..8d101dbc 100644 --- a/scripts/pi-hole/js/queries.js +++ b/scripts/pi-hole/js/queries.js @@ -151,68 +151,68 @@ $(document).ready(function() { blocked = true; $(row).css("color","red"); $("td:eq(4)", row).html( "Pi-holed" ); - $("td:eq(6)", row).html( "" ); + $("td:eq(7)", row).html( "" ); } else if (data[4] === "2") { $(row).css("color","green"); $("td:eq(4)", row).html( "OK (forwarded)" ); - $("td:eq(6)", row).html( "" ); + $("td:eq(7)", row).html( "" ); } else if (data[4] === "3") { $(row).css("color","green"); $("td:eq(4)", row).html( "OK (cached)" ); - $("td:eq(6)", row).html( "" ); + $("td:eq(7)", row).html( "" ); } else if (data[4] === "4") { blocked = true; $(row).css("color","red"); $("td:eq(4)", row).html( "Pi-holed (wildcard)" ); - $("td:eq(6)", row).html( "" ); + $("td:eq(7)", row).html( "" ); } else if (data[4] === "5") { blocked = true; $(row).css("color","red"); $("td:eq(4)", row).html( "Pi-holed (blacklist)" ); - $("td:eq(6)", row).html( "" ); + $("td:eq(7)", row).html( "" ); } else { $("td:eq(4)", row).html( "Unknown" ); - $("td:eq(6)", row).html( "" ); + $("td:eq(7)", row).html( "" ); } if (data[5] === "1") { - $("td:eq(5)", row).css("color","green"); - $("td:eq(5)", row).html( "SECURE" ); + $("td:eq(6)", row).css("color","green"); + $("td:eq(6)", row).html( "SECURE" ); } else if (data[5] === "2") { - $("td:eq(5)", row).css("color","orange"); - $("td:eq(5)", row).html( "INSECURE" ); + $("td:eq(6)", row).css("color","orange"); + $("td:eq(6)", row).html( "INSECURE" ); } else if (data[5] === "3") { - $("td:eq(5)", row).css("color","red"); - $("td:eq(5)", row).html( "BOGUS" ); + $("td:eq(6)", row).css("color","red"); + $("td:eq(6)", row).html( "BOGUS" ); } else if (data[5] === "4") { - $("td:eq(5)", row).css("color","red"); - $("td:eq(5)", row).html( "ABANDONED" ); + $("td:eq(6)", row).css("color","red"); + $("td:eq(6)", row).html( "ABANDONED" ); } else if (data[5] === "5") { - $("td:eq(5)", row).css("color","red"); - $("td:eq(5)", row).html( "?" ); + $("td:eq(6)", row).css("color","red"); + $("td:eq(6)", row).html( "?" ); } else { - $("td:eq(5)", row).css("color","black"); - $("td:eq(5)", row).html( "-" ); + $("td:eq(6)", row).css("color","black"); + $("td:eq(6)", row).html( "-" ); } // Check for existance of sixth column and display only if not Pi-holed @@ -220,25 +220,34 @@ $(document).ready(function() { { if (data[6] === "1") { - $("td:eq(2)", row).html(data[2] + " (NODATA-" + data[1] + ")"); + $("td:eq(5)", row).css("color","black"); + $("td:eq(5)", row).html("NODATA-" + data[1]); } else if (data[6] === "2") { - $("td:eq(2)", row).html(data[2] + " (NXDOMAIN)"); + $("td:eq(5)", row).css("color","black"); + $("td:eq(5)", row).html("NXDOMAIN"); } else if (data[6] === "3") { - $("td:eq(2)", row).html(data[2] + " (CNAME)"); + $("td:eq(5)", row).css("color","green"); + $("td:eq(5)", row).html("CNAME"); } else if (data[6] === "4") { - $("td:eq(2)", row).html(data[2] + " (IP)"); + $("td:eq(5)", row).css("color","green"); + $("td:eq(5)", row).html("IP"); + } + else + { + $("td:eq(5)", row).html("? ("+data[6]+")"); } - // else - // { - // $("td:eq(2)", row).html(data[2] + " (" + data[6] + ", "); - // } } + else + { + $("td:eq(5)", row).html("-"); + } + }, dom: "<'row'<'col-sm-12'f>>" + "<'row'<'col-sm-4'l><'col-sm-8'p>>" + @@ -250,11 +259,12 @@ $(document).ready(function() { "order" : [[0, "desc"]], "columns": [ { "width" : "15%", "render": function (data, type, full, meta) { if(type === "display"){return moment.unix(data).format("Y-MM-DD []HH:mm:ss z");}else{return data;} }}, - { "width" : "10%" }, - { "width" : "37%", "render": $.fn.dataTable.render.text() }, + { "width" : "4%" }, + { "width" : "36%", "render": $.fn.dataTable.render.text() }, { "width" : "8%", "render": $.fn.dataTable.render.text() }, { "width" : "10%" }, - { "width" : "5%" }, + { "width" : "8%" }, + { "width" : "4%" }, { "width" : "10%" } ], "lengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]], From 937a76bf9b16eb799269191ae98be6df78b31298 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Fri, 16 Feb 2018 21:01:05 +0100 Subject: [PATCH 024/172] Remove color from reply column Signed-off-by: DL6ER --- scripts/pi-hole/js/queries.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/scripts/pi-hole/js/queries.js b/scripts/pi-hole/js/queries.js index 8d101dbc..fbfb9a0e 100644 --- a/scripts/pi-hole/js/queries.js +++ b/scripts/pi-hole/js/queries.js @@ -211,31 +211,27 @@ $(document).ready(function() { } else { - $("td:eq(6)", row).css("color","black"); $("td:eq(6)", row).html( "-" ); } // Check for existance of sixth column and display only if not Pi-holed if(data.length > 6 && !blocked) { + $("td:eq(5)", row).css("color","black"); if (data[6] === "1") { - $("td:eq(5)", row).css("color","black"); $("td:eq(5)", row).html("NODATA-" + data[1]); } else if (data[6] === "2") { - $("td:eq(5)", row).css("color","black"); $("td:eq(5)", row).html("NXDOMAIN"); } else if (data[6] === "3") { - $("td:eq(5)", row).css("color","green"); $("td:eq(5)", row).html("CNAME"); } else if (data[6] === "4") { - $("td:eq(5)", row).css("color","green"); $("td:eq(5)", row).html("IP"); } else @@ -245,6 +241,7 @@ $(document).ready(function() { } else { + $("td:eq(5)", row).css("color","black"); $("td:eq(5)", row).html("-"); } From 6ec8dcdc25f0a36bfaaea23ba34d95eb8de0c01c Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Sat, 17 Feb 2018 13:17:17 +0000 Subject: [PATCH 025/172] remove blurb about default whitelist items. No longer needed as we do not whitelist anything Signed-off-by: Adam Warner --- list.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/list.php b/list.php index 5efde479..93bd0f56 100644 --- a/list.php +++ b/list.php @@ -30,7 +30,6 @@ function getFullName() { -

Note that the ad list domains are automatically added to the whitelist so that a list can never get blocked by another list.

@@ -46,8 +45,7 @@ function getFullName() {
-

Note: Whitelisting a subdomain of a wildcard blocked domain is not possible.

-

Some of the domains shown below are domains of the adlists sources, which are automatically added in order to prevent adlists being able to blacklist each other. See here for the default set of adlists.

+

Note: Whitelisting a subdomain of a wildcard blocked domain is not possible.

From 3769069a0ad11d67a3188336d393d0cc926423ad Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sat, 17 Feb 2018 19:51:36 +0100 Subject: [PATCH 026/172] Obtain host names for IP addresses in database. This can also handle cases where we have mixed host names and IP addresses in the result (Pi-hole v3.3+ stores IP addresses in the database, for consistency) Signed-off-by: DL6ER --- api_db.php | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/api_db.php b/api_db.php index 21f1106d..3e3fdf03 100644 --- a/api_db.php +++ b/api_db.php @@ -74,10 +74,32 @@ if (isset($_GET['getAllQueries']) && $auth) $stmt->bindValue(":from", intval($from), SQLITE3_INTEGER); $stmt->bindValue(":until", intval($until), SQLITE3_INTEGER); $results = $stmt->execute(); + $clients = array(); if(!is_bool($results)) while ($row = $results->fetchArray()) { - $allQueries[] = [$row[0],$row[1] == 1 ? "IPv4" : "IPv6",$row[2],$row[3],$row[4]]; + $c = $row[3]; + if(array_key_exists($row[3], $clients)) + { + // Entry already exists + $c = $clients[$row[3]]; + } + else + { + if(filter_var($row[3], FILTER_VALIDATE_IP)) + { + // Get host name of client and convert to lower case + $c = strtolower(gethostbyaddr($row[3])); + } + else + { + // This is already a host name + $c = strtolower($row[3]); + } + // Buffer result + $clients[$row[3]] = $c; + } + $allQueries[] = [$row[0],$row[1] == 1 ? "IPv4" : "IPv6",$row[2],$c,$row[4]]; } } $result = array('data' => $allQueries); @@ -110,8 +132,16 @@ if (isset($_GET['topClients']) && $auth) if(!is_bool($results)) while ($row = $results->fetchArray()) { - // Convert client to lower case - $c = strtolower($row[0]); + if(filter_var($row[0], FILTER_VALIDATE_IP)) + { + // Get host name of client and convert to lower case + $c = strtolower(gethostbyaddr($row[0])); + } + else + { + // This is already a host name + $c = strtolower($row[0]); + } if(array_key_exists($c, $clients)) { // Entry already exists, add to it (might appear multiple times due to mixed capitalization in the database) From 02f14ceb0551549a2c6764dcf4691690c83c3e4f Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 25 Feb 2018 09:44:01 +0100 Subject: [PATCH 027/172] Add name resolution capabilites (with caching) for web interface Signed-off-by: DL6ER --- api_FTL.php | 28 ++++------------------------ scripts/pi-hole/php/FTL.php | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/api_FTL.php b/api_FTL.php index d4e1c085..f45efb74 100644 --- a/api_FTL.php +++ b/api_FTL.php @@ -155,14 +155,7 @@ if ((isset($_GET['topClients']) || isset($_GET['getQuerySources'])) && $auth) foreach($return as $line) { $tmp = explode(" ",$line); - if(count($tmp) == 4) - { - $top_clients[$tmp[3]."|".$tmp[2]] = intval($tmp[1]); - } - else - { - $top_clients[$tmp[2]] = intval($tmp[1]); - } + $top_clients[resolveHostname($tmp[2])] = intval($tmp[1]); } $result = array('top_sources' => $top_clients); @@ -184,14 +177,7 @@ if (isset($_GET['getForwardDestinations']) && $auth) foreach($return as $line) { $tmp = explode(" ",$line); - if(count($tmp) == 4) - { - $forward_dest[$tmp[3]."|".$tmp[2]] = floatval($tmp[1]); - } - else - { - $forward_dest[$tmp[2]] = floatval($tmp[1]); - } + $forward_dest[resolveHostname($tmp[2])] = floatval($tmp[1]); } $result = array('forward_destinations' => $forward_dest); @@ -240,6 +226,7 @@ if (isset($_GET['getAllQueries']) && $auth) foreach($return as $line) { $tmp = explode(" ",$line); + $tmp[3] = resolveHostname($tmp[3]); array_push($allQueries,$tmp); } @@ -318,14 +305,7 @@ if (isset($_GET['getClientNames']) && $auth) foreach($return as $line) { $tmp = explode(" ",$line); - if(count($tmp) == 4) - { - $forward_dest[$tmp[3]."|".$tmp[2]] = floatval($tmp[1]); - } - else - { - $forward_dest[$tmp[2]] = floatval($tmp[1]); - } + $forward_dest[resolveHostname($tmp[2])] = floatval($tmp[1]); } $result = array('clients' => $forward_dest); diff --git a/scripts/pi-hole/php/FTL.php b/scripts/pi-hole/php/FTL.php index 0c07ce5d..443164f7 100644 --- a/scripts/pi-hole/php/FTL.php +++ b/scripts/pi-hole/php/FTL.php @@ -138,4 +138,30 @@ function disconnectFTL($quiet=true) echo "OK.\n\n"; } } + +$clients = []; +function resolveHostname($c) +{ + if(array_key_exists($c, $clients)) + { + // Entry already exists + $c = $clients[$c]; + } + else + { + if(filter_var($c, FILTER_VALIDATE_IP)) + { + // Get host name of client and convert to lower case + $c = strtolower(gethostbyaddr($c)); + } + else + { + // This is already a host name + $c = strtolower($c); + } + // Buffer result + $clients[$c] = $c; + } + return $c; +} ?> From ee4e106d8325a4a678f29ab17c6385d01869686c Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 25 Feb 2018 09:52:40 +0100 Subject: [PATCH 028/172] :codacy: Signed-off-by: DL6ER --- scripts/pi-hole/php/FTL.php | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/scripts/pi-hole/php/FTL.php b/scripts/pi-hole/php/FTL.php index 443164f7..3ced5d81 100644 --- a/scripts/pi-hole/php/FTL.php +++ b/scripts/pi-hole/php/FTL.php @@ -140,28 +140,27 @@ function disconnectFTL($quiet=true) } $clients = []; -function resolveHostname($c) +function resolveHostname($clientip) { - if(array_key_exists($c, $clients)) + if(array_key_exists($clientip, $clients)) { // Entry already exists - $c = $clients[$c]; + $clientname = $clients[$clientip]; + return $clientname; + } + + if(filter_var($clientip, FILTER_VALIDATE_IP)) + { + // Get host name of client and convert to lower case + $clientname = strtolower(gethostbyaddr($clientip)); } else { - if(filter_var($c, FILTER_VALIDATE_IP)) - { - // Get host name of client and convert to lower case - $c = strtolower(gethostbyaddr($c)); - } - else - { - // This is already a host name - $c = strtolower($c); - } - // Buffer result - $clients[$c] = $c; + // This is already a host name + $clientname = strtolower($clientip); } - return $c; + // Buffer result + $clients[$clientname] = $clientip; + return $clientname; } ?> From 80a7f91449825b5c8815927058e76b6ed38453ee Mon Sep 17 00:00:00 2001 From: Tom Date: Fri, 2 Mar 2018 16:44:22 +0000 Subject: [PATCH 029/172] Change the whitelist icon in the sidebar --- 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 709a8093..3851a41d 100644 --- a/scripts/pi-hole/php/header.php +++ b/scripts/pi-hole/php/header.php @@ -445,7 +445,7 @@ if($auth) { class="active"> - Whitelist + Whitelist From 9e5eba4036631b6dfdef60c23c84cf8a2321dd26 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 4 Mar 2018 21:06:28 +0100 Subject: [PATCH 030/172] Return both client IP and hostname in clientname string Signed-off-by: DL6ER --- scripts/pi-hole/php/FTL.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/pi-hole/php/FTL.php b/scripts/pi-hole/php/FTL.php index 3ced5d81..c317c9da 100644 --- a/scripts/pi-hole/php/FTL.php +++ b/scripts/pi-hole/php/FTL.php @@ -146,7 +146,7 @@ function resolveHostname($clientip) { // Entry already exists $clientname = $clients[$clientip]; - return $clientname; + return $clientname."|".$clientip; } if(filter_var($clientip, FILTER_VALIDATE_IP)) @@ -161,6 +161,6 @@ function resolveHostname($clientip) } // Buffer result $clients[$clientname] = $clientip; - return $clientname; + return $clientname."|".$clientip; } ?> From f132122e5753e476e90e3c3122a2477d8b34cf8c Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 5 Mar 2018 09:18:37 +0100 Subject: [PATCH 031/172] Use better client host name caching for DB queries Signed-off-by: DL6ER --- api_db.php | 59 ++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 31 deletions(-) diff --git a/api_db.php b/api_db.php index 3e3fdf03..b4bd8cb3 100644 --- a/api_db.php +++ b/api_db.php @@ -16,6 +16,30 @@ check_cors(); ini_set("max_execution_time","600"); $data = array(); +$clients = []; +function resolveOnlyHostname($clientip) +{ + if(array_key_exists($clientip, $clients)) + { + // Entry already exists + $clientname = $clients[$clientip]; + return $clientname; + } + + if(filter_var($clientip, FILTER_VALIDATE_IP)) + { + // Get host name of client and convert to lower case + $clientname = strtolower(gethostbyaddr($clientip)); + } + else + { + // This is already a host name + $clientname = strtolower($clientip); + } + // Buffer result + $clients[$clientname] = $clientip; + return $clientname; +} // Get posible non-standard location of FTL's database $FTLsettings = parse_ini_file("/etc/pihole/pihole-FTL.conf"); @@ -78,27 +102,7 @@ if (isset($_GET['getAllQueries']) && $auth) if(!is_bool($results)) while ($row = $results->fetchArray()) { - $c = $row[3]; - if(array_key_exists($row[3], $clients)) - { - // Entry already exists - $c = $clients[$row[3]]; - } - else - { - if(filter_var($row[3], FILTER_VALIDATE_IP)) - { - // Get host name of client and convert to lower case - $c = strtolower(gethostbyaddr($row[3])); - } - else - { - // This is already a host name - $c = strtolower($row[3]); - } - // Buffer result - $clients[$row[3]] = $c; - } + $c = resolveOnlyHostname($row[3]); $allQueries[] = [$row[0],$row[1] == 1 ? "IPv4" : "IPv6",$row[2],$c,$row[4]]; } } @@ -132,16 +136,9 @@ if (isset($_GET['topClients']) && $auth) if(!is_bool($results)) while ($row = $results->fetchArray()) { - if(filter_var($row[0], FILTER_VALIDATE_IP)) - { - // Get host name of client and convert to lower case - $c = strtolower(gethostbyaddr($row[0])); - } - else - { - // This is already a host name - $c = strtolower($row[0]); - } + + $c = resolveOnlyHostname($row[0]); + if(array_key_exists($c, $clients)) { // Entry already exists, add to it (might appear multiple times due to mixed capitalization in the database) From 746ac1ea3f0fbf470da3f1728f6852915a41a44e Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 5 Mar 2018 15:45:22 +0100 Subject: [PATCH 032/172] Prevent confusion between arrays Signed-off-by: DL6ER --- api_db.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/api_db.php b/api_db.php index b4bd8cb3..7c126297 100644 --- a/api_db.php +++ b/api_db.php @@ -131,7 +131,7 @@ if (isset($_GET['topClients']) && $auth) $stmt->bindValue(":until", intval($_GET['until']), SQLITE3_INTEGER); $results = $stmt->execute(); - $clients = array(); + $clientnums = array(); if(!is_bool($results)) while ($row = $results->fetchArray()) @@ -139,25 +139,25 @@ if (isset($_GET['topClients']) && $auth) $c = resolveOnlyHostname($row[0]); - if(array_key_exists($c, $clients)) + if(array_key_exists($c, $clientnums)) { // Entry already exists, add to it (might appear multiple times due to mixed capitalization in the database) - $clients[$c] += intval($row[1]); + $clientnums[$c] += intval($row[1]); } else { // Entry does not yet exist - $clients[$c] = intval($row[1]); + $clientnums[$c] = intval($row[1]); } } // Sort by number of hits - arsort($clients); + arsort($clientnums); // Extract only the first ten entries - $clients = array_slice($clients, 0, 10); + $clientnums = array_slice($clientnums, 0, 10); - $result = array('top_sources' => $clients); + $result = array('top_sources' => $clientnums); $data = array_merge($data, $result); } From 57f0642c0f8afb4a6d450eb4e597b94b5f12e788 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 5 Mar 2018 15:46:23 +0100 Subject: [PATCH 033/172] Remove unused array Signed-off-by: DL6ER --- api_db.php | 1 - 1 file changed, 1 deletion(-) diff --git a/api_db.php b/api_db.php index 7c126297..0c3686f2 100644 --- a/api_db.php +++ b/api_db.php @@ -98,7 +98,6 @@ if (isset($_GET['getAllQueries']) && $auth) $stmt->bindValue(":from", intval($from), SQLITE3_INTEGER); $stmt->bindValue(":until", intval($until), SQLITE3_INTEGER); $results = $stmt->execute(); - $clients = array(); if(!is_bool($results)) while ($row = $results->fetchArray()) { From 1ec38e3a797c57b82b63a88605a9f10619a8e90b Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 5 Mar 2018 16:35:42 +0100 Subject: [PATCH 034/172] Don't want IPs in Query Log output Signed-off-by: DL6ER --- api_FTL.php | 6 +++--- scripts/pi-hole/php/FTL.php | 15 ++++++++++----- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/api_FTL.php b/api_FTL.php index f45efb74..f6aedde2 100644 --- a/api_FTL.php +++ b/api_FTL.php @@ -155,7 +155,7 @@ if ((isset($_GET['topClients']) || isset($_GET['getQuerySources'])) && $auth) foreach($return as $line) { $tmp = explode(" ",$line); - $top_clients[resolveHostname($tmp[2])] = intval($tmp[1]); + $top_clients[resolveHostname($tmp[2],true)] = intval($tmp[1]); } $result = array('top_sources' => $top_clients); @@ -177,7 +177,7 @@ if (isset($_GET['getForwardDestinations']) && $auth) foreach($return as $line) { $tmp = explode(" ",$line); - $forward_dest[resolveHostname($tmp[2])] = floatval($tmp[1]); + $forward_dest[resolveHostname($tmp[2],true)] = floatval($tmp[1]); } $result = array('forward_destinations' => $forward_dest); @@ -226,7 +226,7 @@ if (isset($_GET['getAllQueries']) && $auth) foreach($return as $line) { $tmp = explode(" ",$line); - $tmp[3] = resolveHostname($tmp[3]); + $tmp[3] = resolveHostname($tmp[3],false); array_push($allQueries,$tmp); } diff --git a/scripts/pi-hole/php/FTL.php b/scripts/pi-hole/php/FTL.php index c317c9da..a3b859ce 100644 --- a/scripts/pi-hole/php/FTL.php +++ b/scripts/pi-hole/php/FTL.php @@ -139,17 +139,19 @@ function disconnectFTL($quiet=true) } } -$clients = []; -function resolveHostname($clientip) +$clients = array(); +function resolveHostname($clientip, $printIP) { if(array_key_exists($clientip, $clients)) { // Entry already exists $clientname = $clients[$clientip]; - return $clientname."|".$clientip; + if($printIP) + return $clientname."|".$clientip; + return $clientname; } - if(filter_var($clientip, FILTER_VALIDATE_IP)) + else if(filter_var($clientip, FILTER_VALIDATE_IP)) { // Get host name of client and convert to lower case $clientname = strtolower(gethostbyaddr($clientip)); @@ -161,6 +163,9 @@ function resolveHostname($clientip) } // Buffer result $clients[$clientname] = $clientip; - return $clientname."|".$clientip; + + if($printIP) + return $clientname."|".$clientip; + return $clientname; } ?> From c1ffcdd9975bb4be71d9395b85a593df473eab5e Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 5 Mar 2018 16:43:28 +0100 Subject: [PATCH 035/172] Fix resolveHostname() subroutine Signed-off-by: DL6ER --- scripts/pi-hole/php/FTL.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/pi-hole/php/FTL.php b/scripts/pi-hole/php/FTL.php index a3b859ce..0f6d9a3a 100644 --- a/scripts/pi-hole/php/FTL.php +++ b/scripts/pi-hole/php/FTL.php @@ -142,10 +142,12 @@ function disconnectFTL($quiet=true) $clients = array(); function resolveHostname($clientip, $printIP) { + global $clients; + $ipaddr = strtolower($clientip); if(array_key_exists($clientip, $clients)) { // Entry already exists - $clientname = $clients[$clientip]; + $clientname = $clients[$ipaddr]; if($printIP) return $clientname."|".$clientip; return $clientname; @@ -154,15 +156,15 @@ function resolveHostname($clientip, $printIP) else if(filter_var($clientip, FILTER_VALIDATE_IP)) { // Get host name of client and convert to lower case - $clientname = strtolower(gethostbyaddr($clientip)); + $clientname = strtolower(gethostbyaddr($ipaddr)); } else { // This is already a host name - $clientname = strtolower($clientip); + $clientname = $ipaddr; } // Buffer result - $clients[$clientname] = $clientip; + $clients[$ipaddr] = $clientname; if($printIP) return $clientname."|".$clientip; From 322b87befe78e9f8b5ee8515dadea811ebd147c9 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 5 Mar 2018 16:48:05 +0100 Subject: [PATCH 036/172] Imporve resolveHostname() subroutine Signed-off-by: DL6ER --- api_db.php | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/api_db.php b/api_db.php index 0c3686f2..aee13616 100644 --- a/api_db.php +++ b/api_db.php @@ -16,28 +16,35 @@ check_cors(); ini_set("max_execution_time","600"); $data = array(); -$clients = []; -function resolveOnlyHostname($clientip) +$clients = array(); +function resolveHostname($clientip, $printIP) { + global $clients; + $ipaddr = strtolower($clientip); if(array_key_exists($clientip, $clients)) { // Entry already exists - $clientname = $clients[$clientip]; + $clientname = $clients[$ipaddr]; + if($printIP) + return $clientname."|".$clientip; return $clientname; } - if(filter_var($clientip, FILTER_VALIDATE_IP)) + else if(filter_var($clientip, FILTER_VALIDATE_IP)) { // Get host name of client and convert to lower case - $clientname = strtolower(gethostbyaddr($clientip)); + $clientname = strtolower(gethostbyaddr($ipaddr)); } else { // This is already a host name - $clientname = strtolower($clientip); + $clientname = $ipaddr; } // Buffer result - $clients[$clientname] = $clientip; + $clients[$ipaddr] = $clientname; + + if($printIP) + return $clientname."|".$clientip; return $clientname; } @@ -101,7 +108,7 @@ if (isset($_GET['getAllQueries']) && $auth) if(!is_bool($results)) while ($row = $results->fetchArray()) { - $c = resolveOnlyHostname($row[3]); + $c = resolveHostname($row[3],false); $allQueries[] = [$row[0],$row[1] == 1 ? "IPv4" : "IPv6",$row[2],$c,$row[4]]; } } @@ -136,7 +143,7 @@ if (isset($_GET['topClients']) && $auth) while ($row = $results->fetchArray()) { - $c = resolveOnlyHostname($row[0]); + $c = resolveHostname($row[0],false); if(array_key_exists($c, $clientnums)) { From c278428b288d985474c6f4c4b61f9f2593db1e6d Mon Sep 17 00:00:00 2001 From: DL6ER Date: Thu, 8 Mar 2018 06:56:28 +0100 Subject: [PATCH 037/172] Change header texts, move "show all" hyperlink out of the parentheses Signed-off-by: DL6ER --- queries.php | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/queries.php b/queries.php index 792ee2a3..be147ec1 100644 --- a/queries.php +++ b/queries.php @@ -19,47 +19,49 @@ if(isset($setupVars["API_QUERY_LOG_SHOW"])) { if($setupVars["API_QUERY_LOG_SHOW"] === "all") { - $showing = "showing all queries"; + $showing = "showing"; } elseif($setupVars["API_QUERY_LOG_SHOW"] === "permittedonly") { - $showing = "showing permitted queries only"; + $showing = "showing permitted"; } elseif($setupVars["API_QUERY_LOG_SHOW"] === "blockedonly") { - $showing = "showing blocked queries only"; + $showing = "showing blocked"; } elseif($setupVars["API_QUERY_LOG_SHOW"] === "nothing") { - $showing = "showing no queries at all"; + $showing = "showing no queries (due to setting)"; } } else { // If filter variable is not set, we // automatically show all queries - $showing = "showing all queries"; + $showing = "showing queries"; } +$showall = false; if(isset($_GET["all"])) { - $showing .= " within the Pi-hole log"; + $showing .= " all queries within the Pi-hole log"; } else if(isset($_GET["client"])) { - $showing .= " for client ".htmlentities($_GET["client"]); + $showing .= " queries for client ".htmlentities($_GET["client"]); } else if(isset($_GET["domain"])) { - $showing .= " for domain ".htmlentities($_GET["domain"]); + $showing .= " queries for domain ".htmlentities($_GET["domain"]); } -else if(isset($_GET["from"]) && isset($_GET["until"])) +else if(isset($_GET["from"]) || isset($_GET["until"])) { - $showing .= " within limited time interval"; + $showing .= " queries within specified time interval"; } else { - $showing .= ", most recent 100, show all"; + $showing .= " up to 100 queries"; + $showall = true; } if(isset($setupVars["API_PRIVACY_MODE"])) @@ -74,6 +76,8 @@ if(isset($setupVars["API_PRIVACY_MODE"])) if(strlen($showing) > 0) { $showing = "(".$showing.")"; + if($showall) + $showing .= ", show all"; } ?> From 9be0887dacaac919c8695a3458d90a41a5ed574b Mon Sep 17 00:00:00 2001 From: Frode Aannevik Date: Sun, 18 Mar 2018 14:42:12 +0100 Subject: [PATCH 038/172] move flip-status-x span element into menu fix the issue where the span element is obscuring the Disable/Enable element fixes: https://github.com/pi-hole/AdminLTE/issues/698 Signed-off-by: Frode Aannevik --- scripts/pi-hole/php/header.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/pi-hole/php/header.php b/scripts/pi-hole/php/header.php index 3851a41d..7261ef4b 100644 --- a/scripts/pi-hole/php/header.php +++ b/scripts/pi-hole/php/header.php @@ -461,7 +461,7 @@ if($auth) { - Disable    + Disable   
  • @@ -493,7 +493,7 @@ if($auth) {
  • hidden="true"> - Enable    + Enable   
  • active"> From a5ca08c84d94299ecbd07b050d02365b77624c54 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 20 Mar 2018 00:20:09 +0100 Subject: [PATCH 039/172] Add custom tooltip as suggested by user @kh0505 here: https://github.com/pi-hole/AdminLTE/issues/603#issuecomment-373933097 Signed-off-by: DL6ER --- index.php | 25 +++++++++++++++ scripts/pi-hole/js/index.js | 64 ++++++++++++++++++++++++++++++++++++- 2 files changed, 88 insertions(+), 1 deletion(-) diff --git a/index.php b/index.php index c56266a4..416261ac 100644 --- a/index.php +++ b/index.php @@ -115,6 +115,31 @@ else
    +
    diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index 9f8cb8c6..5dd9e853 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -792,8 +792,12 @@ $(document).ready(function() { }, options: { tooltips: { - enabled: true, + enabled: false, mode: "x-axis", + custom: customTooltips, + itemSort: function(a, b) { + return b.yLabel - a.yLabel + }, callbacks: { title: function(tooltipItem, data) { var label = tooltipItem[0].xLabel; @@ -1025,3 +1029,61 @@ $(document).ready(function() { updateForwardDestinationsPie(); } }); + +var customTooltips = function(tooltip) { + // Tooltip Element + var tooltipEl = document.getElementById('chartjs-tooltip'); + if (!tooltipEl) { + tooltipEl = document.createElement('div'); + tooltipEl.id = 'chartjs-tooltip'; + tooltipEl.innerHTML = '
    '; + document.body.appendChild(tooltipEl); + } + // Hide if no tooltip + if (tooltip.opacity === 0) { + tooltipEl.style.opacity = 0; + return; + } + // Set caret Position + tooltipEl.classList.remove('above', 'below', 'no-transform'); + if (tooltip.yAlign) { + tooltipEl.classList.add(tooltip.yAlign); + } else { + tooltipEl.classList.add('above'); + } + function getBody(bodyItem) { + return bodyItem.lines; + } + // Set Text + if (tooltip.body) { + var titleLines = tooltip.title || []; + var bodyLines = tooltip.body.map(getBody); + var innerHtml = ''; + titleLines.forEach(function(title) { + innerHtml += '' + title + ''; + }); + innerHtml += ''; + bodyLines.forEach(function(body, i) { + var colors = tooltip.labelColors[i]; + var style = 'background:' + colors.backgroundColor; + style += '; border-color:' + colors.borderColor; + style += '; border-width: 2px'; + var span = ''; + innerHtml += '' + span + body + ''; + }); + innerHtml += ''; + var tableRoot = tooltipEl.querySelector('table'); + tableRoot.innerHTML = innerHtml; + } + + // Display, position, and set styles for font + var position = this._chart.canvas.getBoundingClientRect(); + tooltipEl.style.opacity = 1; + tooltipEl.style.left = position.left + tooltip.caretX + "px"; + tooltipEl.style.top = position.top + tooltip.caretY + 'px'; + tooltipEl.style.fontFamily = tooltip._bodyFontFamily; + tooltipEl.style.fontSize = tooltip.bodyFontSize + 'px'; + tooltipEl.style.fontStyle = tooltip._bodyFontStyle; + tooltipEl.style.padding = tooltip.yPadding + 'px ' + tooltip.xPadding + 'px'; + + }; From 5e7caa0f0bef566f0f6caea0de12c70805e1c3f7 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 20 Mar 2018 00:22:16 +0100 Subject: [PATCH 040/172] Move style definition into correct file Signed-off-by: DL6ER --- index.php | 25 ------------------------- style/pi-hole.css | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/index.php b/index.php index 416261ac..c56266a4 100644 --- a/index.php +++ b/index.php @@ -115,31 +115,6 @@ else
    -
    diff --git a/style/pi-hole.css b/style/pi-hole.css index 541d5c6e..6a0279f5 100644 --- a/style/pi-hole.css +++ b/style/pi-hole.css @@ -115,3 +115,27 @@ a.lookatme { -webkit-animation: fa-spin 1s infinite linear; animation: fa-spin 1s infinite linear; } + +canvas{ + -moz-user-select: none; + -webkit-user-select: none; + -ms-user-select: none; +} +#chartjs-tooltip { + opacity: 1; + position: absolute; + background: rgba(0, 0, 0, .7); + color: white; + border-radius: 3px; + -webkit-transition: all .1s ease; + transition: all .1s ease; + pointer-events: none; + -webkit-transform: translate(-50%, 0); + transform: translate(-50%, 0); +} +.chartjs-tooltip-key { + display: inline-block; + width: 20px; + height: 10px; + margin-right: 10px; +} From b6be5629ac25fb0ea6bb827a85dafe67fa86d84c Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 20 Mar 2018 00:28:39 +0100 Subject: [PATCH 041/172] Show only non-zero entries Signed-off-by: DL6ER --- scripts/pi-hole/js/index.js | 116 ++++++++++++++++++++---------------- 1 file changed, 63 insertions(+), 53 deletions(-) diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index 5dd9e853..7ec8a9c4 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -1031,59 +1031,69 @@ $(document).ready(function() { }); var customTooltips = function(tooltip) { - // Tooltip Element - var tooltipEl = document.getElementById('chartjs-tooltip'); - if (!tooltipEl) { - tooltipEl = document.createElement('div'); - tooltipEl.id = 'chartjs-tooltip'; - tooltipEl.innerHTML = '
    '; - document.body.appendChild(tooltipEl); - } - // Hide if no tooltip - if (tooltip.opacity === 0) { - tooltipEl.style.opacity = 0; - return; - } - // Set caret Position - tooltipEl.classList.remove('above', 'below', 'no-transform'); - if (tooltip.yAlign) { - tooltipEl.classList.add(tooltip.yAlign); - } else { - tooltipEl.classList.add('above'); - } - function getBody(bodyItem) { - return bodyItem.lines; - } - // Set Text - if (tooltip.body) { - var titleLines = tooltip.title || []; - var bodyLines = tooltip.body.map(getBody); - var innerHtml = ''; - titleLines.forEach(function(title) { - innerHtml += '' + title + ''; - }); - innerHtml += ''; - bodyLines.forEach(function(body, i) { - var colors = tooltip.labelColors[i]; - var style = 'background:' + colors.backgroundColor; - style += '; border-color:' + colors.borderColor; - style += '; border-width: 2px'; - var span = ''; - innerHtml += '' + span + body + ''; - }); - innerHtml += ''; - var tableRoot = tooltipEl.querySelector('table'); - tableRoot.innerHTML = innerHtml; + // Tooltip Element + var tooltipEl = document.getElementById('chartjs-tooltip'); + if (!tooltipEl) { + tooltipEl = document.createElement('div'); + tooltipEl.id = 'chartjs-tooltip'; + tooltipEl.innerHTML = '
    '; + document.body.appendChild(tooltipEl); + } + // Hide if no tooltip + if (tooltip.opacity === 0) { + tooltipEl.style.opacity = 0; + return; + } + // Set caret Position + tooltipEl.classList.remove('above', 'below', 'no-transform'); + if (tooltip.yAlign) { + tooltipEl.classList.add(tooltip.yAlign); + } else { + tooltipEl.classList.add('above'); + } + function getBody(bodyItem) { + return bodyItem.lines; + } + // Set Text + if (tooltip.body) { + var titleLines = tooltip.title || []; + var bodyLines = tooltip.body.map(getBody); + var innerHtml = ''; + titleLines.forEach(function(title) { + innerHtml += '' + title + ''; + }); + innerHtml += ''; + var printed = 0; + bodyLines.forEach(function(body, i) { + var colors = tooltip.labelColors[i]; + var style = 'background:' + colors.backgroundColor; + style += '; border-color:' + colors.borderColor; + style += '; border-width: 2px'; + var span = ''; + var num = body[0].split(':'); + if(num[1] > 0) + { + innerHtml += '' + span + body + ''; + printed++; } + }); + if(printed < 1) + { + innerHtml += 'No activity recorded'; + } + innerHtml += ''; + var tableRoot = tooltipEl.querySelector('table'); + tableRoot.innerHTML = innerHtml; + } - // Display, position, and set styles for font - var position = this._chart.canvas.getBoundingClientRect(); - tooltipEl.style.opacity = 1; - tooltipEl.style.left = position.left + tooltip.caretX + "px"; - tooltipEl.style.top = position.top + tooltip.caretY + 'px'; - tooltipEl.style.fontFamily = tooltip._bodyFontFamily; - tooltipEl.style.fontSize = tooltip.bodyFontSize + 'px'; - tooltipEl.style.fontStyle = tooltip._bodyFontStyle; - tooltipEl.style.padding = tooltip.yPadding + 'px ' + tooltip.xPadding + 'px'; + // Display, position, and set styles for font + var position = this._chart.canvas.getBoundingClientRect(); + tooltipEl.style.opacity = 1; + tooltipEl.style.left = position.left + tooltip.caretX + "px"; + tooltipEl.style.top = position.top + tooltip.caretY + 'px'; + tooltipEl.style.fontFamily = tooltip._bodyFontFamily; + tooltipEl.style.fontSize = tooltip.bodyFontSize + 'px'; + tooltipEl.style.fontStyle = tooltip._bodyFontStyle; + tooltipEl.style.padding = tooltip.yPadding + 'px ' + tooltip.xPadding + 'px'; - }; +}; From e3cd76ad7d931c04294758399e07ef187368c396 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 20 Mar 2018 00:50:53 +0100 Subject: [PATCH 042/172] Add simple measure to prevent compression of the tooltip at the right edge of the screen (may be improved, not tested on mobile screens) Signed-off-by: DL6ER --- scripts/pi-hole/js/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index 7ec8a9c4..5e722325 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -1088,12 +1088,17 @@ var customTooltips = function(tooltip) { // Display, position, and set styles for font var position = this._chart.canvas.getBoundingClientRect(); + var width = tooltip.caretX; + // Prevent compression of the tooltip at the right edge of the screen + if($(document).width() - tooltip.caretX < 400) + { + width = $(document).width()-400; + } tooltipEl.style.opacity = 1; - tooltipEl.style.left = position.left + tooltip.caretX + "px"; + tooltipEl.style.left = position.left + width + "px"; tooltipEl.style.top = position.top + tooltip.caretY + 'px'; tooltipEl.style.fontFamily = tooltip._bodyFontFamily; tooltipEl.style.fontSize = tooltip.bodyFontSize + 'px'; tooltipEl.style.fontStyle = tooltip._bodyFontStyle; tooltipEl.style.padding = tooltip.yPadding + 'px ' + tooltip.xPadding + 'px'; - }; From f6b2887b90deba0ef0bf11bca124b078bc936840 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 20 Mar 2018 19:29:11 +0100 Subject: [PATCH 043/172] Slight improvement to CSS Signed-off-by: DL6ER --- index.php | 2 +- style/pi-hole.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/index.php b/index.php index c56266a4..9207cda7 100644 --- a/index.php +++ b/index.php @@ -114,7 +114,7 @@ else
    - +
    diff --git a/style/pi-hole.css b/style/pi-hole.css index 6a0279f5..14fdb8aa 100644 --- a/style/pi-hole.css +++ b/style/pi-hole.css @@ -116,7 +116,7 @@ a.lookatme { animation: fa-spin 1s infinite linear; } -canvas{ +.extratooltipcanvas{ -moz-user-select: none; -webkit-user-select: none; -ms-user-select: none; From f1c516895f15f2046e6127fd3e0102da17e30e5f Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Thu, 22 Mar 2018 23:56:36 -0500 Subject: [PATCH 044/172] align this readme with the core one. formatting and layout is now the same. also added a ton of updated screenshots. finally, updated donation and affiliate links Signed-off-by: Jacob Salmela --- README.md | 194 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 174 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index e3f3b257..505edf19 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,186 @@ -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) +

    +Pi-hole

    +Network-wide ad blocking via your own Linux hardware
    +
    +Pi-hole Web interface
    +

    -[![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") +Pi-hole[®](https://pi-hole.net/trademark-rules-and-brand-guidelines/)'s Web interface (based off of [AdminLTE](https://almsaeedstudio.com)) provides a central location to manage your Pi-hole and review the statistics generated by FTLDNS[™](https://pi-hole.net/trademark-rules-and-brand-guidelines/). -Using **[AdminLTE](https://almsaeedstudio.com)**, this project will create a Web interface for the ad-blocking Pi-hole: **a black hole for Internet advertisements**. +- **Easy-to-interpret**: simple graphs and beautiful colors make Pi-hole's stats easy to understand +- **Responsive**: looks great on desktop, tablets, and mobile devices +- **Useful**: control and configure your Pi-hole with our settings +- **Insightful**: use the query log, audit log, or long-term stats to gain insight into your networks activity -From this interface, you will be able to see stats on how well your Pi-hole is performing. You will also be able to update the lists used to block ads. +--- + +
    -![Pi-hole Web interface](http://i.imgur.com/EgGZXbT.png) +# Installation + +The Web interface is enabled by default when you install Pi-hole. + +## Post-installation: access the Web interface and gain insight into your network's activity +There are several ways to [access the dashboard](https://discourse.pi-hole.net/t/how-do-i-access-pi-holes-dashboard-admin-interface/3168): + +1. `http:///admin/` +2. `http:/pi.hole/admin/` (when using Pi-hole as your DNS server) +3. `http://pi.hole/` (when using Pi-hole as your DNS server) + +Once logged in (forgot your password?), you can view your network stats to see things like: + +- the domains being queried on your network +- the time the queries were initiated +- the amount of domains that were blocked +- the upstream server queries were sent to +- the type of queries (`A`, `AAAA`, `CNAME`, `SRV`, `TXT`, etc.) +--- + +## Pi-hole is free, but powered by your support +There are many reoccurring costs involved with maintaining free, open source, and privacy respecting software; expenses which [our volunteer developers](https://github.com/orgs/pi-hole/people) pitch in to cover out-of-pocket. This is just one example of how strongly we feel about our software, as well as the importance of keeping it maintained. + +Make no mistake: **your support is absolutely vital to help keep us innovating!** + +### Donations +Sending a donation using our links below is **extremely helpful** in offsetting a portion of our monthly expenses: + +- PP Donate via PayPal
    +- BTC [Bitcoin](https://commerce.coinbase.com/checkout/fb7facaf-bebd-46be-bb77-b358f4546763): 1GKnevUnVaQM2pQieMyeHkpr8DXfkpfAtL
    +- BTC [Bitcoin Cash](https://commerce.coinbase.com/checkout/fb7facaf-bebd-46be-bb77-b358f4546763): qqh25hlmqaj99xraw00e47xmf8sysnyxhyww2d7dnh
    +- BTC [Ethereum](https://commerce.coinbase.com/checkout/fb7facaf-bebd-46be-bb77-b358f4546763): 0xF00aF43d2431BAD585056492b310e48eC40D87e8 + +### Alternative support +If you'd rather not [donate](https://pi-hole.net/donate/) (_which is okay!_), there are other ways you can help support us: + +- [Digital Ocean](http://www.digitalocean.com/?refcode=344d234950e1) _affiliate link_ +- [UNIXstickers.com](http://unixstickers.refr.cc/jacobs) _save $5 when you spend $9 using our affiliate link_ +- [Pi-hole Swag Store](https://pi-hole.net/shop/) _affiliate link_ +- [Amazon](http://www.amazon.com/exec/obidos/redirect-home/pihole09-20) _affiliate link_ +- [Ho-ost](https://clients.ho-ost.com/aff.php?aff=19) _save 50% with our affiliate link_ +- [DNS Made Easy](https://cp.dnsmadeeasy.com/u/133706) _affiliate link_ +- [Vultr](http://www.vultr.com/?ref=7190426) _affiliate link_ +- Spreading the word about our software, and how you have benefited from it + +### Contributing via GitHub +We welcome _everyone_ to contribute to issue reports, suggest new features, and create pull requests. + +If you have something to add - anything from a typo through to a whole new feature, we're happy to check it out! Just make sure to fill out our template when submitting your request; the questions that it asks will help the volunteers quickly understand what you're aiming to achieve. + +### Presentations about Pi-hole +Word-of-mouth continues to help our project grow immensely, and so we are helping make this easier for people. + +If you are going to be presenting Pi-hole at a conference, meetup or even a school project, [get in touch with us](https://pi-hole.net/2017/05/17/giving-a-presentation-on-pi-hole-contact-us-first-for-some-goodies-and-support/) so we can hook you up with free swag to hand out to your audience! + +----- + +## Getting in touch with us +While we are primarily reachable on our Discourse User Forum, we can also be found on a variety of social media outlets. **Please be sure to check the FAQ's** before starting a new discussion, as we do not have the spare time to reply to every request for assistance. + + + +# Features + +## Mobile friendly interface +

    +Mobile friendly +

    + +## Password protection +

    +Password protection +

    + +## Detailed graphs and doughnut charts +

    +Pie charts +

    + +## Top lists of domains and clients +

    +Top domains/top clients +

    + +## A filterable and sortable query log +

    +Query log +

    + +## An audit log +

    +Pi-hole Web interface +

    + +## Long Term Statistics to view data over user defined time ranges +

    +Long-term stats +

    + +## A built-in debugger +

    +Debugger +

    + +## Black and white lists +

    +Blacklist +

    +Whitelist +

    + +## The ability to easily manage and configure Pi-hole features +

    +Settings +

    + +## ... and all the main features of the Command Line Interface! +

    +Tail the log +

    +Query ad lists +

    ## API -A read-only API can be accessed at `/admin/api.php`. With either no parameters or `api.php?summary` it returns the following JSON: +Full usage available [here](https://discourse.pi-hole.net/t/pi-hole-api/1863). can be accessed at `/admin/api.php`. With either no parameters or `/admin/api.php?summary` it returns the following JSON: ```JSON -{ - "domains_being_blocked": "136,708", - "dns_queries_today": "18,108", - "ads_blocked_today": "14,648", - "ads_percentage_today": "80.9" +{ + "domains_being_blocked":243038, + "dns_queries_today":2385, + "ads_blocked_today":414, + "ads_percentage_today":17.35849, + "unique_domains":429, + "queries_forwarded":1537, + "queries_cached":434, + "clients_ever_seen":5, + "unique_clients":5, + "status":"enabled" } ``` -There are many more parameters, such as `summaryRaw`, `overTimeData10mins`, `topItems`, ` topClients` or `getQuerySources`, `getQueryTypes`, `getForwardDestinations`, and finally `getAllQueries`. -Together with a token it is also possible to enable and disable (also with a set timeout) blocking via the API +[There are many more parameters](https://discourse.pi-hole.net/t/pi-hole-api/1863), such as: -The API returns more information (in a slighly different format if `FTL` is running) - it supports a fall-back to the "old" PHP API if `FTL` is not running. Test the type and/or version of the API by using the parameter `type` and `version`. +- `type & version` +- `summaryRaw` +- `summary` +- `overTimeData10mins` +- `topItems` +- `getQuerySources` +- `getForwardDestinations` +- `getQueryTypes` +- `getAllQueries` +- `enable` +- `disable` +- `recentBlocked` -
    -
    -We use BrowserStack for multi-platform multi-browser testing. +Together with a token it is also possible to [enable and disable (also with a set timeout) blocking via the API](https://discourse.pi-hole.net/t/is-there-an-api-command-to-disable-ad-blocking/7693). + +The API returns more information (in a slightly different format if `FTL` is running) - it supports a fall-back to the "old" PHP API if `FTL` is not running. Test the type and/or version of the API by using the parameter `type` and `version`. From 5c8c6885dd9542e3d3c13733c2419adb174c2784 Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Fri, 23 Mar 2018 19:33:45 -0500 Subject: [PATCH 045/172] add settings gif Signed-off-by: Jacob Salmela --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 505edf19..57412759 100644 --- a/README.md +++ b/README.md @@ -139,7 +139,7 @@ While we are primarily reachable on our -Settings +Settings

    ## ... and all the main features of the Command Line Interface! From 44774d914c40cf4fae9ebd6af6dcf899a1c7abe2 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 25 Mar 2018 10:20:26 +0200 Subject: [PATCH 046/172] We should split the string at ": " instead of at ":" to be fully compatible with IPv6 addresses Signed-off-by: DL6ER --- 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 5e722325..4212cbb6 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -1070,7 +1070,7 @@ var customTooltips = function(tooltip) { style += '; border-color:' + colors.borderColor; style += '; border-width: 2px'; var span = ''; - var num = body[0].split(':'); + var num = body[0].split(': '); if(num[1] > 0) { innerHtml += '' + span + body + ''; From 062ba5141bb5e17a679d611c224664bd7a448631 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 25 Mar 2018 11:32:36 +0200 Subject: [PATCH 047/172] Strings must use doublequote Signed-off-by: DL6ER --- scripts/pi-hole/js/index.js | 42 ++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index 4212cbb6..1c52a18f 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -1032,11 +1032,11 @@ $(document).ready(function() { var customTooltips = function(tooltip) { // Tooltip Element - var tooltipEl = document.getElementById('chartjs-tooltip'); + var tooltipEl = document.getElementById("chartjs-tooltip"); if (!tooltipEl) { - tooltipEl = document.createElement('div'); - tooltipEl.id = 'chartjs-tooltip'; - tooltipEl.innerHTML = '
    '; + tooltipEl = document.createElement("div"); + tooltipEl.id = "chartjs-tooltip"; + tooltipEl.innerHTML = "
    "; document.body.appendChild(tooltipEl); } // Hide if no tooltip @@ -1045,11 +1045,11 @@ var customTooltips = function(tooltip) { return; } // Set caret Position - tooltipEl.classList.remove('above', 'below', 'no-transform'); + tooltipEl.classList.remove("above", "below", "no-transform"); if (tooltip.yAlign) { tooltipEl.classList.add(tooltip.yAlign); } else { - tooltipEl.classList.add('above'); + tooltipEl.classList.add("above"); } function getBody(bodyItem) { return bodyItem.lines; @@ -1058,31 +1058,31 @@ var customTooltips = function(tooltip) { if (tooltip.body) { var titleLines = tooltip.title || []; var bodyLines = tooltip.body.map(getBody); - var innerHtml = ''; + var innerHtml = ""; titleLines.forEach(function(title) { - innerHtml += '' + title + ''; + innerHtml += "" + title + ""; }); - innerHtml += ''; + innerHtml += ""; var printed = 0; bodyLines.forEach(function(body, i) { var colors = tooltip.labelColors[i]; - var style = 'background:' + colors.backgroundColor; - style += '; border-color:' + colors.borderColor; - style += '; border-width: 2px'; - var span = ''; - var num = body[0].split(': '); + var style = "background:" + colors.backgroundColor; + style += "; border-color:" + colors.borderColor; + style += "; border-width: 2px"; + var span = ""; + var num = body[0].split(": "); if(num[1] > 0) { - innerHtml += '' + span + body + ''; + innerHtml += "" + span + body + ""; printed++; } }); if(printed < 1) { - innerHtml += 'No activity recorded'; + innerHtml += "No activity recorded"; } - innerHtml += ''; - var tableRoot = tooltipEl.querySelector('table'); + innerHtml += ""; + var tableRoot = tooltipEl.querySelector("table"); tableRoot.innerHTML = innerHtml; } @@ -1096,9 +1096,9 @@ var customTooltips = function(tooltip) { } tooltipEl.style.opacity = 1; tooltipEl.style.left = position.left + width + "px"; - tooltipEl.style.top = position.top + tooltip.caretY + 'px'; + tooltipEl.style.top = position.top + tooltip.caretY + "px"; tooltipEl.style.fontFamily = tooltip._bodyFontFamily; - tooltipEl.style.fontSize = tooltip.bodyFontSize + 'px'; + tooltipEl.style.fontSize = tooltip.bodyFontSize + "px"; tooltipEl.style.fontStyle = tooltip._bodyFontStyle; - tooltipEl.style.padding = tooltip.yPadding + 'px ' + tooltip.xPadding + 'px'; + tooltipEl.style.padding = tooltip.yPadding + "px " + tooltip.xPadding + "px"; }; From 517fa24fe387bd4589b70d5a48751055bc44e99c Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 25 Mar 2018 13:44:48 +0200 Subject: [PATCH 048/172] Show "N/A" for queries where the reply has not yet reached the Pi-hole Signed-off-by: DL6ER --- scripts/pi-hole/js/queries.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/pi-hole/js/queries.js b/scripts/pi-hole/js/queries.js index fbfb9a0e..d4c469b2 100644 --- a/scripts/pi-hole/js/queries.js +++ b/scripts/pi-hole/js/queries.js @@ -218,7 +218,11 @@ $(document).ready(function() { if(data.length > 6 && !blocked) { $("td:eq(5)", row).css("color","black"); - if (data[6] === "1") + if (data[6] === "0") + { + $("td:eq(5)", row).html("N/A"); + } + else if (data[6] === "1") { $("td:eq(5)", row).html("NODATA-" + data[1]); } From 2aca7bf7642b2c7c1513e27801bb4044c61b6a0d Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 25 Mar 2018 14:00:02 +0200 Subject: [PATCH 049/172] customTooltips must be defined before used Signed-off-by: DL6ER --- scripts/pi-hole/js/index.js | 146 ++++++++++++++++++------------------ 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index 1c52a18f..385c3da3 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -29,6 +29,79 @@ function objectToArray(p){ return [idx,arr]; } +var customTooltips = function(tooltip) { + // Tooltip Element + var tooltipEl = document.getElementById("chartjs-tooltip"); + if (!tooltipEl) { + tooltipEl = document.createElement("div"); + tooltipEl.id = "chartjs-tooltip"; + tooltipEl.innerHTML = "
    "; + document.body.appendChild(tooltipEl); + } + // Hide if no tooltip + if (tooltip.opacity === 0) { + tooltipEl.style.opacity = 0; + return; + } + // Set caret Position + tooltipEl.classList.remove("above", "below", "no-transform"); + if (tooltip.yAlign) { + tooltipEl.classList.add(tooltip.yAlign); + } else { + tooltipEl.classList.add("above"); + } + function getBody(bodyItem) { + return bodyItem.lines; + } + // Set Text + if (tooltip.body) { + var titleLines = tooltip.title || []; + var bodyLines = tooltip.body.map(getBody); + var innerHtml = ""; + titleLines.forEach(function(title) { + innerHtml += "" + title + ""; + }); + innerHtml += ""; + var printed = 0; + bodyLines.forEach(function(body, i) { + var colors = tooltip.labelColors[i]; + var style = "background:" + colors.backgroundColor; + style += "; border-color:" + colors.borderColor; + style += "; border-width: 2px"; + var span = ""; + var num = body[0].split(": "); + if(num[1] > 0) + { + innerHtml += "" + span + body + ""; + printed++; + } + }); + if(printed < 1) + { + innerHtml += "No activity recorded"; + } + innerHtml += ""; + var tableRoot = tooltipEl.querySelector("table"); + tableRoot.innerHTML = innerHtml; + } + + // Display, position, and set styles for font + var position = this._chart.canvas.getBoundingClientRect(); + var width = tooltip.caretX; + // Prevent compression of the tooltip at the right edge of the screen + if($(document).width() - tooltip.caretX < 400) + { + width = $(document).width()-400; + } + tooltipEl.style.opacity = 1; + tooltipEl.style.left = position.left + width + "px"; + tooltipEl.style.top = position.top + tooltip.caretY + "px"; + tooltipEl.style.fontFamily = tooltip._bodyFontFamily; + tooltipEl.style.fontSize = tooltip.bodyFontSize + "px"; + tooltipEl.style.fontStyle = tooltip._bodyFontStyle; + tooltipEl.style.padding = tooltip.yPadding + "px " + tooltip.xPadding + "px"; +}; + // Functions to update data in page var failures = 0; @@ -1029,76 +1102,3 @@ $(document).ready(function() { updateForwardDestinationsPie(); } }); - -var customTooltips = function(tooltip) { - // Tooltip Element - var tooltipEl = document.getElementById("chartjs-tooltip"); - if (!tooltipEl) { - tooltipEl = document.createElement("div"); - tooltipEl.id = "chartjs-tooltip"; - tooltipEl.innerHTML = "
    "; - document.body.appendChild(tooltipEl); - } - // Hide if no tooltip - if (tooltip.opacity === 0) { - tooltipEl.style.opacity = 0; - return; - } - // Set caret Position - tooltipEl.classList.remove("above", "below", "no-transform"); - if (tooltip.yAlign) { - tooltipEl.classList.add(tooltip.yAlign); - } else { - tooltipEl.classList.add("above"); - } - function getBody(bodyItem) { - return bodyItem.lines; - } - // Set Text - if (tooltip.body) { - var titleLines = tooltip.title || []; - var bodyLines = tooltip.body.map(getBody); - var innerHtml = ""; - titleLines.forEach(function(title) { - innerHtml += "" + title + ""; - }); - innerHtml += ""; - var printed = 0; - bodyLines.forEach(function(body, i) { - var colors = tooltip.labelColors[i]; - var style = "background:" + colors.backgroundColor; - style += "; border-color:" + colors.borderColor; - style += "; border-width: 2px"; - var span = ""; - var num = body[0].split(": "); - if(num[1] > 0) - { - innerHtml += "" + span + body + ""; - printed++; - } - }); - if(printed < 1) - { - innerHtml += "No activity recorded"; - } - innerHtml += ""; - var tableRoot = tooltipEl.querySelector("table"); - tableRoot.innerHTML = innerHtml; - } - - // Display, position, and set styles for font - var position = this._chart.canvas.getBoundingClientRect(); - var width = tooltip.caretX; - // Prevent compression of the tooltip at the right edge of the screen - if($(document).width() - tooltip.caretX < 400) - { - width = $(document).width()-400; - } - tooltipEl.style.opacity = 1; - tooltipEl.style.left = position.left + width + "px"; - tooltipEl.style.top = position.top + tooltip.caretY + "px"; - tooltipEl.style.fontFamily = tooltip._bodyFontFamily; - tooltipEl.style.fontSize = tooltip.bodyFontSize + "px"; - tooltipEl.style.fontStyle = tooltip._bodyFontStyle; - tooltipEl.style.padding = tooltip.yPadding + "px " + tooltip.xPadding + "px"; -}; From 7bf5207e060445df7796c794c3174dec1b61ea79 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 25 Mar 2018 18:39:03 +0200 Subject: [PATCH 050/172] Fix JS error Signed-off-by: DL6ER --- 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 385c3da3..b52aeaa4 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -68,7 +68,7 @@ var customTooltips = function(tooltip) { var style = "background:" + colors.backgroundColor; style += "; border-color:" + colors.borderColor; style += "; border-width: 2px"; - var span = ""; + var span = ""; var num = body[0].split(": "); if(num[1] > 0) { From 27d40465cdb05f9a4c817ca240624aabf991f346 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 25 Mar 2018 18:48:23 +0200 Subject: [PATCH 051/172] Use jQuery's .html() routine to overwrite element's content Signed-off-by: DL6ER --- scripts/pi-hole/js/index.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index b52aeaa4..ae7f52d9 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -35,8 +35,8 @@ var customTooltips = function(tooltip) { if (!tooltipEl) { tooltipEl = document.createElement("div"); tooltipEl.id = "chartjs-tooltip"; - tooltipEl.innerHTML = "
    "; document.body.appendChild(tooltipEl); + $("#chartjs-tooltip").html("
    "); } // Hide if no tooltip if (tooltip.opacity === 0) { @@ -57,7 +57,7 @@ var customTooltips = function(tooltip) { if (tooltip.body) { var titleLines = tooltip.title || []; var bodyLines = tooltip.body.map(getBody); - var innerHtml = ""; + var innerHtml = ""; titleLines.forEach(function(title) { innerHtml += ""; }); @@ -80,9 +80,8 @@ var customTooltips = function(tooltip) { { innerHtml += ""; } - innerHtml += ""; - var tableRoot = tooltipEl.querySelector("table"); - tableRoot.innerHTML = innerHtml; + innerHtml += "
    " + title + "
    No activity recorded
    "; + $("#chartjs-tooltip").html(innerHtml); } // Display, position, and set styles for font From 5aba5a1314a251a6cc0dd339c0ea45c3e43a08e5 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 25 Mar 2018 18:49:15 +0200 Subject: [PATCH 052/172] Add missing semicolon Signed-off-by: DL6ER --- 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 ae7f52d9..cfd51726 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -868,7 +868,7 @@ $(document).ready(function() { mode: "x-axis", custom: customTooltips, itemSort: function(a, b) { - return b.yLabel - a.yLabel + return b.yLabel - a.yLabel; }, callbacks: { title: function(tooltipItem, data) { From dca374bfcd30aaff1f348549b66530c5fb3f00ca Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 1 Apr 2018 16:39:54 +0200 Subject: [PATCH 053/172] Simplify NODATA reply type (no need to show A/AAAA here as we show that in the second column) and add reply time if available Signed-off-by: DL6ER --- scripts/pi-hole/js/queries.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/pi-hole/js/queries.js b/scripts/pi-hole/js/queries.js index d4c469b2..04c3a771 100644 --- a/scripts/pi-hole/js/queries.js +++ b/scripts/pi-hole/js/queries.js @@ -224,7 +224,7 @@ $(document).ready(function() { } else if (data[6] === "1") { - $("td:eq(5)", row).html("NODATA-" + data[1]); + $("td:eq(5)", row).html("NODATA"); } else if (data[6] === "2") { @@ -248,6 +248,11 @@ $(document).ready(function() { $("td:eq(5)", row).css("color","black"); $("td:eq(5)", row).html("-"); } + if(data.length > 7 && data[7] > 0) + { + var content = $("td:eq(5)", row).html(); + $("td:eq(5)", row).html(content + " (" + (0.1*data[7]).toFixed(1)+"ms)"); + } }, dom: "<'row'<'col-sm-12'f>>" + From 5e9c1aec9a117c699d99bcc13546a3c4677d0f63 Mon Sep 17 00:00:00 2001 From: Everett Southwick Date: Sun, 1 Apr 2018 18:02:09 -0500 Subject: [PATCH 054/172] Add support for public Cloudflare DNS servers. Signed-off-by: Everett Southwick --- scripts/pi-hole/php/savesettings.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/pi-hole/php/savesettings.php b/scripts/pi-hole/php/savesettings.php index a17bc5f7..af8a90ec 100644 --- a/scripts/pi-hole/php/savesettings.php +++ b/scripts/pi-hole/php/savesettings.php @@ -123,7 +123,8 @@ function isinserverlist($addr) { "Norton" => ["v4_1" => "199.85.126.10", "v4_2" => "199.85.127.10"], "Comodo" => ["v4_1" => "8.26.56.26", "v4_2" => "8.20.247.20"], "DNS.WATCH" => ["v4_1" => "84.200.69.80", "v4_2" => "84.200.70.40", "v6_1" => "2001:1608:10:25:0:0:1c04:b12f", "v6_2" => "2001:1608:10:25:0:0:9249:d69b"], - "Quad9" => ["v4_1" => "9.9.9.9", "v4_2" => "149.112.112.112", "v6_1" => "2620:fe::fe"] + "Quad9" => ["v4_1" => "9.9.9.9", "v4_2" => "149.112.112.112", "v6_1" => "2620:fe::fe"], + "Cloudflare" => ["v4_1" => "1.1.1.1", "v4_2" => "1.0.0.1", "v6_1" => "2606:4700:4700::1111", "v6_2" => "2606:4700:4700::1001"] ]; $adlist = []; From 8b2e7b89ace329704e859d7475e7a2ab3fc24088 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 2 Apr 2018 14:28:48 +0200 Subject: [PATCH 055/172] Add separate legends for pie charts on the dashboard. Fixes #635 Signed-off-by: DL6ER --- index.php | 14 ++++++++++---- scripts/pi-hole/js/index.js | 26 ++++++++++++++++++++++---- style/pi-hole.css | 28 ++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 8 deletions(-) diff --git a/index.php b/index.php index c56266a4..3874380e 100644 --- a/index.php +++ b/index.php @@ -132,8 +132,11 @@ else

    Query Types (integrated)

    -
    - +
    + +
    +
    +
    @@ -148,8 +151,11 @@ else

    Forward Destinations (integrated)

    -
    - +
    + +
    +
    +
    diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index 9f8cb8c6..7636ed9d 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -178,6 +178,16 @@ function updateQueryTypesPie() { queryTypePieChart.update(); // Don't use rotation animation for further updates queryTypePieChart.options.animation.duration=0; + // Generate legend in separate div + $("#query-types-legend").html(queryTypePieChart.generateLegend()); + $("#query-types-legend > ul > li").on("click",function(e){ + $(this).toggleClass("strike"); + var index = $(this).index(); + var ci = e.view.queryTypePieChart; + var curr = ci.data.datasets[0]._meta[3].data[index]; + curr.hidden = !curr.hidden; + ci.update(); + }); }).done(function() { // Reload graph after minute setTimeout(updateQueryTypesPie, 60000); @@ -392,6 +402,16 @@ function updateForwardDestinationsPie() { forwardDestinationPieChart.update(); // Don't use rotation animation for further updates forwardDestinationPieChart.options.animation.duration=0; + // Generate legend in separate div + $("#forward-destinations-legend").html(forwardDestinationPieChart.generateLegend()); + $("#forward-destinations-legend > ul > li").on("click",function(e){ + $(this).toggleClass("strike"); + var index = $(this).index(); + var ci = e.view.forwardDestinationPieChart; + var curr = ci.data.datasets[0]._meta[3].data[index]; + curr.hidden = !curr.hidden; + ci.update(); + }); }).done(function() { // Reload graph after one minute setTimeout(updateForwardDestinationsPie, 60000); @@ -960,8 +980,7 @@ $(document).ready(function() { }, options: { legend: { - display: true, - position: "right" + display: false }, tooltips: { enabled: true, @@ -998,8 +1017,7 @@ $(document).ready(function() { }, options: { legend: { - display: true, - position: "right" + display: false }, tooltips: { enabled: true, diff --git a/style/pi-hole.css b/style/pi-hole.css index 541d5c6e..59389e9e 100644 --- a/style/pi-hole.css +++ b/style/pi-hole.css @@ -115,3 +115,31 @@ a.lookatme { -webkit-animation: fa-spin 1s infinite linear; animation: fa-spin 1s infinite linear; } + +.chart-legend { + height:250px; + overflow:auto; +} + +.chart-legend ul { + list-style-type: none; +} + +.chart-legend li { + cursor:pointer; +} + +.chart-legend li span { + display: inline-block; + width: 20px; + height: 12px; + margin-right: 5px; +} + +.strike { + text-decoration: line-through !important; +} + +.float-left{ + float:left; +} From e5e956ace65c29d6f59ed1270611fd8a21b022df Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 2 Apr 2018 22:07:07 +0200 Subject: [PATCH 056/172] Automatically detect which _meta to use Signed-off-by: DL6ER --- scripts/pi-hole/js/index.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index 7636ed9d..75b275b5 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -184,8 +184,12 @@ function updateQueryTypesPie() { $(this).toggleClass("strike"); var index = $(this).index(); var ci = e.view.queryTypePieChart; - var curr = ci.data.datasets[0]._meta[3].data[index]; - curr.hidden = !curr.hidden; + var meta = ci.data.datasets[0]._meta; + for(let i in meta) + { + var curr = meta[i].data[index]; + curr.hidden = !curr.hidden; + } ci.update(); }); }).done(function() { @@ -408,8 +412,12 @@ function updateForwardDestinationsPie() { $(this).toggleClass("strike"); var index = $(this).index(); var ci = e.view.forwardDestinationPieChart; - var curr = ci.data.datasets[0]._meta[3].data[index]; - curr.hidden = !curr.hidden; + var meta = ci.data.datasets[0]._meta; + for(let i in meta) + { + var curr = meta[i].data[index]; + curr.hidden = !curr.hidden; + } ci.update(); }); }).done(function() { From 4cf0f4d6ff9ae4abace3555b696a1ebc33891dbe Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 2 Apr 2018 22:29:38 +0200 Subject: [PATCH 057/172] Make sure the properties exist when looping over objects Signed-off-by: DL6ER --- scripts/pi-hole/js/index.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index 75b275b5..f9452cbd 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -187,8 +187,11 @@ function updateQueryTypesPie() { var meta = ci.data.datasets[0]._meta; for(let i in meta) { - var curr = meta[i].data[index]; - curr.hidden = !curr.hidden; + if ({}.hasOwnProperty.call(meta, i)) + { + var curr = meta[i].data[index]; + curr.hidden = !curr.hidden; + } } ci.update(); }); @@ -415,8 +418,11 @@ function updateForwardDestinationsPie() { var meta = ci.data.datasets[0]._meta; for(let i in meta) { - var curr = meta[i].data[index]; - curr.hidden = !curr.hidden; + if ({}.hasOwnProperty.call(meta, i)) + { + var curr = meta[i].data[index]; + curr.hidden = !curr.hidden; + } } ci.update(); }); From 7244e3a9e0db9add9240498246399b6a4aa3c945 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Mon, 2 Apr 2018 17:43:19 -0400 Subject: [PATCH 058/172] Don't search for the element by ID when we already have it Signed-off-by: Mcat12 --- 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 cfd51726..98376e79 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -36,7 +36,7 @@ var customTooltips = function(tooltip) { tooltipEl = document.createElement("div"); tooltipEl.id = "chartjs-tooltip"; document.body.appendChild(tooltipEl); - $("#chartjs-tooltip").html("
    "); + $(tooltipEl).html("
    "); } // Hide if no tooltip if (tooltip.opacity === 0) { @@ -81,7 +81,7 @@ var customTooltips = function(tooltip) { innerHtml += "No activity recorded"; } innerHtml += ""; - $("#chartjs-tooltip").html(innerHtml); + $(tooltipEl).html(innerHtml); } // Display, position, and set styles for font From 6e99e1daaf91e870d12588a8c39609653e96754e Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 3 Apr 2018 10:19:33 +0200 Subject: [PATCH 059/172] Remove old privacy settings from FTLDNS branch as they are superseded by FTL's new privacy levels which take action momentarily and don't require a restart of the resolver. Settings for them still have to be implemented on the dashboard. Signed-off-by: DL6ER --- settings.php | 41 ++--------------------------------------- 1 file changed, 2 insertions(+), 39 deletions(-) diff --git a/settings.php b/settings.php index b2b264a6..129f5e76 100644 --- a/settings.php +++ b/settings.php @@ -844,10 +844,10 @@ if (isset($_GET['tab']) && in_array($_GET['tab'], array("sysadmin", "blocklists"
    - value=""> - value="">
    @@ -911,43 +911,6 @@ if (isset($_GET['tab']) && in_array($_GET['tab'], array("sysadmin", "blocklists"
    -
    -
    -

    Privacy settings (Statistics / Query Log)

    -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    -

    Privacy mode

    -
    -
    - -
    -
    -
    -