[CODE] Integrating the spam filter into IPB

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 IPB

Postby MysteryFCM » Sat Jan 31, 2009 9:05 am

An IPB mod is now available, thanks to ColdinCbus (CoU)

http://www.calendarofupdates.com/update ... st&p=74291

Open- /sources/action_public/register.php

FIND:

Code: Select all

      //-----------------------------------------
      // CHECK 2: Any errors (duplicate names, etc)?
      //-----------------------------------------
      
      if ( count( $form_errors ) )
      {
         $this->complete_login_form( $form_errors );
         return;
      }


Above add:

Code: Select all

// BEGIN SPAM MOD
   $ip = $_SERVER['REMOTE_ADDR'];
   $fspamcheck = file_get_contents('http://temerc.com/Check_Spammers/check_spammers_plain.php?name='.$members_display_name.'&email='.$in_email.'&ip='.$ip);
   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: '.$members_display_name.'<br><br>Email: '.$in_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
     $form_errors['dname'][] = $this->ipsclass->lang['reg_error_taken'];
   }
   // END SPAM MOD


FIND again:

Code: Select all

      //-----------------------------------------
      // CHECK 2: Any errors (duplicate names, etc)?
      //-----------------------------------------
      
      if ( count( $form_errors ) )
      {
         $this->complete_login_form( $form_errors );
         return;
      }


Above add:

Code: Select all

// BEGIN SPAM MOD login name
   $ip = $_SERVER['REMOTE_ADDR'];
   $fspamcheck = file_get_contents('http://temerc.com/Check_Spammers/check_spammers_plain.php?name='.$in_username.'&email='.$in_email.'&ip='.$ip);
   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: '.$in_username.'<br><br>Email: '.$in_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
     $form_errors['username'][$this->ipsclass->lang['reg_error_username_taken']] = $this->ipsclass->lang['reg_error_username_taken'];
   }
// END SPAM MOD

if($in_username != $members_display_name){ //check if display name and login name don't match
// BEGIN SPAM MOD display name
$fspamcheck = file_get_contents('http://temerc.com/Check_Spammers/check_spammers_plain.php?name='.$members_display_name.'&email='.$in_email.'&ip='.$ip);
   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: '.$members_display_name.'<br><br>Email: '.$in_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
     $form_errors['username'][$this->ipsclass->lang['reg_error_username_taken']] = $this->ipsclass->lang['reg_error_username_taken'];
   }
// END SPAM MOD
}//endcheck if login and display are different
Last edited by MysteryFCM on Mon Jun 08, 2009 5:13 pm, edited 5 times in total.
Reason: Forgot to stickify it ........
Regards

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

Keeping it FREE!

User avatar
Jinto
Posts: 5
Joined: Fri May 08, 2009 8:05 pm
experience: I know the functions, OS settings, registry tweaks and more
PC time: Alot more than I should
Location: Usa
Contact:

Re: [CODE] Integrating the spam filter into IPB

Postby Jinto » Sat May 09, 2009 9:40 am

Code: Select all

Warning: Cannot modify header information - headers already sent by (output started at /home2/kingdom/public_html/forums/sources/action_public/register.php:2079) in /home2/kingdom/public_html/forums/sources/classes/class_display.php on line 494

Warning: Cannot modify header information - headers already sent by (output started at /home2/kingdom/public_html/forums/sources/action_public/register.php:2079) in /home2/kingdom/public_html/forums/sources/classes/class_display.php on line 495

Warning: Cannot modify header information - headers already sent by (output started at /home2/kingdom/public_html/forums/sources/action_public/register.php:2079) in /home2/kingdom/public_html/forums/sources/classes/class_display.php on line 496

Warning: Cannot modify header information - headers already sent by (output started at /home2/kingdom/public_html/forums/sources/action_public/register.php:2079) in /home2/kingdom/public_html/forums/sources/classes/class_display.php on line 500

Warning: Cannot modify header information - headers already sent by (output started at /home2/kingdom/public_html/forums/sources/action_public/register.php:2079) in /home2/kingdom/public_html/forums/sources/classes/class_display.php on line 502

Warning: Cannot modify header information - headers already sent by (output started at /home2/kingdom/public_html/forums/sources/action_public/register.php:2079) in /home2/kingdom/public_html/forums/sources/classes/class_display.php on line 503


When applying the mod/edit im getting the above errors but i cant figure out why im getting the errors above and have checked many times to make sure i edited everything correct as i would like to remove all the spam registrations that im getting and doing a google search on one of the emails that looked normal i found this site and thus the mod a few minutes later

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 IPB

Postby MysteryFCM » Sat May 09, 2009 11:16 am

Unfortunately, IPB have never gotten back to me with a development licence, so I'm unable to debug this for you directly.

However, a thread on the IPB forums suggested it is likely caused by the class_display.php file having a blank line after ?> (closing PHP tag). If possible, could you check this please?

If this isn't the case, all I can do is point you toward the IPB developers I'm afraid.
Regards

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

Keeping it FREE!

User avatar
Jinto
Posts: 5
Joined: Fri May 08, 2009 8:05 pm
experience: I know the functions, OS settings, registry tweaks and more
PC time: Alot more than I should
Location: Usa
Contact:

Re: [CODE] Integrating the spam filter into IPB

Postby Jinto » Sat May 09, 2009 11:45 am

Well here is a screen shot of the lines that the error codes claims is the trouble spot i used editpadepro and gadwin printscreen to take the cap so that you could see the exact line numbers
Attachments
ScreenShot128.jpg

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 IPB

Postby MysteryFCM » Sat May 09, 2009 11:55 am

You've got the header("HTTP/"); line in there twice. Though this is sometimes required, it can cause some problems.

Can you try adding "//" (without the quotes) at the beginning of the header("HTTP/1.0 200 OK") line, and see if that resolves it? (if the forum has a caching facility, you may need to clear the cache afterwards)
Regards

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

Keeping it FREE!

User avatar
Jinto
Posts: 5
Joined: Fri May 08, 2009 8:05 pm
experience: I know the functions, OS settings, registry tweaks and more
PC time: Alot more than I should
Location: Usa
Contact:

Re: [CODE] Integrating the spam filter into IPB

Postby Jinto » Sat May 09, 2009 12:16 pm

Code: Select all

Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /home2/kingdom/public_html/forums/sources/action_public/register.php on line 2080

Warning: file_get_contents(http://...@gmail.com&ip=68.191.128.133) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in /home2/kingdom/public_html/forums/sources/action_public/register.php on line 2080

Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /home2/kingdom/public_html/forums/sources/action_public/register.php on line 2101

Warning: file_get_contents(http://...@gmail.com&ip=68.191.128.133) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in /home2/kingdom/public_html/forums/sources/action_public/register.php on line 2101

Warning: Cannot modify header information - headers already sent by (output started at /home2/kingdom/public_html/forums/sources/action_public/register.php:2080) in /home2/kingdom/public_html/forums/sources/classes/class_display.php on line 495

Warning: Cannot modify header information - headers already sent by (output started at /home2/kingdom/public_html/forums/sources/action_public/register.php:2080) in /home2/kingdom/public_html/forums/sources/classes/class_display.php on line 496

Warning: Cannot modify header information - headers already sent by (output started at /home2/kingdom/public_html/forums/sources/action_public/register.php:2080) in /home2/kingdom/public_html/forums/sources/classes/class_display.php on line 500

Warning: Cannot modify header information - headers already sent by (output started at /home2/kingdom/public_html/forums/sources/action_public/register.php:2080) in /home2/kingdom/public_html/forums/sources/classes/class_display.php on line 502

Warning: Cannot modify header information - headers already sent by (output started at /home2/kingdom/public_html/forums/sources/action_public/register.php:2080) in /home2/kingdom/public_html/forums/sources/classes/class_display.php on line 503


Ok after clearing the cache and having it rebuild the cache for everything i get the above error the attachment is the changes though i want sure if you wanted me to // next to both http entries
Attachments
ScreenShot129.jpg

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 IPB

Postby MysteryFCM » Sat May 09, 2009 12:31 pm

The first error is showing that your hosting company will likely not support the SBST unless they enable the use of file_get_contents() and file_put_contents(). The full list of requirements for the spam filter is at;

http://support.it-mate.co.uk/?mode=Prod ... searchtool

If you can get them to enable this, you'll be able to use the mod (both errors should then go away as the second is currently very likely caused by the first). Otherwise I'm afraid you'll need to remove it.
Regards

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

Keeping it FREE!

User avatar
Jinto
Posts: 5
Joined: Fri May 08, 2009 8:05 pm
experience: I know the functions, OS settings, registry tweaks and more
PC time: Alot more than I should
Location: Usa
Contact:

Re: [CODE] Integrating the spam filter into IPB

Postby Jinto » Sat May 09, 2009 12:55 pm

Many thanks for the help i sent in a support ticket to see if there a chance i get get ti enabled...which im sure they will say no

But anyway thanks a lot for helping me out on this if by some miracle it does get enabled and i got no errors or get errors ill make another post to try and nail down the trouble spots with ipb

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 IPB

Postby MysteryFCM » Sat May 09, 2009 1:45 pm

No problem, and thank you :)
Regards

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

Keeping it FREE!

User avatar
Jinto
Posts: 5
Joined: Fri May 08, 2009 8:05 pm
experience: I know the functions, OS settings, registry tweaks and more
PC time: Alot more than I should
Location: Usa
Contact:

Re: [CODE] Integrating the spam filter into IPB

Postby Jinto » Sat May 09, 2009 9:03 pm

Partially the error you are getting. file_get_contents() and file_put_contents() are not disabled; however, the erorr you are getting is due to allow_url_fopen turned off for security reasons. allow_url_fopen basically disables only the allowance of using URLs for PHP functions (e.g. if you use file_get_contents() and file_put_contents() with http:// in the script). If you can use file_get_contents() and file_put_contents() with relative or absolute paths (in other words locally pointing within your own folders) then you will not have any errors.

Alternativly; we did leave CURL open (as it's a better method) to access outside URLs through PHP if needed.)


im guessing this means i cant use with with ipb or maybe requires more editing that what i know of lol

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 IPB

Postby MysteryFCM » Sun May 10, 2009 2:49 am

You could change the following so it uses cURL, but bear in mind, some of the SBST itself, requires allow_url_fopen to be enabled (i.e. so it can write to the text files), so whilst it should work, it may not work completely;

Code: Select all

$fspamcheck = file_get_contents('http://temerc.com/Check_Spammers/check_spammers_plain.php?name='.$members_display_name.'&email='.$in_email.'&ip='.$ip);


This needs changed to;

Code: Select all

//$fspamcheck = file_get_contents('http://temerc.com/Check_Spammers/check_spammers_plain.php?name='.$members_display_name.'&email='.$in_email.'&ip='.$ip);
$curl = @curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://temerc.com/Check_Spammers/check_spammers_plain.php?name='.$members_display_name.'&email='.$in_email.'&ip='.$ip);
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
$fspamcheck = @curl_exec($curl);
curl_close($curl);
Regards

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

Keeping it FREE!

Spof52
Posts: 3
Joined: Mon Jun 21, 2010 11:51 am
Contact:

Re: [CODE] Integrating the spam filter into IPB

Postby Spof52 » Mon Jun 21, 2010 12:48 pm

Hi MysteryFCM,

First of all a BIG thanks for this code, installed it over the weekend and it worked straight out of the box using (IPB V2.3)

Couple of questions,

How do I turn email notification off, it was good to see it working, but soooo many notifications rofl

Also I'm just a bit curious as to what happens during the registration process ie your code reports that they're spammers during the registration process do they just get kicked out of the form?

Regards

Spof52

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 IPB

Postby MysteryFCM » Tue Jun 22, 2010 4:02 am

When a spammer is identified, they're stopped from registering.

All you need to do is remove your e-mail address from the mod's code :) (or comment out the "mail(...." line)
Regards

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

Keeping it FREE!

Spof52
Posts: 3
Joined: Mon Jun 21, 2010 11:51 am
Contact:

Re: [CODE] Integrating the spam filter into IPB

Postby Spof52 » Mon Sep 20, 2010 8:38 am

Hi there MysteryFm,

Another quick question for you with the spam list mod, do you use either stopforumspam or Botscout as reference points?

The reason I ask is that I've had a couple of wannabe members come through but when I check them against those spam lists they show as positive hits, for example:

user: lemonde IP: 91.201.66.162 sub1@capitalshield.net

ip addie has 82 hits on stopforumspam & 31 hits on BotScout

Regards

Spof52

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 IPB

Postby MysteryFCM » Mon Sep 20, 2010 3:49 pm

Interesting, thank you for letting me know. The SBST should be picking both of those up if you've got the SFS and BotScout API keys in the config file.

http://forum.hosts-file.net/sbst/?email ... shield.net
Regards

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

Keeping it FREE!

Spof52
Posts: 3
Joined: Mon Jun 21, 2010 11:51 am
Contact:

Re: [CODE] Integrating the spam filter into IPB

Postby Spof52 » Tue Sep 21, 2010 9:10 am

Ahh, I'm just using the IPB register.php edit from Coldinbus so don't have a SFS/Botscout config file

Regards

Spof52

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 IPB

Postby MysteryFCM » Tue Sep 21, 2010 9:47 am

No problem :)
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