Check Website
Inclusion Status
It is currently Tue Dec 10, 2019 6:15 pm

All times are UTC




Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: [CODE] Integrating the spam filter into WordPress
PostPosted: Tue Jun 09, 2009 12:17 am 
Offline
Site Admin

Joined: Thu May 28, 2009 10:25 am
Posts: 6018
Check user on posting

Open wp_comments-post.php

Find: (approx line #92, as of WordPress v4.x, previously line #34)

Code:
$comment_author       = trim(strip_tags($_POST['author']));
$comment_author_email = trim($_POST['email']);
$comment_author_url   = trim($_POST['url']);
$comment_content      = trim($_POST['comment']);


Add AFTER

Code:
// BEGIN SPAM MOD
   $ip = $_SERVER['REMOTE_ADDR'];
   $fspamcheck = file_get_contents('http://temerc.com/Check_Spammers/check_spammers_plain.php?name='.$comment_author.'&email='.$comment_author_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: '.$comment_author.'<br><br>Email: '.$comment_author_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 Spambot Search Tool 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
       wp_die( __('Your comment has been blocked by our <a href="http://temerc.com/Check_Spammers/">spam filter</a>. Please either try again or contact an administrator') );
   }
   // END SPAM MOD


To block them registering aswell (this is not required for the above, it's simply an optional extra)

Open wp-login.php

For those not yet on WordPress v4

Find: (Approx line #206)

Code:
   // Check the username


For those on WordPress v4

Find:(Line #683)

Code:
      $user_login = $_POST['user_login'];
      $user_email = $_POST['user_email'];


For those on Wordpress < v4

Add BEFORE

For those on WordPress 4.x

Add AFTER

Code:
// BEGIN SPAM MOD
   $ip = $_SERVER['REMOTE_ADDR'];
   $fspamcheck = file_get_contents('http://temerc.com/Check_Spammers/check_spammers_plain.php?name='.$user_login.'&email='.$user_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: '.$user_login.'<br><br>Email: '.$user_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 Spambot Search Tool 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
      $errors->add('reg_blocked', __('<strong>ERROR</strong>: Your registration has been blocked by our <a href="http://temerc.com/Check_Spammers/">spam filter</a>. Please either try again or contact an administrator'));
   }
   // END SPAM MOD

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

Keeping it FREE!



IP:
top
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
hpHosts and hpHosts Online are copyright © Malwarebytes Corp - All Rights Reserved

Powered by phpBB © 2000-2009 phpBB Group