• Resolved kolshix

    (@kolshix)


    I open “Relevanssi User Searches” and find there SPAM:

    column “Today and yesterday” example like:
    ww_w.some_site.com
    some_site.com
    ht_tps://some_site.com
    spam.com
    w_ww.spam.com
    different domains
    ….
    last 50 -100 requests

    How to protect from search spam in logs search ?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter kolshix

    (@kolshix)

    Now I use

    
    /**** START  */ 
    		function search_filter_spam($query) {			
    			if ($query->is_search ) {			
    				$url =  get_search_query('s');
    				$regex = "((https?|ftp)\:\/\/)?"; // SCHEME 
    				$regex .= "([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)?"; // User and Pass 
    				$regex .= "([a-z0-9-.]*)\.([a-z]{2,3})"; // Host or IP 
    				$regex .= "(\:[0-9]{2,5})?"; // Port 
    				$regex .= "(\/([a-z0-9+\$_-]\.?)+)*\/?"; // Path 
    				$regex .= "(\?[a-z+&\$_.-][a-z0-9;:@&%=+\/\$_.-]*)?"; // GET Query 
    				$regex .= "(#[a-z_.-][a-z0-9+\$_.-]*)?"; // Anchor 
    
    				if(preg_match("/^$regex$/i", $url)) { // <code>i</code> flag for case-insensitive
    			//	if(get_headers($url, 1)){
    				   echo 'Stop SPAM!';
    				   exit();
    				}
    			}			
    		}
    		add_action('pre_get_posts', 'search_filter_spam');	
    
    

    Maybe there are other solutions, more correct.

    • This reply was modified 4 years, 11 months ago by kolshix.
    • This reply was modified 4 years, 11 months ago by kolshix.
    Plugin Author Mikko Saari

    (@msaari)

    That’s one possible approach; I’ve used something similar to block Chinese spam requests.

    It would be even better if you could stop this on server level, before WordPress is even started. For possible techniques, see here.

    Thread Starter kolshix

    (@kolshix)

    ))))
    the funny thing is that I was also attacked by Chinese spammers.
    All domains led to Chinese sites

    • This reply was modified 4 years, 11 months ago by kolshix.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Spam in search log’ is closed to new replies.