mirror of
https://github.com/pi-hole/web.git
synced 2025-12-24 12:48:29 +00:00
Add a class for better readability of list type within the code
Signed-off-by: Adam Warner <me@adamwarner.co.uk>
This commit is contained in:
@@ -34,27 +34,27 @@ $db = SQLite3_connect($GRAVITYDB, SQLITE3_OPEN_READWRITE);
|
||||
|
||||
switch($list) {
|
||||
case "white":
|
||||
echo add_to_table($db, "domainlist", $domains, $comment, false, false, 0);
|
||||
echo add_to_table($db, "domainlist", $domains, $comment, false, false, ListType::whitelist);
|
||||
break;
|
||||
|
||||
case "black":
|
||||
echo add_to_table($db, "domainlist", $domains, $comment, false, false, 1);
|
||||
echo add_to_table($db, "domainlist", $domains, $comment, false, false, ListType::blacklist);
|
||||
break;
|
||||
|
||||
case "white_regex":
|
||||
echo add_to_table($db, "domainlist", $domains, $comment, false, false, 2);
|
||||
echo add_to_table($db, "domainlist", $domains, $comment, false, false, ListType::regex_whitelist);
|
||||
break;
|
||||
|
||||
case "white_wild":
|
||||
echo add_to_table($db, "domainlist", $domains, $comment, true, false, 2);
|
||||
echo add_to_table($db, "domainlist", $domains, $comment, true, false, ListType::regex_whitelist);
|
||||
break;
|
||||
|
||||
case "black_regex":
|
||||
echo add_to_table($db, "domainlist", $domains, $comment, false, false, 3);
|
||||
echo add_to_table($db, "domainlist", $domains, $comment, false, false, ListType::regex_blacklist);
|
||||
break;
|
||||
|
||||
case "black_wild":
|
||||
echo add_to_table($db, "domainlist", $domains, $comment, true, false, 3);
|
||||
echo add_to_table($db, "domainlist", $domains, $comment, true, false, ListType::regex_blacklist);
|
||||
break;
|
||||
|
||||
case "audit":
|
||||
|
||||
@@ -285,4 +285,9 @@ function remove_from_table($db, $table, $domains, $returnnum=false, $type=-1)
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
class ListType{
|
||||
const whitelist = 0;
|
||||
const blacklist = 1;
|
||||
const regex_whitelist = 2;
|
||||
const regex_blacklist = 3;
|
||||
}
|
||||
|
||||
@@ -55,14 +55,14 @@ function filterArray(&$inArray) {
|
||||
switch ($listtype)
|
||||
{
|
||||
case "white":
|
||||
$exact = array("whitelist" => getTableContent(0));
|
||||
$regex = array("regex_whitelist" => getTableContent(2));
|
||||
$exact = array("whitelist" => getTableContent(ListType::whitelist));
|
||||
$regex = array("regex_whitelist" => getTableContent(ListType::regex_whitelist));
|
||||
$list = array_merge($exact, $regex);
|
||||
break;
|
||||
|
||||
case "black":
|
||||
$exact = array("blacklist" => getTableContent(1));
|
||||
$regex = array("regex_blacklist" => getTableContent(3));
|
||||
$exact = array("blacklist" => getTableContent(ListType::blacklist));
|
||||
$regex = array("regex_blacklist" => getTableContent(ListType::regex_blacklist));
|
||||
$list = array_merge($exact, $regex);
|
||||
break;
|
||||
|
||||
|
||||
@@ -27,19 +27,19 @@ $db = SQLite3_connect($GRAVITYDB, SQLITE3_OPEN_READWRITE);
|
||||
|
||||
switch($type) {
|
||||
case "white":
|
||||
echo remove_from_table($db, "domainlist", $domains, false, 0);
|
||||
echo remove_from_table($db, "domainlist", $domains, false, ListType::whitelist);
|
||||
break;
|
||||
|
||||
case "black":
|
||||
echo remove_from_table($db, "domainlist", $domains, false, 1);
|
||||
echo remove_from_table($db, "domainlist", $domains, false, ListType::blacklist);
|
||||
break;
|
||||
|
||||
case "white_regex":
|
||||
echo remove_from_table($db, "domainlist", $domains, false, 2);
|
||||
echo remove_from_table($db, "domainlist", $domains, false, ListType::regex_whitelist);
|
||||
break;
|
||||
|
||||
case "black_regex":
|
||||
echo remove_from_table($db, "domainlist", $domains, false, 3);
|
||||
echo remove_from_table($db, "domainlist", $domains, false, ListType::regex_blacklist);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -365,10 +365,10 @@ else
|
||||
exit("cannot open/create ".htmlentities($archive_file_name)."<br>\nPHP user: ".exec('whoami')."\n");
|
||||
}
|
||||
|
||||
archive_add_table("whitelist.exact.json", "domainlist");
|
||||
archive_add_table("whitelist.regex.json", "domainlist");
|
||||
archive_add_table("blacklist.exact.json", "domainlist");
|
||||
archive_add_table("blacklist.regex.json", "domainlist");
|
||||
archive_add_table("whitelist.exact.json", "domainlist", ListType::whitelist);
|
||||
archive_add_table("whitelist.regex.json", "domainlist", ListType::regex_whitelist);
|
||||
archive_add_table("blacklist.exact.json", "domainlist", ListType::blacklist);
|
||||
archive_add_table("blacklist.regex.json", "domainlist", ListType::regex_blacklist);
|
||||
archive_add_table("adlist.json", "adlist");
|
||||
archive_add_table("domain_audit.json", "domain_audit");
|
||||
archive_add_file("/etc/pihole/","setupVars.conf");
|
||||
|
||||
Reference in New Issue
Block a user