[CODE] Integrating the spam filter into phpBB2

Mods for various forums/blogs for use with the SBST

Moderator: fspamlist

User avatar
MysteryFCM
Site Admin
Site Admin
Posts: 3721
Joined: Sun May 15, 2005 12:42 pm
Location: Newcastle, UK
Contact:

[CODE] Integrating the spam filter into phpBB2

Postby MysteryFCM » Fri Nov 28, 2008 2:49 am

Open /includes/usercp_register.php

Find:

Code: Select all

$error = FALSE;


Replace with:

Code: Select all

$error = FALSE;

/// BEGIN SPAM MOD
$username = $HTTP_POST_VARS['username'];
$email = $HTTP_POST_VARS['email'];
$ip = ( !empty($HTTP_SERVER_VARS['REMOTE_ADDR']) ) ? $HTTP_SERVER_VARS['REMOTE_ADDR'] : ( ( !empty($HTTP_ENV_VARS['REMOTE_ADDR']) ) ? $HTTP_ENV_VARS['REMOTE_ADDR'] : getenv('REMOTE_ADDR') );
$fspamcheck = file_get_contents('http://temerc.com/Check_Spammers/check_spammers_plain.php?name='.$username.'&email='.$email.'&ip='.$ip);
//echo $fspamcheck;
if (strpos($fspamcheck, 'TRUE') !==False) {
   // Notify admin via e-mail
   $blockedby = str_replace(' TRUE', '', $fspamcheck);
   $blockedby = str_replace(' ', ' & ', $blockedby);
   $msg = 'The following was blocked by the '.$blockedby.' filter<br><br>Username: '.$username.'<br><br>Email: '.$email.'<br><br>IP: '.$ip;
   // Change your@email.addr to the e-mail address you want e-mail reports sent to
   $to = "your@email.addr";
   $from = "nobody@".$_SERVER['SERVER_NAME'];
   $subject = "Spammer blocked by hpHosts Spam filter";
   $headers =    "MIME-Versin: 1.0\r\n" .
   "Content-type: text/html; charset=ISO-8859-1; format=flowed\r\n" .
   "Content-Transfer-Encoding: 8bit\r\n" .
   "From: " . $from . "\r\n" .
   "X-Mailer: hpHosts Spam Filter";
   mail($to, $subject, $msg, $headers);
   // Notify user
   message_die(GENERAL_MESSAGE, "Registration blocked by spam filter. Please contact the forum administrator.", '', __LINE__, __FILE__);
}
/// END SPAM MOD


If you are hosting the check_spammers function locally, then change;

http://temerc.com/Check_Spammers/check_spammers_plain.php

to;

http://YOUR_DOMAIN/PATH_TO_CHECK_SPAMMERS/check_spammers_plain.php
Regards

Steven Burn
I.T. Mate / hpHosts
it-mate.co.uk / hosts-file.net

Keeping it FREE!

User avatar
Peter K
Posts: 10
Joined: Wed Aug 19, 2009 10:03 am
experience: Not only can I turn PC on, I know most of its functions too
Contact:

Re: [CODE] Integrating the spam filter into phpBB2

Postby Peter K » Sat Aug 22, 2009 10:02 am

For use on forums in Dutch:

Find:

Code: Select all

"Registration blocked by spam filter. Please contact the forum administrator."


Replace by:

Code: Select all

"Registratie geweigerd door spamfilter. Zoek contact met de beheerder van dit forum."


A solution using the language files would be better. Shouldn't be to hard to find out how to make. When I've got some time left...

User avatar
Peter K
Posts: 10
Joined: Wed Aug 19, 2009 10:03 am
experience: Not only can I turn PC on, I know most of its functions too
Contact:

Re: [CODE] Integrating the spam filter into phpBB2

Postby Peter K » Sat Aug 22, 2009 12:22 pm

OK, I'm not a programmer, but my guess is it should reald something like this. While I can't check, can somebody tell if this is correct?

In Mod:
Find:

Code: Select all

"Registration blocked by spam filter. Please contact the forum administrator."


Replace by:

Code: Select all

$lang['Spam_Filter']


Open /languages/english/lang_main.php
Find:

Code: Select all

?>

Before, add:

Code: Select all

//Spam Mod
$lang['Spam_Filter'] = "Registration blocked by spam filter. Please contact the forum administrator.";
//End Spam Mod


Open /languages/dutch/lang_main.php
Find:

Code: Select all

?>

Before, add:

Code: Select all

//Spam Mod
$lang['Spam_Filter'] = "Registratie geweigerd door spamfilter. Zoek contact met de beheerder van dit forum."
//End Spam Mod


Open /languages/french/lang_main.php
Find:

Code: Select all

?>

Before, add:

Code: Select all

//Spam Mod
$lang['Spam_Filter'] = "Enregistrement réfusé par filtre spam. Veuillez contacter le webmestre."
//End Spam mod


And so on for all other language files you might have

User avatar
MysteryFCM
Site Admin
Site Admin
Posts: 3721
Joined: Sun May 15, 2005 12:42 pm
Location: Newcastle, UK
Contact:

Re: [CODE] Integrating the spam filter into phpBB2

Postby MysteryFCM » Sat Aug 22, 2009 2:15 pm

Nice one :)
Regards

Steven Burn
I.T. Mate / hpHosts
it-mate.co.uk / hosts-file.net

Keeping it FREE!

User avatar
Peter K
Posts: 10
Joined: Wed Aug 19, 2009 10:03 am
experience: Not only can I turn PC on, I know most of its functions too
Contact:

Re: [CODE] Integrating the spam filter into phpBB2

Postby Peter K » Sun Aug 23, 2009 2:53 am

Nice, but of small use <?> . Since registering is for non registered users only, as it it has no clue to guess what language the visitor might speak, phpbb will use the standard board language (english by default). So if you have another language installed, you might as well replace the english text by another directly into the mod.
Correct me if I'm wrong...

User avatar
MysteryFCM
Site Admin
Site Admin
Posts: 3721
Joined: Sun May 15, 2005 12:42 pm
Location: Newcastle, UK
Contact:

Re: [CODE] Integrating the spam filter into phpBB2

Postby MysteryFCM » Sun Aug 23, 2009 5:37 am

Sorry for taking so long.

If the board is targetted to a specific language, then straight into the mod would likely be easier, yes.
Regards

Steven Burn
I.T. Mate / hpHosts
it-mate.co.uk / hosts-file.net

Keeping it FREE!

yeastmeister
Posts: 8
Joined: Tue Mar 16, 2010 8:11 am
Contact:

Re: [CODE] Integrating the spam filter into phpBB2

Postby yeastmeister » Sat Apr 10, 2010 5:46 am

I've got a slight problem. I installed it as instructed in my phpbb2 forum, and it works great, but my users can no longer click the profile button to change their own settings. It gives the blocked message. Anyone else seeing this behavior, or is it something strange with my particular system.

Even me, as the site admin, can't click the profile button anymore. If I go into the admin panel, and then edit the users like that, it brings up the correct page.

User avatar
MysteryFCM
Site Admin
Site Admin
Posts: 3721
Joined: Sun May 15, 2005 12:42 pm
Location: Newcastle, UK
Contact:

Re: [CODE] Integrating the spam filter into phpBB2

Postby MysteryFCM » Sat Apr 10, 2010 5:48 am

Can you e-mail me a copy of your current usercp_register.php file please so I can take a look?

/edit

Forgot the e-mail address;

sbst_files @ it-mate.co.uk
Regards

Steven Burn
I.T. Mate / hpHosts
it-mate.co.uk / hosts-file.net

Keeping it FREE!

yeastmeister
Posts: 8
Joined: Tue Mar 16, 2010 8:11 am
Contact:

Re: [CODE] Integrating the spam filter into phpBB2

Postby yeastmeister » Mon Apr 12, 2010 5:42 am

Actually, further testing shows that its no longer working at all. Even clicking on registration just brings up a block page. I didn't change anything in the board, it used to work, and no longer does. Did something change on the temerc.com side?

User avatar
MysteryFCM
Site Admin
Site Admin
Posts: 3721
Joined: Sun May 15, 2005 12:42 pm
Location: Newcastle, UK
Contact:

Re: [CODE] Integrating the spam filter into phpBB2

Postby MysteryFCM » Mon Apr 12, 2010 6:38 am

My apologies for taking so long. Can you uncomment the following line, so we can see what's actually being returned please?

Code: Select all

//echo $fspamcheck;


The only change has been an upgrade to the latest release.

viewtopic.php?p=3442004#p3442004
Regards

Steven Burn
I.T. Mate / hpHosts
it-mate.co.uk / hosts-file.net

Keeping it FREE!

yeastmeister
Posts: 8
Joined: Tue Mar 16, 2010 8:11 am
Contact:

Re: [CODE] Integrating the spam filter into phpBB2

Postby yeastmeister » Mon Apr 12, 2010 7:23 am

A little background, the last time it was working on my board was March 16th, does that help nail down a code change?

I'm now running it locally, with the same results, using the latest code.

Fspamlist = TRUE is whats echoing back.

If I set emails to be sent, I can see that its passing what appears to be null username and email to fspamlist, along with the IP address. At least thats what the email is showing me, no username or email reported, which makes sense since this is now happening when the user clicks registration. The 'Are you 13 or older' page never shows up, it immediately goes to the block page when I have fspamlist set to true in the config.

Since I'm pretty sure I didn't change anything on my side, is it possible that the latest code update broke phpbb2?

Looking at the check_spammers_plain file, I think I see that if mail and name are null, then its gets set to nobody@example.com, and no_name_given respectively. If I type either of those into fspamlist, it looks like they come up positive. Could that be the issue with fspamlist?

User avatar
MysteryFCM
Site Admin
Site Admin
Posts: 3721
Joined: Sun May 15, 2005 12:42 pm
Location: Newcastle, UK
Contact:

Re: [CODE] Integrating the spam filter into phpBB2

Postby MysteryFCM » Mon Apr 12, 2010 7:49 am

It's certainly possible, but the changes made, were not specific to or used by, any of the boards software itself (the only change made near the 16th, was on the 21st, which disabled the undisposable check due to the services disappearing). The only thing it uses, is the return value.

The e-mails you're receiving, aren't actually data being sent to fSpamlist, but just a copy of the results (i.e. the fact it was flagged by fSpamlist).

This actually has me a little puzzled, most notably because it was occuring before you hosted it locally (this rules out a bug in the SBST itself, and points to a problem specific to phpBB2, or a conflict with another mod running on your board).

Leave it with me and I'll see if I can reproduce and identify it.
Regards

Steven Burn
I.T. Mate / hpHosts
it-mate.co.uk / hosts-file.net

Keeping it FREE!

User avatar
MysteryFCM
Site Admin
Site Admin
Posts: 3721
Joined: Sun May 15, 2005 12:42 pm
Location: Newcastle, UK
Contact:

Re: [CODE] Integrating the spam filter into phpBB2

Postby MysteryFCM » Mon Apr 12, 2010 7:59 am

yeastmeister wrote:Looking at the check_spammers_plain file, I think I see that if mail and name are null, then its gets set to nobody@example.com, and no_name_given respectively. If I type either of those into fspamlist, it looks like they come up positive. Could that be the issue with fspamlist?


It's certainly possible, yes, but phpBB2 should be sending the e-mail + IP at the very least. I've modified the fSpamlist API so it ignores these two if passed, could you check again and tell me if the problem persists please?
Regards

Steven Burn
I.T. Mate / hpHosts
it-mate.co.uk / hosts-file.net

Keeping it FREE!

yeastmeister
Posts: 8
Joined: Tue Mar 16, 2010 8:11 am
Contact:

Re: [CODE] Integrating the spam filter into phpBB2

Postby yeastmeister » Mon Apr 12, 2010 8:23 am

Odd, Ok, now I have it working hosted locally, but the copy on your server fails. Yep, I could reproduce it by modifying the

if($mail==''){$mail='nobody@example.com';}
if($name==''){$name='no_name_given';}

lines in the fspamlist section of the check_spammers_plain.php to be other values for mail and name.

Also, just to point out, the latest build has this line
if($ip==''){$mail='1.2.3.4';}

Shouldn't that be
if($ip==''){$ip='1.2.3.4';}

Seems to be working now, at least now its not giving me the page when I try to register, or press the profile button. I haven't seen it block any spammers yet, but its looking like it is.

User avatar
MysteryFCM
Site Admin
Site Admin
Posts: 3721
Joined: Sun May 15, 2005 12:42 pm
Location: Newcastle, UK
Contact:

Re: [CODE] Integrating the spam filter into phpBB2

Postby MysteryFCM » Mon Apr 12, 2010 8:32 am

Nice one, thanks for letting me know :)

Code: Select all

Also, just to point out, the latest build has this line
if($ip==''){$mail='1.2.3.4';}

Shouldn't that be
if($ip==''){$ip='1.2.3.4';}


It should be yes, I'll get it fixed, cheers :)
Regards

Steven Burn
I.T. Mate / hpHosts
it-mate.co.uk / hosts-file.net

Keeping it FREE!

yeastmeister
Posts: 8
Joined: Tue Mar 16, 2010 8:11 am
Contact:

Re: [CODE] Integrating the spam filter into phpBB2

Postby yeastmeister » Tue Apr 13, 2010 5:20 am

Possibly one more...

functions.php

line 219, should that ~ be there?

User avatar
MysteryFCM
Site Admin
Site Admin
Posts: 3721
Joined: Sun May 15, 2005 12:42 pm
Location: Newcastle, UK
Contact:

Re: [CODE] Integrating the spam filter into phpBB2

Postby MysteryFCM » Tue Apr 13, 2010 5:24 am

Typo on my part it seems. Cheers :)

I'll get a new release out today with the 2 bug fixes :)
Regards

Steven Burn
I.T. Mate / hpHosts
it-mate.co.uk / hosts-file.net

Keeping it FREE!

yeastmeister
Posts: 8
Joined: Tue Mar 16, 2010 8:11 am
Contact:

Re: [CODE] Integrating the spam filter into phpBB2

Postby yeastmeister » Tue Apr 13, 2010 7:31 am

A fix suggestion.

The way its implemented, it calls the function before they enter in their registration data. Which is fine, but it can't have a username and password because they haven't entered it yet. You pass a dummy username and email in case of the null, so every person clicking the register button gets checked with the same user name, email, and their own ip address.

What I have done is instead of passing a dummy name/email, I just pass the ip address for all 3 fields. So in check_spammers_plain.php I changed them to:

if($mail==''){$mail=$ip;}
if($name==''){$name=$ip;}

Since the ip is the only information we have at that time, it seems better than everyone having the same username. If they are a known spammer ip, we want to block them anyway.

In usercp_register.php I allso added

if ($mode == 'register')
{

to the top, and a trailing } to the end, so that it doesn't get called when they click the profile button, since they are already logged in at that point, it doesn't seem necessary.

Do you see any problems with this?

User avatar
MysteryFCM
Site Admin
Site Admin
Posts: 3721
Joined: Sun May 15, 2005 12:42 pm
Location: Newcastle, UK
Contact:

Re: [CODE] Integrating the spam filter into phpBB2

Postby MysteryFCM » Tue Apr 13, 2010 7:39 am

I don't forsee any problems with that, no :)
Regards

Steven Burn
I.T. Mate / hpHosts
it-mate.co.uk / hosts-file.net

Keeping it FREE!


Return to “Mods”

Who is online

Users browsing this forum: No registered users and 1 guest