Preventing Blog Spam In .Text

It's been extremely annoying over the last couple of weeks as blog spammers discovered both my blogs and started posting daily spam in the comment sections. I finally got the source code for .Text (0.95.2004.102) compiling again and implemented a spam filter in DotText.Web.dll. You just need to modify btnSubmit_Click() in the Dottext.Web.UI.Controls.PostComment class to detect the spam and not post it. All I do at the moment is limit the number of links allowed. Drop me a note if you want the dll or the code.

There are other solutions out there such as the CAPTCHA Control or installing database triggers like this.

Print | posted on Monday, January 10, 2005 8:38 PM

Feedback

# RE: Preventing Blog Spam In .Text

Left by vgblog@thegillfamily.us (vern) at 1/11/2005 1:55 PM
Gravatar I would love to have that dll... Is it a straight 'drop-in' replacement? (Theoretically, of course. My mileage may vary, yada yada yada)

# re: Preventing Blog Spam In .Text

Left by Ian at 1/13/2005 8:15 AM
Gravatar Sure. You can download the DLL here:

http://www.ianwij.com/downloads/Dottext.Web.dll

I'm sorry but it's not configurable. It just counts how many "http:" strings are in the comment textbox and if it exceeds 10, the comment can not be posted.

# re: Preventing Blog Spam In .Text

Left by Ian at 1/13/2005 8:18 AM
Gravatar Another solution using the Movable Type Blacklist is here:
http://www.shahine.com/omar/PermaLink,guid,f1f15d4e-e3aa-46b3-96ee-5b4db4fffe5b.aspx

# re: Preventing Blog Spam In .Text

Left by asdfasdf at 8/24/2005 12:48 PM
Gravatar asdfasdf

# re: Preventing Blog Spam In .Text

Left by asdfasd at 8/24/2005 12:51 PM
Gravatar I didn't type in the right code.... Seems to be posting.

# re: Preventing Blog Spam In .Text

Left by Ian at 6/6/2005 9:26 AM
Gravatar Getting worse. I'm now checking for a small set of keywords that I'ved banned and had to resort to T-SQL to delete mass spam that gets through.

# re: Preventing Blog Spam In .Text

Left by Ian at 6/6/2005 6:48 PM
Gravatar I've installed Miguel Jimenez's CAPTCHA control v1.4 to stop all this automated spam I've been getting.

The only drawback is that if you enter a comment but get the code wrong, all the typing will be lost. Bummer.

# re: Preventing Blog Spam In .Text

Left by vern at 3/20/2005 2:06 PM
Gravatar Ian,
I was wondering if you could post, or email me, the code used for this function.
I am going to try to add it in, and make the # links configurable via web.config.

Thanks!

# re: Preventing Blog Spam In .Text

Left by Ian at 3/22/2005 1:50 PM
Gravatar private bool IsSpamFree(string txtBody)
{
int count = 0;
int nextPos = 0;
string strBuffer = txtBody.ToLower();

//count how many hrefs are in the text (regex would be better)

while (nextPos > -1)
{
nextPos = strBuffer.IndexOf("http:", nextPos);
if (nextPos > 0)
{
count++;
nextPos = nextPos + 4;
}
}

//if there's more than 10 href's, assume its spam
if (count > 10)
return false;
else
return true;
}

private void btnSubmit_Click(object sender, System.EventArgs e)
{
if(Page.IsValid)
{
try
{

if (IsSpamFree(tbComment.Text))
{
Entry currentEntry = Cacher.GetEntryFromRequest(Context,CacheTime.Short);

Entry entry = new Entry(PostType.Comment);
entry.Author = tbName.Text;
entry.TitleUrl = Globals.CheckForUrl(tbUrl.Text);
entry.Body = tbComment.Text;
entry.Title = tbTitle.Text;
entry.ParentID = currentEntry.EntryID;
entry.SourceName = Dottext.Framework.Util.Globals.GetUserIpAddress(Context);
entry.SourceUrl = currentEntry.Link;

Dottext.Framework.Entries.InsertComment(entry);

if(chkRemember.Checked)
{
HttpCookie user = new HttpCookie("CommentUser");
user.Values["Name"] = tbName.Text;
user.Values["Url"] = tbUrl.Text;
user.Expires = DateTime.Now.AddDays(30);
Response.Cookies.Add(user);
}

Response.Redirect(string.Format("{0}?Pending=true",Request.Path));
}
//BindComments();

}
catch{}
}
}

# re: Comment spam

Left by Edgardo Vega's Blog at 3/23/2005 11:27 AM
Gravatar

# Internet freeplay slot tournaments.

Left by Slot car game internet. at 12/4/2008 3:57 PM
Gravatar Internet casino slot tournaments. Slot car game internet. Free internet casino slot tournaments.

# Avril lavigne porn pictures.

Left by Avril lavigne porn. at 12/28/2008 6:29 PM
Gravatar Avril lavigne porn pictures.

Your comment:





 
Please add 7 and 6 and type the answer here:

Copyright © Ian Wijesinghe

Design by Bartosz Brzezinski

Design by Phil Haack Based On A Design By Bartosz Brzezinski