mirror of
https://github.com/pi-hole/web.git
synced 2026-04-24 18:59:48 +01:00
Implement whitelist regex support to web interface.
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
@@ -44,12 +44,18 @@ switch($type) {
|
||||
echo shell_exec("sudo pihole -a audit ".$domains);
|
||||
}
|
||||
break;
|
||||
case "regex":
|
||||
case "black_regex":
|
||||
echo shell_exec("sudo pihole --regex --web ".$domains);
|
||||
break;
|
||||
case "wild":
|
||||
case "white_regex":
|
||||
echo shell_exec("sudo pihole --whiteregex --web ".$domains);
|
||||
break;
|
||||
case "black_wild":
|
||||
echo shell_exec("sudo pihole --wild --web ".$domains);
|
||||
break;
|
||||
case "white_wild":
|
||||
echo shell_exec("sudo pihole --whitewild --web ".$domains);
|
||||
break;
|
||||
case "audit":
|
||||
echo shell_exec("sudo pihole -a audit ".$domains);
|
||||
break;
|
||||
|
||||
@@ -11,7 +11,6 @@ $ERRORLOG = getenv('PHP_ERROR_LOG');
|
||||
if (empty($ERRORLOG)) {
|
||||
$ERRORLOG = '/var/log/lighttpd/error.log';
|
||||
}
|
||||
$regexfile = "/etc/pihole/regex.list";
|
||||
|
||||
function pi_log($message) {
|
||||
error_log(date('Y-m-d H:i:s') . ': ' . $message . "\n", 3, $GLOBALS['ERRORLOG']);
|
||||
|
||||
@@ -21,7 +21,7 @@ function getTableContent($listname) {
|
||||
global $db;
|
||||
$entries = array();
|
||||
$querystr = implode(" ",array("SELECT ${listname}.*,\"group\".enabled as group_enabled",
|
||||
"FROM $listname",
|
||||
"FROM ${listname}",
|
||||
"LEFT JOIN ${listname}_by_group ON ${listname}_by_group.${listname}_id = ${listname}.id",
|
||||
"LEFT JOIN \"group\" ON \"group\".id = ${listname}_by_group.group_id",
|
||||
"GROUP BY domain;"));
|
||||
@@ -54,13 +54,15 @@ function filterArray(&$inArray) {
|
||||
switch ($listtype)
|
||||
{
|
||||
case "white":
|
||||
$list = getTableContent("whitelist");
|
||||
$exact = getTableContent("whitelist");
|
||||
$regex = getTableContent("regex_whitelist");
|
||||
$list = array_merge($exact, $regex);
|
||||
break;
|
||||
|
||||
case "black":
|
||||
$exact = getTableContent("blacklist");
|
||||
$regex = getTableContent("regex");
|
||||
$list = array_merge($exact, $regex);
|
||||
$regex = getTableContent("regex_blacklist");
|
||||
$list = array_merge($exact, $regex);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -18,7 +18,7 @@ if (empty($api)) {
|
||||
|
||||
// Don't check if the added item is a valid domain for regex expressions.
|
||||
// Regex filters are validated by FTL on import and skipped if invalid
|
||||
if($type !== "regex") {
|
||||
if($type !== "black_regex" && $type !== "white_regex") {
|
||||
check_domain();
|
||||
}
|
||||
|
||||
@@ -27,13 +27,16 @@ $domain = escapeshellcmd($_POST['domain']);
|
||||
|
||||
switch($type) {
|
||||
case "white":
|
||||
exec("sudo pihole -w -q -d ".$domain);
|
||||
echo shell_exec("sudo pihole -w -q -d ".$domain);
|
||||
break;
|
||||
case "black":
|
||||
exec("sudo pihole -b -q -d ".$domain);
|
||||
echo shell_exec("sudo pihole -b -q -d ".$domain);
|
||||
break;
|
||||
case "regex":
|
||||
exec("sudo pihole --regex -q -d ".$domain);
|
||||
case "black_regex":
|
||||
echo shell_exec("sudo pihole --regex -q -d ".$domain);
|
||||
break;
|
||||
case "white_regex":
|
||||
echo shell_exec("sudo pihole --whiteregex -q -d ".$domain);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user