From ae26f948a402f9231f6399ad5533599585db6a39 Mon Sep 17 00:00:00 2001 From: billz Date: Thu, 26 Mar 2020 19:45:39 +0000 Subject: [PATCH] WIP --- config/blocklists.json | 5 +++ config/config.php | 1 + includes/adblock.php | 35 ++++++++++++++++ includes/defaults.php | 1 + includes/functions.php | 6 +++ index.php | 9 +++++ templates/adblock.php | 90 ++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 147 insertions(+) create mode 100644 config/blocklists.json create mode 100644 includes/adblock.php create mode 100755 templates/adblock.php diff --git a/config/blocklists.json b/config/blocklists.json new file mode 100644 index 00000000..6a4ea178 --- /dev/null +++ b/config/blocklists.json @@ -0,0 +1,5 @@ +{ + "notracking/hosts-blocklist": [ + "notracking-master" + ] +} diff --git a/config/config.php b/config/config.php index 9966bd93..479419d1 100755 --- a/config/config.php +++ b/config/config.php @@ -30,6 +30,7 @@ define('RASPI_WIFICLIENT_ENABLED', true); define('RASPI_HOTSPOT_ENABLED', true); define('RASPI_NETWORK_ENABLED', true); define('RASPI_DHCP_ENABLED', true); +define('RASPI_ADBLOCK_ENABLED', true); define('RASPI_OPENVPN_ENABLED', false); define('RASPI_TORPROXY_ENABLED', false); define('RASPI_CONFAUTH_ENABLED', true); diff --git a/includes/adblock.php b/includes/adblock.php new file mode 100644 index 00000000..b4da1a58 --- /dev/null +++ b/includes/adblock.php @@ -0,0 +1,35 @@ + 0); + $serviceStatus = $dnsmasq_state ? "up" : "down"; + + echo renderTemplate( + "adblock", compact( + "status", + "serviceStatus" + ) + ); +} + +/** + * BZ: todo + * + */ +function SaveAdBlockConfig() +{ + +} diff --git a/includes/defaults.php b/includes/defaults.php index a3e7374c..36147b91 100755 --- a/includes/defaults.php +++ b/includes/defaults.php @@ -31,6 +31,7 @@ $defaults = [ 'RASPI_HOTSPOT_ENABLED' => true, 'RASPI_NETWORK_ENABLED' => true, 'RASPI_DHCP_ENABLED' => true, + 'RASPI_ADBLOCK_ENABLED' => true, 'RASPI_OPENVPN_ENABLED' => false, 'RASPI_TORPROXY_ENABLED' => false, 'RASPI_CONFAUTH_ENABLED' => true, diff --git a/includes/functions.php b/includes/functions.php index e177aa52..0386ef63 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -352,6 +352,12 @@ function dnsServers() return (array) $data; } +function blocklistProviders() +{ + $data = json_decode(file_get_contents("./config/blocklists.json")); + return (array) $data; +} + function optionsForSelect($options) { $html = ""; diff --git a/index.php b/index.php index 4ba4e760..7dcdacb8 100755 --- a/index.php +++ b/index.php @@ -31,6 +31,7 @@ require_once 'includes/authenticate.php'; require_once 'includes/admin.php'; require_once 'includes/dhcp.php'; require_once 'includes/hostapd.php'; +require_once 'includes/adblock.php'; require_once 'includes/system.php'; require_once 'includes/sysstats.php'; require_once 'includes/configure_client.php'; @@ -137,6 +138,11 @@ $bridgedEnabled = $arrHostapdConf['BridgedEnable']; + + + @@ -239,6 +245,9 @@ $bridgedEnabled = $arrHostapdConf['BridgedEnable']; case "hostapd_conf": DisplayHostAPDConfig(); break; + case "adblock_conf": + DisplayAdBlockConfig(); + break; case "openvpn_conf": DisplayOpenVPNConfig(); break; diff --git a/templates/adblock.php b/templates/adblock.php new file mode 100755 index 00000000..4ee17a85 --- /dev/null +++ b/templates/adblock.php @@ -0,0 +1,90 @@ +
+
+
+
+
+
+ +
+
+ +
+
+
+
+ showMessages(); ?> +
+ + + + +
+ + +
+ +
+
+

+ +
+ +
+ aria-describedby="adblock-description"> + +
+

+ 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.") ?> +
+

+
+ +
+
+ +
+
+
+
+
+ + +
+

+
+
+ '; + ?> +
+
+
+ + + ' , PHP_EOL; + } else { + echo '' , PHP_EOL; + } + ?> + + +
+
+ +
+
+
+