Kill Trackback Spam in .Text

After about 3 days, I've accumulated about 60 spam trackbacks.  The quick fix is in SQL below, and a delete statement follows that to clean what's there already...

I shouldn't have to say: it's a good idea to backup your db before futzing with it.

Very easy, just a quick adjustment to the blog_InsertEntry sproc...

Be sure to replace {user} with the qualified username.  Add the bolded text below into the sproc to wrap up the INSERTs:

blog_InsertEntry

CREATE   Proc {user}.blog_InsertEntry
(
 @Title nvarchar(255),
 @TitleUrl nvarchar(255), 
 @Text ntext,
 @SourceUrl nvarchar(200),
 @PostType int,
 @Author nvarchar(50),
 @Email nvarchar(50),
 @SourceName nvarchar(200),
 @Description nvarchar(500),
 @BlogID int,
 @DateAdded datetime,
 @ParentID int,
 @PostConfig int,
 @EntryName nvarchar(150),
 @ID int output)
as

if(@EntryName is not null)
Begin
 if exists(Select EntryName From blog_Content where BlogID = @BlogID and EntryName = @EntryName)
 Begin
  RAISERROR('The EntryName you entry is already in use with in this Blog. Please pick a unique EntryName.',11,1)
  RETURN 1
 End
End
if(Ltrim(Rtrim(@Description)) = '')
set @Description = null
if not(
 @PostType = 4 and (
 @Title like ('%casino%') or
 @Title like ('%gambling%') or
 @Title like ('%holdem%') or 
 @Title like ('%hold em%') or 
 @Title like ('%poker%') or
 @Title like ('%roulette%') or
 @Title like ('%slot machines%') or
 @Title like ('%blackjack%'))
)
Begin

 INSERT INTO blog_Content
 (Title, TitleUrl, [Text], SourceUrl, PostType, Author, Email, DateAdded,DateUpdated, SourceName, [Description], PostConfig, ParentID, BlogID, EntryName )
 VALUES
 (@Title, @TitleUrl, @Text, @SourceUrl, @PostType, @Author, @Email, @DateAdded, @DateAdded, @SourceName, @Description, @PostConfig, @ParentID, @BlogID, @EntryName)
 Select @ID = @@Identity
if(@PostType = 1 or @PostType = 2)
  Begin
   exec blog_UpdateConfigUpdateTime @blogID, @DateAdded
  End
 Else if(@PostType = 3)
  Begin
   Update blog_Content
   Set FeedBackCount = FeedBackCount + 1 where [ID] = @ParentID
  End
End
GO


And of course a quick script to clean out the crap:

delete from {user}.blog_content where
title like ('%casino%') or
title like ('%gambling%') or
title like ('%holdem%') or
title like ('%hold em%') or
title like ('%poker%') or
title like ('%roulette%') or
title like ('%slot machines%') or
title like ('%blackjack%')

Print | posted on Tuesday, June 21, 2005 11:44 PM

Feedback

# re: Kill Trackback Spam in .Text

left by Christophet Pietschmann, MCSD, M at 6/24/2005 6:39 PM Gravatar
In the last couple days I also got about 80 spam comments on my blog; coincidentally the mass spamming started the day after I read your blog post. I implemented this method of blocking spam on my blog now.
Thanks for the tip.

# re: Kill Trackback Spam in .Text

left by optionsScalper at 6/25/2005 12:16 AM Gravatar
No problem, my 66 trackbacks right now mean I still have work to do, but it's nice to know it can be handled so easily in SQL.
Title  
Name
Email (never displayed)
Url
Comments   
Please add 8 and 8 and type the answer here: