I am no php programmer but I found the code submitted by Recif on the StopForumSpam forum works well for me on my phpBB 3.0.8 board.
I have started to research php, and I have added a "mail" function to alert me when anyone tries to Register on my board. This is purely for information - since I implemented the code to check the SFS database I have no idea who is trying to spam the site.
I know that this is only workable when the board is small - if I get too many attempts I will change it to a count which I can interrogate.
I am posting the code in the knowledge that it is far from perfect, but maybe others can improve on it and give the spammers a hard time!!!!
The code was inserted in ucp_register.php after line 321 - immediately before
Code: Select all
// Register user...
$user_id = user_add($user_row, $cp_data);
The code I use is:-
Code: Select all
// code inserted from StopForumSpam 8.1.2011 by Frank Parkinson
// 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";
$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("[email protected]","Failed Registration Attempt",$data['email']);
header('Location: http://spammerbegone.com');
exit;
}
// end of inserted StopForumSpam code
Because the amended "ucp_register.php" mails me all failed attempts to register on the forum, I can see that during the 24 hour period of January 11th there were 39 attempts. Each one failed to get through to the board, and while I don't know which were spam bots and which were human spammers, I hope that I have wasted the time of at least some w**kers!
Incidentally, during just over 17 hours today there was one genuine registration and there were 25 spam registration attempts; one spammer got through, presumably the StopForumSpam site was down at the time because the spammer email address is definitely in SFS database.
My coding skills are not great, and I know the code lacks sophistication to handle "SFS database unavailable" or just "slow response" situations, but it certainly seems to provide a wonderful tool.