CodeBetter CAPTCHA Modification
0 |
I used TrimothyHumphrey's CAPTCHA for anti-spam-comment in this blog. These days, I am trying to upgrade my blog system from Community Server 2.1 to Community Server 2007. It seems I need a new CAPTCHA component.
After a short survey in Google, I found the CodeBetter CAPTCHA may be the best one. No need to modify any source code of CS2007, no need to modify any aspx or ascx! What I have to do is only to set web.config and add proper control adapter to set default.browser for specific comment/post editior control, then it will find the submit button automatically and insert a CAPTCHA check before it.
(ASP.NET 2.0 control adapter seems another cool thing I didn't know. Damn, how many good things did I miss?)
I found it doesn't work on anonymous forum post submit and I found someone posted the same problem about CommunityServer.Discussions.Controls.CreateEditForumPostForm in Brendan's blog but still got no answer.
After a little digging in source code, I found the cause is that the submit button of forum post editor is named as 'PostButton' and it's not in the submit button searching list. So modify the code list this, you will see the CAPTCHA shining in forums area... Cool!!
Thanks to Brendan, this CAPTCHA is really fancy!
//Modify CaptchaControlAdapter.cs
// find the submit button
Control c = CSControlUtility.Instance().FindControl(form, "btnSubmit");
//2007-11-10 by Jeffrey,
//For CommunityServer.Discussions.Controls.CreateEditForumPostForm
if (c==null)
c = CSControlUtility.Instance().FindControl(form, "PostButton");
if(c == null)
c = CSControlUtility.Instance().FindControl(form, "CreateAccount");
Comments
Be the first to post a comment