diff --git a/api_db.php b/api_db.php index 51d59ba4..e40ac160 100644 --- a/api_db.php +++ b/api_db.php @@ -202,7 +202,8 @@ if (isset($_GET['topDomains']) && $auth) { $limit = " AND timestamp <= :until"; } - $stmt = $db->prepare('SELECT domain,count(domain) FROM queries WHERE (STATUS == 2 OR STATUS == 3)'.$limit.' GROUP by domain order by count(domain) desc limit 20'); + // Select top permitted domains only + $stmt = $db->prepare('SELECT domain,count(domain) FROM queries WHERE status IN (2,3,12,13,14)'.$limit.' GROUP by domain order by count(domain) desc limit 20'); $stmt->bindValue(":from", intval($_GET['from']), SQLITE3_INTEGER); $stmt->bindValue(":until", intval($_GET['until']), SQLITE3_INTEGER); $results = $stmt->execute(); @@ -252,7 +253,7 @@ if (isset($_GET['topAds']) && $auth) { $limit = " AND timestamp <= :until"; } - $stmt = $db->prepare('SELECT domain,count(domain) FROM queries WHERE (STATUS == 1 OR STATUS > 3)'.$limit.' GROUP by domain order by count(domain) desc limit 10'); + $stmt = $db->prepare('SELECT domain,count(domain) FROM queries WHERE status IN (1,4,5,6,7,8,9,10,11)'.$limit.' GROUP by domain order by count(domain) desc limit 10'); $stmt->bindValue(":from", intval($_GET['from']), SQLITE3_INTEGER); $stmt->bindValue(":until", intval($_GET['until']), SQLITE3_INTEGER); $results = $stmt->execute(); @@ -384,7 +385,7 @@ if (isset($_GET['getGraphData']) && $auth) $data = array_merge($data, $result); // Count blocked queries in intervals - $stmt = $db->prepare('SELECT (timestamp/:interval)*:interval interval, COUNT(*) FROM queries WHERE (status == 1 OR status > 3)'.$limit.' GROUP by interval ORDER by interval'); + $stmt = $db->prepare('SELECT (timestamp/:interval)*:interval interval, COUNT(*) FROM queries WHERE status IN (1,4,5,6,7,8,9,10,11)'.$limit.' GROUP by interval ORDER by interval'); $stmt->bindValue(":from", $from, SQLITE3_INTEGER); $stmt->bindValue(":until", $until, SQLITE3_INTEGER); $stmt->bindValue(":interval", $interval, SQLITE3_INTEGER); diff --git a/scripts/pi-hole/js/db_queries.js b/scripts/pi-hole/js/db_queries.js index 131c0f42..2c87dc15 100644 --- a/scripts/pi-hole/js/db_queries.js +++ b/scripts/pi-hole/js/db_queries.js @@ -146,7 +146,7 @@ var reloadCallback = function () { var data = tableApi.rows().data(); for (var i = 0; i < data.length; i++) { statistics[0]++; // TOTAL query - if (data[i][4] === 1 || (data[i][4] > 4 && data[i][4] !== 10)) { + if (data[i][4] === 1 || (data[i][4] > 4 && ![10, 12, 13, 14].includes(data[i][4]))) { statistics[2]++; // EXACT blocked } else if (data[i][4] === 3) { statistics[1]++; // CACHE query