Code to check StopForumSpam database

A forum to report any problems or suggestions relating to the technical workings of the forum.
Start a New Topic with a meaningful heading.
Alternatively e-mail webmaster@csf-forum.org
Please - no posts relating to cancer support!

Moderator: Cathy Allen

webmaster
Posts: 76
Joined: Wed Jan 27, 2010 8:50 pm
Location: P-O
Contact:

Code to check StopForumSpam database

Postby webmaster » Wed Feb 23, 2011 10:52 pm

This post is only of interest to other webmasters running forums powered by phpBB3 earlier than version 3.1. It is put on the csf-forum site as a service to those webmasters.

For phpBB version 3.1 this method is obsolete. There is an official extension to check StopForumSpam at registration, and another to email Administrators when a registration is successful.


For version 3.0 (unsuported from 1st January 2017)


To try to eliminate spammers posting on the forum we use a Question & Answer system, plus User Verification - an e-mail is automatically sent to the person registering, and they must click on a link in this e-mail to activate the account. This means that the person (or spammer) attempting to register must provide a valid e-mail address.

This e-mail address and the IP address of the person registering are then checked against the StopForumSpam database of known spammers - if they are on the database they are redirected automatically to the "Spammerbegone" web site and registration is terminated.

The Question & Answer checks have totally eliminated automated spam (spambots), and the check against StopForumSpam has detected and refused most human spammers.

In my experience the Q&A should be good enough for most forums, but if you want to add the automatic test against StopForumSpam code has to be inserted in the "includes/ucp/ucp_register.php" file of your phpBB3 installation.

I am no php programmer, but it is easy to implement.

This is how to how to do it in phpBB 3.0.8. The code was developed by Recif in the StopForumSpam forum and has been slightly amended by me. I have used the automatic update to phpBB 3.0.9 and the code was carried forward without a problem, but it may be that line numbers are not the same in 3.0.9, so please be careful! As of 2013 the code works with 3.0.12.

It has not been changed to support phpBB versions 3.1.x and seems unlikely to work on these versions without changes!


There are some additional changes to the code to email me whenever the database is checked - the e-mail informs me whether the check is successful or not.

You need to insert the code in "includes/ucp/ucp_register.php" before

Code: Select all

            // Register user...
            $user_id = user_add($user_row, $cp_data);


Which is about line 325.

To avoid problems and to allow you to return to the unmodified code, you should ensure that you make a copy of the file before making changes.

The code to be inserted is:-


Code: Select all

            
     // code inserted from StopForumSpam 8.1.2011 by Frank Parkinson         
          // amended 30.1.2012 to improve email information            
            
     // Verifier si spammeur via le site stopforumspam.com           
function objectsIntoArray($arrObjData, $arrSkipIndices = array())
{
    $arrData = array();
   
    // if input is object, convert into array
    if (is_object($arrObjData)) {
        $arrObjData = get_object_vars($arrObjData);
    }
   
    if (is_array($arrObjData)) {
        foreach ($arrObjData as $index => $value) {
            if (is_object($value) || is_array($value)) {
                $value = objectsIntoArray($value, $arrSkipIndices);
            }
            if (in_array($index, $arrSkipIndices)) {
                continue;
            }
            $arrData[$index] = $value;
        }
    }
    return $arrData;
}
$verifip = $user->ip;
   // old code was:  $xmlUrl = "http://www.stopforumspam.com/api?username=".$data['username']."&ip=$verifip&f=xmldom";


  // following line corrected November 2012

$webmasttxt = "Email= ".$data['email']." IP =  ".$user->ip." Username= ".$data['username'];

$xmlUrl = "http://www.stopforumspam.com/api?username=".$data['username']."&ip=$verifip&email=".$data['email']."&f=xmldom";

$xmlStr = file_get_contents($xmlUrl);
$xmlObj = simplexml_load_string($xmlStr);
$arrXml = objectsIntoArray($xmlObj);
   //    old code was:  $checkusername = $arrXml[username][appears];
$checkemail = $arrXml[email][appears];
$checkip = $arrXml[ip][appears];
if ($checkemail > 0 || $checkip > 0) {
    mail("webmaster@csf-forum.org","Failed Registration Attempt",$webmasttxt);
    header('Location: http://www.spamlaws.com/');
    exit;
}
    mail("webmaster@csf-forum.org","Successful Registration Attempt",$webmasttxt);
    // end of inserted StopForumSpam code



You need to change "your-forum.org" to your own forum URL.


ZB Block added to forum late November 2012

After a massive increase in attacks by spammers (even though none have got past the just-described StopForumSpam check), I decided to improve the forum security.

Spammers from all over the world had begun to correctly answer the Q&A at registration - this must indicate a group of spammers who had finally got the answers and passed them on, as it is inconceivable that they all, independently, cracked the questions.

I have implemented ZB Block, software to protect PHP sites and forums, to be found at http://www.spambotsecurity.com/.

This software denies spammers and spambots access to the forum at the point of entry, whereas my check with StopForumSpam is done after successfully going through the registration process. As a result the forum should show a great drop in wasted bandwidth, amongst other benefits.

The manual for ZB Block is attached.
Attachments
ZB_Block_Manual.pdf
ZB Block manual
(333.62 KiB) Downloaded 102 times
Last edited by webmaster on Tue Jun 07, 2016 4:37 pm, edited 10 times in total.

Return to “Webmaster”

Who is online

Users browsing this forum: No registered users and 1 guest