Merge branch 'devel' into fixQueryLog

Conflicts:
	data.php
This commit is contained in:
Mcat12
2016-03-16 20:55:45 -04:00
10 changed files with 41 additions and 284 deletions

View File

@@ -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;
}