Subkismet Demo Page

This is a page used to demo the Subkismet Spam Busting Library. Learn more from the the project page.

The CAPTCHA demos on this page assume you’ve registered the Subkismet.Captcha control namespace. The Akismet demo assumes you’ve imported the Subkismet namespace.

<%@ Register TagPrefix="sbk" Assembly="Subkismet" Namespace="Subkismet.Captcha" %>
<%@ Import Namespace="Subkismet" %>
Invisible CAPTCHA Demo

Not much to see in this demo because we’re demoing the invisible CAPTCHA control.

When you click submit, you should see a success message. Turn off javascript to see what’s really happening.

Please add 2 and 4 and type the answer here:

The relevant source code: [+]

<script runat="server" language="C#">
  protected void OnButtonClick(object sender, EventArgs args)
  {
    if(Page.IsValid)
    {
      successLiteral.Visible = true;
    }
  }

</script>
<p class="success">
  <asp:Literal ID="successLiteral" 
    runat="server" 
    Text="Valid!" 
    Visible="false" />
</p>
<div>
  <sbk:InvisibleCaptcha id="commentValidator" 
    runat="server" 
    ErrorMessage="Oops! You must be bad at math." 
    Display="dynamic" 
    ValidationGroup="Invisible" />
  
  <asp:Button ID="invisibleDemoButton" runat="server" 
    Text="Submit" 
    OnClick="OnButtonClick" 
    ValidationGroup="Invisible" />
</div>
Visible CAPTCHA Demo

This demo is a bit more visual than the previous. It demonstrates the visible captcha.

Click submit and you should see a success message if you entered the CAPTCHA correctly.


The relevant source code: [+]

Akismet Demo

For this demo, you’ll need to enter your Wordpress API Key which is used by Akismet. I promise I won’t record it anywhere. It is only used for the purposes of demoing Akismet.

Verify API Key

Enter your WordPress API Key and click submit to verify it.


The relevant source code: [+]

<script runat="server" language="C#">  

protected void VerifyApiKey(object sender, EventArgs args)
{
  Akismet<Comment> akismet = Akismet<Comment>
      .CreateSimpleAkismet(this.apiKeyTextBox.Text, new Uri("http://localhost/"));
  verifyResultLiteral.Text = akismet.VerifyApiKey()
    ? "<span class=\"success\">Your API Key is verified.</span>"
    : "<span class=\"error\">Could not verify your API key.</span>";
}

protected void PostToAkismet(object sender, EventArgs args)
{
  Akismet<Comment> akismet = Akismet<Comment>
      .CreateSimpleAkismet(this.apiKeyTextBox.Text, new Uri("http://localhost/"));
  Comment comment = new Comment(System.Net.IPAddress.Parse("127.0.0.1")
      , "user-agent");
  comment.Author = this.authorTextBox.Text;
  comment.CommentType = "comment";
  comment.Content = this.bodyTextBox.Text;
  resultLiteral.Text = akismet.IsSpam(comment)
    ? "<span class=\"error\">Get ready for SPAM musubi. This is SPAM.</span>"
    : "<span class=\"success\">Enjoy the ham, it&#8217;s not SPAM.</span>";
}
</script>

<fieldset>
<legend>Verify API Key</legend>
<asp:Literal ID="verifyResultLiteral" runat="server" />
<p>Enter your WordPress API Key and click submit to verify it.</p>
<div class="form">
  <asp:Label ID="keyLabel" runat="server"
  Text="Wordpress API Key"
  AssociatedControlID="apiKeyTextBox" />
  <asp:TextBox ID="apiKeyTextBox" runat="server" />
  <div>
    <asp:Button ID="verifyButton" runat="server" 
      Text="Verify"
      CausesValidation="False" 
      OnClick="VerifyApiKey" />
  </div>
</div>
</fieldset>      

<asp:Literal ID="resultLiteral" runat="server" />        
      
<asp:Label ID="authorLabel" runat="server"
Text="Author (Enter 'viagra-test-123' to trigger a 'spam' response."
AssociatedControlID="authorTextBox" />
<asp:TextBox ID="authorTextBox" runat="server" />

<asp:Label ID="bodyLabel" runat="server"
Text="Body"
AssociatedControlID="bodyTextBox" />
<asp:TextBox ID="bodyTextBox" runat="server" 
TextMode="MultiLine" 
Columns="40" 
Rows="10" />

<div>
<asp:Button ID="submitAkismetButton" runat="server" 
  Text="Submit" 
  OnClick="PostToAkismet" />
</div>