mirror of
https://github.com/pi-hole/web.git
synced 2024-12-06 19:36:21 +01:00
Added functions getOverTimeData10mins() and overTime10mins($entries)
This commit is contained in:
@@ -37,6 +37,20 @@
|
||||
);
|
||||
}
|
||||
|
||||
function getOverTimeData10mins() {
|
||||
global $log;
|
||||
$dns_queries = getDnsQueries($log);
|
||||
$ads_blocked = getBlockedQueries($log);
|
||||
|
||||
$domains_over_time = overTime10mins($dns_queries);
|
||||
$ads_over_time = overTime10mins($ads_blocked);
|
||||
alignTimeArrays($ads_over_time, $domains_over_time);
|
||||
return Array(
|
||||
'domains_over_time' => $domains_over_time,
|
||||
'ads_over_time' => $ads_over_time,
|
||||
);
|
||||
}
|
||||
|
||||
function getTopItems() {
|
||||
global $log;
|
||||
$dns_queries = getDnsQueries($log);
|
||||
@@ -252,6 +266,25 @@
|
||||
return $byTime;
|
||||
}
|
||||
|
||||
function overTime10mins($entries) {
|
||||
$byTime = array();
|
||||
foreach ($entries as $entry) {
|
||||
$time = date_create(substr($entry, 0, 16));
|
||||
$hour = $time->format('G');
|
||||
$minute = $time->format('i');
|
||||
|
||||
$time = $minute/6 + 6*$hour;
|
||||
|
||||
if (isset($byTime[$time])) {
|
||||
$byTime[$time]++;
|
||||
}
|
||||
else {
|
||||
$byTime[$time] = 1;
|
||||
}
|
||||
}
|
||||
return $byTime;
|
||||
}
|
||||
|
||||
function alignTimeArrays(&$times1, &$times2) {
|
||||
if(count($times1) == 0 || count($times2) < 2) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user