diff options
author | DL6ER <dl6er@dl6er.de> | 2019-12-12 14:08:19 +0300 |
---|---|---|
committer | DL6ER <dl6er@dl6er.de> | 2019-12-12 14:08:19 +0300 |
commit | 52dd72dfa5f497d7c09d37b834aa0164edb66121 (patch) | |
tree | 12ff197ca583b011082c88fbb1431225627ccb96 /advanced | |
parent | 922ce7359c4774122c6e47f303ac8a4358afdf56 (diff) |
Ensure output is always correct and also display if domain has been found but is disabled
Signed-off-by: DL6ER <dl6er@dl6er.de>
Diffstat (limited to 'advanced')
-rwxr-xr-x | advanced/Scripts/query.sh | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/advanced/Scripts/query.sh b/advanced/Scripts/query.sh index 467fe6f4..aaaf811c 100755 --- a/advanced/Scripts/query.sh +++ b/advanced/Scripts/query.sh @@ -99,8 +99,8 @@ scanDatabaseTable() { # as a literal underscore character. We pretreat the $domain variable accordingly to escape underscores. if [[ "${table}" == "gravity" ]]; then case "${type}" in - "exact" ) querystr="SELECT gravity.domain,adlist.address FROM gravity LEFT JOIN adlist ON adlist.id = gravity.adlist_id WHERE domain = '${domain}'";; - * ) querystr="SELECT gravity.domain,adlist.address FROM gravity LEFT JOIN adlist ON adlist.id = gravity.adlist_id WHERE domain LIKE '%${domain//_/\\_}%' ESCAPE '\\'";; + "exact" ) querystr="SELECT gravity.domain,adlist.address,adlist.enabled FROM gravity LEFT JOIN adlist ON adlist.id = gravity.adlist_id WHERE domain = '${domain}'";; + * ) querystr="SELECT gravity.domain,adlist.address,adlist.enabled FROM gravity LEFT JOIN adlist ON adlist.id = gravity.adlist_id WHERE domain LIKE '%${domain//_/\\_}%' ESCAPE '\\'";; esac else case "${type}" in @@ -210,12 +210,20 @@ if [[ -n "${exact}" ]] && [[ -z "${blockpage}" ]]; then fi for result in "${results[@]}"; do - adlistAddress="${result/*|/}" + match="${result/|*/}" + extra="${result#*|}" + adlistAddress="${extra/|*/}" + enabled="${extra#*|}" + if [[ "${enabled}" == "0" ]]; then + enabled="(disabled)" + else + enabled="" + fi if [[ -n "${blockpage}" ]]; then echo "${fileNum} ${adlistAddress}" elif [[ -n "${exact}" ]]; then - echo " - ${adlistAddress}" + echo " - ${adlistAddress} ${enabled}" else if [[ ! "${adlistAddress}" == "${adlistAddress_prev:-}" ]]; then count="" @@ -230,7 +238,7 @@ for result in "${results[@]}"; do [[ "${count}" -gt "${max_count}" ]] && continue echo " ${COL_GRAY}Over ${count} results found, skipping rest of file${COL_NC}" else - echo " ${result/*|//}" + echo " ${match} ${enabled}" fi fi done |