Skip to content

Commit

Permalink
Fixed status indicator
Browse files Browse the repository at this point in the history
Was still using old indexing
  • Loading branch information
AzureMarker committed Mar 18, 2016
1 parent edeaaab commit 5394118
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions data.php
Expand Up @@ -121,29 +121,28 @@ function getAllQueries() {
$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]])){
if (isset($new_lines[$exploded[count($exploded)-3]])){
$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),
Expand All @@ -152,7 +151,6 @@ function getAllQueries() {
$extra,
));
}

return $allQueries;
}

Expand Down

0 comments on commit 5394118

Please sign in to comment.