Search spam in logs
-
Hello, I am having a problem weeding out certain spammy search entries which are showing up in my logs, sometimes up to 30 times a day. the search query consists of a long string of pipe characaters: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
I have used the code you provided below to block unwanted search in functions.php but it doesn’t stop this particular search. How do I block special characters?
add_filter( 'pre_get_posts', 'rlv_block_search' ); function rlv_block_search( $query ) { if (!empty($query->query_vars['s'])) { $blacklist = array( 'index/thinkapp/invokefunction', '/index/thinkapp/invokefunction', '1 1 1 1', '||||', 'home/thinkapp/invokefunction', '/home/thinkapp/invokefunction', 'captcha' ); // add blacklist entries here; no need for whole words, use the smallest part you can foreach( $blacklist as $term ) { if( mb_stripos( $query->query_vars['s'], $term ) !== false ) exit(); } } }
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Search spam in logs’ is closed to new replies.