diff --git a/scripts/pi-hole/php/add.php b/scripts/pi-hole/php/add.php index 11468e70..593bdfbf 100644 --- a/scripts/pi-hole/php/add.php +++ b/scripts/pi-hole/php/add.php @@ -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": diff --git a/scripts/pi-hole/php/database.php b/scripts/pi-hole/php/database.php index 819d6769..060ce6fd 100644 --- a/scripts/pi-hole/php/database.php +++ b/scripts/pi-hole/php/database.php @@ -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; +} diff --git a/scripts/pi-hole/php/get.php b/scripts/pi-hole/php/get.php index 29a30cae..f47f2c84 100644 --- a/scripts/pi-hole/php/get.php +++ b/scripts/pi-hole/php/get.php @@ -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; diff --git a/scripts/pi-hole/php/sub.php b/scripts/pi-hole/php/sub.php index 764ae6c7..cdee3ceb 100644 --- a/scripts/pi-hole/php/sub.php +++ b/scripts/pi-hole/php/sub.php @@ -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: diff --git a/scripts/pi-hole/php/teleporter.php b/scripts/pi-hole/php/teleporter.php index c2b8e1f3..2ddbca6c 100644 --- a/scripts/pi-hole/php/teleporter.php +++ b/scripts/pi-hole/php/teleporter.php @@ -365,10 +365,10 @@ else exit("cannot open/create ".htmlentities($archive_file_name)."
\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");