mirror of
https://github.com/pi-hole/pi-hole
synced 2025-01-03 12:40:56 +00:00
Simplify code
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
parent
3aa838bbe4
commit
6ba58896d2
@ -103,7 +103,7 @@ if [[ -n "${str:-}" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
scanDatabaseTable() {
|
scanDatabaseTable() {
|
||||||
local domain table type querystr result
|
local domain table type querystr result table_prev
|
||||||
domain="${1}"
|
domain="${1}"
|
||||||
table="${2}"
|
table="${2}"
|
||||||
type="${3:-}"
|
type="${3:-}"
|
||||||
@ -119,35 +119,29 @@ scanDatabaseTable() {
|
|||||||
|
|
||||||
# Send prepared query to gravity database
|
# Send prepared query to gravity database
|
||||||
result="$(sqlite3 "${gravityDBfile}" "${querystr}")" 2> /dev/null
|
result="$(sqlite3 "${gravityDBfile}" "${querystr}")" 2> /dev/null
|
||||||
if [[ -n "${result}" ]]; then
|
if [[ -z "${result}" ]]; then
|
||||||
# Prepend listname (separated by a colon) if we found at least one result
|
# Return early when we have no results
|
||||||
# and output result
|
|
||||||
results="$(sed "s/^/${table}:/g;" <<< "${result}")"
|
|
||||||
else
|
|
||||||
# Output empty string as the database query didn't return any result
|
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
mapfile -t results <<< "${results}"
|
|
||||||
if [[ -n "${results[*]}" ]]; then
|
wbMatch=true
|
||||||
wbMatch=true
|
mapfile -t results <<< "${result}"
|
||||||
# Loop through each result in order to print unique file title once
|
# Loop through each result
|
||||||
for result in "${results[@]}"; do
|
for result in "${results[@]}"; do
|
||||||
fileName="${result%%:*}"
|
if [[ -n "${blockpage}" ]]; then
|
||||||
if [[ -n "${blockpage}" ]]; then
|
echo "π ${result}"
|
||||||
echo "π ${result}"
|
exit 0
|
||||||
exit 0
|
elif [[ -n "${exact}" ]]; then
|
||||||
elif [[ -n "${exact}" ]]; then
|
echo " ${matchType^} found in ${COL_BOLD}${table^}${COL_NC}"
|
||||||
echo " ${matchType^} found in ${COL_BOLD}${fileName^}${COL_NC}"
|
else
|
||||||
else
|
# Only print table name once
|
||||||
# Only print filename title once per file
|
if [[ ! "${table}" == "${table_prev:-}" ]]; then
|
||||||
if [[ ! "${fileName}" == "${fileName_prev:-}" ]]; then
|
echo " ${matchType^} found in ${COL_BOLD}${table^}${COL_NC}"
|
||||||
echo " ${matchType^} found in ${COL_BOLD}${fileName^}${COL_NC}"
|
table_prev="${table}"
|
||||||
fileName_prev="${fileName}"
|
|
||||||
fi
|
|
||||||
echo " ${result#*:}"
|
|
||||||
fi
|
fi
|
||||||
done
|
echo " ${result}"
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Scan Whitelist and Blacklist
|
# Scan Whitelist and Blacklist
|
||||||
|
Loading…
Reference in New Issue
Block a user