Move function add_regex($regex) to func.php

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2018-07-15 12:48:46 +02:00
parent 65d0c7a1d9
commit 3e4613caf0
2 changed files with 17 additions and 17 deletions

View File

@@ -45,4 +45,21 @@ if(!function_exists('hash_equals')) {
}
}
function add_regex($regex)
{
global $regexfile;
if(file_put_contents($regexfile, "\n".$regex, FILE_APPEND) === FALSE)
{
$err = error_get_last()["message"];
echo "Unable to add regex \"".htmlspecialchars($regex)."\" to ${regexfile}<br>Error message: $err";
}
else
{
// Send SIGHUP to pihole-FTL using a frontend command
// to force reloading of the regex domains
// This will also wipe the resolver's cache
echo exec("sudo pihole restartdns reload");
}
}
?>