From 1db322b96367ab5f5d6cc3dccbf591e5e08879f1 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sat, 10 Feb 2018 14:10:55 +0100 Subject: [PATCH 1/3] Show most recent 100 queries instead of queries within most recent 10 minutes Signed-off-by: DL6ER --- api_FTL.php | 4 ++++ queries.php | 2 +- scripts/pi-hole/js/queries.js | 13 +++++++------ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/api_FTL.php b/api_FTL.php index d4e1c085..61efa5b9 100644 --- a/api_FTL.php +++ b/api_FTL.php @@ -230,6 +230,10 @@ if (isset($_GET['getAllQueries']) && $auth) // Get specific client only sendRequestFTL("getallqueries-client ".$_GET['client']); } + else if(is_numeric($_GET['getAllQueries'])) + { + sendRequestFTL("getallqueries (".$_GET['getAllQueries'].")"); + } else { // Get all queries diff --git a/queries.php b/queries.php index 89ed91d7..792ee2a3 100644 --- a/queries.php +++ b/queries.php @@ -59,7 +59,7 @@ else if(isset($_GET["from"]) && isset($_GET["until"])) } else { - $showing .= " within recent 10 minutes, show all"; + $showing .= ", most recent 100, show all"; } if(isset($setupVars["API_PRIVACY_MODE"])) diff --git a/scripts/pi-hole/js/queries.js b/scripts/pi-hole/js/queries.js index 722f8543..623ce881 100644 --- a/scripts/pi-hole/js/queries.js +++ b/scripts/pi-hole/js/queries.js @@ -122,26 +122,27 @@ $(document).ready(function() { location.search.substr(1).split("&").forEach(function(item) {GETDict[item.split("=")[0]] = item.split("=")[1];}); var APIstring = "api.php?getAllQueries"; + var options = ""; if("from" in GETDict && "until" in GETDict) { - APIstring += "&from="+GETDict["from"]; + options += "&from="+GETDict["from"]; APIstring += "&until="+GETDict["until"]; } else if("client" in GETDict) { - APIstring += "&client="+GETDict["client"]; + options += "&client="+GETDict["client"]; } else if("domain" in GETDict) { - APIstring += "&domain="+GETDict["domain"]; + options += "&domain="+GETDict["domain"]; } + // If we don't ask filtering and also not for all queries, just request the most recent 100 queries else if(!("all" in GETDict)) { - var timestamp = Math.floor(Date.now() / 1000); - APIstring += "&from="+(timestamp - 600); - APIstring += "&until="+(timestamp + 100); + APIstring += "=100"; } + APIstring += options; tableApi = $("#all-queries").DataTable( { "rowCallback": function( row, data, index ){ From c62daea621eb9b7dd174f671ce951316736d53bb Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sat, 10 Feb 2018 16:32:29 +0100 Subject: [PATCH 2/3] Remove unnecessary options variable Signed-off-by: DL6ER --- scripts/pi-hole/js/queries.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/scripts/pi-hole/js/queries.js b/scripts/pi-hole/js/queries.js index 623ce881..58ec73b9 100644 --- a/scripts/pi-hole/js/queries.js +++ b/scripts/pi-hole/js/queries.js @@ -82,7 +82,7 @@ function add(domain,list) { } }); }); - + // Reset Modal after it has faded out alertModal.one("hidden.bs.modal", function() { alProcessing.show(); @@ -122,27 +122,25 @@ $(document).ready(function() { location.search.substr(1).split("&").forEach(function(item) {GETDict[item.split("=")[0]] = item.split("=")[1];}); var APIstring = "api.php?getAllQueries"; - var options = ""; if("from" in GETDict && "until" in GETDict) { - options += "&from="+GETDict["from"]; + APIstring += "&from="+GETDict["from"]; APIstring += "&until="+GETDict["until"]; } else if("client" in GETDict) { - options += "&client="+GETDict["client"]; + APIstring += "&client="+GETDict["client"]; } else if("domain" in GETDict) { - options += "&domain="+GETDict["domain"]; + APIstring += "&domain="+GETDict["domain"]; } // If we don't ask filtering and also not for all queries, just request the most recent 100 queries else if(!("all" in GETDict)) { APIstring += "=100"; } - APIstring += options; tableApi = $("#all-queries").DataTable( { "rowCallback": function( row, data, index ){ From c278428b288d985474c6f4c4b61f9f2593db1e6d Mon Sep 17 00:00:00 2001 From: DL6ER Date: Thu, 8 Mar 2018 06:56:28 +0100 Subject: [PATCH 3/3] 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"; } ?>