New Wilmington Mission Conference

NWMC is the mission conference that amazingly challenges youth
with the Presbyterian tradition in Christ's church. (July 19- 26, 2008)
Welcome to New Wilmington Mission Conference Sign in | Join | Help
in Search

The Web and Christ's Mission

Preventing Account Registration and Comment Spam in Community Server

This site still isn't all that big or popular in the grand scheme of things, but I've been spending wasting too much time deleting spam comments and accounts recently.  I was tired of deleting 20 comments each day and the spam accounts were more irritating because I couldn't be certain which ones they were.  A few days ago I decided it was time to take action and hack my Community Server skins to add a little bot catcher.  It was surprisingly easy, taking just half an hour changing only two files.

Trying to be quick, easy and effective, I started with Jeff Atwood's advice on CAPTCHA and decided to just require a standard value to be entered each time.  I didn't even use a picture or challenging font like he did.  Those are bridges I'll cross if and when they are needed.  All I wanted to do was stop bots targeting the Community Server platform from plaguing me.  Here's how I did it.  The code looks ugly, but it copies and pastes fine.

I edited the Skin-CreateUser.ascx file found in the Themes\default\Skins folder by adding the following code just before the table row containing the time zone information.

    <tr>
        <td align="right">Type NWMC here:</td>
        <td>
            <div class="CommonFormField">
                <asp:TextBox ID="botTest" runat="server" onKeyUp="validateForm(this);"></asp:TextBox>
                <asp:CompareValidator ID="botTestVal" runat="server" ControlToValidate="botTest" ValueToCompare="NWMC" ErrorMessage="Please type NWMC in the specified box."></asp:CompareValidator>
                <asp:RequiredFieldValidator runat="server" ErrorMessage="*" ControlToValidate="botTest" ID="botTestReq" />
            </div>
        </td>
    </tr>

I also added the following line to validateForm javascript function near the end of the file.  I placed it at the end of the group of "if(state)" lines.

if(state){ state = ($('<%= botTest.ClientID %>').value == 'NWMC');}

 

The second step was to add the following two lines to the Skin-CommentForm.ascx file in the Themes\Blogs\default\Skins folder.  I chose to add it just after the line with the url textbox.

<dt>

<label for="<%=botTest.ClientID %>">Please Type the words 'Web Mission' in the box below:</label>
<em>(<CS:ResourceControl ID="ResourceControl2" runat="server" ResourceName="Required" /></em>)
<asp:CompareValidator runat="server" ErrorMessage="*" ControlToValidate="botTest" ID="botTestValueVal" Type="string" ValueToCompare="Web Mission" />
<asp:RequiredFieldValidator runat="server" ErrorMessage="*" ControlToValidate="botTest" ID="botTestReq" />

</dt>
<dd><asp:TextBox id="botTest" runat="server" CssClass="smallbox" /></dd>


That's it.  I'm pleased to say my decisions have been effective since I immediately stopped getting all comments and account registrations.  A new account was registered today, so I'm pleased to see typing NWMC isn't too much of a deterrent.  Now I just need someone to post a comment . . . 

Published Wednesday, March 21, 2007 10:14 PM by Andrew Dawson
Filed under ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

rachelludwig said:

Sounds easy enough...

March 22, 2007 6:57 PM
 

Dave Burke said:

Nice!  I've done CAPTCHAs for CS and plan to release one for CS2007, which you're welcome to use if this doesn't do the job for you.  But it looks like you're all set!  

http://dbvt.com/files/folders/addons/entry5198.aspx

March 28, 2007 3:28 AM
 

Dave Burke said:

blog bits Telligenti Dan Hounshell adds ads (heh he) to his RSS feeds with a new CSModule and creates

March 28, 2007 3:54 AM
 

Dave Burke's Community Server Bits said:

Whodrun4 at the New Wilmington Mission Conference site uses a ASP.NET CompareValidator as a quick-n-dirty

March 28, 2007 4:03 AM
 

Andrew Dawson said:

This has more than done the job for the time being which reminds me I need to turn comment approval back off which I'm glad to do.

March 28, 2007 8:02 AM

Leave a Comment

(required) 
(optional)
(required)   
(required) 
Powered by Community Server (Personal Edition), by Telligent Systems