mirror of
https://github.com/pi-hole/web.git
synced 2024-12-06 19:36:21 +01:00
Use constants in place of class constants
Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
This commit is contained in:
@@ -86,22 +86,22 @@ if (isset($_GET['enable']) && $auth) {
|
||||
|
||||
switch ($_GET['list']) {
|
||||
case 'black':
|
||||
$_POST['type'] = ListType::blacklist;
|
||||
$_POST['type'] = LISTTYPE_BLACKLIST;
|
||||
|
||||
break;
|
||||
|
||||
case 'regex_black':
|
||||
$_POST['type'] = ListType::regex_blacklist;
|
||||
$_POST['type'] = LISTTYPE_REGEX_BLACKLIST;
|
||||
|
||||
break;
|
||||
|
||||
case 'white':
|
||||
$_POST['type'] = ListType::whitelist;
|
||||
$_POST['type'] = LISTTYPE_WHITELIST;
|
||||
|
||||
break;
|
||||
|
||||
case 'regex_white':
|
||||
$_POST['type'] = ListType::regex_whitelist;
|
||||
$_POST['type'] = LISTTYPE_REGEX_WHITELIST;
|
||||
|
||||
break;
|
||||
|
||||
|
||||
@@ -7,6 +7,12 @@
|
||||
* Please see LICENSE file for your rights under this license
|
||||
*/
|
||||
|
||||
// List Type Constants
|
||||
const LISTTYPE_WHITELIST = 0;
|
||||
const LISTTYPE_BLACKLIST = 1;
|
||||
const LISTTYPE_REGEX_WHITELIST = 2;
|
||||
const LISTTYPE_REGEX_BLACKLIST = 3;
|
||||
|
||||
function getGravityDBFilename()
|
||||
{
|
||||
// Get possible non-standard location of FTL's database
|
||||
@@ -278,13 +284,3 @@ function remove_from_table($db, $table, $domains, $returnnum = false, $type = -1
|
||||
|
||||
return 'Success, removed '.$num.' domain'.$plural;
|
||||
}
|
||||
|
||||
if (!class_exists('ListType')) {
|
||||
class ListType
|
||||
{
|
||||
public const whitelist = 0;
|
||||
public const blacklist = 1;
|
||||
public const regex_whitelist = 2;
|
||||
public const regex_blacklist = 3;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -508,7 +508,7 @@ if ($_POST['action'] == 'get_groups') {
|
||||
array_push($groups, $gres['group_id']);
|
||||
}
|
||||
$res['groups'] = $groups;
|
||||
if ($res['type'] === ListType::whitelist || $res['type'] === ListType::blacklist) {
|
||||
if ($res['type'] === LISTTYPE_WHITELIST || $res['type'] === LISTTYPE_BLACKLIST) {
|
||||
// Convert domain name to international form
|
||||
// Skip this for the root zone `.`
|
||||
if ($res['domain'] != '.') {
|
||||
@@ -571,9 +571,9 @@ if ($_POST['action'] == 'get_groups') {
|
||||
if (isset($_POST['type'])) {
|
||||
$type = intval($_POST['type']);
|
||||
} elseif (isset($_POST['list']) && $_POST['list'] === 'white') {
|
||||
$type = ListType::whitelist;
|
||||
$type = LISTTYPE_WHITELIST;
|
||||
} elseif (isset($_POST['list']) && $_POST['list'] === 'black') {
|
||||
$type = ListType::blacklist;
|
||||
$type = LISTTYPE_BLACKLIST;
|
||||
}
|
||||
|
||||
if (!$insert_stmt->bindValue(':type', $type, SQLITE3_TEXT)
|
||||
|
||||
@@ -242,13 +242,13 @@ function archive_insert_into_table($file, $table, $flush = false, $wildcardstyle
|
||||
$type = null;
|
||||
if ($table === 'whitelist') {
|
||||
$table = 'domainlist';
|
||||
$type = ListType::whitelist;
|
||||
$type = LISTTYPE_WHITELIST;
|
||||
} elseif ($table === 'blacklist') {
|
||||
$table = 'domainlist';
|
||||
$type = ListType::blacklist;
|
||||
$type = LISTTYPE_BLACKLIST;
|
||||
} elseif ($table === 'regex_blacklist') {
|
||||
$table = 'domainlist';
|
||||
$type = ListType::regex_blacklist;
|
||||
$type = LISTTYPE_REGEX_BLACKLIST;
|
||||
} elseif ($table === 'domain_audit') {
|
||||
$table = 'domain_audit';
|
||||
$type = -1; // -1 -> not used inside add_to_table()
|
||||
@@ -578,10 +578,10 @@ if (isset($_POST['action'])) {
|
||||
exit('cannot open/create '.htmlentities($archive_file_name)."<br>\nPHP user: ".exec('whoami')."\n");
|
||||
}
|
||||
|
||||
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('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_table('group.json', 'group');
|
||||
|
||||
Reference in New Issue
Block a user