diff --git a/data.php b/data.php index 8c3ee81a..d24befd7 100644 --- a/data.php +++ b/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; } diff --git a/header.html b/header.html index 9e904bea..49371f74 100644 --- a/header.html +++ b/header.html @@ -123,17 +123,21 @@ + +
  • diff --git a/index.php b/index.php index ef7bad78..32b7ce36 100644 --- a/index.php +++ b/index.php @@ -347,7 +347,7 @@ queryTypeChart.addData({ value: value, color: colors.shift(), - label: key + label: key.substr(6,key.length - 7) }); }); $('#query-types .overlay').remove(); diff --git a/list.php b/list.php deleted file mode 100644 index 8087f20f..00000000 --- a/list.php +++ /dev/null @@ -1,212 +0,0 @@ - - - - - - -
    - - - - - -
    - - - - - - - - - - - - - - - diff --git a/php/add.php b/php/add.php deleted file mode 100644 index c602119d..00000000 --- a/php/add.php +++ /dev/null @@ -1,17 +0,0 @@ -= 0; $i--) { - if($list[$i] == "") - unset($list[$i]); -} - -echo json_encode(array_values($list)); \ No newline at end of file diff --git a/php/sub.php b/php/sub.php deleted file mode 100644 index 9c5862e9..00000000 --- a/php/sub.php +++ /dev/null @@ -1,17 +0,0 @@ -Type Domain Client + Status @@ -32,6 +33,7 @@ Type Domain Client + Status @@ -50,6 +52,15 @@ - - + \ No newline at end of file