# Create search string for ABP entries only if needed
if["${abpfound}" -eq 1];then
abpentry="${domain}"
searchstr="'||${abpentry}^'"
# While a dot is found ...
while["${abpentry}" !="${abpentry/./}"]
do
# ... remove text before the dot (including the dot) and append the result to $searchstr
abpentry=$(echo"${abpentry}"| cut -f 2- -d '.')
searchstr="$searchstr, '||${abpentry}^'"
done
# The final search string will look like:
# "domain IN ('||sub2.sub1.domain.com^', '||sub1.domain.com^', '||domain.com^', '||com^') OR"
searchstr="domain IN (${searchstr}) OR "
fi
case"${exact}" in
case"${exact}" in
"exact")querystr="SELECT gravity.domain,adlist.address,adlist.enabled FROM gravity LEFT JOIN adlist ON adlist.id = gravity.adlist_id WHERE domain = '${domain}'";;
"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 '\\'";;
* )querystr="SELECT gravity.domain,adlist.address,adlist.enabled FROM gravity LEFT JOIN adlist ON adlist.id = gravity.adlist_id WHERE ${searchstr}domain LIKE '%${domain//_/\\_}%' ESCAPE '\\'";;