diff --git a/api.php b/api.php index 395be210..e0341c15 100644 --- a/api.php +++ b/api.php @@ -31,6 +31,10 @@ } } + if (isset($_GET['getQueryTypes'])) { + $data = array_merge($data, getIpvType()); + } + echo json_encode($data); ?> diff --git a/data.php b/data.php index 802302c5..c86c299c 100644 --- a/data.php +++ b/data.php @@ -62,6 +62,25 @@ ); } + function getIpvType() { + $log = readInLog(); + $dns_queries = getDnsQueries($log); + $queryTypes = array(); + + foreach($dns_queries as $query) { + $info = trim(explode(": ", $query)[1]); + $queryType = explode(" ", $info)[0]; + if (isset($queryTypes[$queryType])) { + $queryTypes[$queryType]++; + } + else { + $queryTypes[$queryType] = 1; + } + } + + return $queryTypes; + } + /******** Private Members ********/ function readInBlockList() { global $domains; @@ -147,11 +166,11 @@ } function findQueries($var) { - return strpos($var, "query") != false; + return strpos($var, ": query[") !== false; } function findAds($var) { - return strpos($var, "gravity.list") != false; + return strpos($var, "gravity.list") !== false; } /* $data = array( diff --git a/index.php b/index.php index 24e96bc8..b62fc9d9 100644 --- a/index.php +++ b/index.php @@ -57,6 +57,7 @@ +