Add regex support on the web interface

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2018-06-04 23:35:41 +01:00
parent adfa0b6a03
commit 36930e3834
3 changed files with 57 additions and 57 deletions

View File

@@ -12,30 +12,35 @@ if(!isset($_GET['list']))
$listtype = $_GET['list'];
$basedir = "/etc/pihole/";
require "func.php";
switch ($listtype) {
case "white":
$list = getListContent("white");
break;
case "white":
$list = array(getListContent("whitelist.txt"));
break;
case "black":
$list = array_merge(getListContent("black"),getWildcardListContent());
break;
case "black":
$exact = array(getListContent("blacklist.txt"));
$regex = array(getListContent("regex.list"));
$list = array_merge($exact, $regex);
break;
default:
die("Invalid list parameter");
break;
default:
die("Invalid list parameter");
break;
}
function getListContent($type) {
$rawList = file_get_contents(checkfile("/etc/pihole/".$type."list.txt"));
function getListContent($listname) {
global $basedir;
$rawList = file_get_contents(checkfile($basedir.$listname));
$list = explode("\n", $rawList);
// Get rid of empty lines
for($i = sizeof($list)-1; $i >= 0; $i--) {
if($list[$i] == "")
if(strlen($list[$i]) < 1)
unset($list[$i]);
}
@@ -43,23 +48,6 @@ function getListContent($type) {
}
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 filterArray(&$inArray) {
$outArray = array();
foreach ($inArray as $key=>$value) {