Update spamblock query to work in MySQL 5.7+ with default "strict" mode
Created by: fasterit
The old query will fail with ONLY_FULL_GROUP_BY set which is default from MySQL 5.7.5 onwards. This results in the .htaccess file not being updated.
Also adding some fencing to the foreach to prevent php error messages.