mirror of
https://github.com/pi-hole/web.git
synced 2026-04-28 04:33:58 +01:00
Merge branch 'devel' into fixQueryLog
Conflicts: data.php
This commit is contained in:
25
data.php
25
data.php
@@ -14,7 +14,7 @@
|
||||
|
||||
$ads_blocked_today = count(getBlockedQueries($log));
|
||||
|
||||
$ads_percentage_today = $ads_blocked_today / $dns_queries_today * 100;
|
||||
$ads_percentage_today = $dns_queries_today > 0 ? ($ads_blocked_today / $dns_queries_today * 100) : 0;
|
||||
|
||||
return array(
|
||||
'domains_being_blocked' => $domains_being_blocked,
|
||||
@@ -121,19 +121,38 @@
|
||||
$allQueries = array("data" => array());
|
||||
$log = readInLog();
|
||||
$dns_queries = getDnsQueries($log);
|
||||
|
||||
|
||||
$fileName = '/etc/pihole/gravity.list';
|
||||
//Turn gravity.list into an array
|
||||
$lines = explode("\n", file_get_contents($fileName));
|
||||
|
||||
//Create a new array and set domain name as index instead of value, with value as 1
|
||||
foreach(array_values($lines) as $v){
|
||||
$new_lines[trim(strstr($v, ' '))] = 1;
|
||||
}
|
||||
|
||||
foreach ($dns_queries as $query) {
|
||||
$time = date_create(substr($query, 0, 16));
|
||||
|
||||
$exploded = explode(" ", trim($query));
|
||||
|
||||
//Is index of the domain name set?
|
||||
if (isset($new_lines[$exploded[6]])){
|
||||
$extra = "Pi-holed";
|
||||
}
|
||||
else
|
||||
{
|
||||
$extra = "OK";
|
||||
}
|
||||
array_push($allQueries['data'], array(
|
||||
$time->format('Y-m-d\TH:i:s'),
|
||||
substr($exploded[count($exploded)-4], 6, -1),
|
||||
$exploded[count($exploded)-3],
|
||||
$exploded[count($exploded)-1],
|
||||
$extra,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
return $allQueries;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user