diff --git a/list.php b/list.php index dc8097c16..308eccf0f 100644 --- a/list.php +++ b/list.php @@ -24,6 +24,7 @@ function getFullName() { +

Note that the ad list domains are automatically added to the whitelist so that a list can never get blocked by another list.

@@ -48,6 +49,7 @@ function getFullName() { Failure! Something went wrong.
+ diff --git a/scripts/pi-hole/js/gravity.js b/scripts/pi-hole/js/gravity.js index a208cae12..1a00ee27f 100644 --- a/scripts/pi-hole/js/gravity.js +++ b/scripts/pi-hole/js/gravity.js @@ -32,9 +32,23 @@ $("#gravityBtn").on("click", () => { eventsource(); }); +$("#gravityBtn").on("click", () => { + $("#gravityBtn").attr("disabled", true); + eventsource(); +}); + // Handle hiding of alerts $(function(){ $("[data-hide]").on("click", function(){ $(this).closest("." + $(this).attr("data-hide")).hide(); }); + + // Do we want to start updating immediately? + // gravity.php?go + var searchString = window.location.search.substring(1); + if(searchString.indexOf("go") !== -1) + { + $("#gravityBtn").attr("disabled", true); + eventsource(); + } }); diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js index e7e613eac..b614bdeed 100644 --- a/scripts/pi-hole/js/settings.js +++ b/scripts/pi-hole/js/settings.js @@ -87,3 +87,14 @@ $(document).ready(function(){ $("[data-toggle=\"tooltip\"]").tooltip({"html": true, container : "body"}); }); +// Handle list deletion +$("button[id^='adlist-btn-']").on("click", function (e) { + e.preventDefault(); + + var status = $(this).siblings("input[name^='adlist-del-']").is(":checked"); + var textType = status ? "none" : "line-through"; + + $(this).siblings("input[name^='adlist-del-']").prop("checked", !status); + $(this).siblings("input[name^='adlist-enable-']").prop("disabled", !status); + $(this).siblings("a").css("text-decoration", textType); +}); diff --git a/scripts/pi-hole/php/savesettings.php b/scripts/pi-hole/php/savesettings.php index e65a7a610..08cbbcc29 100644 --- a/scripts/pi-hole/php/savesettings.php +++ b/scripts/pi-hole/php/savesettings.php @@ -48,6 +48,35 @@ function validDomain($domain_name) "8.20.247.20" => "Comodo" ]; +$adlist = []; +function readAdlists() +{ + // Reset list + $list = []; + $handle = @fopen("/etc/pihole/adlists.list", "r"); + if ($handle) + { + while (($line = fgets($handle)) !== false) + { + if(substr($line, 0, 5) === "#http") + { + // Commented list + array_push($list, [false,rtrim(substr($line, 1))]); + } + elseif(substr($line, 0, 4) === "http") + { + // Active list + array_push($list, [true,rtrim($line)]); + } + } + fclose($handle); + } + return $list; +} + + // Read available adlists + $adlist = readAdlists(); + $error = ""; $success = ""; @@ -369,6 +398,41 @@ function validDomain($domain_name) break; + case "adlists": + foreach ($adlist as $key => $value) + { + if(isset($_POST["adlist-del-".$key])) + { + // Delete list + exec("sudo pihole -a adlist del ".escapeshellcmd($value[1])); + } + elseif(isset($_POST["adlist-enable-".$key]) && !$value[0]) + { + // Is not enabled, but should be + exec("sudo pihole -a adlist enable ".escapeshellcmd($value[1])); + + } + elseif(!isset($_POST["adlist-enable-".$key]) && $value[0]) + { + // Is enabled, but shouldn't be + exec("sudo pihole -a adlist disable ".escapeshellcmd($value[1])); + } + } + + if(strlen($_POST["newuserlists"]) > 1) + { + $domains = array_filter(preg_split('/\r\n|[\r\n]/', $_POST["newuserlists"])); + foreach($domains as $domain) + { + exec("sudo pihole -a adlist add ".escapeshellcmd($domain)); + } + } + + // Reread available adlists + $adlist = readAdlists(); + + break; + default: // Option not found $debug = true; diff --git a/settings.php b/settings.php index 21e89fc16..95c989045 100644 --- a/settings.php +++ b/settings.php @@ -11,11 +11,19 @@ } + refresh to the gravity page and start updating immediately +?> + + + @@ -518,7 +526,43 @@ function convertseconds($argument) { } ?> -
+
+
+

Pi-Hole's Block Lists

+
+
+
+
+
+ + $value) { ?> +
+
+ +
+
+ +
+ +
+
+
+ +
+
+

API