1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Set up another layer of protection against spam at WP (perfect for autoblogs)

Discussion in 'Blogging' started by HTTP_REFERER, Jul 14, 2009.

  1. HTTP_REFERER

    HTTP_REFERER Newbie

    Joined:
    Feb 28, 2009
    Messages:
    22
    Likes Received:
    48
    Hello everyone,

    I decided to share this snippet of code with you because you're probably the ones that will make the most out of it (used with plugins such as Akismet, this will remove almost all spam out of your autoblogs and legit blogs) - and because should this fall in the wrong hands, all those comment spam PHP scripts will cease to work in shared hosting environments (where most people use them) ;).

    It is very easy to setup and should work on almost all paid hosts.

    I am yet to see any antispam plugin that uses this - if you know of any, let me know.

    This snippet will also work on any other type of websites. But as it makes the page to take longer to load, it is not recommended to use it on other pages (up to 3 seconds - this value can be modified on the code itself easily).

    Open the file "wp-comments-post.php" for edition. I recommend using the notepad (should you use Windows) and using "nano" should you be in Linux text-mode only (in case you have your own dedi/VPS and no reliable control panel).

    Locate these lines:
    Code:
    /** Sets up the WordPress Environment. */
    require( dirname(__FILE__) . '/wp-load.php' );
    Add the below snippet above the line you found (before it). Extra blank lines are not a problem.
    Code:
    $iswebserver = @fsockopen($_SERVER['REMOTE_ADDR'], 80, $errnum, $errstr, 3);
    if ($iswebserver) die('Please shutdown any webservers you might have installed in your computer and try again.');
    
    Save the file and you're good to go!

    You can change the message "Please shutdown any webservers you might have installed in your computer and try again." by anything else - provided you keep the starting and ending ' symbols and so not use the ' symbol anywhere in the message.

    Well, nothing else by now. I know it is a really simple addon, but I got tired of receiving "new comment received" emails and testing each IP one by one to see if it is automated spam generated through a PHP server or not. And this simple code will automate this process and automatically discard comments sent from web servers (it will not even process them).
     
    • Thanks Thanks x 2
  2. portugalkix

    portugalkix BANNED BANNED

    Joined:
    Dec 22, 2008
    Messages:
    449
    Likes Received:
    206
    I'll try this method.

    It is made by you ?
     
  3. HTTP_REFERER

    HTTP_REFERER Newbie

    Joined:
    Feb 28, 2009
    Messages:
    22
    Likes Received:
    48
    Yeah, I coded it.
     
  4. aReJay

    aReJay Power Member

    Joined:
    Apr 29, 2009
    Messages:
    736
    Likes Received:
    237
    Location:
    Down under
    Ummm,

    I agree this will block the most basic auto-spam PHP scripts. However will also block some legitimate visitors.

    You will not even cause the major spammers to flinch.

    Sorry.
     
  5. hardpie

    hardpie Newbie

    Joined:
    Feb 7, 2015
    Messages:
    15
    Likes Received:
    0
    very interested
     
  6. nanavlad

    nanavlad Jr. VIP Jr. VIP Premium Member

    Joined:
    Dec 2, 2009
    Messages:
    2,420
    Likes Received:
    892
    Gender:
    Male
    Occupation:
    SEO Consultant
    Location:
    Proxy Central
  7. mohamedraouf

    mohamedraouf Junior Member

    Joined:
    Sep 16, 2014
    Messages:
    122
    Likes Received:
    10
    You could also provide some screenshots to see how it looks like. Now i need to try it and see how it works ;D