Anti-Splog marked a main site as Splog

I have Anti-Splog activate on multi-network site with WP Multi-Network plugin and can't access the main site because Anti-Splog has marked it as splog.

I renamed/removed the plugin folder via FTP, but I had to edit the database and change the value 1 under "spam" in "wp_blogs" table to 0 so I can access network admin again.

Is there a way to ensure that Anti-Splog ignore every site in "wp_site" table?

  • Adam Czajczyk

    Hello RavanH,

    I hope you're well today and thank you for your question!

    The Anti-Splog plugin is considering a number of factors that may suggest that the given site is or is not a spam site. I would suggest starting with setting "certainty" options in plugin settings to a bit higher values as this should lower a chance of the site getting marked as a spam.

    It's also worth reviewing spam keywords settings to make sure that none of those were used/over-used on the site in question.

    This are "basic steps" but I'd also suspect the setup itself. It's a Multi-Network which is not a WP standard configuration and Anti-Splog doesn't carry any specific/official compatibility for Multi-Network. I'm not saying that it won't work but I think its "increased sensitivity" might be related here.

    However, I have also forwarded the issue to our developers, asking them if there's a way to some how exclude some sites (e.g. based on some rules or the db data specified) from Anti-Splog entirely, so please keep an eye on this thread for further information. Please note though - it might take some time for them to answer as they're dealing with a lot of complex issues on daily basis.

    We'll update this ticket as soon as we get some feedback from them.

    Best regards,
    Adam

  • RavanH

    Hi Adam, thanks for following this up.

    To be precise: I'm not talking about tweaking sensibility of the splog detection. I wish to absolutely ensure that any main site (not just the one with ID 1) is never considered as a Splog. I suspect Anti-splog just checks for ID and excludes #1 from consideration but with WP Multi Network, there can be more than one primary site. Other primary sites do not have an ID of 1 but they do appear in the general wp_site table, just as the main primary site (with ID 1) does.

    So my request would be for Anti-splog to exclude all ID's that feature in the wp_site table, not just ID 1.

    It should not be hard to do so I hope this can be picked up by the devs soon :slight_smile:

  • Lindeni Mahlalela

    Hello RavanH

    I hope you are doing great today. Thank you for the question and I am sorry that you had issues with our plugin.

    Unfortunately I was unable to replicate this issue on my side as I tried to replicate it by setting up a Multi Network Network with the same plugin you used and installed Anti Splog plugin, it did not mark the main site as splog on my setup so at this point we can't tell why it happened on your site but if you have any more information we can continue to investigate and possibly find the issue and a permanent solution.

    Is there a way to ensure that Anti-Splog ignore every site in "wp_site" table?

    Thanks for the question. It seems the only way is to find the 'wp_ust' table in the database and set the value of the 'ignore' column to 1 for all the sites in the 'wp_site' table, you will have to lookup the blog_id from the 'wp_site' table and change the 'ignore' column corresponding to each blog_id in the wp_site table.

    You can also try the following code snippet which will get the blogs from the site table and loop through them updating the 'ignore' column for each of them.

    add_action('plugins_loaded', 'anti_splog_ignore_main_sites');
    function anti_splog_ignore_main_sites(){
        global $wpdb;
        $table = $wpdb->base_prefix . 'site';
        $site_ids = $wpdb->get_col( "SELECT id FROM {$table}" );
    
        foreach ( $site_ids as $blog_id){
            ust_blog_ignore( $blog_id );
        }
    }

    You can paste this code in your current theme's functions.php file but I recommend that you place it in a new PHP file created under 'wp-content/mu-plugins' folder. You may create the folder if it does not exist, so you should have the file like:

    wp-content/mu-plugins/anti-splog-ignore-sites.php

    With the code like this:

    <?php
    //paste the above code snippet her

    Then visit the website once and the 'wp_ust' table will be updated such that all the 'ignore' column will be set to one for all the blogs in the wp_site table. Please note that I have used 'wp_' because you used 'wp_' in you query but the code snippet uses '$wpdb->base_prefix' which will always return the correct table prefix regardless. Also note that you should use this code once and remove it because it only needs to do this update once, otherwise it will be running doing the same thing each time your website is loaded.

    I hope this helps, please let us know if you have any information that will help us replicate this issue and we will always be happy to help in any way possible.

    Have a nice day.
    Lindeni

  • RavanH

    Hi Lindeni, thanks for the help.

    To reproduce, it might help to activate the option "Spam/Unspam Blog Users" and then spam a user that created a blog from the context of a secondary main site / network... This reminds me of another issue that I has with the "Spam/Unspam Blog Users": it also marks any blog as spam where a user is only a basic user, not admin or owner/creator. But I'll create a new thread about that :wink:

    Before I saw your post I took a dive into Anti-Splog to see where or how this came about. And I found that the global $current_site->blog_id is used to check if a site is a main site or not. This should in theory always work whenever the check is done from within the context of the same network. Meaning: when Anti-Splog checks a blog that is in the current network, the check will prevent the current network's main site to be excluded. But apparently it may happen that a blog is checked that does not belong to the current network... In such a case, the $current_site->blog_id will not match and the blog may be marked as spam even though it's the main site of another network.

    I did some modifications to anti-splog.php and moderate.php which should prevent this. I can share diffs if you like but the gist of it is adding this function to anti-splog.php :

    function ust_is_a_main_site( $blog_id ) {
    	return in_array( $blog_id, (array)get_networks( array('fields' => 'ids') ) );
    }

    which then can be used in different places to pass the main blog check. Like for example inside ust_do_ajax() or in moderate.php lines 16-18:

    if ( ust_is_a_main_site( $details->userblog_id ) ) {
    					continue;
    				} // main blog not a spam !

    Anyway, I'll take your advise and set the sites to ignore in the DB manually :slight_smile:

  • RavanH

    Oh, hang on. I made the assumption that the site ID and network ID always match (because they do on my multi-network) but this is not true. A new network, created later on, will have an ID with increment of one relative to last network IDs while its main blog will have an ID with increment of one relative to last blog ID. So these will not be similar once blogs have been added to any network...

    Improved function:

    function ust_is_a_main_site( $blog_id ) {
    	$network_ids = (array)get_networks( array('fields' => 'ids') );
    	foreach ( $network_ids as $network_id ) {
    		if ( is_main_site( $blog_id, $network_id ) )
    			return true;
    	}
    	return false;
    }
  • Lindeni Mahlalela

    Hello RavanH

    I hope you are doing great today. Thank you so much for your feedback, we really appreciate it.

    To reproduce, it might help to activate the option "Spam/Unspam Blog Users" and then spam a user that created a blog from the context of a secondary main site / network

    I am not sure why I still can't reproduce this, maybe I am missing something. From the code you shared it makes sense that those checks need to be in place to avoid spamming the main sites.

    We will add this on Anti Splog to make sure it works in the future, for now if you have any other suggestion regarding Multi-Network compatibility, we will be happy to hear it for future improvement but for now I will add the above fix to avoid spamming main sites.

    Thanks for the feedback and improvement suggestions. I will update here if I have any further feedback regarding this fix.

    Have a nice day.
    Lindeni

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.