diff --git a/api.php b/api.php index 87246f43..d9f22550 100644 --- a/api.php +++ b/api.php @@ -39,6 +39,10 @@ $data = array_merge($data, getForwardDestinations()); } + if (isset($_GET['getQuerySources'])) { + $data = array_merge($data, getQuerySources()); + } + echo json_encode($data); ?> diff --git a/data.php b/data.php index 2a7a128c..06ec811b 100644 --- a/data.php +++ b/data.php @@ -100,6 +100,23 @@ } + function getQuerySources() { + $log = readInLog(); + $dns_queries = getDnsQueries($log); + $sources = array(); + foreach($dns_queries as $query) { + $exploded = explode(" ", $query); + $ip = trim($exploded[count($exploded)-1]); + if (isset($sources[$ip])) { + $sources[$ip]++; + } + else { + $sources[$ip] = 1; + } + } + return $sources; + } + /******** Private Members ********/ function readInBlockList() { global $domains; diff --git a/index.php b/index.php index 7757531e..dbd66c17 100644 --- a/index.php +++ b/index.php @@ -95,6 +95,22 @@