mirror of
https://github.com/pi-hole/web.git
synced 2025-12-24 20:55:28 +00:00
Implemented wildcard blocking in Query Log
This commit is contained in:
@@ -283,6 +283,7 @@
|
||||
|
||||
// Create empty array for gravity
|
||||
$gravity_domains = getGravity();
|
||||
$wildcard_domains = getWildcardListContent();
|
||||
|
||||
setShowBlockedPermitted();
|
||||
|
||||
@@ -304,8 +305,36 @@
|
||||
$domain = $exploded[count($exploded)-3];
|
||||
$tmp = $exploded[count($exploded)-4];
|
||||
|
||||
$status = isset($gravity_domains[$domain]) ? "Pi-holed" : "OK";
|
||||
if(($status === "Pi-holed" && $showBlocked) || ($status === "OK" && $showPermitted))
|
||||
$status = "";
|
||||
|
||||
if(isset($gravity_domains[$domain]))
|
||||
{
|
||||
if($gravity_domains[$domain] > 0)
|
||||
{
|
||||
// Exact matching gravity domain
|
||||
$status = "Pi-holed (exact)";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Explicitly whitelisted
|
||||
$status = "OK (whitelisted)";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Test for wildcard blocking
|
||||
foreach ($wildcard_domains as $entry) {
|
||||
if(strpos($domain, $entry) !== false)
|
||||
{
|
||||
$status = "Pi-holed (wildcard)";
|
||||
}
|
||||
}
|
||||
if(!strlen($status))
|
||||
{
|
||||
$status = "OK";
|
||||
}
|
||||
}
|
||||
if((substr($status,0,2) === "Pi" && $showBlocked) || (substr($status,0,2) === "OK" && $showPermitted))
|
||||
{
|
||||
$type = substr($exploded[count($exploded)-4], 6, -1);
|
||||
$client = $exploded[count($exploded)-1];
|
||||
@@ -410,16 +439,33 @@
|
||||
if($action && strlen($key) > 0)
|
||||
{
|
||||
// $action is true (we want to add) *and* key is not empty
|
||||
$array[$key] = true;
|
||||
$array[$key] = 1;
|
||||
}
|
||||
elseif(!$action && isset($array[$key]))
|
||||
{
|
||||
// $action is false (we want to remove) *and* key is set
|
||||
unset($array[$key]);
|
||||
$array[$key] = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getWildcardListContent() {
|
||||
$rawList = file_get_contents(checkfile("/etc/dnsmasq.d/03-pihole-wildcard.conf"));
|
||||
$wclist = explode("\n", $rawList);
|
||||
$list = [];
|
||||
|
||||
foreach ($wclist as $entry) {
|
||||
$expl = explode("/", $entry);
|
||||
if(count($expl) == 3)
|
||||
{
|
||||
array_push($list,$expl[1]);
|
||||
}
|
||||
}
|
||||
|
||||
return array_unique($list);
|
||||
|
||||
}
|
||||
|
||||
function getGravity() {
|
||||
global $gravity,$whitelist,$blacklist;
|
||||
$domains = [];
|
||||
|
||||
Reference in New Issue
Block a user