Only enable/disable those lists where the status should be changed (efficiency + speed)

This commit is contained in:
DL6ER
2016-12-16 15:22:58 +01:00
parent 7b87301e7c
commit 6e7020a8ba
2 changed files with 8 additions and 6 deletions
+7 -5
View File
@@ -328,15 +328,17 @@ function readAdlists(&$list, $listname)
case "adlists":
foreach ($adlistsdefault as $key => $value)
{
if(isset($_POST["adlist-".$key]))
if(isset($_POST["adlist-".$key]) && !$value[0])
{
$action = "enable";
// Is not enabled, but should be
exec("sudo pihole -a adlist enable ".escapeshellcmd ($value[1]));
}
else
elseif(!isset($_POST["adlist-".$key]) && $value[0])
{
$action = "disable";
// Is enabled, but shouldn't be
exec("sudo pihole -a adlist disable ".escapeshellcmd ($value[1]));
}
exec("sudo pihole -a adlist ".$action." ".escapeshellcmd ($value[1]));
}
if(strlen($_POST["newuserlists"]) > 1)
+1 -1
View File
@@ -494,7 +494,7 @@
<label>User defined lists</label>
<?php foreach ($adlistsuser as $key => $value) { ?>
<div class="form-group">
<div class="checkbox"><label style="word-break: break-word;"><input type="checkbox" name="adlist-<?php echo $key; ?>" <?php if($value[0]){ ?>checked<?php } ?>> <a href="<?php echo htmlentities ($value[1]); ?>" target="_new"><?php echo htmlentities($value[1]); ?></a></label></div>
<div class="checkbox"><label style="word-break: break-word;"><input type="checkbox" name="userlist-<?php echo $key; ?>" <?php if($value[0]){ ?>checked<?php } ?>> <a href="<?php echo htmlentities ($value[1]); ?>" target="_new"><?php echo htmlentities($value[1]); ?></a></label></div>
</div>
<?php } ?>
<div class="form-group">