January 29 2011 Saturday

A simple CAPTCHA test for XPages...

While all are chatting around Lotusphere 2011, I am working for the community :)

Here is a simple CAPTCHA test for XPages...

It is not a turing test, actually. But it will keep spammer bots away until they become obsessed with your site...

You can download a sample database (see update below if you have problems). You are free to use, alter, extend or distribute this code. Just don't forget credits :) The screenshots are here:

Image:A simple CAPTCHA test for XPages...

Image:A simple CAPTCHA test for XPages...

It contains a custom control and a script library (SSJS). You may simply import these two into your database and include the custom control on your page. As I said, it is not a turing test. It just makes it difficult to exploit web forms. However, it is not impossible to break it...

The custom control also supports multi-language. Just update the list of languages supported and setStrings() function for custom strings...

..... 
var LANGUAGES=["en","tr"]; // Languages supported. First is default...
.......
this.setStrings=function() {

captchaTexts["en"]=["zero","one", ... ,"twentyfour","twentyfive"];
captchaTexts["tr"]=["sıfır","bir", ..., "yirmidört","yirmibeş"];

switch(captchaLanguage) {
    case "en":
            this.validationMessage="Are you sure about your math?";
            this.emptyMessage="You forgot? Or you don't know about Math...";
            this.chooseString="Choose...";
            break;
    case "tr":
            this.validationMessage="Matematik bildiğinizden emin misiniz?";
            this.emptyMessage="Unuttunuz mu? Yoksa matematikle sorununuz mu var?";
            this.chooseString="Seçiniz...";
            break;                
    }                
}


UPDATE:

I noticed there is a problem with serialization in pre-8.5.2 versions. So I uploaded a different version as R2.0 here. Notice that the object structure and custom control implementation has been changed here and you should see different places for multilingual texts...
Serdar Basegmez   |   January 29 2011 08:13:30 AM   |    Development  HowTo  Scriptlet  XPages    |  
  |   Next   |   Previous

Comments (4)

Gravatar Image
Derek Scott    http://www.notesmail.com    12/10/2014 10:43:25 AM

You can also implement CAPTCHA in Domino web forms using simply Notes formula language. :)

Security Image Generator (CAPTCHA) for Domino web forms

{ Link }

Gravatar Image
chrisle       05/02/2011 10:55:07 AM

Amazing ! Many thanks !!!

it's first Captcha i found for xpages , and

is an excellent initiative.

it's works on 8.5.1 FP2

I'm very happy ;o)

Gravatar Image
Serdar Basegmez    http://www.developi.com    05/02/2011 10:27:35 AM

Yep, I did notice this.

The problem is with the serialization of the captcha class.

I changed this with a serializable form and updated the post. Be careful that both custom control and script library has been changed.

Gravatar Image
chrisle       05/02/2011 9:48:17 AM

thanks for application.

it's works on domino 8.5.2, but not in domino 8.5.1 FP2

error:

Source de l'erreur

Nom de page :/Sample.xsp

ID commande : scriptBlock1

Exception

Erreur lors de l'exécution de l'expression calculée JavaScript

Script-Interpreterfehler, Zeile=1, Spalte=11: Verweisfehler: 'myCaptcha' nicht gefunden

Javascript code

1: myCaptcha.captchaEncode(viewScope.get("cap1"))

Have you a solution ?

cordially