diff --git a/includes/functions.php b/includes/functions.php index 0386ef63..55d1d1f7 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -376,3 +376,44 @@ function optionsForSelect($options) } return $html; } + +function blocklistUpdated($file) +{ + $blocklist = RASPI_CONFIG.'/adblock/'.$file; + if (file_exists($blocklist)) { + $lastModified = date ("F d Y H:i:s.", filemtime($blocklist)); + $lastModified = formatDateAgo($lastModified); + return $lastModified; + } else { + return 'Never'; + } +} + +function formatDateAgo($datetime, $full = false) +{ + $now = new DateTime; + $ago = new DateTime($datetime); + $diff = $now->diff($ago); + + $diff->w = floor($diff->d / 7); + $diff->d -= $diff->w * 7; + + $string = array( + 'y' => 'year', + 'm' => 'month', + 'w' => 'week', + 'd' => 'day', + 'h' => 'hour', + 'i' => 'minute', + 's' => 'second', + ); + foreach ($string as $k => &$v) { + if ($diff->$k) { + $v = $diff->$k . ' ' . $v . ($diff->$k > 1 ? 's' : ''); + } else { + unset($string[$k]); + } + } + if (!$full) $string = array_slice($string, 0, 1); + return $string ? implode(', ', $string) . ' ago' : 'just now'; +} diff --git a/templates/adblock/general.php b/templates/adblock/general.php index 769a592c..f541ed26 100644 --- a/templates/adblock/general.php +++ b/templates/adblock/general.php @@ -11,21 +11,27 @@

block DNS requests for ads, tracking and other virtual garbage. Blocklists are gathered from multiple, actively maintained sources and automatically updated, cleaned, optimized and moderated on a daily basis.") ?> -

+
conf-file and addn-hosts to the dnsmasq configuration.") ?>

-
- -
- - +
+

+

Hostnames blocklist last updated:
+
Domains blocklist last updated:
+

+
+ +
+ + +