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 = [];