From 6b1d6d19ac478c91ff8206014c744adab9fb2dcf Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 5 Dec 2016 13:30:24 +0100 Subject: [PATCH] Add function countBlockedQueries() --- data.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/data.php b/data.php index d0d4d6e9..f57cf200 100644 --- a/data.php +++ b/data.php @@ -11,7 +11,7 @@ $dns_queries_today = countDnsQueries(); - $ads_blocked_today = count(getBlockedQueries($log)); + $ads_blocked_today = countBlockedQueries(); $ads_percentage_today = $dns_queries_today > 0 ? ($ads_blocked_today / $dns_queries_today * 100) : 0; @@ -230,6 +230,11 @@ return $lines; } + function countBlockedQueries() { + $hostname = trim(file_get_contents("/etc/hostname"), "\x00..\x1F"); + return exec("grep \"gravity.list\" /var/log/pihole.log | grep -v \"pi.hole\" | grep -v -c \"".$hostname."\""); + } + function getForwards(\SplFileObject $log) { $log->rewind(); $lines = [];