Check for empty strings

This commit is contained in:
billz 2020-09-20 09:42:13 +01:00
parent 9b02fc5b27
commit 3c5737224e
1 changed files with 13 additions and 11 deletions

View File

@ -24,6 +24,7 @@ function DisplayAdBlockConfig()
if ($_POST['adblock-custom-enable'] == "1") {
// validate custom hosts input
$lines = preg_split('/\r\n|\n|\r/', trim($_POST['adblock-custom-hosts']));
if (!in_array("", $lines, true)) {
foreach ($lines as $line) {
$ip_host = preg_split('/\s+/', $line);
$index++;
@ -36,7 +37,8 @@ function DisplayAdBlockConfig()
break;
}
}
file_put_contents("/tmp/dnsmasq_custom", $_POST['adblock-custom-hosts']);
}
file_put_contents("/tmp/dnsmasq_custom", $_POST['adblock-custom-hosts'].PHP_EOL);
system("sudo cp /tmp/dnsmasq_custom " .RASPI_ADBLOCK_LISTPATH .'custom.txt', $return);
$config.= 'addn-hosts=' .RASPI_ADBLOCK_LISTPATH .'custom.txt'.PHP_EOL;
$custom_enabled = true;