Seaside Smalltalk CAPTCHA

Last night I got my CAPTCHA (Completely Automated Public Turing test to tell Computers and Humans Apart) working in Seaside (Squeak Smalltalk).  I want users to have to type a random word image in on registration to help keep spam bots away from the site.

Here is what I did:

renderHumanImageRecognitionOn: html

| textMorph |
textMorph := TextMorph new.
textMorph contentsAsIs: (
Text
string: self randomString
attributes: (
Array
with: TextEmphasis struckOut
with: TextEmphasis italic
with: (TextFontReference toFont: (StrikeFont familyName: #BitstreamVeraSans size: 36))
)).
html tableRow with:
[ html tableData colspan: 2; align: 'center';
with: [html imageForm: textMorph imageForm]].
html tableRow with:
[ html tableData
with: 'Verification word:'.
html tableData
with: [html textInput on: #verificationWord of: self]]

I got a some help from my buddy Blaine Buxton with rendering a morph into a jpeg image.  Thanks Blaine!

Advertisements

4 thoughts on “Seaside Smalltalk CAPTCHA

  1. I didn’t leave a link to the site. To see the CAPTCHA in Seaside / Squeak go to:

    http://www.w6talent.com

    and click the sign up link on the right side of the page. Please don’t sign up unless you are actually a model that works for a real talent agency.

    The whole site is a Seaside app written in Squeak. I have Apache as a front end doing redirect to the Squeak image for dynamic content. All files and images are served up by Apache.

  2. Thanks a lot, that really helped me!

    As for the randomString method, I implemented it as follows (don’t know if that’s the best/proper way):

    «
    randomString

    self randomWord: (String new: 6).
    (1 to: 6) do: [:index | self randomWord at: index put: (65 to: 90) atRandom asCharacter].

    ^self randomWord
    »

    randomWord is an instance variable I use to later check the user’s input.

    Thanks again! 🙂

  3. I can’t implement that code on gemstool 3.1 because TextMorph class doesn’t exist.

    Are there any way to solve this and generate captcha image?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s