scriptygoddess

12 Oct, 2003

Subscribe to comments – (comment spam) bug fix

Posted by: Jennifer In: Lessons learned

Leaving this post here for archival purposes – but the latest version of the subscribe to comments script is now in cgi format – find more info here

So just to give you some history on the problem I was having. As comment SPAM has been coming in, as well as deleting them as quickly as I can (of course) I've been adding the IPs to my list of banned IPs in MT. The one kicker was that sometimes, while the comment would not appear on the site, I was getting the "comment notification" from the subscribe to comments script.

Took me awhile to figure it out, but what was happening was these types of comments were coming from people who I had already banned through MT, but my subscribe to comments script didn't know that and would send out the notifications. MT would block the comment from actually appearing on the site, but whoever was subscribed to the post would get the SPAM. I don't know how many of you have run into this problem, but I'll post what you need to do to fix it…

Go to where you uploaded your subscribe to comments scipt files and find the one called "functions.php". Make a backup of it (always a good thing to do) :) and open it up. Find the function called "post_comment()" – the function starts with this line:

function post_comment() {

what you want to do is skip past just after these lines:

$blogname= stripslashes($blogname);
$author= stripslashes($author);
$text = stripslashes($text);
$title = stripslashes($title);

and add the following (with modifications noted below)

mysql_connect ("localhost", "DATABASE-USERNAME", "DATABASE-PASSWORD");
mysql_select_db("MT-DATABASE");
if ($_SERVER['HTTP_X_FORWARD_FOR']) {
$ip = $_SERVER['HTTP_X_FORWARD_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
$ipbanreslt = mysql_query("SELECT ipbanlist_ip FROM mt_ipbanlist WHERE '".$ip."' LIKE ipbanlist_ip");
$num_rows_ip = mysql_num_rows($ipbanreslt);
if ($num_rows_ip > 0) {
$emailbody = "AUTHOR: $author\nURL OF POST: $link\nCOMMENT:\n $text\nIP: $ip\nEMAIL: $email\nURL: $url";
mail("YOUREMAIL@EMAIL.COM","[$blogname] IP WARNING on $title",$emailbody,"From: YOUREMAIL@EMAIL.COM");
echo "<html><head><title></title><meta http-equiv=\"refresh\" content=\"0;URL=http://www.fbi.gov/homepage.htm\"></head><body></body></html>";
exit;
}

What this will do is send you an email that a spammer tried to hit your site. It has the potential to SPAM your inbox, but I like to know what's going on and that the script is working. If you don't want these emails just add a // before the mail("youremail@email.com", etc… line.

As for the redirect to the FBI site – heh – that's just me having some fun. I figure if I'm a spammer, and I spam a site, and I'm suddenly on the FBI homepage, I'd get a little freaked out. You can change that URL to anything you feel like it. Basically I'm just making them go away. I'm not bringing them back to my site after their comment is denied.

1 Response to "Subscribe to comments – (comment spam) bug fix"

1 | blog.mapu.de

October 26th, 2003 at 10:27 am

Avatar

Gesammeltes zu Kommentar-Spam bei MT
Ich hatte zwar seither keine Probleme mehr mit Kommentar-Spam (*auf Holz klopf*), falls es aber mal wieder vermehrt Ärger geben sollte, habe ich hier mal meine dazu gesammelten Links abgelegt: Kommentar-Spam bei MovableType [Bloghaus] Subscribe to comm…

Featured Sponsors

Genesis Framework for WordPress

Advertise Here


  • Scott: Just moved changed the site URL as WP's installed in a subfolder. Cookie clearance worked for me. Thanks!
  • Stephen Lareau: Hi great blog thanks. Just thought I would add that it helps to put target = like this:1-800-555-1212 and
  • Cord Blomquist: Jennifer, you may want to check out tp2wp.com, a new service my company just launched that converts TypePad and Movable Type export files into WordPre

About


Advertisements